fsl_gpio.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Freescale Semiconductor, Inc.
3  * Copyright 2016-2020 NXP
4  * All rights reserved.
5  *
6  * SPDX-License-Identifier: BSD-3-Clause
7  */
8 
9 #ifndef _FSL_GPIO_H_
10 #define _FSL_GPIO_H_
11 
12 #include "fsl_common.h"
13 
19 /*******************************************************************************
20  * Definitions
21  ******************************************************************************/
22 
26 #define FSL_GPIO_DRIVER_VERSION (MAKE_VERSION(2, 0, 3))
27 
30 typedef enum _gpio_pin_direction
31 {
35 
38 {
46 
48 typedef struct _gpio_pin_config
49 {
51  uint8_t outputLogic;
55 
56 /*******************************************************************************
57  * API
58  ******************************************************************************/
59 
60 #if defined(__cplusplus)
61 extern "C" {
62 #endif
63 
78 void GPIO_PinInit(GPIO_Type *base, uint32_t pin, const gpio_pin_config_t *Config);
95 void GPIO_PinWrite(GPIO_Type *base, uint32_t pin, uint8_t output);
96 
101 static inline void GPIO_WritePinOutput(GPIO_Type *base, uint32_t pin, uint8_t output)
102 {
103  GPIO_PinWrite(base, pin, output);
104 }
105 
112 static inline void GPIO_PortSet(GPIO_Type *base, uint32_t mask)
113 {
114 #if (defined(FSL_FEATURE_IGPIO_HAS_DR_SET) && (FSL_FEATURE_IGPIO_HAS_DR_SET == 1))
115  base->DR_SET = mask;
116 #else
117  base->DR |= mask;
118 #endif /* FSL_FEATURE_IGPIO_HAS_DR_SET */
119 }
120 
125 static inline void GPIO_SetPinsOutput(GPIO_Type *base, uint32_t mask)
126 {
127  GPIO_PortSet(base, mask);
128 }
129 
136 static inline void GPIO_PortClear(GPIO_Type *base, uint32_t mask)
137 {
138 #if (defined(FSL_FEATURE_IGPIO_HAS_DR_CLEAR) && (FSL_FEATURE_IGPIO_HAS_DR_CLEAR == 1))
139  base->DR_CLEAR = mask;
140 #else
141  base->DR &= ~mask;
142 #endif /* FSL_FEATURE_IGPIO_HAS_DR_CLEAR */
143 }
144 
149 static inline void GPIO_ClearPinsOutput(GPIO_Type *base, uint32_t mask)
150 {
151  GPIO_PortClear(base, mask);
152 }
153 
160 static inline void GPIO_PortToggle(GPIO_Type *base, uint32_t mask)
161 {
162 #if (defined(FSL_FEATURE_IGPIO_HAS_DR_TOGGLE) && (FSL_FEATURE_IGPIO_HAS_DR_TOGGLE == 1))
163  base->DR_TOGGLE = mask;
164 #endif /* FSL_FEATURE_IGPIO_HAS_DR_TOGGLE */
165 }
166 
174 static inline uint32_t GPIO_PinRead(GPIO_Type *base, uint32_t pin)
175 {
176  assert(pin < 32U);
177 
178  return (((base->DR) >> pin) & 0x1U);
179 }
180 
185 static inline uint32_t GPIO_ReadPinInput(GPIO_Type *base, uint32_t pin)
186 {
187  return GPIO_PinRead(base, pin);
188 }
203 static inline uint8_t GPIO_PinReadPadStatus(GPIO_Type *base, uint32_t pin)
204 {
205  assert(pin < 32U);
206 
207  return (uint8_t)(((base->PSR) >> pin) & 0x1U);
208 }
209 
214 static inline uint8_t GPIO_ReadPadStatus(GPIO_Type *base, uint32_t pin)
215 {
216  return GPIO_PinReadPadStatus(base, pin);
217 }
218 
234 void GPIO_PinSetInterruptConfig(GPIO_Type *base, uint32_t pin, gpio_interrupt_mode_t pinInterruptMode);
235 
240 static inline void GPIO_SetPinInterruptConfig(GPIO_Type *base, uint32_t pin, gpio_interrupt_mode_t pinInterruptMode)
241 {
242  GPIO_PinSetInterruptConfig(base, pin, pinInterruptMode);
243 }
244 
251 static inline void GPIO_PortEnableInterrupts(GPIO_Type *base, uint32_t mask)
252 {
253  base->IMR |= mask;
254 }
255 
262 static inline void GPIO_EnableInterrupts(GPIO_Type *base, uint32_t mask)
263 {
264  GPIO_PortEnableInterrupts(base, mask);
265 }
266 
273 static inline void GPIO_PortDisableInterrupts(GPIO_Type *base, uint32_t mask)
274 {
275  base->IMR &= ~mask;
276 }
277 
282 static inline void GPIO_DisableInterrupts(GPIO_Type *base, uint32_t mask)
283 {
284  GPIO_PortDisableInterrupts(base, mask);
285 }
286 
293 static inline uint32_t GPIO_PortGetInterruptFlags(GPIO_Type *base)
294 {
295  return base->ISR;
296 }
297 
304 static inline uint32_t GPIO_GetPinsInterruptFlags(GPIO_Type *base)
305 {
306  return GPIO_PortGetInterruptFlags(base);
307 }
308 
316 static inline void GPIO_PortClearInterruptFlags(GPIO_Type *base, uint32_t mask)
317 {
318  base->ISR = mask;
319 }
320 
328 static inline void GPIO_ClearPinsInterruptFlags(GPIO_Type *base, uint32_t mask)
329 {
330  GPIO_PortClearInterruptFlags(base, mask);
331 }
334 #if defined(__cplusplus)
335 }
336 #endif
337 
342 #endif /* _FSL_GPIO_H_*/
GPIO_DisableInterrupts
static void GPIO_DisableInterrupts(GPIO_Type *base, uint32_t mask)
Disables the specific pin interrupt.
Definition: fsl_gpio.h:282
fsl_common.h
GPIO_ClearPinsOutput
static void GPIO_ClearPinsOutput(GPIO_Type *base, uint32_t mask)
Sets the output level of the multiple GPIO pins to the logic 0.
Definition: fsl_gpio.h:149
_gpio_pin_config
GPIO Init structure definition.
Definition: fsl_gpio.h:48
_gpio_pin_config::direction
gpio_pin_direction_t direction
Definition: fsl_gpio.h:50
GPIO_PortEnableInterrupts
static void GPIO_PortEnableInterrupts(GPIO_Type *base, uint32_t mask)
Enables the specific pin interrupt.
Definition: fsl_gpio.h:251
GPIO_PinWrite
void GPIO_PinWrite(GPIO_Type *base, uint32_t pin, uint8_t output)
Sets the output level of the individual GPIO pin to logic 1 or 0.
Definition: fsl_gpio.c:111
GPIO_PinSetInterruptConfig
void GPIO_PinSetInterruptConfig(GPIO_Type *base, uint32_t pin, gpio_interrupt_mode_t pinInterruptMode)
Sets the current pin interrupt mode.
Definition: fsl_gpio.c:132
GPIO_Type::DR
__IO uint32_t DR
Definition: MIMXRT1052.h:19126
GPIO_ClearPinsInterruptFlags
static void GPIO_ClearPinsInterruptFlags(GPIO_Type *base, uint32_t mask)
Clears pin interrupt flag. Status flags are cleared by writing a 1 to the corresponding bit position.
Definition: fsl_gpio.h:328
_gpio_pin_config::interruptMode
gpio_interrupt_mode_t interruptMode
Definition: fsl_gpio.h:53
_gpio_pin_direction
_gpio_pin_direction
GPIO direction definition.
Definition: fsl_gpio.h:30
GPIO_ReadPadStatus
static uint8_t GPIO_ReadPadStatus(GPIO_Type *base, uint32_t pin)
Reads the current GPIO pin pad status.
Definition: fsl_gpio.h:214
GPIO_SetPinsOutput
static void GPIO_SetPinsOutput(GPIO_Type *base, uint32_t mask)
Sets the output level of the multiple GPIO pins to the logic 1.
Definition: fsl_gpio.h:125
gpio_interrupt_mode_t
enum _gpio_interrupt_mode gpio_interrupt_mode_t
GPIO interrupt mode definition.
GPIO_PortSet
static void GPIO_PortSet(GPIO_Type *base, uint32_t mask)
Sets the output level of the multiple GPIO pins to the logic 1.
Definition: fsl_gpio.h:112
GPIO_Type::PSR
__I uint32_t PSR
Definition: MIMXRT1052.h:19128
GPIO_EnableInterrupts
static void GPIO_EnableInterrupts(GPIO_Type *base, uint32_t mask)
Enables the specific pin interrupt.
Definition: fsl_gpio.h:262
kGPIO_IntRisingOrFallingEdge
@ kGPIO_IntRisingOrFallingEdge
Definition: fsl_gpio.h:44
GPIO_Type::IMR
__IO uint32_t IMR
Definition: MIMXRT1052.h:19131
kGPIO_NoIntmode
@ kGPIO_NoIntmode
Definition: fsl_gpio.h:39
_gpio_interrupt_mode
_gpio_interrupt_mode
GPIO interrupt mode definition.
Definition: fsl_gpio.h:37
kGPIO_DigitalInput
@ kGPIO_DigitalInput
Definition: fsl_gpio.h:32
GPIO_PinInit
void GPIO_PinInit(GPIO_Type *base, uint32_t pin, const gpio_pin_config_t *Config)
Initializes the GPIO peripheral according to the specified parameters in the initConfig.
Definition: fsl_gpio.c:71
GPIO_Type::DR_CLEAR
__O uint32_t DR_CLEAR
Definition: MIMXRT1052.h:19136
GPIO_PortClearInterruptFlags
static void GPIO_PortClearInterruptFlags(GPIO_Type *base, uint32_t mask)
Clears pin interrupt flag. Status flags are cleared by writing a 1 to the corresponding bit position.
Definition: fsl_gpio.h:316
GPIO_PortGetInterruptFlags
static uint32_t GPIO_PortGetInterruptFlags(GPIO_Type *base)
Reads individual pin interrupt status.
Definition: fsl_gpio.h:293
kGPIO_DigitalOutput
@ kGPIO_DigitalOutput
Definition: fsl_gpio.h:33
gpio_pin_config_t
struct _gpio_pin_config gpio_pin_config_t
GPIO Init structure definition.
GPIO_PortClear
static void GPIO_PortClear(GPIO_Type *base, uint32_t mask)
Sets the output level of the multiple GPIO pins to the logic 0.
Definition: fsl_gpio.h:136
kGPIO_IntLowLevel
@ kGPIO_IntLowLevel
Definition: fsl_gpio.h:40
GPIO_PortToggle
static void GPIO_PortToggle(GPIO_Type *base, uint32_t mask)
Reverses the current output logic of the multiple GPIO pins.
Definition: fsl_gpio.h:160
gpio_pin_direction_t
enum _gpio_pin_direction gpio_pin_direction_t
GPIO direction definition.
kGPIO_IntHighLevel
@ kGPIO_IntHighLevel
Definition: fsl_gpio.h:41
GPIO_Type::DR_SET
__O uint32_t DR_SET
Definition: MIMXRT1052.h:19135
GPIO_Type::DR_TOGGLE
__O uint32_t DR_TOGGLE
Definition: MIMXRT1052.h:19137
GPIO_PinReadPadStatus
static uint8_t GPIO_PinReadPadStatus(GPIO_Type *base, uint32_t pin)
Reads the current GPIO pin pad status.
Definition: fsl_gpio.h:203
GPIO_SetPinInterruptConfig
static void GPIO_SetPinInterruptConfig(GPIO_Type *base, uint32_t pin, gpio_interrupt_mode_t pinInterruptMode)
Sets the current pin interrupt mode.
Definition: fsl_gpio.h:240
kGPIO_IntFallingEdge
@ kGPIO_IntFallingEdge
Definition: fsl_gpio.h:43
GPIO_Type
Definition: MIMXRT1052.h:19125
GPIO_Type::ISR
__IO uint32_t ISR
Definition: MIMXRT1052.h:19132
GPIO_WritePinOutput
static void GPIO_WritePinOutput(GPIO_Type *base, uint32_t pin, uint8_t output)
Sets the output level of the individual GPIO pin to logic 1 or 0.
Definition: fsl_gpio.h:101
GPIO_ReadPinInput
static uint32_t GPIO_ReadPinInput(GPIO_Type *base, uint32_t pin)
Reads the current input value of the GPIO port.
Definition: fsl_gpio.h:185
GPIO_PortDisableInterrupts
static void GPIO_PortDisableInterrupts(GPIO_Type *base, uint32_t mask)
Disables the specific pin interrupt.
Definition: fsl_gpio.h:273
kGPIO_IntRisingEdge
@ kGPIO_IntRisingEdge
Definition: fsl_gpio.h:42
GPIO_PinRead
static uint32_t GPIO_PinRead(GPIO_Type *base, uint32_t pin)
Reads the current input value of the GPIO port.
Definition: fsl_gpio.h:174
_gpio_pin_config::outputLogic
uint8_t outputLogic
Definition: fsl_gpio.h:51
GPIO_GetPinsInterruptFlags
static uint32_t GPIO_GetPinsInterruptFlags(GPIO_Type *base)
Reads individual pin interrupt status.
Definition: fsl_gpio.h:304


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:13:56