]> git.sur5r.net Git - freertos/blob - Demo/PPC405_Xilinx_Virtex4_GCC/TestApp_Peripheral/src/xuartlite_selftest_example.c
Add PPC405 port in V10.1 format.
[freertos] / Demo / PPC405_Xilinx_Virtex4_GCC / TestApp_Peripheral / src / xuartlite_selftest_example.c
1 #define TESTAPP_GEN
2 \r
3 /* $Id: xuartlite_selftest_example.c,v 1.1 2007/05/15 07:00:27 mta Exp $ */\r
4 /*****************************************************************************\r
5 *\r
6 *       XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS"\r
7 *       AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND\r
8 *       SOLUTIONS FOR XILINX DEVICES.  BY PROVIDING THIS DESIGN, CODE,\r
9 *       OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE,\r
10 *       APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION\r
11 *       THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT,\r
12 *       AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE\r
13 *       FOR YOUR IMPLEMENTATION.  XILINX EXPRESSLY DISCLAIMS ANY\r
14 *       WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE\r
15 *       IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR\r
16 *       REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF\r
17 *       INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\r
18 *       FOR A PARTICULAR PURPOSE.\r
19 *\r
20 *       (c) Copyright 2005 Xilinx Inc.\r
21 *       All rights reserved.\r
22 *\r
23 *****************************************************************************/\r
24 /****************************************************************************/\r
25 /**\r
26 *\r
27 * @file xuartlite_selftest_example.c\r
28 *\r
29 * This file contains a design example using the UartLite driver (XUartLite) and\r
30 * hardware device.\r
31 *\r
32 * @note\r
33 *\r
34 * None\r
35 *\r
36 * MODIFICATION HISTORY:\r
37 * <pre>\r
38 * Ver   Who  Date     Changes\r
39 * ----- ---- -------- -----------------------------------------------\r
40 * 1.00a ecm  01/25/04 First Release.\r
41 * 1.00a sv   06/13/05 Minor changes to comply to Doxygen and Coding guidelines\r
42 * </pre>\r
43 ******************************************************************************/\r
44 \r
45 /***************************** Include Files *********************************/\r
46 \r
47 #include "xparameters.h"\r
48 #include "xuartlite.h"\r
49 \r
50 /************************** Constant Definitions *****************************/\r
51 \r
52 /*\r
53  * The following constants map to the XPAR parameters created in the\r
54  * xparameters.h file. They are defined here such that a user can easily\r
55  * change all the needed parameters in one place.\r
56  */\r
57 #define UARTLITE_DEVICE_ID          XPAR_RS232_UART_DEVICE_ID\r
58 \r
59 \r
60 /**************************** Type Definitions *******************************/\r
61 \r
62 \r
63 /***************** Macros (Inline Functions) Definitions *********************/\r
64 \r
65 \r
66 /************************** Function Prototypes ******************************/\r
67 \r
68 XStatus UartLiteSelfTestExample(Xuint16 DeviceId);\r
69 \r
70 /************************** Variable Definitions *****************************/\r
71 \r
72 XUartLite UartLite;         /* Instance of the UartLite device */\r
73 \r
74 /*****************************************************************************/\r
75 /**\r
76 *\r
77 * Main function to call the example.  This function is not included if the\r
78 * example is generated from the TestAppGen test tool.\r
79 *\r
80 * @param    None.\r
81 *\r
82 * @return   XST_SUCCESS if succesful, otherwise XST_FAILURE.\r
83 *\r
84 * @note     None.\r
85 *\r
86 ******************************************************************************/\r
87 #ifndef TESTAPP_GEN\r
88 int main(void)\r
89 {\r
90     XStatus Status;\r
91 \r
92     /*\r
93      * Run the UartLite self test example, specify the the Device ID that is\r
94      * generated in xparameters.h\r
95      */\r
96     Status = UartLiteSelfTestExample(UARTLITE_DEVICE_ID);\r
97     if (Status != XST_SUCCESS)\r
98     {\r
99         return XST_FAILURE;\r
100     }\r
101 \r
102     return XST_SUCCESS;\r
103 \r
104 }\r
105 #endif\r
106 \r
107 /*****************************************************************************/\r
108 /**\r
109 *\r
110 * This function does a minimal test on the UartLite device and driver as a\r
111 * design example. The purpose of this function is to illustrate\r
112 * how to use the XUartLite component.\r
113 *\r
114 *\r
115 * @param    DeviceId is the XPAR_<uartlite_instance>_DEVICE_ID value from\r
116 *           xparameters.h.\r
117 *\r
118 * @return   XST_SUCCESS if succesful, otherwise XST_FAILURE.\r
119 *\r
120 * @note     None.\r
121 *\r
122 ****************************************************************************/\r
123 XStatus UartLiteSelfTestExample(Xuint16 DeviceId)\r
124 {\r
125     XStatus Status;\r
126 \r
127     /*\r
128      * Initialize the UartLite driver so that it is ready to use.\r
129      */\r
130     Status = XUartLite_Initialize(&UartLite, DeviceId);\r
131     if (Status != XST_SUCCESS)\r
132     {\r
133         return XST_FAILURE;\r
134     }\r
135 \r
136     /*\r
137      * Perform a self-test to ensure that the hardware was built correctly.\r
138      */\r
139     Status = XUartLite_SelfTest(&UartLite);\r
140     if (Status != XST_SUCCESS)\r
141     {\r
142         return XST_FAILURE;\r
143     }\r
144 \r
145     return XST_SUCCESS;\r
146 }\r
147 \r