]> git.sur5r.net Git - freertos/blob - Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/src/xuartlite_selftest_example.c
Add autogenerated test source code to the new MicroBlaze project.
[freertos] / Demo / MicroBlaze_Spartan-6_EthernetLite / SDKProjects / RTOSDemoSource / src / xuartlite_selftest_example.c
1 #define TESTAPP_GEN
2 \r
3 /* $Id: xuartlite_selftest_example.c,v 1.1.2.1 2009/11/24 05:14:25 svemula Exp $ */\r
4 /******************************************************************************\r
5 *\r
6 * (c) Copyright 2005-2009 Xilinx, Inc. All rights reserved.\r
7 *\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
11 *\r
12 * DISCLAIMER\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
28 *\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
39 *\r
40 * THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE\r
41 * AT ALL TIMES.\r
42 *\r
43 ******************************************************************************/\r
44 /****************************************************************************/\r
45 /**\r
46 *\r
47 * @file xuartlite_selftest_example.c\r
48 *\r
49 * This file contains a design example using the UartLite driver (XUartLite) and\r
50 * hardware device.\r
51 *\r
52 * @note\r
53 *\r
54 * None\r
55 *\r
56 * MODIFICATION HISTORY:\r
57 * <pre>\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
63 * </pre>\r
64 ******************************************************************************/\r
65 \r
66 /***************************** Include Files *********************************/\r
67 \r
68 #include "xparameters.h"\r
69 #include "xuartlite.h"\r
70 \r
71 /************************** Constant Definitions *****************************/\r
72 \r
73 /*\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
77  */\r
78 #define UARTLITE_DEVICE_ID              XPAR_UARTLITE_0_DEVICE_ID\r
79 \r
80 \r
81 /**************************** Type Definitions *******************************/\r
82 \r
83 \r
84 /***************** Macros (Inline Functions) Definitions *********************/\r
85 \r
86 \r
87 /************************** Function Prototypes ******************************/\r
88 \r
89 int UartLiteSelfTestExample(u16 DeviceId);\r
90 \r
91 /************************** Variable Definitions *****************************/\r
92 \r
93 XUartLite UartLite;              /* Instance of the UartLite device */\r
94 \r
95 /*****************************************************************************/\r
96 /**\r
97 *\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
100 *\r
101 * @param        None.\r
102 *\r
103 * @return       XST_SUCCESS if successful, otherwise XST_FAILURE.\r
104 *\r
105 * @note         None.\r
106 *\r
107 ******************************************************************************/\r
108 #ifndef TESTAPP_GEN\r
109 int main(void)\r
110 {\r
111         int Status;\r
112 \r
113         /*\r
114          * Run the UartLite self test example, specify the Device ID that is\r
115          * generated in xparameters.h\r
116          */\r
117         Status = UartLiteSelfTestExample(UARTLITE_DEVICE_ID);\r
118         if (Status != XST_SUCCESS) {\r
119                 return XST_FAILURE;\r
120         }\r
121 \r
122         return XST_SUCCESS;\r
123 \r
124 }\r
125 #endif\r
126 \r
127 /*****************************************************************************/\r
128 /**\r
129 *\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
133 *\r
134 *\r
135 * @param        DeviceId is the XPAR_<uartlite_instance>_DEVICE_ID value from\r
136 *               xparameters.h.\r
137 *\r
138 * @return       XST_SUCCESS if successful, otherwise XST_FAILURE.\r
139 *\r
140 * @note         None.\r
141 *\r
142 ****************************************************************************/\r
143 int UartLiteSelfTestExample(u16 DeviceId)\r
144 {\r
145         int Status;\r
146 \r
147         /*\r
148          * Initialize the UartLite driver so that it is ready to use.\r
149          */\r
150         Status = XUartLite_Initialize(&UartLite, DeviceId);\r
151         if (Status != XST_SUCCESS) {\r
152                 return XST_FAILURE;\r
153         }\r
154 \r
155         /*\r
156          * Perform a self-test to ensure that the hardware was built correctly.\r
157          */\r
158         Status = XUartLite_SelfTest(&UartLite);\r
159         if (Status != XST_SUCCESS) {\r
160                 return XST_FAILURE;\r
161         }\r
162 \r
163         return XST_SUCCESS;\r
164 }\r
165 \r
166 \r