3 /* $Id: xtmrctr_selftest_example.c,v 1.1.2.1 2010/12/01 07:53:56 svemula Exp $ */
\r
4 /******************************************************************************
\r
6 * (c) Copyright 2002-2010 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
46 * @file xtmrctr_selftest_example.c
\r
48 * This file contains a example for using the Timer Counter hardware and
\r
56 * MODIFICATION HISTORY:
\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
64 *****************************************************************************/
\r
66 /***************************** Include Files ********************************/
\r
68 #include "xparameters.h"
\r
69 #include "xtmrctr.h"
\r
72 /************************** Constant Definitions ****************************/
\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
79 #define TMRCTR_DEVICE_ID XPAR_TMRCTR_0_DEVICE_ID
\r
82 * This example only uses the 1st of the 2 timer counters contained in a
\r
83 * single timer counter hardware device
\r
85 #define TIMER_COUNTER_0 0
\r
87 /**************************** Type Definitions ******************************/
\r
90 /***************** Macros (Inline Functions) Definitions *******************/
\r
93 /************************** Function Prototypes ****************************/
\r
95 int TmrCtrSelfTestExample(u16 DeviceId, u8 TmrCtrNumber);
\r
97 /************************** Variable Definitions **************************/
\r
99 XTmrCtr TimerCounter; /* The instance of the timer counter */
\r
102 /*****************************************************************************/
\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
109 * @return XST_SUCCESS to indicate success, else XST_FAILURE to indicate
\r
114 ******************************************************************************/
\r
115 #ifndef TESTAPP_GEN
\r
120 Status = TmrCtrSelfTestExample(TMRCTR_DEVICE_ID, TIMER_COUNTER_0);
\r
121 if (Status != XST_SUCCESS) {
\r
122 return XST_FAILURE;
\r
125 return XST_SUCCESS;
\r
130 /*****************************************************************************/
\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
138 * @param DeviceId is the XPAR_<TMRCTR_instance>_DEVICE_ID value from
\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
145 * @return XST_SUCCESS if successful, XST_FAILURE if unsuccessful
\r
149 ****************************************************************************/
\r
150 int TmrCtrSelfTestExample(u16 DeviceId, u8 TmrCtrNumber)
\r
153 XTmrCtr *TmrCtrInstancePtr = &TimerCounter;
\r
156 * Initialize the TmrCtr driver so that it iss ready to use
\r
158 Status = XTmrCtr_Initialize(TmrCtrInstancePtr, DeviceId);
\r
159 if (Status != XST_SUCCESS) {
\r
160 return XST_FAILURE;
\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
167 Status = XTmrCtr_SelfTest(TmrCtrInstancePtr, TmrCtrNumber);
\r
168 if (Status != XST_SUCCESS) {
\r
169 return XST_FAILURE;
\r
172 return XST_SUCCESS;
\r