#include <cfg/arch.h>
#include <cfg/arch/gpio.h>
#include <dev/irqreg.h>
#include <arch/cm3/stm/stm32xxxx.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 |
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); ... }
sig | Bank/port interrupt to be associated with this handler. |
bit | Bit number of the specified bank/port. |
handler | This routine will be called by Nut/OS, when the specified pin changes its state. |
arg | Argument to be passed to the interrupt handler routine. |
References AFIO, EXTI, NutRegisterIrqHandler(), rc, and sig_INTERRUPT0.
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().
sig | Interrupt to enable. |
bit | Bit number of the specified bank/port. |
int GpioIrqDisable | ( | GPIO_SIGNAL * | sig, |
uint8_t | bit | ||
) |
Disable a specified GPIO interrupt.
sig | Interrupt to disable. |
bit | Bit number of the specified bank/port. |