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
35 * @addtogroup gpio_v4_1
38 * The implementation of the XGpio driver's self test function.
39 * See xgpio.h for more information about the driver.
46 * MODIFICATION HISTORY:
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.
56 *****************************************************************************/
58 /***************************** Include Files ********************************/
61 /************************** Constant Definitions ****************************/
63 /**************************** Type Definitions ******************************/
65 /***************** Macros (Inline Functions) Definitions ********************/
67 /************************** Variable Definitions ****************************/
69 /************************** Function Prototypes *****************************/
72 /******************************************************************************/
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.
79 * All other hardware features of the device are not guaranteed to be in the
80 * hardware since they are parameterizable.
83 * @param InstancePtr is a pointer to the XGpio instance to be worked on.
84 * This parameter must have been previously initialized with
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.
94 ******************************************************************************/
95 int XGpio_SelfTest(XGpio * InstancePtr)
97 Xil_AssertNonvoid(InstancePtr != NULL);
98 Xil_AssertNonvoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);
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
106 (void) XGpio_DiscreteRead(InstancePtr, 1);
108 return (XST_SUCCESS);