Nut/OS  5.0.5
API Reference
gpio_stm32.h File Reference
#include <cfg/arch.h>
#include <cfg/arch/gpio.h>
#include <dev/irqreg.h>
#include <arch/cm3/stm/stm32xxxx.h>
Include dependency graph for gpio_stm32.h:

Go to the source code of this file.

Data Structures

struct  GPIO_VECTOR
struct  GPIO_SIGNAL

Functions

uint32_t GpioPinConfigGet (int bank, int bit)
 Get pin configuration.
int GpioPinConfigSet (int bank, int bit, uint32_t flags)
 Set pin configuration.
int GpioPortConfigSet (int bank, uint32_t mask, uint32_t flags)
 Set port wide pin configuration.
int GpioRegisterIrqHandler (GPIO_SIGNAL *sig, uint8_t bit, void(*handler)(void *), void *arg)
 Register a GPIO pin interrupt handler.
int GpioIrqEnable (GPIO_SIGNAL *sig, uint8_t bit)
 Enable a specified GPIO interrupt.
int GpioIrqDisable (GPIO_SIGNAL *sig, uint8_t bit)
 Disable a specified GPIO interrupt.

Variables

GPIO_SIGNAL sig_GPIO
GPIO_SIGNAL sig_GPIO1
GPIO_SIGNAL sig_GPIO2
GPIO_SIGNAL sig_GPIO3

Function Documentation

int GpioRegisterIrqHandler ( GPIO_SIGNAL sig,
uint8_t  bit,
void(*)(void *)  handler,
void *  arg 
)

Register a GPIO pin interrupt handler.

Generating interrupts on GPIO pin changes is not supported on all platforms. In this case dedicated external interrupt pins may be used with NutRegisterIrqHandler().

Interrupts are triggered on rising and falling edges. Level triggering or triggering on specific edges is not supported.

After registering, interrupts are disabled. Calling GpioIrqEnable() is required to activate the interrupt.

The following code fragment registers an interrupt handler which is called on each change of bit 4 of the first GPIO port:

 #include <dev/gpio.h>

 static void PinChange(void *arg)
 {
     ...
 }

 {
     ...
     GpioPinConfigSet(0, 4, GPIO_CFG_PULLUP);
     GpioRegisterIrqHandler(&sig_GPIO, 4, PinChange, NULL);
     GpioIrqEnable(&sig_GPIO, 4);
     ...
 }
Parameters:
sigBank/port interrupt to be associated with this handler.
bitBit number of the specified bank/port.
handlerThis routine will be called by Nut/OS, when the specified pin changes its state.
argArgument to be passed to the interrupt handler routine.
Returns:
0 on success, -1 otherwise.

References AFIO, EXTI, NutRegisterIrqHandler(), rc, and sig_INTERRUPT0.

Here is the call graph for this function:

int GpioIrqEnable ( GPIO_SIGNAL sig,
uint8_t  bit 
)

Enable a specified GPIO interrupt.

A related interrupt handler must have been registered before calling this function. See GpioRegisterIrqHandler().

Parameters:
sigInterrupt to enable.
bitBit number of the specified bank/port.
Returns:
0 on success, -1 otherwise.
int GpioIrqDisable ( GPIO_SIGNAL sig,
uint8_t  bit 
)

Disable a specified GPIO interrupt.

Parameters:
sigInterrupt to disable.
bitBit number of the specified bank/port.
Returns:
0 on success, -1 otherwise.

Variable Documentation