]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/gpio_v4_1/src/xgpio.h
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.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2002 - 2015 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.h
35 * @addtogroup gpio_v4_1
36 * @{
37 * @details
38 *
39 * This file contains the software API definition of the Xilinx General Purpose
40 * I/O (XGpio) device driver.
41 *
42 * The Xilinx GPIO controller is a soft IP core designed for Xilinx FPGAs and
43 * contains the following general features:
44 *   - Support for up to 32 I/O discretes for each channel (64 bits total).
45 *   - Each of the discretes can be configured for input or output.
46 *   - Configurable support for dual channels and interrupt generation.
47 *
48 * The driver provides interrupt management functions. Implementation of
49 * interrupt handlers is left to the user. Refer to the provided interrupt
50 * example in the examples directory for details.
51 *
52 * This driver is intended to be RTOS and processor independent. Any needs for
53 * dynamic memory management, threads or thread mutual exclusion, virtual
54 * memory, or cache control must be satisfied by the layer above this driver.
55 *
56 * <b>Initialization & Configuration</b>
57 *
58 * The XGpio_Config structure is used by the driver to configure itself. This
59 * configuration structure is typically created by the tool-chain based on HW
60 * build properties.
61 *
62 * To support multiple runtime loading and initialization strategies employed
63 * by various operating systems, the driver instance can be initialized in one
64 * of the following ways:
65 *
66 *   - XGpio_Initialize(InstancePtr, DeviceId) - The driver looks up its own
67 *     configuration structure created by the tool-chain based on an ID provided
68 *     by the tool-chain.
69 *
70 *   - XGpio_CfgInitialize(InstancePtr, CfgPtr, EffectiveAddr) - Uses a
71 *     configuration structure provided by the caller. If running in a system
72 *     with address translation, the provided virtual memory base address
73 *     replaces the physical address present in the configuration structure.
74 *
75 * @note
76 *
77 * This API utilizes 32 bit I/O to the GPIO registers. With less than 32 bits,
78 * the unused bits from registers are read as zero and written as don't cares.
79 *
80 * <pre>
81 * MODIFICATION HISTORY:
82 *
83 * Ver   Who  Date     Changes
84 * ----- ---- -------- -----------------------------------------------
85 * 1.00a rmm  03/13/02 First release
86 * 2.00a jhl  11/26/03 Added support for dual channels and interrupts
87 * 2.01a jvb  12/14/05 I separated dependency on the static config table and
88 *                     xparameters.h from the driver initialization by moving
89 *                     _Initialize and _LookupConfig to _sinit.c. I also added
90 *                     the new _CfgInitialize routine.
91 * 2.11a mta  03/21/07 Updated to new coding style, added GetDataDirection
92 * 2.12a sv   11/21/07 Updated driver to support access through DCR bus
93 * 2.12a sv   06/05/08 Updated driver to fix the XGpio_InterruptDisable function
94 *                     to properly update the Interrupt Enable register
95 * 2.13a sdm  08/22/08 Removed support for static interrupt handlers from the MDD
96 *                     file
97 * 3.00a sv   11/21/09 Updated to use HAL Processor APIs.
98 *                     Renamed the macros XGpio_mWriteReg to XGpio_WriteReg and
99 *                     XGpio_mReadReg to XGpio_ReadReg. Removed the macros
100 *                     XGpio_mSetDataDirection, XGpio_mGetDataReg and
101 *                     XGpio_mSetDataReg. Users should use XGpio_WriteReg and
102 *                     XGpio_ReadReg to achieve the same functionality.
103 * 3.01a bss  04/18/13 Updated driver tcl to generate Canonical params in
104 *                     xparameters.h. CR#698589
105 * 4.0   adk  19/12/13 Updated as per the New Tcl API's
106 * 4.1   lks  11/18/15 Updated to use cannonical xparameters in examples and
107 *                     clean up of the comments, removed support for DCR bridge
108 *                     and removed xgpio_intr_example for CR 900381
109 *
110 * </pre>
111 *****************************************************************************/
112
113 #ifndef XGPIO_H                 /* prevent circular inclusions */
114 #define XGPIO_H                 /* by using protection macros */
115
116 #ifdef __cplusplus
117 extern "C" {
118 #endif
119
120 /***************************** Include Files ********************************/
121
122 #include "xil_types.h"
123 #include "xil_assert.h"
124 #include "xstatus.h"
125 #include "xgpio_l.h"
126
127 /************************** Constant Definitions ****************************/
128
129 /**************************** Type Definitions ******************************/
130
131 /**
132  * This typedef contains configuration information for the device.
133  */
134 typedef struct {
135         u16 DeviceId;           /* Unique ID  of device */
136         u32 BaseAddress;        /* Device base address */
137         int InterruptPresent;   /* Are interrupts supported in h/w */
138         int IsDual;             /* Are 2 channels supported in h/w */
139 } XGpio_Config;
140
141 /**
142  * The XGpio driver instance data. The user is required to allocate a
143  * variable of this type for every GPIO device in the system. A pointer
144  * to a variable of this type is then passed to the driver API functions.
145  */
146 typedef struct {
147         u32 BaseAddress;        /* Device base address */
148         u32 IsReady;            /* Device is initialized and ready */
149         int InterruptPresent;   /* Are interrupts supported in h/w */
150         int IsDual;             /* Are 2 channels supported in h/w */
151 } XGpio;
152
153 /***************** Macros (Inline Functions) Definitions ********************/
154
155
156 /************************** Function Prototypes *****************************/
157
158 /*
159  * Initialization functions in xgpio_sinit.c
160  */
161 int XGpio_Initialize(XGpio *InstancePtr, u16 DeviceId);
162 XGpio_Config *XGpio_LookupConfig(u16 DeviceId);
163
164 /*
165  * API Basic functions implemented in xgpio.c
166  */
167 int XGpio_CfgInitialize(XGpio *InstancePtr, XGpio_Config * Config,
168                         u32 EffectiveAddr);
169 void XGpio_SetDataDirection(XGpio *InstancePtr, unsigned Channel,
170                             u32 DirectionMask);
171 u32 XGpio_GetDataDirection(XGpio *InstancePtr, unsigned Channel);
172 u32 XGpio_DiscreteRead(XGpio *InstancePtr, unsigned Channel);
173 void XGpio_DiscreteWrite(XGpio *InstancePtr, unsigned Channel, u32 Mask);
174
175
176 /*
177  * API Functions implemented in xgpio_extra.c
178  */
179 void XGpio_DiscreteSet(XGpio *InstancePtr, unsigned Channel, u32 Mask);
180 void XGpio_DiscreteClear(XGpio *InstancePtr, unsigned Channel, u32 Mask);
181
182 /*
183  * API Functions implemented in xgpio_selftest.c
184  */
185 int XGpio_SelfTest(XGpio *InstancePtr);
186
187 /*
188  * API Functions implemented in xgpio_intr.c
189  */
190 void XGpio_InterruptGlobalEnable(XGpio *InstancePtr);
191 void XGpio_InterruptGlobalDisable(XGpio *InstancePtr);
192 void XGpio_InterruptEnable(XGpio *InstancePtr, u32 Mask);
193 void XGpio_InterruptDisable(XGpio *InstancePtr, u32 Mask);
194 void XGpio_InterruptClear(XGpio *InstancePtr, u32 Mask);
195 u32 XGpio_InterruptGetEnabled(XGpio *InstancePtr);
196 u32 XGpio_InterruptGetStatus(XGpio *InstancePtr);
197
198 #ifdef __cplusplus
199 }
200 #endif
201
202 #endif /* end of protection macro */
203 /** @} */