]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M4_SimpleLink_CC3220SF_CCS/ti/drivers/gpio/GPIOCC32XX.h
Add SimpleLink CC3220SF demo.
[freertos] / FreeRTOS / Demo / CORTEX_M4_SimpleLink_CC3220SF_CCS / ti / drivers / gpio / GPIOCC32XX.h
1 /*
2  * Copyright (c) 2015-2016, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * *  Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * *  Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * *  Neither the name of Texas Instruments Incorporated nor the names of
17  *    its contributors may be used to endorse or promote products derived
18  *    from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 /*! ============================================================================
33  *  @file       GPIOCC32XX.h
34  *
35  *  @brief      GPIO driver implementation for CC32xx devices
36  *
37  *  The GPIO header file should be included in an application as follows:
38  *  @code
39  *  #include <ti/drivers/GPIO.h>
40  *  #include <ti/drivers/gpio/GPIOCC32XX.h>
41  *  @endcode
42  *
43  *  Refer to @ref GPIO.h for a complete description of the GPIO
44  *  driver APIs provided and examples of their use.
45  *
46  *  ### CC32xx GPIO Driver Configuration #
47  *
48  *  In order to use the GPIO APIs, the application is required
49  *  to provide 3 structures in the Board.c file:
50  *
51  *  1.  An array of @ref GPIO_PinConfig elements that defines the
52  *  initial configuration of each pin used by the application. A
53  *  pin is referenced in the application by its corresponding index in this
54  *  array. The pin type (that is, INPUT/OUTPUT), its initial state (that is
55  *  OUTPUT_HIGH or LOW), interrupt behavior (RISING/FALLING edge, etc.)
56  *  (see @ref GPIO_PinConfigSettings), and
57  *  device specific pin identification (see @ref GPIOCC32XX_PinConfigIds)
58  *  are configured in each element of this array.
59  *  Below is an CC32XX device specific example of the GPIO_PinConfig array:
60  *  @code
61  *  //
62  *  // Array of Pin configurations
63  *  // NOTE: The order of the pin configurations must coincide with what was
64  *  //       defined in CC3220SF_LAUNCHXL.h
65  *  // NOTE: Pins not used for interrupts should be placed at the end of the
66  *  //       array.  Callback entries can be omitted from callbacks array to
67  *  //       reduce memory usage.
68  *  //
69  *  GPIO_PinConfig gpioPinConfigs[] = {
70  *      // input pins with callbacks
71  *      // CC3220SF_LAUNCHXL_GPIO_SW2
72  *      GPIOCC32XX_GPIO_22 | GPIO_CFG_INPUT | GPIO_CFG_IN_INT_RISING,
73  *      // CC3220SF_LAUNCHXL_GPIO_SW3
74  *      GPIOCC32XX_GPIO_13 | GPIO_CFG_INPUT | GPIO_CFG_IN_INT_RISING,
75  *
76  *      // output pins
77  *      // CC3220SF_LAUNCHXL_GPIO_LED_D7
78  *      GPIOCC32XX_GPIO_09 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
79  *  };
80  *  @endcode
81  *
82  *  2.  An array of @ref GPIO_CallbackFxn elements that is used to store
83  *  callback function pointers for GPIO pins configured with interrupts.
84  *  The indexes for these array elements correspond to the pins defined
85  *  in the @ref GPIO_PinConfig array. These function pointers can be defined
86  *  statically by referencing the callback function name in the array
87  *  element, or dynamically, by setting the array element to NULL and using
88  *  GPIO_setCallback() at runtime to plug the callback entry.
89  *  Pins not used for interrupts can be omitted from the callback array to
90  *  reduce memory usage (if they are placed at the end of the @ref
91  *  GPIO_PinConfig array). The callback function syntax should match the
92  *  following:
93  *  @code
94  *  void (*GPIO_CallbackFxn)(unsigned int index);
95  *  @endcode
96  *  The index parameter is the same index that was passed to
97  *  GPIO_setCallback(). This allows the same callback function to be used
98  *  for multiple GPIO interrupts, by using the index to identify the GPIO
99  *  that caused the interrupt.
100  *  Below is a CC32XX device specific example of the @ref GPIO_CallbackFxn
101  *  array:
102  *  @code
103  *  //
104  *  // Array of callback function pointers
105  *  // NOTE: The order of the pin configurations must coincide with what was
106  *  //       defined in CC3220SF_LAUNCHXL.h
107  *  // NOTE: Pins not used for interrupts can be omitted from callbacks array to
108  *  //       reduce memory usage (if placed at end of gpioPinConfigs array).
109  *  //
110  *  GPIO_CallbackFxn gpioCallbackFunctions[] = {
111  *      NULL,  // CC3220SF_LAUNCHXL_GPIO_SW2
112  *      NULL   // CC3220SF_LAUNCHXL_GPIO_SW3
113  *  };
114  *  @endcode
115  *
116  *  3.  The device specific GPIOCC32XX_Config structure that tells the GPIO
117  *  driver where the two aforementioned arrays are and the number of elements
118  *  in each. The interrupt priority of all pins configured to generate
119  *  interrupts is also specified here. Values for the interrupt priority are
120  *  device-specific. You should be well-acquainted with the interrupt
121  *  controller used in your device before setting this parameter to a
122  *  non-default value. The sentinel value of (~0) (the default value) is
123  *  used to indicate that the lowest possible priority should be used.
124  *  Below is an example of an initialized GPIOCC32XX_Config
125  *  structure:
126  *  @code
127  *  const GPIOCC32XX_Config GPIOCC32XX_config = {
128  *      .pinConfigs = (GPIO_PinConfig *)gpioPinConfigs,
129  *      .callbacks = (GPIO_CallbackFxn *)gpioCallbackFunctions,
130  *      .numberOfPinConfigs = sizeof(gpioPinConfigs)/sizeof(GPIO_PinConfig),
131  *      .numberOfCallbacks = sizeof(gpioCallbackFunctions)/sizeof(GPIO_CallbackFxn),
132  *      .intPriority = (~0)
133  *  };
134  *  @endcode
135  *
136  *  ============================================================================
137  */
138
139 #ifndef ti_drivers_GPIOCC32XX__include
140 #define ti_drivers_GPIOCC32XX__include
141
142 #ifdef __cplusplus
143 extern "C" {
144 #endif
145
146 #include <stdint.h>
147 #include <ti/drivers/GPIO.h>
148
149 /*!
150  *  @brief  GPIO device specific driver configuration structure
151  *
152  *  The device specific GPIOCC32XX_Config structure that tells the GPIO
153  *  driver where the two aforementioned arrays are and the number of elements
154  *  in each. The interrupt priority of all pins configured to generate
155  *  interrupts is also specified here. Values for the interrupt priority are
156  *  device-specific. You should be well-acquainted with the interrupt
157  *  controller used in your device before setting this parameter to a
158  *  non-default value. The sentinel value of (~0) (the default value) is
159  *  used to indicate that the lowest possible priority should be used.
160  *
161  *  Below is an example of an initialized GPIOCC32XX_Config
162  *  structure:
163  *  @code
164  *  const GPIOCC32XX_Config GPIOCC32XX_config = {
165  *      .pinConfigs = (GPIO_PinConfig *)gpioPinConfigs,
166  *      .callbacks = (GPIO_CallbackFxn *)gpioCallbackFunctions,
167  *      .numberOfPinConfigs = sizeof(gpioPinConfigs)/sizeof(GPIO_PinConfig),
168  *      .numberOfCallbacks = sizeof(gpioCallbackFunctions)/sizeof(GPIO_CallbackFxn),
169  *      .intPriority = (~0)
170  *  };
171  *  @endcode
172  */
173 typedef struct GPIOCC32XX_Config {
174     /*! Pointer to the board's GPIO_PinConfig array */
175     GPIO_PinConfig  *pinConfigs;
176
177     /*! Pointer to the board's GPIO_CallbackFxn array */
178     GPIO_CallbackFxn  *callbacks;
179
180     /*! Number of GPIO_PinConfigs defined */
181     uint32_t numberOfPinConfigs;
182
183     /*! Number of GPIO_Callbacks defined */
184     uint32_t numberOfCallbacks;
185
186     /*!
187      *  Interrupt priority used for call back interrupts.
188      *
189      *  intPriority is the interrupt priority, as defined by the
190      *  underlying OS.  It is passed unmodified to the underlying OS's
191      *  interrupt handler creation code, so you need to refer to the OS
192      *  documentation for usage.  For example, for SYS/BIOS applications,
193      *  refer to the ti.sysbios.family.arm.m3.Hwi documentation for SYS/BIOS
194      *  usage of interrupt priorities.  If the driver uses the ti.dpl
195      *  interface instead of making OS calls directly, then the HwiP port
196      *  handles the interrupt priority in an OS specific way.  In the case
197      *  of the SYS/BIOS port, intPriority is passed unmodified to Hwi_create().
198      *
199      *  Setting ~0 will configure the lowest possible priority
200      */
201     uint32_t intPriority;
202 } GPIOCC32XX_Config;
203
204 /*!
205  *  \defgroup GPIOCC32XX_PinConfigIds GPIO pin identification macros used to configure GPIO pins
206  *  @{
207  */
208 /**
209  *  @name Device specific GPIO port/pin identifiers to be used within the board's GPIO_PinConfig table.
210  *  @{
211 */
212 #define GPIOCC32XX_EMPTY_PIN  0x0000    /*!< @hideinitializer */
213
214 #define GPIOCC32XX_GPIO_00    0x0001    /*!< @hideinitializer */
215 #define GPIOCC32XX_GPIO_01    0x0002    /*!< @hideinitializer */
216 #define GPIOCC32XX_GPIO_02    0x0004    /*!< @hideinitializer */
217 #define GPIOCC32XX_GPIO_03    0x0008    /*!< @hideinitializer */
218 #define GPIOCC32XX_GPIO_04    0x0010    /*!< @hideinitializer */
219 #define GPIOCC32XX_GPIO_05    0x0020    /*!< @hideinitializer */
220 #define GPIOCC32XX_GPIO_06    0x0040    /*!< @hideinitializer */
221 #define GPIOCC32XX_GPIO_07    0x0080    /*!< @hideinitializer */
222
223 #define GPIOCC32XX_GPIO_08    0x0101    /*!< @hideinitializer */
224 #define GPIOCC32XX_GPIO_09    0x0102    /*!< @hideinitializer */
225 #define GPIOCC32XX_GPIO_10    0x0104    /*!< @hideinitializer */
226 #define GPIOCC32XX_GPIO_11    0x0108    /*!< @hideinitializer */
227 #define GPIOCC32XX_GPIO_12    0x0110    /*!< @hideinitializer */
228 #define GPIOCC32XX_GPIO_13    0x0120    /*!< @hideinitializer */
229 #define GPIOCC32XX_GPIO_14    0x0140    /*!< @hideinitializer */
230 #define GPIOCC32XX_GPIO_15    0x0180    /*!< @hideinitializer */
231
232 #define GPIOCC32XX_GPIO_16    0x0201    /*!< @hideinitializer */
233 #define GPIOCC32XX_GPIO_17    0x0202    /*!< @hideinitializer */
234 #define GPIOCC32XX_GPIO_18    0x0204    /*!< @hideinitializer */
235 #define GPIOCC32XX_GPIO_19    0x0208    /*!< @hideinitializer */
236 #define GPIOCC32XX_GPIO_20    0x0210    /*!< @hideinitializer */
237 #define GPIOCC32XX_GPIO_21    0x0220    /*!< @hideinitializer */
238 #define GPIOCC32XX_GPIO_22    0x0240    /*!< @hideinitializer */
239 #define GPIOCC32XX_GPIO_23    0x0280    /*!< @hideinitializer */
240
241 #define GPIOCC32XX_GPIO_24    0x0301    /*!< @hideinitializer */
242 #define GPIOCC32XX_GPIO_25    0x0302    /*!< @hideinitializer */
243 #define GPIOCC32XX_GPIO_26    0x0304    /*!< @hideinitializer */
244 #define GPIOCC32XX_GPIO_27    0x0308    /*!< @hideinitializer */
245 #define GPIOCC32XX_GPIO_28    0x0310    /*!< @hideinitializer */
246 #define GPIOCC32XX_GPIO_29    0x0320    /*!< @hideinitializer */
247 #define GPIOCC32XX_GPIO_30    0x0340    /*!< @hideinitializer */
248 #define GPIOCC32XX_GPIO_31    0x0380    /*!< @hideinitializer */
249 /** @} */
250
251 /**
252  *  @name CC32xx device specific GPIO_PinConfig macros
253  *  @{
254  */
255 #define GPIOCC32XX_USE_STATIC 0x8000    /*!< @hideinitializer use statically-defined parking state */
256 /** @} */
257
258 /** @} end of GPIOCC32XX_PinConfigIds group */
259
260 #ifdef __cplusplus
261 }
262 #endif
263
264 #endif /* ti_drivers_GPIOCC32XX__include */