]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/gpio_v4_0/src/xgpio_selftest.c
Update some more standard demos for use on 64-bit architectures.
[freertos] / FreeRTOS / Demo / MicroBlaze_Kintex7_EthernetLite / BSP / microblaze_0 / libsrc / gpio_v4_0 / src / xgpio_selftest.c
1 /******************************************************************************
2 *
3 * Copyright (C) 2002 - 2014 Xilinx, Inc.  All rights reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 *
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
30 *
31 ******************************************************************************/
32 /*****************************************************************************/
33 /**
34 * @file xgpio_selftest.c
35 *
36 * The implementation of the XGpio driver's self test function.
37 * See xgpio.h for more information about the driver.
38 *
39 * @note
40 *
41 * None
42 *
43 * <pre>
44 * MODIFICATION HISTORY:
45 *
46 * Ver   Who  Date     Changes
47 * ----- ---- -------- -----------------------------------------------
48 * 1.00a rmm  02/04/02 First release
49 * 2.00a jhl  01/13/04 Addition of dual channels and interrupts.
50 * 2.11a mta  03/21/07 Updated to new coding style
51 * 3.00a sv   11/21/09 Updated to use HAL Processor APIs.
52 * </pre>
53 *
54 *****************************************************************************/
55
56 /***************************** Include Files ********************************/
57 #include "xgpio.h"
58
59 /************************** Constant Definitions ****************************/
60
61 /**************************** Type Definitions ******************************/
62
63 /***************** Macros (Inline Functions) Definitions ********************/
64
65 /************************** Variable Definitions ****************************/
66
67 /************************** Function Prototypes *****************************/
68
69
70 /******************************************************************************/
71 /**
72 * Run a self-test on the driver/device. This function does a minimal test
73 * in which the data register is read. It only does a read without any kind
74 * of test because the hardware has been parameterized such that it may be only
75 * an input such that the state of the inputs won't be known.
76 *
77 * All other hardware features of the device are not guaranteed to be in the
78 * hardware since they are parameterizable.
79 *
80 *
81 * @param        InstancePtr is a pointer to the XGpio instance to be worked on.
82 *               This parameter must have been previously initialized with
83 *               XGpio_Initialize().
84 *
85 * @return       XST_SUCCESS always. If the GPIO device was not present in the
86 *               hardware a bus error could be generated. Other indicators of a
87 *               bus error, such as registers in bridges or buses, may be
88 *               necessary to determine if this function caused a bus error.
89 *
90 * @note         None.
91 *
92 ******************************************************************************/
93 int XGpio_SelfTest(XGpio * InstancePtr)
94 {
95         Xil_AssertNonvoid(InstancePtr != NULL);
96         Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
97
98         /*
99          * Read from the data register of channel 1 which is always guaranteed
100          * to be in the hardware device. Since the data may be configured as
101          * all inputs, there is not way to guarantee the value read so don't
102          * test it.
103          */
104         (void) XGpio_DiscreteRead(InstancePtr, 1);
105
106         return (XST_SUCCESS);
107 }