61#define GPIO_LOCK_UNLOCK_CODE 0x4C4F434B
302#define PCTL_AF(pin, af) ((af) << ((pin) << 2))
303#define PCTL_MASK(pin) PCTL_AF((pin), 0xf)
321void gpio_set_af(uint32_t gpioport, uint8_t alt_func_num, uint8_t gpios)
328 if (alt_func_num == 0) {
340 for (i = 0; i < 8; i++) {
343 if (!(gpios & pin_mask)) {
347 pctl32 &= ~PCTL_MASK(i);
348 pctl32 |=
PCTL_AF(i, (alt_func_num & 0xf));
372 GPIO_LOCK(gpioport) = ~GPIO_LOCK_UNLOCK_CODE;
void gpio_mode_setup(uint32_t gpioport, enum gpio_mode mode, enum gpio_pullup pullup, uint8_t gpios)
Configure a group of pins.
void gpio_unlock_commit(uint32_t gpioport, uint8_t gpios)
Unlock the commit control of a special function pin.
void gpio_set_af(uint32_t gpioport, uint8_t alt_func_num, uint8_t gpios)
Multiplex group of pins to the given alternate function.
void gpio_set_output_config(uint32_t gpioport, enum gpio_output_type otype, enum gpio_drive_strength drive, uint8_t gpios)
Configure output parameters of a group of pins.
void gpio_enable_ahb_aperture(void)
Enable access to GPIO registers via the AHB aperture.
void gpio_toggle(uint32_t gpioport, uint8_t gpios)
Toggle a Group of Pins.
@ GPIO_DRIVE_8MA_SLEW_CTL
8mA drive with slew rate control
@ GPIO_DRIVE_8MA
8mA drive
@ GPIO_DRIVE_2MA
2mA drive
@ GPIO_DRIVE_4MA
4mA drive
@ GPIO_PUPD_PULLUP
Pull the pin high.
@ GPIO_PUPD_PULLDOWN
Pull the pin low.
@ GPIO_PUPD_NONE
Do not pull the pin high or low.
@ GPIO_MODE_ANALOG
Configure pin as analog function.
@ GPIO_MODE_INPUT
Configure pin as input.
@ GPIO_MODE_OUTPUT
Configure pin as output.
@ GPIO_OTYPE_OD
Open drain configuration.
@ GPIO_TRIG_EDGE_BOTH
Falling and Rising edges trigger.
@ GPIO_TRIG_EDGE_FALL
Falling edge trigger.
@ GPIO_TRIG_LVL_LOW
Level trigger, signal low.
@ GPIO_TRIG_LVL_HIGH
Level trigger, signal high.
@ GPIO_TRIG_EDGE_RISE
Rising edge trigger.
#define GPIO_LOCK_UNLOCK_CODE
void gpio_enable_interrupts(uint32_t gpioport, uint8_t gpios)
Enable interrupts on specified GPIO pins.
void gpio_configure_trigger(uint32_t gpioport, enum gpio_trigger trigger, uint8_t gpios)
Configure the interrupt trigger on the given GPIO pins.
void gpio_disable_interrupts(uint32_t gpioport, uint8_t gpios)
Disable interrupts on specified GPIO pins.