mbed library sources. Supersedes mbed-src. Edited target satm32f446 for user USART3 pins

Dependents:   IGLOO_board

Fork of mbed-dev by mbed official

Committer:
ua1arn
Date:
Mon Jul 30 12:31:10 2018 +0000
Revision:
188:3f10722804f9
Parent:
186:707f6e361f3e
before add multi-configuration USB descriptors

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Anna Bridge 186:707f6e361f3e 1 /**
Anna Bridge 186:707f6e361f3e 2 * @file
Anna Bridge 186:707f6e361f3e 3 * @brief General-Purpose Input/Output (GPIO) function prototypes and data types.
Anna Bridge 186:707f6e361f3e 4 */
Anna Bridge 186:707f6e361f3e 5
Anna Bridge 186:707f6e361f3e 6 /* ****************************************************************************
Anna Bridge 186:707f6e361f3e 7 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
Anna Bridge 186:707f6e361f3e 8 *
Anna Bridge 186:707f6e361f3e 9 * Permission is hereby granted, free of charge, to any person obtaining a
Anna Bridge 186:707f6e361f3e 10 * copy of this software and associated documentation files (the "Software"),
Anna Bridge 186:707f6e361f3e 11 * to deal in the Software without restriction, including without limitation
Anna Bridge 186:707f6e361f3e 12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
Anna Bridge 186:707f6e361f3e 13 * and/or sell copies of the Software, and to permit persons to whom the
Anna Bridge 186:707f6e361f3e 14 * Software is furnished to do so, subject to the following conditions:
Anna Bridge 186:707f6e361f3e 15 *
Anna Bridge 186:707f6e361f3e 16 * The above copyright notice and this permission notice shall be included
Anna Bridge 186:707f6e361f3e 17 * in all copies or substantial portions of the Software.
Anna Bridge 186:707f6e361f3e 18 *
Anna Bridge 186:707f6e361f3e 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
Anna Bridge 186:707f6e361f3e 20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Anna Bridge 186:707f6e361f3e 21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
Anna Bridge 186:707f6e361f3e 22 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
Anna Bridge 186:707f6e361f3e 23 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
Anna Bridge 186:707f6e361f3e 24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
Anna Bridge 186:707f6e361f3e 25 * OTHER DEALINGS IN THE SOFTWARE.
Anna Bridge 186:707f6e361f3e 26 *
Anna Bridge 186:707f6e361f3e 27 * Except as contained in this notice, the name of Maxim Integrated
Anna Bridge 186:707f6e361f3e 28 * Products, Inc. shall not be used except as stated in the Maxim Integrated
Anna Bridge 186:707f6e361f3e 29 * Products, Inc. Branding Policy.
Anna Bridge 186:707f6e361f3e 30 *
Anna Bridge 186:707f6e361f3e 31 * The mere transfer of this software does not imply any licenses
Anna Bridge 186:707f6e361f3e 32 * of trade secrets, proprietary technology, copyrights, patents,
Anna Bridge 186:707f6e361f3e 33 * trademarks, maskwork rights, or any other form of intellectual
Anna Bridge 186:707f6e361f3e 34 * property whatsoever. Maxim Integrated Products, Inc. retains all
Anna Bridge 186:707f6e361f3e 35 * ownership rights.
Anna Bridge 186:707f6e361f3e 36 *
Anna Bridge 186:707f6e361f3e 37 * $Date: 2016-10-10 18:56:06 -0500 (Mon, 10 Oct 2016) $
Anna Bridge 186:707f6e361f3e 38 * $Revision: 24659 $
Anna Bridge 186:707f6e361f3e 39 *
Anna Bridge 186:707f6e361f3e 40 *************************************************************************** */
Anna Bridge 186:707f6e361f3e 41
Anna Bridge 186:707f6e361f3e 42 /* Define to prevent redundant inclusion */
Anna Bridge 186:707f6e361f3e 43 #ifndef _GPIO_H_
Anna Bridge 186:707f6e361f3e 44 #define _GPIO_H_
Anna Bridge 186:707f6e361f3e 45
Anna Bridge 186:707f6e361f3e 46 /* **** Includes **** */
Anna Bridge 186:707f6e361f3e 47 #include "mxc_config.h"
Anna Bridge 186:707f6e361f3e 48 #include "gpio_regs.h"
Anna Bridge 186:707f6e361f3e 49
Anna Bridge 186:707f6e361f3e 50 #ifdef __cplusplus
Anna Bridge 186:707f6e361f3e 51 extern "C" {
Anna Bridge 186:707f6e361f3e 52 #endif
Anna Bridge 186:707f6e361f3e 53
Anna Bridge 186:707f6e361f3e 54 // Doxy group definition for this peripheral module
Anna Bridge 186:707f6e361f3e 55 /**
Anna Bridge 186:707f6e361f3e 56 * @ingroup periphlibs
Anna Bridge 186:707f6e361f3e 57 * @defgroup gpio General-Purpose Input/Output (GPIO)
Anna Bridge 186:707f6e361f3e 58 * @{
Anna Bridge 186:707f6e361f3e 59 */
Anna Bridge 186:707f6e361f3e 60
Anna Bridge 186:707f6e361f3e 61 /* **** Definitions **** */
Anna Bridge 186:707f6e361f3e 62 /**
Anna Bridge 186:707f6e361f3e 63 * @defgroup gpio_port_pin Port and Pin Definitions
Anna Bridge 186:707f6e361f3e 64 * @ingroup gpio
Anna Bridge 186:707f6e361f3e 65 * @{
Anna Bridge 186:707f6e361f3e 66 * @defgroup gpio_port Port Definitions
Anna Bridge 186:707f6e361f3e 67 * @ingroup gpio_port_pin
Anna Bridge 186:707f6e361f3e 68 * @{
Anna Bridge 186:707f6e361f3e 69 */
Anna Bridge 186:707f6e361f3e 70 #define PORT_0 (0) /**< Port 0 Define*/
Anna Bridge 186:707f6e361f3e 71 #define PORT_1 (1) /**< Port 1 Define*/
Anna Bridge 186:707f6e361f3e 72 #define PORT_2 (2) /**< Port 2 Define*/
Anna Bridge 186:707f6e361f3e 73 #define PORT_3 (3) /**< Port 3 Define*/
Anna Bridge 186:707f6e361f3e 74 #define PORT_4 (4) /**< Port 4 Define*/
Anna Bridge 186:707f6e361f3e 75 #define PORT_5 (5) /**< Port 5 Define*/
Anna Bridge 186:707f6e361f3e 76 #define PORT_6 (6) /**< Port 6 Define*/
Anna Bridge 186:707f6e361f3e 77 #define PORT_7 (7) /**< Port 7 Define*/
Anna Bridge 186:707f6e361f3e 78 #define PORT_8 (8) /**< Port 8 Define*/
Anna Bridge 186:707f6e361f3e 79 #define PORT_9 (9) /**< Port 9 Define*/
Anna Bridge 186:707f6e361f3e 80 #define PORT_10 (10) /**< Port 10 Define*/
Anna Bridge 186:707f6e361f3e 81 #define PORT_11 (11) /**< Port 11 Define*/
Anna Bridge 186:707f6e361f3e 82 #define PORT_12 (12) /**< Port 12 Define*/
Anna Bridge 186:707f6e361f3e 83 #define PORT_13 (13) /**< Port 13 Define*/
Anna Bridge 186:707f6e361f3e 84 #define PORT_14 (14) /**< Port 14 Define*/
Anna Bridge 186:707f6e361f3e 85 #define PORT_15 (15) /**< Port 15 Define*/
Anna Bridge 186:707f6e361f3e 86 /**@} end of gpio_port group*/
Anna Bridge 186:707f6e361f3e 87 /**
Anna Bridge 186:707f6e361f3e 88 * @defgroup gpio_pin Pin Definitions
Anna Bridge 186:707f6e361f3e 89 * @ingroup gpio_port_pin
Anna Bridge 186:707f6e361f3e 90 * @{
Anna Bridge 186:707f6e361f3e 91 */
Anna Bridge 186:707f6e361f3e 92 #define PIN_0 (1 << 0) /**< Pin 0 Define */
Anna Bridge 186:707f6e361f3e 93 #define PIN_1 (1 << 1) /**< Pin 1 Define */
Anna Bridge 186:707f6e361f3e 94 #define PIN_2 (1 << 2) /**< Pin 2 Define */
Anna Bridge 186:707f6e361f3e 95 #define PIN_3 (1 << 3) /**< Pin 3 Define */
Anna Bridge 186:707f6e361f3e 96 #define PIN_4 (1 << 4) /**< Pin 4 Define */
Anna Bridge 186:707f6e361f3e 97 #define PIN_5 (1 << 5) /**< Pin 5 Define */
Anna Bridge 186:707f6e361f3e 98 #define PIN_6 (1 << 6) /**< Pin 6 Define */
Anna Bridge 186:707f6e361f3e 99 #define PIN_7 (1 << 7) /**< Pin 7 Define */
Anna Bridge 186:707f6e361f3e 100 /**@} end of gpio_pin group */
Anna Bridge 186:707f6e361f3e 101 /**@} end of gpio_port_pin group */
Anna Bridge 186:707f6e361f3e 102
Anna Bridge 186:707f6e361f3e 103 /**
Anna Bridge 186:707f6e361f3e 104 * Enumeration type for the GPIO Function Type
Anna Bridge 186:707f6e361f3e 105 */
Anna Bridge 186:707f6e361f3e 106 typedef enum {
Anna Bridge 186:707f6e361f3e 107 GPIO_FUNC_GPIO = MXC_V_GPIO_FUNC_SEL_MODE_GPIO, /**< GPIO Function Selection */
Anna Bridge 186:707f6e361f3e 108 GPIO_FUNC_PT = MXC_V_GPIO_FUNC_SEL_MODE_PT, /**< Pulse Train Function Selection */
Anna Bridge 186:707f6e361f3e 109 GPIO_FUNC_TMR = MXC_V_GPIO_FUNC_SEL_MODE_TMR /**< Timer Function Selection */
Anna Bridge 186:707f6e361f3e 110 }
Anna Bridge 186:707f6e361f3e 111 gpio_func_t;
Anna Bridge 186:707f6e361f3e 112
Anna Bridge 186:707f6e361f3e 113 /**
Anna Bridge 186:707f6e361f3e 114 * Enumeration type for the type of GPIO pad on a given pin.
Anna Bridge 186:707f6e361f3e 115 */
Anna Bridge 186:707f6e361f3e 116 typedef enum {
Anna Bridge 186:707f6e361f3e 117 GPIO_PAD_INPUT_PULLUP = MXC_V_GPIO_OUT_MODE_HIGH_Z_WEAK_PULLUP, /**< Set pad to high impedance, weak pull-up */
Anna Bridge 186:707f6e361f3e 118 GPIO_PAD_OPEN_DRAIN = MXC_V_GPIO_OUT_MODE_OPEN_DRAIN, /**< Set pad to open-drain with high impedance with input buffer */
Anna Bridge 186:707f6e361f3e 119 GPIO_PAD_OPEN_DRAIN_PULLUP = MXC_V_GPIO_OUT_MODE_OPEN_DRAIN_WEAK_PULLUP, /**< Set pad to open-drain with weak pull-up */
Anna Bridge 186:707f6e361f3e 120 GPIO_PAD_INPUT = MXC_V_GPIO_OUT_MODE_NORMAL_HIGH_Z, /**< Set pad to high impednace, input buffer enabled */
Anna Bridge 186:707f6e361f3e 121 GPIO_PAD_NORMAL = MXC_V_GPIO_OUT_MODE_NORMAL, /**< Set pad to normal drive mode for high an low output */
Anna Bridge 186:707f6e361f3e 122 GPIO_PAD_SLOW = MXC_V_GPIO_OUT_MODE_SLOW_DRIVE, /**< Set pad to slow drive mode, which is normal mode with negative feedback to slow edge transitions */
Anna Bridge 186:707f6e361f3e 123 GPIO_PAD_FAST = MXC_V_GPIO_OUT_MODE_FAST_DRIVE, /**< Set pad to fash drive mode, which is normal mode with a transistor drive to drive fast high and low */
Anna Bridge 186:707f6e361f3e 124 GPIO_PAD_INPUT_PULLDOWN = MXC_V_GPIO_OUT_MODE_HIGH_Z_WEAK_PULLDOWN, /**< Set pad to weak pulldown mode */
Anna Bridge 186:707f6e361f3e 125 GPIO_PAD_OPEN_SOURCE = MXC_V_GPIO_OUT_MODE_OPEN_SOURCE, /**< Set pad to open source mode, transistor drive to high */
Anna Bridge 186:707f6e361f3e 126 GPIO_PAD_OPEN_SOURCE_PULLDOWN = MXC_V_GPIO_OUT_MODE_OPEN_SOURCE_WEAK_PULLDOWN /**< Set pad to open source with weak pulldown mode, transistor drive to high, weak pulldown to GND for low */
Anna Bridge 186:707f6e361f3e 127 } gpio_pad_t;
Anna Bridge 186:707f6e361f3e 128
Anna Bridge 186:707f6e361f3e 129 /**
Anna Bridge 186:707f6e361f3e 130 * Structure type for configuring a GPIO port.
Anna Bridge 186:707f6e361f3e 131 */
Anna Bridge 186:707f6e361f3e 132 typedef struct {
Anna Bridge 186:707f6e361f3e 133 uint32_t port; /// Index of GPIO port
Anna Bridge 186:707f6e361f3e 134 uint32_t mask; /// Pin mask. Multiple bits can be set.
Anna Bridge 186:707f6e361f3e 135 gpio_func_t func; /// Function type
Anna Bridge 186:707f6e361f3e 136 gpio_pad_t pad; /// Pad type
Anna Bridge 186:707f6e361f3e 137 } gpio_cfg_t;
Anna Bridge 186:707f6e361f3e 138
Anna Bridge 186:707f6e361f3e 139 /**
Anna Bridge 186:707f6e361f3e 140 * Enumeration type for the interrupt type on a GPIO port.
Anna Bridge 186:707f6e361f3e 141 */
Anna Bridge 186:707f6e361f3e 142 typedef enum {
Anna Bridge 186:707f6e361f3e 143 GPIO_INT_DISABLE = MXC_V_GPIO_INT_MODE_DISABLE, /**< Disable interrupts */
Anna Bridge 186:707f6e361f3e 144 GPIO_INT_FALLING_EDGE = MXC_V_GPIO_INT_MODE_FALLING_EDGE, /**< Interrupt on Falling Edge */
Anna Bridge 186:707f6e361f3e 145 GPIO_INT_RISING_EDGE = MXC_V_GPIO_INT_MODE_RISING_EDGE, /**< Interrupt on Rising Edge */
Anna Bridge 186:707f6e361f3e 146 GPIO_INT_ANY_EDGE = MXC_V_GPIO_INT_MODE_ANY_EDGE, /**< Interrupt on Falling or Rising Edge */
Anna Bridge 186:707f6e361f3e 147 GPIO_INT_LOW_LEVEL = MXC_V_GPIO_INT_MODE_LOW_LVL, /**< Interrupt on a low level input detection */
Anna Bridge 186:707f6e361f3e 148 GPIO_INT_HIGH_LEVEL = MXC_V_GPIO_INT_MODE_HIGH_LVL /**< Interrupt on a high level input detection */
Anna Bridge 186:707f6e361f3e 149 } gpio_int_mode_t;
Anna Bridge 186:707f6e361f3e 150
Anna Bridge 186:707f6e361f3e 151 /* **** Function Prototypes **** */
Anna Bridge 186:707f6e361f3e 152
Anna Bridge 186:707f6e361f3e 153 /**
Anna Bridge 186:707f6e361f3e 154 * @brief Configure GPIO pin(s).
Anna Bridge 186:707f6e361f3e 155 * @param cfg Pointer to configuration structure describing the pin.
Anna Bridge 186:707f6e361f3e 156 *
Anna Bridge 186:707f6e361f3e 157 * @return #E_NO_ERROR if everything is successful.
Anna Bridge 186:707f6e361f3e 158 *
Anna Bridge 186:707f6e361f3e 159 */
Anna Bridge 186:707f6e361f3e 160 int GPIO_Config(const gpio_cfg_t *cfg);
Anna Bridge 186:707f6e361f3e 161
Anna Bridge 186:707f6e361f3e 162 /**
Anna Bridge 186:707f6e361f3e 163 * @brief Gets the pin(s) input state.
Anna Bridge 186:707f6e361f3e 164 * @param cfg Pointer to configuration structure describing the pin.
Anna Bridge 186:707f6e361f3e 165 *
Anna Bridge 186:707f6e361f3e 166 * @return The requested pin state.
Anna Bridge 186:707f6e361f3e 167 *
Anna Bridge 186:707f6e361f3e 168 */
Anna Bridge 186:707f6e361f3e 169 __STATIC_INLINE uint32_t GPIO_InGet(const gpio_cfg_t *cfg)
Anna Bridge 186:707f6e361f3e 170 {
Anna Bridge 186:707f6e361f3e 171 return (MXC_GPIO->in_val[cfg->port] & cfg->mask);
Anna Bridge 186:707f6e361f3e 172 }
Anna Bridge 186:707f6e361f3e 173
Anna Bridge 186:707f6e361f3e 174 /**
Anna Bridge 186:707f6e361f3e 175 * @brief Sets the pin(s) to a high level output.
Anna Bridge 186:707f6e361f3e 176 * @param cfg Pointer to configuration structure describing the pin.
Anna Bridge 186:707f6e361f3e 177 *
Anna Bridge 186:707f6e361f3e 178 */
Anna Bridge 186:707f6e361f3e 179 __STATIC_INLINE void GPIO_OutSet(const gpio_cfg_t *cfg)
Anna Bridge 186:707f6e361f3e 180 {
Anna Bridge 186:707f6e361f3e 181 MXC_GPIO->out_val[cfg->port] |= cfg->mask;
Anna Bridge 186:707f6e361f3e 182 }
Anna Bridge 186:707f6e361f3e 183
Anna Bridge 186:707f6e361f3e 184 /**
Anna Bridge 186:707f6e361f3e 185 * @brief Clears the pin(s) to a low level output.
Anna Bridge 186:707f6e361f3e 186 * @param cfg Pointer to configuration structure describing the pin.
Anna Bridge 186:707f6e361f3e 187 *
Anna Bridge 186:707f6e361f3e 188 */
Anna Bridge 186:707f6e361f3e 189 __STATIC_INLINE void GPIO_OutClr(const gpio_cfg_t *cfg)
Anna Bridge 186:707f6e361f3e 190 {
Anna Bridge 186:707f6e361f3e 191 MXC_GPIO->out_val[cfg->port] &= ~(cfg->mask);
Anna Bridge 186:707f6e361f3e 192 }
Anna Bridge 186:707f6e361f3e 193
Anna Bridge 186:707f6e361f3e 194 /**
Anna Bridge 186:707f6e361f3e 195 * @brief Gets the pin(s) output state.
Anna Bridge 186:707f6e361f3e 196 * @param cfg Pointer to configuration structure describing the pin.
Anna Bridge 186:707f6e361f3e 197 *
Anna Bridge 186:707f6e361f3e 198 * @return The state of the requested pin.
Anna Bridge 186:707f6e361f3e 199 *
Anna Bridge 186:707f6e361f3e 200 */
Anna Bridge 186:707f6e361f3e 201 __STATIC_INLINE uint32_t GPIO_OutGet(const gpio_cfg_t *cfg)
Anna Bridge 186:707f6e361f3e 202 {
Anna Bridge 186:707f6e361f3e 203 return (MXC_GPIO->out_val[cfg->port] & cfg->mask);
Anna Bridge 186:707f6e361f3e 204 }
Anna Bridge 186:707f6e361f3e 205
Anna Bridge 186:707f6e361f3e 206 /**
Anna Bridge 186:707f6e361f3e 207 * @brief Write the pin(s) to a desired output level.
Anna Bridge 186:707f6e361f3e 208 * @param cfg Pointer to configuration structure describing the pin.
Anna Bridge 186:707f6e361f3e 209 * @param val Desired output level of the pin(s). This will be masked
Anna Bridge 186:707f6e361f3e 210 * with the configuration mask.
Anna Bridge 186:707f6e361f3e 211 *
Anna Bridge 186:707f6e361f3e 212 */
Anna Bridge 186:707f6e361f3e 213 __STATIC_INLINE void GPIO_OutPut(const gpio_cfg_t *cfg, uint32_t val)
Anna Bridge 186:707f6e361f3e 214 {
Anna Bridge 186:707f6e361f3e 215 MXC_GPIO->out_val[cfg->port] = (MXC_GPIO->out_val[cfg->port] & ~cfg->mask) | (val & cfg->mask);
Anna Bridge 186:707f6e361f3e 216 }
Anna Bridge 186:707f6e361f3e 217
Anna Bridge 186:707f6e361f3e 218 /**
Anna Bridge 186:707f6e361f3e 219 * @brief Toggles the the pin(s) output level.
Anna Bridge 186:707f6e361f3e 220 * @param cfg Pointer to configuration structure describing the pin.
Anna Bridge 186:707f6e361f3e 221 *
Anna Bridge 186:707f6e361f3e 222 */
Anna Bridge 186:707f6e361f3e 223 __STATIC_INLINE void GPIO_OutToggle(const gpio_cfg_t *cfg)
Anna Bridge 186:707f6e361f3e 224 {
Anna Bridge 186:707f6e361f3e 225 MXC_GPIO->out_val[cfg->port] ^= cfg->mask;
Anna Bridge 186:707f6e361f3e 226 }
Anna Bridge 186:707f6e361f3e 227
Anna Bridge 186:707f6e361f3e 228 /**
Anna Bridge 186:707f6e361f3e 229 * @brief Configure GPIO interrupt(s)
Anna Bridge 186:707f6e361f3e 230 * @param cfg Pointer to configuration structure describing the pin.
Anna Bridge 186:707f6e361f3e 231 * @param mode Requested interrupt mode.
Anna Bridge 186:707f6e361f3e 232 *
Anna Bridge 186:707f6e361f3e 233 */
Anna Bridge 186:707f6e361f3e 234 void GPIO_IntConfig(const gpio_cfg_t *cfg, gpio_int_mode_t mode);
Anna Bridge 186:707f6e361f3e 235
Anna Bridge 186:707f6e361f3e 236 /**
Anna Bridge 186:707f6e361f3e 237 * @brief Enables the specified GPIO interrupt
Anna Bridge 186:707f6e361f3e 238 * @param cfg Pointer to configuration structure describing the pin.
Anna Bridge 186:707f6e361f3e 239 *
Anna Bridge 186:707f6e361f3e 240 */
Anna Bridge 186:707f6e361f3e 241 __STATIC_INLINE void GPIO_IntEnable(const gpio_cfg_t *cfg)
Anna Bridge 186:707f6e361f3e 242 {
Anna Bridge 186:707f6e361f3e 243 MXC_GPIO->inten[cfg->port] |= cfg->mask;
Anna Bridge 186:707f6e361f3e 244 }
Anna Bridge 186:707f6e361f3e 245
Anna Bridge 186:707f6e361f3e 246 /**
Anna Bridge 186:707f6e361f3e 247 * @brief Disables the specified GPIO interrupt.
Anna Bridge 186:707f6e361f3e 248 * @param cfg Pointer to configuration structure describing the pin.
Anna Bridge 186:707f6e361f3e 249 *
Anna Bridge 186:707f6e361f3e 250 */
Anna Bridge 186:707f6e361f3e 251 __STATIC_INLINE void GPIO_IntDisable(const gpio_cfg_t *cfg)
Anna Bridge 186:707f6e361f3e 252 {
Anna Bridge 186:707f6e361f3e 253 MXC_GPIO->inten[cfg->port] &= ~cfg->mask;
Anna Bridge 186:707f6e361f3e 254 }
Anna Bridge 186:707f6e361f3e 255
Anna Bridge 186:707f6e361f3e 256 /**
Anna Bridge 186:707f6e361f3e 257 * @brief Gets the interrupt(s) status on a GPIO pin.
Anna Bridge 186:707f6e361f3e 258 * @param cfg Pointer to configuration structure describing the pin
Anna Bridge 186:707f6e361f3e 259 * for which the status is being requested.
Anna Bridge 186:707f6e361f3e 260 *
Anna Bridge 186:707f6e361f3e 261 * @return The requested interrupt status.
Anna Bridge 186:707f6e361f3e 262 *
Anna Bridge 186:707f6e361f3e 263 */
Anna Bridge 186:707f6e361f3e 264 __STATIC_INLINE uint32_t GPIO_IntStatus(const gpio_cfg_t *cfg)
Anna Bridge 186:707f6e361f3e 265 {
Anna Bridge 186:707f6e361f3e 266 return (MXC_GPIO->intfl[cfg->port] & cfg->mask);
Anna Bridge 186:707f6e361f3e 267 }
Anna Bridge 186:707f6e361f3e 268
Anna Bridge 186:707f6e361f3e 269 /**
Anna Bridge 186:707f6e361f3e 270 * @brief Clears the interrupt(s) status on a GPIO pin.
Anna Bridge 186:707f6e361f3e 271 * @param cfg Pointer to configuration structure describing the pin
Anna Bridge 186:707f6e361f3e 272 * to clear the interrupt state of.
Anna Bridge 186:707f6e361f3e 273 *
Anna Bridge 186:707f6e361f3e 274 */
Anna Bridge 186:707f6e361f3e 275 __STATIC_INLINE void GPIO_IntClr(const gpio_cfg_t *cfg)
Anna Bridge 186:707f6e361f3e 276 {
Anna Bridge 186:707f6e361f3e 277 MXC_GPIO->intfl[cfg->port] = cfg->mask;
Anna Bridge 186:707f6e361f3e 278 }
Anna Bridge 186:707f6e361f3e 279
Anna Bridge 186:707f6e361f3e 280 /**
Anna Bridge 186:707f6e361f3e 281 * @brief Type alias for a GPIO callback function with prototype:
Anna Bridge 186:707f6e361f3e 282 * @code
Anna Bridge 186:707f6e361f3e 283 * void callback_fn(void *cbdata);
Anna Bridge 186:707f6e361f3e 284 * @endcode
Anna Bridge 186:707f6e361f3e 285 * @param cbdata A void pointer to the data type as registered when
Anna Bridge 186:707f6e361f3e 286 * @c GPIO_RegisterCallback() was called.
Anna Bridge 186:707f6e361f3e 287 *
Anna Bridge 186:707f6e361f3e 288 */
Anna Bridge 186:707f6e361f3e 289 typedef void (*gpio_callback_fn)(void *cbdata);
Anna Bridge 186:707f6e361f3e 290
Anna Bridge 186:707f6e361f3e 291 /**
Anna Bridge 186:707f6e361f3e 292 * @brief Registers a callback for the interrupt on a given port and pin.
Anna Bridge 186:707f6e361f3e 293 * @param cfg Pointer to configuration structure describing the pin
Anna Bridge 186:707f6e361f3e 294 * @param callback A pointer to a function of type #gpio_callback_fn.
Anna Bridge 186:707f6e361f3e 295 * @param cbdata The parameter to be passed to the callback function, #gpio_callback_fn, when an interrupt occurs.
Anna Bridge 186:707f6e361f3e 296 *
Anna Bridge 186:707f6e361f3e 297 */
Anna Bridge 186:707f6e361f3e 298 void GPIO_RegisterCallback(const gpio_cfg_t *cfg, gpio_callback_fn callback, void *cbdata);
Anna Bridge 186:707f6e361f3e 299
Anna Bridge 186:707f6e361f3e 300 /**
Anna Bridge 186:707f6e361f3e 301 * @brief GPIO IRQ Handler. @note If a callback is registered for a given
Anna Bridge 186:707f6e361f3e 302 * interrupt, the callback function will be called.
Anna Bridge 186:707f6e361f3e 303 *
Anna Bridge 186:707f6e361f3e 304 * @param port number of the port that generated the interrupt service routine.
Anna Bridge 186:707f6e361f3e 305 *
Anna Bridge 186:707f6e361f3e 306 */
Anna Bridge 186:707f6e361f3e 307 void GPIO_Handler(unsigned int port);
Anna Bridge 186:707f6e361f3e 308
Anna Bridge 186:707f6e361f3e 309 /**@} end of group gpio */
Anna Bridge 186:707f6e361f3e 310
Anna Bridge 186:707f6e361f3e 311 #ifdef __cplusplus
Anna Bridge 186:707f6e361f3e 312 }
Anna Bridge 186:707f6e361f3e 313 #endif
Anna Bridge 186:707f6e361f3e 314
Anna Bridge 186:707f6e361f3e 315 #endif /* _GPIO_H_ */