GPIO
[EM_Library]

General Purpose Input/Output (GPIO) API. More...

Collaboration diagram for GPIO:

Enumerations

enum  GPIO_Port_TypeDef {
  gpioPortA = 0,
  gpioPortB = 1,
  gpioPortC = 2,
  gpioPortD = 3,
  gpioPortE = 4,
  gpioPortF = 5
}
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).
void GPIO_IntConfig (GPIO_Port_TypeDef port, unsigned int pin, bool risingEdge, bool fallingEdge, bool enable)
 Configure GPIO interrupt.
void GPIO_PinModeSet (GPIO_Port_TypeDef port, unsigned int pin, GPIO_Mode_TypeDef mode, unsigned int out)
 Set the mode for a GPIO pin.
__STATIC_INLINE void GPIO_DbgSWDClkEnable (bool enable)
 Enable/disable serial wire clock pin.
__STATIC_INLINE void GPIO_DbgSWDIOEnable (bool enable)
 Enable/disable serial wire data pin.
void GPIO_DriveModeSet (GPIO_Port_TypeDef port, GPIO_DriveMode_TypeDef mode)
 Sets the drive mode for a GPIO port.
__STATIC_INLINE void GPIO_InputSenseSet (uint32_t val, uint32_t mask)
 Enable/disable input sensing.
__STATIC_INLINE void GPIO_IntClear (uint32_t flags)
 Clear one or more pending GPIO interrupts.
__STATIC_INLINE void GPIO_IntDisable (uint32_t flags)
 Disable one or more GPIO interrupts.
__STATIC_INLINE void GPIO_IntEnable (uint32_t flags)
 Enable one or more GPIO interrupts.
__STATIC_INLINE uint32_t GPIO_IntGet (void)
 Get pending GPIO interrupts.
__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.
__STATIC_INLINE void GPIO_IntSet (uint32_t flags)
 Set one or more pending GPIO interrupts from SW.
__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.
__STATIC_INLINE void GPIO_PinOutClear (GPIO_Port_TypeDef port, unsigned int pin)
 Set a single pin in GPIO data out port register to 0.
__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.
__STATIC_INLINE void GPIO_PinOutSet (GPIO_Port_TypeDef port, unsigned int pin)
 Set a single pin in GPIO data out register to 1.
__STATIC_INLINE void GPIO_PinOutToggle (GPIO_Port_TypeDef port, unsigned int pin)
 Toggle a single pin in GPIO port data out register.
__STATIC_INLINE uint32_t GPIO_PortInGet (GPIO_Port_TypeDef port)
 Read the pad values for GPIO port.
__STATIC_INLINE void GPIO_PortOutClear (GPIO_Port_TypeDef port, uint32_t pins)
 Set bits in DOUT register for a port to 0.
__STATIC_INLINE uint32_t GPIO_PortOutGet (GPIO_Port_TypeDef port)
 Get current setting for a GPIO port data out register.
__STATIC_INLINE void GPIO_PortOutSet (GPIO_Port_TypeDef port, uint32_t pins)
 Set bits GPIO data out register to 1.
__STATIC_INLINE void GPIO_PortOutSetVal (GPIO_Port_TypeDef port, uint32_t val, uint32_t mask)
 Set GPIO port data out register.
__STATIC_INLINE void GPIO_PortOutToggle (GPIO_Port_TypeDef port, uint32_t pins)
 Toggle a single pin in GPIO port data out register.
__STATIC_INLINE void GPIO_Unlock (void)
 Unlocks the GPIO configuration.

Detailed Description

General Purpose Input/Output (GPIO) API.


Enumeration Type Documentation

GPIO drive mode.

Enumerator:
gpioDriveModeStandard 

Default 6mA

gpioDriveModeLowest 

0.5 mA

gpioDriveModeHigh 

20 mA

gpioDriveModeLow 

2 mA

Definition at line 74 of file em_gpio.h.

Pin mode. For more details on each mode, please refer to the EFM32 reference manual.

Enumerator:
gpioModeDisabled 

Input disabled. Pullup if DOUT is set.

gpioModeInput 

Input enabled. Filter if DOUT is set

gpioModeInputPull 

Input enabled. DOUT determines pull direction

gpioModeInputPullFilter 

Input enabled with filter. DOUT determines pull direction

gpioModePushPull 

Push-pull output

gpioModePushPullDrive 

Push-pull output with drive-strength set by DRIVEMODE

gpioModeWiredOr 

Wired-or output

gpioModeWiredOrPullDown 

Wired-or output with pull-down

gpioModeWiredAnd 

Open-drain output

gpioModeWiredAndFilter 

Open-drain output with filter

gpioModeWiredAndPullUp 

Open-drain output with pullup

gpioModeWiredAndPullUpFilter 

Open-drain output with filter and pullup

gpioModeWiredAndDrive 

Open-drain output with drive-strength set by DRIVEMODE

