#include <arch/avr32.h>
#include <stdlib.h>
#include <string.h>
#include <dev/gpio.h>
#include <avr32/io.h>
Go to the source code of this file.
Defines | |
#define | PERIPHERALS_MASK (GPIO_CFG_PERIPHERAL0|GPIO_CFG_PERIPHERAL1|GPIO_CFG_PERIPHERAL2|GPIO_CFG_PERIPHERAL3) |
Functions | |
int | GpioPinGet (int bank, int bit) |
Get pin level. | |
void | GpioPinSetLow (int bank, int bit) |
Set pin level to low. | |
void | GpioPinSetHigh (int bank, int bit) |
Set pin level to high. | |
void | GpioPinSet (int bank, int bit, int value) |
Set pin level. | |
unsigned int | GpioPortGet (int bank) |
Get all pin levels of a specified bank/port. | |
void | GpioPortSetLow (int bank, unsigned int mask) |
Set multiple pin levels of a bank/port to low. | |
void | GpioPortSetHigh (int bank, unsigned int mask) |
Set multiple pin levels of a bank/port to high. | |
void | GpioPortSet (int bank, unsigned int value) |
Set all pin levels of a bank/port. | |
uint32_t | GpioPinConfigGet (int bank, int bit) |
Get pin configuration. | |
int | GpioPortConfigSet (int bank, unsigned int mask, uint32_t flags) |
Set port wide pin configuration. | |
int | GpioPinConfigSet (int bank, int bit, uint32_t flags) |
Set pin configuration. | |
int | GpioRegisterIrqHandler (GPIO_SIGNAL *sig, int bit, void(*handler)(void *), void *arg) |
Register a GPIO pin interrupt handler. | |
int | GpioIrqEnable (GPIO_SIGNAL *sig, int bit) |
Enable a specified GPIO interrupt. | |
int | GpioIrqDisable (GPIO_SIGNAL *sig, int bit) |
Disable a specified GPIO interrupt. |
#define PERIPHERALS_MASK (GPIO_CFG_PERIPHERAL0|GPIO_CFG_PERIPHERAL1|GPIO_CFG_PERIPHERAL2|GPIO_CFG_PERIPHERAL3) |
Referenced by GpioPortConfigSet().
int GpioPinGet | ( | int | bank, |
int | bit | ||
) |
Get pin level.
bank | GPIO bank/port number. |
bit | Bit number of the specified bank/port. |
Definition at line 153 of file gpio_nutos.c.
Referenced by sys_key().
void GpioPinSetLow | ( | int | bank, |
int | bit | ||
) |
Set pin level to low.
Trying to set undefined pins is silently ignored.
bank | GPIO bank/port number. |
bit | Bit number of the specified bank/port. |
Definition at line 169 of file gpio_nutos.c.
Referenced by GpioPinSet(), GpioSpiBus0Select(), init_dio(), and ProcessRequests().
void GpioPinSetHigh | ( | int | bank, |
int | bit | ||
) |
Set pin level to high.
Trying to set undefined pins is silently ignored.
bank | GPIO bank/port number. |
bit | Bit number of the specified bank/port. |
Definition at line 185 of file gpio_nutos.c.
Referenced by GpioPinSet(), InitLED(), and ProcessRequests().
void GpioPinSet | ( | int | bank, |
int | bit, | ||
int | value | ||
) |
Set pin level.
Trying to set undefined pins is silently ignored.
bank | GPIO bank/port number. |
bit | Bit number of the specified bank/port. |
value | Level, 0 for low or any other value for high. |
Definition at line 202 of file gpio_nutos.c.
Referenced by NutSetLed().
unsigned int GpioPortGet | ( | int | bank | ) |
Get all pin levels of a specified bank/port.
bank | GPIO bank/port number. |
Definition at line 221 of file gpio_nutos.c.
Referenced by GpioPortSetHigh(), and GpioPortSetLow().
void GpioPortSetLow | ( | int | bank, |
unsigned int | mask | ||
) |
Set multiple pin levels of a bank/port to low.
bank | GPIO bank/port number. |
mask | Pin levels are set to low, if the corresponding bit in this mask is 1. |
Definition at line 238 of file gpio_nutos.c.
Referenced by GpioPortSet().
void GpioPortSetHigh | ( | int | bank, |
unsigned int | mask | ||
) |
Set multiple pin levels of a bank/port to high.
Trying to set undefined ports is silently ignored.
bank | GPIO bank/port number. |
mask | Pin levels are set to high, if the corresponding bit in this mask is 1. |
Definition at line 255 of file gpio_nutos.c.
Referenced by GpioPortSet().
void GpioPortSet | ( | int | bank, |
unsigned int | value | ||
) |
Set all pin levels of a bank/port.
This routine can be used to simultaneously set all pins of a specific port. However, in some implementations the high bit values will be set before the low bit values. If this is a problem, you should use GpioPortSetHigh() and GpioPortSetLow().
bank | GPIO bank/port number. |
value | Pin levels are set to high, if the corresponding bit in this mask is 1. All other pin levels are set to low. |
Definition at line 276 of file gpio_nutos.c.
Referenced by GpioPortSetHigh(), and GpioPortSetLow().
uint32_t GpioPinConfigGet | ( | int | bank, |
int | bit | ||
) |
Get pin configuration.
bank | GPIO bank/port number. |
bit | Bit number of the specified bank/port. |
Definition at line 292 of file gpio_nutos.c.
References _BV, GPIO_CFG_DEBOUNCE, GPIO_CFG_DISABLED, GPIO_CFG_OUTPUT, GPIO_CFG_PERIPHERAL0, GPIO_CFG_PERIPHERAL1, GPIO_CFG_PERIPHERAL2, GPIO_CFG_PERIPHERAL3, and GPIO_CFG_PULLUP.
Referenced by GpioPinConfigSet().
int GpioPortConfigSet | ( | int | bank, |
unsigned int | mask, | ||
uint32_t | flags | ||
) |
Set port wide pin configuration.
bank | GPIO bank/port number. |
mask | The given attributes are set for a specific pin, if the corresponding bit in this mask is 1. |
flags | Attribute flags to set. |
Definition at line 349 of file gpio_nutos.c.
References GPIO_CFG_DEBOUNCE, GPIO_CFG_DISABLED, GPIO_CFG_OUTPUT, GPIO_CFG_PULLUP, and PERIPHERALS_MASK.
Referenced by GpioPinConfigSet().
int GpioPinConfigSet | ( | int | bank, |
int | bit, | ||
uint32_t | flags | ||
) |
Set pin configuration.
Applications may also use this function to make sure, that a specific attribute is available for a specific pin.
bank | GPIO bank/port number. |
bit | Bit number of the specified bank/port. |
flags | Attribute flags. |
Definition at line 406 of file gpio_nutos.c.
References _BV, GpioPinConfigGet(), and GpioPortConfigSet().
Referenced by GpioSpiBus0Select(), init_dio(), InitKEY(), and InitLED().
int GpioRegisterIrqHandler | ( | GPIO_SIGNAL * | sig, |
int | 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, 30); ... }
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. |
Definition at line 457 of file gpio_nutos.c.
References GPIO_SIGNAL::ios_handler, GPIO_SIGNAL::ios_sig, GPIO_SIGNAL::ios_vector, GPIO_VECTOR::iov_arg, GPIO_VECTOR::iov_handler, malloc(), memset(), NutIrqEnable(), and NutRegisterIrqHandler().
int GpioIrqEnable | ( | GPIO_SIGNAL * | sig, |
int | 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. |
Definition at line 492 of file gpio_nutos.c.
References GPIO_SIGNAL::ios_ctl, and NUT_IRQCTL_ENABLE.
int GpioIrqDisable | ( | GPIO_SIGNAL * | sig, |
int | bit | ||
) |
Disable a specified GPIO interrupt.
sig | Interrupt to disable. |
bit | Bit number of the specified bank/port. |
Definition at line 505 of file gpio_nutos.c.
References GPIO_SIGNAL::ios_ctl, and NUT_IRQCTL_DISABLE.