EFM32 Gecko Software Documentation
efm32g-doc-4.2.1
|
General Purpose Input/Output (GPIO) API
. More...
Enumerations | |
enum | GPIO_Port_TypeDef |
enum | GPIO_DriveMode_TypeDef { gpioDriveModeStandard = GPIO_P_CTRL_DRIVEMODE_STANDARD, gpioDriveModeLowest = GPIO_P_CTRL_DRIVEMODE_LOWEST, gpioDriveModeHigh = GPIO_P_CTRL_DRIVEMODE_HIGH, gpioDriveModeLow = GPIO_P_CTRL_DRIVEMODE_LOW } |
enum | GPIO_Mode_TypeDef { gpioModeDisabled = _GPIO_P_MODEL_MODE0_DISABLED, gpioModeInput = _GPIO_P_MODEL_MODE0_INPUT, gpioModeInputPull = _GPIO_P_MODEL_MODE0_INPUTPULL, gpioModeInputPullFilter = _GPIO_P_MODEL_MODE0_INPUTPULLFILTER, gpioModePushPull = _GPIO_P_MODEL_MODE0_PUSHPULL, gpioModePushPullDrive = _GPIO_P_MODEL_MODE0_PUSHPULLDRIVE, gpioModeWiredOr = _GPIO_P_MODEL_MODE0_WIREDOR, gpioModeWiredOrPullDown = _GPIO_P_MODEL_MODE0_WIREDORPULLDOWN, gpioModeWiredAnd = _GPIO_P_MODEL_MODE0_WIREDAND, gpioModeWiredAndFilter = _GPIO_P_MODEL_MODE0_WIREDANDFILTER, gpioModeWiredAndPullUp = _GPIO_P_MODEL_MODE0_WIREDANDPULLUP, gpioModeWiredAndPullUpFilter = _GPIO_P_MODEL_MODE0_WIREDANDPULLUPFILTER, gpioModeWiredAndDrive = _GPIO_P_MODEL_MODE0_WIREDANDDRIVE, gpioModeWiredAndDriveFilter = _GPIO_P_MODEL_MODE0_WIREDANDDRIVEFILTER, gpioModeWiredAndDrivePullUp = _GPIO_P_MODEL_MODE0_WIREDANDDRIVEPULLUP, gpioModeWiredAndDrivePullUpFilter = _GPIO_P_MODEL_MODE0_WIREDANDDRIVEPULLUPFILTER } |
Functions | |
void | GPIO_DbgLocationSet (unsigned int location) |
Sets the pin location of the debug pins (Serial Wire interface). More... | |
void | GPIO_IntConfig (GPIO_Port_TypeDef port, unsigned int pin, bool risingEdge, bool fallingEdge, bool enable) |
Configure GPIO interrupt. More... | |
void | GPIO_PinModeSet (GPIO_Port_TypeDef port, unsigned int pin, GPIO_Mode_TypeDef mode, unsigned int out) |
Set the mode for a GPIO pin. More... | |
__STATIC_INLINE void | GPIO_DbgSWDClkEnable (bool enable) |
Enable/disable serial wire clock pin. More... | |
__STATIC_INLINE void | GPIO_DbgSWDIOEnable (bool enable) |
Enable/disable serial wire data I/O pin. More... | |
__STATIC_INLINE void | GPIO_DbgSWOEnable (bool enable) |
Enable/Disable serial wire output pin. More... | |
void | GPIO_DriveModeSet (GPIO_Port_TypeDef port, GPIO_DriveMode_TypeDef mode) |
Sets the drive mode for a GPIO port. More... | |
__STATIC_INLINE void | GPIO_InputSenseSet (uint32_t val, uint32_t mask) |
Enable/disable input sensing. More... | |
__STATIC_INLINE void | GPIO_IntClear (uint32_t flags) |
Clear one or more pending GPIO interrupts. More... | |
__STATIC_INLINE void | GPIO_IntDisable (uint32_t flags) |
Disable one or more GPIO interrupts. More... | |
__STATIC_INLINE void | GPIO_IntEnable (uint32_t flags) |
Enable one or more GPIO interrupts. More... | |
__STATIC_INLINE uint32_t | GPIO_IntGet (void) |
Get pending GPIO interrupts. More... | |
__STATIC_INLINE uint32_t | GPIO_IntGetEnabled (void) |
Get enabled and pending GPIO interrupt flags. Useful for handling more interrupt sources in the same interrupt handler. More... | |
__STATIC_INLINE void | GPIO_IntSet (uint32_t flags) |
Set one or more pending GPIO interrupts from SW. More... | |
__STATIC_INLINE void | GPIO_Lock (void) |
Locks the GPIO configuration. | |
__STATIC_INLINE unsigned int | GPIO_PinInGet (GPIO_Port_TypeDef port, unsigned int pin) |
Read the pad value for a single pin in a GPIO port. More... | |
__STATIC_INLINE void | GPIO_PinOutClear (GPIO_Port_TypeDef port, unsigned int pin) |
Set a single pin in GPIO data out port register to 0. More... | |
__STATIC_INLINE unsigned int | GPIO_PinOutGet (GPIO_Port_TypeDef port, unsigned int pin) |
Get current setting for a pin in a GPIO port data out register. More... | |
__STATIC_INLINE void | GPIO_PinOutSet (GPIO_Port_TypeDef port, unsigned int pin) |
Set a single pin in GPIO data out register to 1. More... | |
__STATIC_INLINE void | GPIO_PinOutToggle (GPIO_Port_TypeDef port, unsigned int pin) |
Toggle a single pin in GPIO port data out register. More... | |
__STATIC_INLINE uint32_t | GPIO_PortInGet (GPIO_Port_TypeDef port) |
Read the pad values for GPIO port. More... | |
__STATIC_INLINE void | GPIO_PortOutClear (GPIO_Port_TypeDef port, uint32_t pins) |
Set bits in DOUT register for a port to 0. More... | |
__STATIC_INLINE uint32_t | GPIO_PortOutGet (GPIO_Port_TypeDef port) |
Get current setting for a GPIO port data out register. More... | |
__STATIC_INLINE void | GPIO_PortOutSet (GPIO_Port_TypeDef port, uint32_t pins) |
Set bits GPIO data out register to 1. More... | |
__STATIC_INLINE void | GPIO_PortOutSetVal (GPIO_Port_TypeDef port, uint32_t val, uint32_t mask) |
Set GPIO port data out register. More... | |
__STATIC_INLINE void | GPIO_PortOutToggle (GPIO_Port_TypeDef port, uint32_t pins) |
Toggle pins in GPIO port data out register. More... | |
__STATIC_INLINE void | GPIO_Unlock (void) |
Unlocks the GPIO configuration. | |
enum GPIO_Port_TypeDef |
enum GPIO_Mode_TypeDef |
Pin mode. For more details on each mode, please refer to the reference manual.
void GPIO_DbgLocationSet | ( | unsigned int | location | ) |
[in] | location | The debug pin location to use (0-3). |
Definition at line 78 of file em_gpio.c.
References _GPIO_ROUTE_SWLOCATION_MASK, _GPIO_ROUTE_SWLOCATION_SHIFT, and GPIO.
Referenced by DBG_SWOEnable().
void GPIO_IntConfig | ( | GPIO_Port_TypeDef | port, |
unsigned int | pin, | ||
bool | risingEdge, | ||
bool | fallingEdge, | ||
bool | enable | ||
) |
If reconfiguring a GPIO interrupt that is already enabled, it is generally recommended to disable it first, see GPIO_Disable().
The actual GPIO interrupt handler must be in place before enabling the interrupt.
Notice that any pending interrupt for the selected pin is cleared by this function.
[in] | port | The port to associate with pin . |
[in] | pin | The GPIO interrupt number (= port pin). |
[in] | risingEdge | Set to true if interrupts shall be enabled on rising edge, otherwise false. |
[in] | fallingEdge | Set to true if interrupts shall be enabled on falling edge, otherwise false. |
[in] | enable | Set to true if interrupt shall be enabled after configuration completed, false to leave disabled. See GPIO_IntDisable() and GPIO_IntEnable(). |
Definition at line 168 of file em_gpio.c.
References BUS_RegBitWrite(), BUS_RegMaskedWrite(), and GPIO.
Referenced by ezradio_hal_GpioInit().
void GPIO_PinModeSet | ( | GPIO_Port_TypeDef | port, |
unsigned int | pin, | ||
GPIO_Mode_TypeDef | mode, | ||
unsigned int | out | ||
) |
[in] | port | The GPIO port to access. |
[in] | pin | The pin number in the port. |
[in] | mode | The desired pin mode. |
[in] | out | Value to set for pin in DOUT register. The DOUT setting is important for even some input mode configurations, determining pull-up/down direction. |
Definition at line 226 of file em_gpio.c.
References BUS_RegMaskedWrite(), GPIO, GPIO_PinOutClear(), GPIO_PinOutSet(), and gpioModeDisabled.
Referenced by ADC0_IRQHandler(), BSP_BccPinsEnable(), BSP_EbiInit(), BSP_McuBoard_DeInit(), BSP_McuBoard_Init(), BSP_McuBoard_UsbVbusPowerEnable(), CAPLESENSE_setupGPIO(), DBG_SWOEnable(), ezradio_hal_GpioInit(), I2CSPM_Init(), KSZ8851SNL_SPI_Init(), MICROSD_Deinit(), MICROSD_Init(), MSDD_Init(), RETARGET_SerialInit(), SPI_TFT_Init(), and TFT_DirectGPIOConfig().
__STATIC_INLINE void GPIO_DbgSWDClkEnable | ( | bool | enable | ) |
[in] | enable |
|
Definition at line 385 of file em_gpio.h.
References _GPIO_ROUTE_SWCLKPEN_SHIFT, BUS_RegBitWrite(), and GPIO.
__STATIC_INLINE void GPIO_DbgSWDIOEnable | ( | bool | enable | ) |
[in] | enable |
|
Definition at line 409 of file em_gpio.h.
References _GPIO_ROUTE_SWDIOPEN_SHIFT, BUS_RegBitWrite(), and GPIO.
__STATIC_INLINE void GPIO_DbgSWOEnable | ( | bool | enable | ) |
[in] | enable |
|
Definition at line 435 of file em_gpio.h.
References _GPIO_ROUTE_SWOPEN_SHIFT, BUS_RegBitWrite(), and GPIO.
Referenced by DBG_SWOEnable().
void GPIO_DriveModeSet | ( | GPIO_Port_TypeDef | port, |
GPIO_DriveMode_TypeDef | mode | ||
) |
[in] | port | The GPIO port to access. |
[in] | mode | Drive mode to use for port. |
Definition at line 101 of file em_gpio.c.
References _GPIO_P_CTRL_DRIVEMODE_MASK, _GPIO_P_CTRL_DRIVEMODE_SHIFT, and GPIO.
Referenced by CAPLESENSE_setupGPIO().
__STATIC_INLINE void GPIO_InputSenseSet | ( | uint32_t | val, |
uint32_t | mask | ||
) |
Disabling input sensing if not used, can save some energy consumption.
[in] | val | Bitwise logic OR of one or more of:
|
[in] | mask | Mask containing bitwise logic OR of bits similar as for val used to indicate which input sense options to disable/enable. |
Definition at line 548 of file em_gpio.h.
References GPIO.
Referenced by ezradio_hal_GpioInit().
__STATIC_INLINE void GPIO_IntClear | ( | uint32_t | flags | ) |
__STATIC_INLINE void GPIO_IntDisable | ( | uint32_t | flags | ) |
__STATIC_INLINE void GPIO_IntEnable | ( | uint32_t | flags | ) |
[in] | flags | GPIO interrupt sources to enable. |
Definition at line 592 of file em_gpio.h.
References GPIO.
__STATIC_INLINE uint32_t GPIO_IntGet | ( | void | ) |
__STATIC_INLINE uint32_t GPIO_IntGetEnabled | ( | void | ) |
Definition at line 626 of file em_gpio.h.
References GPIO.
__STATIC_INLINE void GPIO_IntSet | ( | uint32_t | flags | ) |
__STATIC_INLINE unsigned int GPIO_PinInGet | ( | GPIO_Port_TypeDef | port, |
unsigned int | pin | ||
) |
[in] | port | The GPIO port to access. |
[in] | pin | The pin number to read. |
Definition at line 675 of file em_gpio.h.
References BUS_RegBitRead(), and GPIO.
Referenced by ADC0_IRQHandler(), BSP_McuBoard_UsbVbusOcFlagGet(), ezradio_hal_NirqLevel(), and TOUCH_IsBusy().
__STATIC_INLINE void GPIO_PinOutClear | ( | GPIO_Port_TypeDef | port, |
unsigned int | pin | ||
) |
[in] | port | The GPIO port to access. |
[in] | pin | The pin to set. |
Definition at line 698 of file em_gpio.h.
References BUS_RegBitWrite(), and GPIO.
Referenced by BSP_McuBoard_UsbStatusLedEnable(), ezradio_hal_ClearNsel(), ezradio_hal_DeassertShutdown(), GPIO_PinModeSet(), I2CSPM_Init(), KSZ8851SNL_SPI_SetChipSelect(), and SPI_TFT_WriteRegister().
__STATIC_INLINE unsigned int GPIO_PinOutGet | ( | GPIO_Port_TypeDef | port, |
unsigned int | pin | ||
) |
[in] | port | The GPIO port to access. |
[in] | pin | The pin to get setting for. |
Definition at line 722 of file em_gpio.h.
References BUS_RegBitRead(), and GPIO.
__STATIC_INLINE void GPIO_PinOutSet | ( | GPIO_Port_TypeDef | port, |
unsigned int | pin | ||
) |
[in] | port | The GPIO port to access. |
[in] | pin | The pin to set. |
Definition at line 745 of file em_gpio.h.
References BUS_RegBitWrite(), and GPIO.
Referenced by BSP_McuBoard_UsbStatusLedEnable(), ezradio_hal_AssertShutdown(), ezradio_hal_SetNsel(), GPIO_PinModeSet(), I2CSPM_Init(), KSZ8851SNL_SPI_SetChipSelect(), and SPI_TFT_WriteRegister().
__STATIC_INLINE void GPIO_PinOutToggle | ( | GPIO_Port_TypeDef | port, |
unsigned int | pin | ||
) |
[in] | port | The GPIO port to access. |
[in] | pin | The pin to toggle. |
Definition at line 771 of file em_gpio.h.
References GPIO.
__STATIC_INLINE uint32_t GPIO_PortInGet | ( | GPIO_Port_TypeDef | port | ) |
__STATIC_INLINE void GPIO_PortOutClear | ( | GPIO_Port_TypeDef | port, |
uint32_t | pins | ||
) |
[in] | port | The GPIO port to access. |
[in] | pins | Bit mask for bits to clear in DOUT register. |
Definition at line 809 of file em_gpio.h.
References BUS_RegMaskedClear(), and GPIO.
__STATIC_INLINE uint32_t GPIO_PortOutGet | ( | GPIO_Port_TypeDef | port | ) |
__STATIC_INLINE void GPIO_PortOutSet | ( | GPIO_Port_TypeDef | port, |
uint32_t | pins | ||
) |
[in] | port | The GPIO port to access. |
[in] | pins | Bit mask for bits to set to 1 in DOUT register. |
Definition at line 853 of file em_gpio.h.
References BUS_RegMaskedSet(), and GPIO.
__STATIC_INLINE void GPIO_PortOutSetVal | ( | GPIO_Port_TypeDef | port, |
uint32_t | val, | ||
uint32_t | mask | ||
) |
[in] | port | The GPIO port to access. |
[in] | val | Value to write to port data out register. |
[in] | mask | Mask indicating which bits to modify. |
Definition at line 882 of file em_gpio.h.
References GPIO.
__STATIC_INLINE void GPIO_PortOutToggle | ( | GPIO_Port_TypeDef | port, |
uint32_t | pins | ||
) |
[in] | port | The GPIO port to access. |
[in] | pins | Bitmask with pins to toggle. |
Definition at line 907 of file em_gpio.h.
References GPIO.