]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/gpio_v4_1/src/xgpio_selftest.c
Update the Microblaze hardware design and BSP to the latest IP and tool versions.
[freertos] / FreeRTOS / Demo / MicroBlaze_Kintex7_EthernetLite / BSP / microblaze_0 / libsrc / gpio_v4_1 / 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 * @addtogroup gpio_v4_1
36 * @{
37 *
38 * The implementation of the XGpio driver's self test function.
39 * See xgpio.h for more information about the driver.
40 *
41 * @note
42 *
43 * None
44 *
45 * <pre>
46 * MODIFICATION HISTORY:
47 *
48 * Ver   Who  Date     Changes
49 * ----- ---- -------- -----------------------------------------------
50 * 1.00a rmm  02/04/02 First release
51 * 2.00a jhl  01/13/04 Addition of dual channels and interrupts.
52 * 2.11a mta  03/21/07 Updated to new coding style
53 * 3.00a sv   11/21/09 Updated to use HAL Processor APIs.
54 * </pre>
55 *
56 *****************************************************************************/
57
58 /***************************** Include Files ********************************/
59 #include "xgpio.h"
60
61 /************************** Constant Definitions ****************************/
62
63 /**************************** Type Definitions ******************************/
64
65 /***************** Macros (Inline Functions) Definitions ********************/
66
67 /************************** Variable Definitions ****************************/
68
69 /************************** Function Prototypes *****************************/
70
71
72 /******************************************************************************/
73 /**
74 * Run a self-test on the driver/device. This function does a minimal test
75 * in which the data register is read. It only does a read without any kind
76 * of test because the hardware has been parameterized such that it may be only
77 * an input such that the state of the inputs won't be known.
78 *
79 * All other hardware features of the device are not guaranteed to be in the
80 * hardware since they are parameterizable.
81 *
82 *
83 * @param        InstancePtr is a pointer to the XGpio instance to be worked on.
84 *               This parameter must have been previously initialized with
85 *               XGpio_Initialize().
86 *
87 * @return       XST_SUCCESS always. If the GPIO device was not present in the
88 *               hardware a bus error could be generated. Other indicators of a
89 *               bus error, such as registers in bridges or buses, may be
90 *               necessary to determine if this function caused a bus error.
91 *
92 * @note         None.
93 *
94 ******************************************************************************/
95 int XGpio_SelfTest(XGpio * InstancePtr)
96 {
97         Xil_AssertNonvoid(InstancePtr != NULL);
98         Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
99
100         /*
101          * Read from the data register of channel 1 which is always guaranteed
102          * to be in the hardware device. Since the data may be configured as
103          * all inputs, there is not way to guarantee the value read so don't
104          * test it.
105          */
106         (void) XGpio_DiscreteRead(InstancePtr, 1);
107
108         return (XST_SUCCESS);
109 }
110 /** @} */