gpioModeWiredAndDriveFilter 

Open-drain output with filter and drive-strength set by DRIVEMODE

gpioModeWiredAndDrivePullUp 

Open-drain output with pullup and drive-strength set by DRIVEMODE

gpioModeWiredAndDrivePullUpFilter 

Open-drain output with filter, pullup and drive-strength set by DRIVEMODE

Definition at line 88 of file em_gpio.h.

GPIO ports identificator.

Enumerator:
gpioPortA 

Port A

gpioPortB 

Port B

gpioPortC 

Port C

gpioPortD 

Port D

gpioPortE 

Port E

gpioPortF 

Port F

Definition at line 63 of file em_gpio.h.


Function Documentation

void GPIO_DbgLocationSet ( unsigned int  location  ) 

Sets the pin location of the debug pins (Serial Wire interface).

Note:
Changing the pins used for debugging uncontrolled, may result in a lockout.
Parameters:
[in] location The debug pin location to use (0-3).

Definition at line 75 of file em_gpio.c.

__STATIC_INLINE void GPIO_DbgSWDClkEnable ( bool  enable  ) 

Enable/disable serial wire clock pin.

Note:
Disabling SWDClk will disable the debug interface, which may result in a lockout if done early in startup (before debugger is able to halt core).
Parameters:
[in] enable 
  • false - disable serial wire clock.
  • true - enable serial wire clock (default after reset).

Definition at line 173 of file em_gpio.h.

References BITBAND_Peripheral().

Here is the call graph for this function:

__STATIC_INLINE void GPIO_DbgSWDIOEnable ( bool  enable  ) 

Enable/disable serial wire data pin.

Note:
Disabling SWDClk will disable the debug interface, which may result in a lockout if done early in startup (before debugger is able to halt core).
Parameters:
[in] enable 
  • false - disable serial wire data pin.
  • true - enable serial wire data pin (default after reset).

Definition at line 191 of file em_gpio.h.

References BITBAND_Peripheral().

Here is the call graph for this function:

void GPIO_DriveModeSet ( GPIO_Port_TypeDef  port,
GPIO_DriveMode_TypeDef  mode 
)

Sets the drive mode for a GPIO port.

Parameters:
[in] port The GPIO port to access.
[in] mode Drive mode to use for port.

Definition at line 98 of file em_gpio.c.

__STATIC_INLINE void GPIO_InputSenseSet ( uint32_t  val,
uint32_t  mask 
)

Enable/disable input sensing.

Disabling input sensing if not used, can save some energy consumption.

Parameters:
[in] val Bitwise logic OR of one or more of:

  • GPIO_INSENSE_INT - interrupt input sensing.
  • GPIO_INSENSE_PRS - peripheral reflex system input sensing.
