1 /******************************************************************************
3 * Copyright (C) 2002 - 2014 Xilinx, Inc. All rights reserved.
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
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
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.
31 ******************************************************************************/
32 /*****************************************************************************/
34 * @file xgpio_selftest.c
36 * The implementation of the XGpio driver's self test function.
37 * See xgpio.h for more information about the driver.
44 * MODIFICATION HISTORY:
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.
54 *****************************************************************************/
56 /***************************** Include Files ********************************/
59 /************************** Constant Definitions ****************************/
61 /**************************** Type Definitions ******************************/
63 /***************** Macros (Inline Functions) Definitions ********************/
65 /************************** Variable Definitions ****************************/
67 /************************** Function Prototypes *****************************/
70 /******************************************************************************/
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.
77 * All other hardware features of the device are not guaranteed to be in the
78 * hardware since they are parameterizable.
81 * @param InstancePtr is a pointer to the XGpio instance to be worked on.
82 * This parameter must have been previously initialized with
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.
92 ******************************************************************************/
93 int XGpio_SelfTest(XGpio * InstancePtr)
95 Xil_AssertNonvoid(InstancePtr != NULL);
96 Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
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
104 (void) XGpio_DiscreteRead(InstancePtr, 1);
106 return (XST_SUCCESS);