3 /* $Id: xuartlite_selftest_example.c,v 1.1.2.1 2009/11/24 05:14:25 svemula Exp $ */
\r
4 /******************************************************************************
\r
6 * (c) Copyright 2005-2009 Xilinx, Inc. All rights reserved.
\r
8 * This file contains confidential and proprietary information of Xilinx, Inc.
\r
9 * and is protected under U.S. and international copyright and other
\r
10 * intellectual property laws.
\r
13 * This disclaimer is not a license and does not grant any rights to the
\r
14 * materials distributed herewith. Except as otherwise provided in a valid
\r
15 * license issued to you by Xilinx, and to the maximum extent permitted by
\r
16 * applicable law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND WITH ALL
\r
17 * FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS,
\r
18 * IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
\r
19 * MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE;
\r
20 * and (2) Xilinx shall not be liable (whether in contract or tort, including
\r
21 * negligence, or under any other theory of liability) for any loss or damage
\r
22 * of any kind or nature related to, arising under or in connection with these
\r
23 * materials, including for any direct, or any indirect, special, incidental,
\r
24 * or consequential loss or damage (including loss of data, profits, goodwill,
\r
25 * or any type of loss or damage suffered as a result of any action brought by
\r
26 * a third party) even if such damage or loss was reasonably foreseeable or
\r
27 * Xilinx had been advised of the possibility of the same.
\r
29 * CRITICAL APPLICATIONS
\r
30 * Xilinx products are not designed or intended to be fail-safe, or for use in
\r
31 * any application requiring fail-safe performance, such as life-support or
\r
32 * safety devices or systems, Class III medical devices, nuclear facilities,
\r
33 * applications related to the deployment of airbags, or any other applications
\r
34 * that could lead to death, personal injury, or severe property or
\r
35 * environmental damage (individually and collectively, "Critical
\r
36 * Applications"). Customer assumes the sole risk and liability of any use of
\r
37 * Xilinx products in Critical Applications, subject only to applicable laws
\r
38 * and regulations governing limitations on product liability.
\r
40 * THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE
\r
43 ******************************************************************************/
\r
44 /****************************************************************************/
\r
47 * @file xuartlite_selftest_example.c
\r
49 * This file contains a design example using the UartLite driver (XUartLite) and
\r
56 * MODIFICATION HISTORY:
\r
58 * Ver Who Date Changes
\r
59 * ----- ---- -------- -----------------------------------------------
\r
60 * 1.00a ecm 01/25/04 First Release.
\r
61 * 1.00a sv 06/13/05 Minor changes to comply to Doxygen and Coding guidelines
\r
62 * 2.00a ktn 10/20/09 Minor changes as per coding guidelines.
\r
64 ******************************************************************************/
\r
66 /***************************** Include Files *********************************/
\r
68 #include "xparameters.h"
\r
69 #include "xuartlite.h"
\r
71 /************************** Constant Definitions *****************************/
\r
74 * The following constants map to the XPAR parameters created in the
\r
75 * xparameters.h file. They are defined here such that a user can easily
\r
76 * change all the needed parameters in one place.
\r
78 #define UARTLITE_DEVICE_ID XPAR_UARTLITE_0_DEVICE_ID
\r
81 /**************************** Type Definitions *******************************/
\r
84 /***************** Macros (Inline Functions) Definitions *********************/
\r
87 /************************** Function Prototypes ******************************/
\r
89 int UartLiteSelfTestExample(u16 DeviceId);
\r
91 /************************** Variable Definitions *****************************/
\r
93 XUartLite UartLite; /* Instance of the UartLite device */
\r
95 /*****************************************************************************/
\r
98 * Main function to call the example. This function is not included if the
\r
99 * example is generated from the TestAppGen test tool.
\r
103 * @return XST_SUCCESS if successful, otherwise XST_FAILURE.
\r
107 ******************************************************************************/
\r
108 #ifndef TESTAPP_GEN
\r
114 * Run the UartLite self test example, specify the Device ID that is
\r
115 * generated in xparameters.h
\r
117 Status = UartLiteSelfTestExample(UARTLITE_DEVICE_ID);
\r
118 if (Status != XST_SUCCESS) {
\r
119 return XST_FAILURE;
\r
122 return XST_SUCCESS;
\r
127 /*****************************************************************************/
\r
130 * This function does a minimal test on the UartLite device and driver as a
\r
131 * design example. The purpose of this function is to illustrate
\r
132 * how to use the XUartLite component.
\r
135 * @param DeviceId is the XPAR_<uartlite_instance>_DEVICE_ID value from
\r
138 * @return XST_SUCCESS if successful, otherwise XST_FAILURE.
\r
142 ****************************************************************************/
\r
143 int UartLiteSelfTestExample(u16 DeviceId)
\r
148 * Initialize the UartLite driver so that it is ready to use.
\r
150 Status = XUartLite_Initialize(&UartLite, DeviceId);
\r
151 if (Status != XST_SUCCESS) {
\r
152 return XST_FAILURE;
\r
156 * Perform a self-test to ensure that the hardware was built correctly.
\r
158 Status = XUartLite_SelfTest(&UartLite);
\r
159 if (Status != XST_SUCCESS) {
\r
160 return XST_FAILURE;
\r
163 return XST_SUCCESS;
\r