]> begriffs open source - freertos/blob - Demo/MicroBlaze_Spartan-6_Ethernet/RTOSDemoSource/src/xtmrctr_selftest_example.c
Remove files that are not required from the MicroBlaze demo project directories.
[freertos] / Demo / MicroBlaze_Spartan-6_Ethernet / RTOSDemoSource / src / xtmrctr_selftest_example.c
1 #define TESTAPP_GEN
2 \r
3 /* $Id: xtmrctr_selftest_example.c,v 1.1.2.1 2010/12/01 07:53:56 svemula Exp $ */\r
4 /******************************************************************************\r
5 *\r
6 * (c) Copyright 2002-2010 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 * @file xtmrctr_selftest_example.c\r
47 *\r
48 * This file contains a example for  using the Timer Counter hardware and\r
49 * driver\r
50 *\r
51 * @note\r
52 *\r
53 * None\r
54 *\r
55 * <pre>\r
56 * MODIFICATION HISTORY:\r
57 *\r
58 * Ver   Who  Date        Changes\r
59 * ----- ---- -------- -----------------------------------------------\r
60 * 1.00a sv   04/25/05 Initial release for TestApp integration.\r
61 * 2.00a ktn  11/26/09 Minor changes as per coding guidelines.\r
62 * </pre>\r
63 *\r
64 *****************************************************************************/\r
65 \r
66 /***************************** Include Files ********************************/\r
67 \r
68 #include "xparameters.h"\r
69 #include "xtmrctr.h"\r
70 \r
71 \r
72 /************************** Constant Definitions ****************************/\r
73 \r
74 /*\r
75  * The following constants map to the XPAR parameters created in the\r
76  * xparameters.h file. They are defined here such that a user can easily\r
77  * change all the needed parameters in one place.\r
78  */\r
79 #define TMRCTR_DEVICE_ID  XPAR_TMRCTR_0_DEVICE_ID\r
80 \r
81 /*\r
82  * This example only uses the 1st of the 2 timer counters contained in a\r
83  * single timer counter hardware device\r
84  */\r
85 #define TIMER_COUNTER_0  0\r
86 \r
87 /**************************** Type Definitions ******************************/\r
88 \r
89 \r
90 /***************** Macros (Inline Functions) Definitions *******************/\r
91 \r
92 \r
93 /************************** Function Prototypes ****************************/\r
94 \r
95 int TmrCtrSelfTestExample(u16 DeviceId, u8 TmrCtrNumber);\r
96 \r
97 /************************** Variable Definitions **************************/\r
98 \r
99 XTmrCtr TimerCounter; /* The instance of the timer counter */\r
100 \r
101 \r
102 /*****************************************************************************/\r
103 /**\r
104 * Main function to call the example. This function is not included if the\r
105 * example is generated from the TestAppGen test tool.\r
106 *\r
107 * @param        None\r
108 *\r
109 * @return   XST_SUCCESS to indicate success, else XST_FAILURE to indicate\r
110 *                  a Failure.\r
111 *\r
112 * @note  None\r
113 *\r
114 ******************************************************************************/\r
115 #ifndef TESTAPP_GEN\r
116 int main(void)\r
117 {\r
118         int Status;\r
119 \r
120         Status = TmrCtrSelfTestExample(TMRCTR_DEVICE_ID, TIMER_COUNTER_0);\r
121         if (Status != XST_SUCCESS) {\r
122                 return XST_FAILURE;\r
123         }\r
124 \r
125         return XST_SUCCESS;\r
126 }\r
127 #endif\r
128 \r
129 \r
130 /*****************************************************************************/\r
131 /**\r
132 *\r
133 * This function does a minimal test on the TmrCtr device and driver as a\r
134 * design example. The purpose of this function is to illustrate\r
135 * how to use the XTmrCtr component.\r
136 *\r
137 *\r
138 * @param        DeviceId is the XPAR_<TMRCTR_instance>_DEVICE_ID value from\r
139 *               xparameters.h\r
140 * @param        TmrCtrNumber is the timer counter of the device to operate on.\r
141 *               Each device may contain multiple timer counters.\r
142 *               The timer number is a zero based number with a range of\r
143 *               0 - (XTC_DEVICE_TIMER_COUNT - 1).\r
144 *\r
145 * @return       XST_SUCCESS if successful, XST_FAILURE if unsuccessful\r
146 *\r
147 * @note         None\r
148 *\r
149 ****************************************************************************/\r
150 int TmrCtrSelfTestExample(u16 DeviceId, u8 TmrCtrNumber)\r
151 {\r
152         int Status;\r
153         XTmrCtr *TmrCtrInstancePtr = &TimerCounter;\r
154 \r
155         /*\r
156          * Initialize the TmrCtr driver so that it iss ready to use\r
157          */\r
158         Status = XTmrCtr_Initialize(TmrCtrInstancePtr, DeviceId);\r
159         if (Status != XST_SUCCESS) {\r
160                 return XST_FAILURE;\r
161         }\r
162 \r
163         /*\r
164          * Perform a self-test to ensure that the hardware was built\r
165          * correctly, use the 1st timer in the device (0)\r
166          */\r
167         Status = XTmrCtr_SelfTest(TmrCtrInstancePtr, TmrCtrNumber);\r
168         if (Status != XST_SUCCESS) {\r
169                 return XST_FAILURE;\r
170         }\r
171 \r
172         return XST_SUCCESS;\r
173 }\r
174 \r