libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
Macros | |
#define | GPIO(port) (GPIO_BASE + (0x040 * (port))) |
#define | GPIO0 (GPIO_BASE + 0x000) |
#define | GPIO1 (GPIO_BASE + 0x040) |
#define | GPIO2 (GPIO_BASE + 0x080) |
#define | GPIO3 (GPIO_BASE + 0x0C0) |
#define | GPIO4 (GPIO_BASE + 0x100) |
#define | GPIO_OFFSET(gpio) (0x1 << ((gpio) % 32)) |
#define | GPIO_PDOR(gpio_base) MMIO32((gpio_base) + 0x00) |
#define | GPIO_PSOR(gpio_base) MMIO32((gpio_base) + 0x04) |
#define | GPIO_PCOR(gpio_base) MMIO32((gpio_base) + 0x08) |
#define | GPIO_PTOR(gpio_base) MMIO32((gpio_base) + 0x0C) |
#define | GPIO_PDIR(gpio_base) MMIO32((gpio_base) + 0x10) |
Functions | |
void | gpio_set (uint32_t gpio) |
Set GPIO. More... | |
void | gpio_clear (uint32_t gpio) |
Set GPIO. More... | |
bool | gpio_get (uint32_t gpio) |
Get GPIOs logic state. More... | |
void | gpio_toggle (uint32_t gpio) |
Toggles GPIO. More... | |
uint32_t | gpio_port_read (uint32_t gpioport) |
Read a whole GPIO Port. More... | |
void | gpio_port_write (uint32_t gpioport, uint32_t data) |
Write a whole GPIO Port. More... | |
void gpio_clear | ( | uint32_t | gpio | ) |
Set GPIO.
Clears GPIO by GPIO number according to MUX list
[in] | gpio | unsigned 32 bit. GPIO number |
Definition at line 65 of file gpio.c.
References GPIO, GPIO_OFFSET, and GPIO_PCOR.
bool gpio_get | ( | uint32_t | gpio | ) |
Get GPIOs logic state.
Get logic level of GPIO given by GPIO number according to MUX list. Reading a GPIO value is possible even if the port is not muxed for GPIO.
[in] | gpio | unsigned 32 bit. GPIO number |
Definition at line 81 of file gpio.c.
References GPIO, GPIO_OFFSET, and GPIO_PDIR.
uint32_t gpio_port_read | ( | uint32_t | gpioport | ) |
Read a whole GPIO Port.
Gets all 32 GPIOs of a Port.
[in] | gpioport | unsigned 32 bit. GPIO port GPIO register base addresses |
Definition at line 110 of file gpio.c.
References GPIO_PDIR.
void gpio_port_write | ( | uint32_t | gpioport, |
uint32_t | data | ||
) |
Write a whole GPIO Port.
Sets all 32 GPIOs of a Port.
[in] | gpioport | unsigned 32 bit. GPIO port GPIO register base addresses |
[in] | gpio | unsigned 32 bit. 1 for a logic 1 driven at port, 0 for a logic 0 driven at port. |
Definition at line 125 of file gpio.c.
References GPIO_PDOR.
void gpio_set | ( | uint32_t | gpio | ) |
Set GPIO.
Set GPIO by GPIO number according to MUX list
[in] | gpio | unsigned 32 bit. GPIO number |
Definition at line 51 of file gpio.c.
References GPIO, GPIO_OFFSET, and GPIO_PSOR.
void gpio_toggle | ( | uint32_t | gpio | ) |
Toggles GPIO.
Toggles GPIO by GPIO number according to MUX list
[in] | gpio | unsigned 32 bit. GPIO number |
Definition at line 95 of file gpio.c.
References GPIO, GPIO_OFFSET, and GPIO_PTOR.