[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 327 of file em_gpio.h.

__STATIC_INLINE void GPIO_IntClear ( uint32_t  flags  ) 

Clear one or more pending GPIO interrupts.

Parameters:
[in] flags Bitwise logic OR of GPIO interrupt sources to clear.

Definition at line 340 of file em_gpio.h.

void GPIO_IntConfig ( GPIO_Port_TypeDef  port,
unsigned int  pin,
bool  risingEdge,
bool  fallingEdge,
bool  enable 
)

Configure GPIO interrupt.

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.

Note:
A certain pin number can only be associated with one port. Ie, if GPIO interrupt 1 is assigned to port A/pin 1, then it is not possibly to use pin 1 from any other ports for interrupts. Please refer to the reference manual.
Parameters:
[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 143 of file em_gpio.c.

References BITBAND_Peripheral().

Here is the call graph for this function:

__STATIC_INLINE void GPIO_IntDisable ( uint32_t  flags  ) 

Disable one or more GPIO interrupts.

Parameters:
[in] flags GPIO interrupt sources to disable.

Definition at line 353 of file em_gpio.h.

__STATIC_INLINE void GPIO_IntEnable ( uint32_t  flags  ) 

Enable one or more GPIO interrupts.

Note:
Depending on the use, a pending interrupt may already be set prior to enabling the interrupt. Consider using GPIO_IntClear() prior to enabling if such a pending interrupt should be ignored.
Parameters:
[in] flags GPIO interrupt sources to enable.

Definition at line 371 of file em_gpio.h.

__STATIC_INLINE uint32_t GPIO_IntGet ( void   ) 

Get pending GPIO interrupts.

Returns:
GPIO interrupt sources pending.

Definition at line 384 of file em_gpio.h.

__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.

Note:
Interrupt flags are not cleared by the use of this function.
Returns:
Pending and enabled GPIO interrupt sources. The return value is the bitwise AND combination of
  • the OR combination of enabled interrupt sources in GPIO_IEN register and
  • the OR combination of valid interrupt flags in GPIO_IF register.

Definition at line 405 of file em_gpio.h.

__STATIC_INLINE void GPIO_IntSet ( uint32_t  flags  ) 

Set one or more pending GPIO interrupts from SW.

Parameters:
[in] flags GPIO interrupt sources to set to pending.

Definition at line 425 of file em_gpio.h.

__STATIC_INLINE void GPIO_Lock ( void   ) 

Locks the GPIO configuration.

Definition at line 435 of file em_gpio.h.

__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.

Parameters:
[in] port The GPIO port to access.
[in] pin The pin number to read.
Returns:
The pin value, 0 or 1.

Definition at line 454 of file em_gpio.h.

void GPIO_PinModeSet ( GPIO_Port_TypeDef  port,
unsigned int  pin,
GPIO_Mode_TypeDef  mode,
unsigned int  out 
)

Set the mode for a GPIO pin.

Parameters:
[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 199 of file em_gpio.c.

References gpioModeDisabled.

__STATIC_INLINE void GPIO_PinOutClear ( GPIO_Port_TypeDef  port,
unsigned int  pin 
)

Set a single pin in GPIO data out port register to 0.

Note:
In order for the setting to take effect on the output pad, the pin must have been configured properly. If not, it will take effect whenever the pin has been properly configured.
Parameters:
[in] port The GPIO port to access.
[in] pin The pin to set.

Definition at line 477 of file em_gpio.h.

__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.

Parameters:
[in] port The GPIO port to access.
[in] pin The pin to get setting for.
Returns:
The DOUT setting for the requested pin, 0 or 1.

Definition at line 498 of file em_gpio.h.

__STATIC_INLINE void GPIO_PinOutSet ( GPIO_Port_TypeDef  port,
unsigned int  pin 
)

Set a single pin in GPIO data out register to 1.

Note:
In order for the setting to take effect on the output pad, the pin must have been configured properly. If not, it will take effect whenever the pin has been properly configured.
Parameters:
[in] port The GPIO port to access.
[in] pin The pin to set.

Definition at line 521 of file em_gpio.h.

__STATIC_INLINE void GPIO_PinOutToggle ( GPIO_Port_TypeDef  port,
unsigned int  pin 
)

Toggle a single pin in GPIO port data out register.

Note:
In order for the setting to take effect on the output pad, the pin must have been configured properly. If not, it will take effect whenever the pin has been properly configured.
Parameters:
[in] port The GPIO port to access.
[in] pin The pin to toggle.

Definition at line 544 of file em_gpio.h.

__STATIC_INLINE uint32_t GPIO_PortInGet ( GPIO_Port_TypeDef  port  ) 

Read the pad values for GPIO port.

Parameters:
[in] port The GPIO port to access.

Definition at line 559 of file em_gpio.h.

__STATIC_INLINE void GPIO_PortOutClear ( GPIO_Port_TypeDef  port,
uint32_t  pins 
)

Set bits in DOUT register for a port to 0.

Note:
In order for the setting to take effect on the output pad, the pin must have been configured properly. If not, it will take effect whenever the pin has been properly configured.
Parameters:
[in] port The GPIO port to access.
[in] pins Bit mask for bits to clear in DOUT register.

Definition at line 582 of file em_gpio.h.

__STATIC_INLINE uint32_t GPIO_PortOutGet ( GPIO_Port_TypeDef  port  ) 

Get current setting for a GPIO port data out register.

Parameters:
[in] port The GPIO port to access.
Returns:
The data out setting for the requested port.

Definition at line 600 of file em_gpio.h.

__STATIC_INLINE void GPIO_PortOutSet ( GPIO_Port_TypeDef  port,
uint32_t  pins 
)

Set bits GPIO data out register to 1.

Note:
In order for the setting to take effect on the respective output pads, the pins must have been configured properly. If not, it will take effect whenever the pin has been properly configured.
Parameters:
[in] port The GPIO port to access.
[in] pins Bit mask for bits to set to 1 in DOUT register.

Definition at line 623 of file em_gpio.h.

__STATIC_INLINE void GPIO_PortOutSetVal ( GPIO_Port_TypeDef  port,
uint32_t  val,
uint32_t  mask 
)

Set GPIO port data out register.

Note:
In order for the setting to take effect on the respective output pads, the pins must have been configured properly. If not, it will take effect whenever the pin has been properly configured.
Parameters:
[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 649 of file em_gpio.h.

__STATIC_INLINE void GPIO_PortOutToggle ( GPIO_Port_TypeDef  port,
uint32_t  pins 
)

Toggle a single pin in GPIO port data out register.

Note:
In order for the setting to take effect on the output pad, the pin must have been configured properly. If not, it will take effect whenever the pin has been properly configured.
Parameters:
[in] port The GPIO port to access.
[in] pins Bitmask with pins to toggle.

Definition at line 672 of file em_gpio.h.

__STATIC_INLINE void GPIO_Unlock ( void   ) 

Unlocks the GPIO configuration.

Definition at line 684 of file em_gpio.h.