libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
GPIO peripheral API

Access functions for the I/O Controller More...

Collaboration diagram for GPIO peripheral API:

Functions

void gpio_set (uint32_t gpioport, uint32_t gpios)
 Atomic set output. More...
 
void gpio_clear (uint32_t gpioport, uint32_t gpios)
 Atomic clear output. More...
 
void gpio_toggle (uint32_t gpioport, uint32_t gpios)
 Toggle output. More...
 
uint32_t gpio_get (uint32_t gpioport, uint32_t gpios)
 Read GPIO values. More...
 
void gpio_mode_setup (uint32_t gpioport, uint32_t mode, uint32_t pull_up_down, uint32_t gpios)
 Set GPIO Pin Mode. More...
 
void gpio_set_options (uint32_t gpioport, uint32_t drive, uint32_t sense, uint32_t gpios)
 Configure GPIO pin input and output specifics. More...
 
void gpio_configure_task (uint8_t task_num, uint8_t pin_num, uint8_t polarity, uint32_t init)
 Configure Task in GPIO TE Module. More...
 
void gpio_configure_event (uint8_t event_num, uint8_t pin_num, uint8_t polarity)
 Configure Event in GPIO TE Module. More...
 
void gpio_enable_interrupts (uint32_t mask)
 Enable GPIO interrupts. More...
 
void gpio_disable_interrupts (uint32_t mask)
 Disable GPIO interrupts. More...
 
void gpio_clear_interrupts (void)
 Disable all GPIO interrupts. More...
 

Detailed Description

Access functions for the I/O Controller

LGPL License Terms libopencm3 License

Author
© 2016 Maxim Sloyko maxim.nosp@m.s@go.nosp@m.ogle..nosp@m.com

Function Documentation

◆ gpio_clear()

void gpio_clear ( uint32_t  gpioport,
uint32_t  gpios 
)

Atomic clear output.

Parameters
[in]gpioportPort identifier GPIO ports
[in]gpiosPin identifiers GPIO Pin Identifiers

Definition at line 52 of file gpio.c.

References GPIO_OUTCLR.

◆ gpio_clear_interrupts()

void gpio_clear_interrupts ( void  )

Disable all GPIO interrupts.

Definition at line 203 of file gpio.c.

References GPIO_INTENCLR.

◆ gpio_configure_event()

void gpio_configure_event ( uint8_t  event_num,
uint8_t  pin_num,
uint8_t  polarity 
)

Configure Event in GPIO TE Module.

Parameters
[in]event_numEvent number (0-3)
[in]pin_numGPIO Pin number (0-31)
[in]polarityOperation to perform when task is triggered.

Definition at line 175 of file gpio.c.

References GPIO_TE_CONFIG, GPIO_TE_CONFIG_MODE_SHIFT, GPIO_TE_CONFIG_POLARITY_SHIFT, GPIO_TE_CONFIG_PSEL_SHIFT, and GPIO_TE_MODE_EVENT.

◆ gpio_configure_task()

void gpio_configure_task ( uint8_t  task_num,
uint8_t  pin_num,
uint8_t  polarity,
uint32_t  init 
)

Configure Task in GPIO TE Module.

Parameters
[in]task_numuint8_t Task number (0-3)
[in]pin_numuint8_t GPIO Pin number (0-31)
[in]polarityuint8_t polarity Operation to perform when task is triggered.
[in]inituint8_t Initial state of the pin, non-zero means initially active, zero means initially inactive

Definition at line 155 of file gpio.c.

References GPIO_TE_CONFIG, GPIO_TE_CONFIG_MODE_SHIFT, GPIO_TE_CONFIG_OUTINIT, GPIO_TE_CONFIG_POLARITY_SHIFT, GPIO_TE_CONFIG_PSEL_SHIFT, and GPIO_TE_MODE_TASK.

◆ gpio_disable_interrupts()

void gpio_disable_interrupts ( uint32_t  mask)

Disable GPIO interrupts.

Parameters
[in]maskinterrupts to disable.

Definition at line 195 of file gpio.c.

References GPIO_INTENCLR.

◆ gpio_enable_interrupts()

void gpio_enable_interrupts ( uint32_t  mask)

Enable GPIO interrupts.

Parameters
[in]maskinterrupts to enable.

Definition at line 186 of file gpio.c.

References GPIO_INTENSET.

◆ gpio_get()

uint32_t gpio_get ( uint32_t  gpioport,
uint32_t  gpios 
)

Read GPIO values.

Parameters
[in]gpioportPort identifier GPIO ports
[in]gpiosPin identifiers GPIO Pin Identifiers

Definition at line 76 of file gpio.c.

References GPIO_IN.

◆ gpio_mode_setup()

void gpio_mode_setup ( uint32_t  gpioport,
uint32_t  mode,
uint32_t  pull_up_down,
uint32_t  gpios 
)

Set GPIO Pin Mode.

Sets the mode (input/output) and configuration (analog/digitial and open drain/push pull), for a set of GPIO pins on a given GPIO port.

Parameters
[in]gpioportPort identifier GPIO ports
[in]modePin mode GPIO Pin Mode
[in]pull_up_downPull up / pull down configuration GPIO Output Pin Pullup
[in]gpiosPin identifiers GPIO Pin Identifiers If multiple pins are to be set, use bitwise OR '|' to separate them.

Definition at line 94 of file gpio.c.

References GPIO_CNF_MODE_MASK, GPIO_CNF_MODE_SHIFT, GPIO_CNF_PUPD_MASK, GPIO_CNF_PUPD_SHIFT, and GPIO_PIN_CNF.

◆ gpio_set()

void gpio_set ( uint32_t  gpioport,
uint32_t  gpios 
)

Atomic set output.

Parameters
[in]gpioportPort identifier GPIO ports
[in]gpiosPin identifiers GPIO Pin Identifiers

Definition at line 41 of file gpio.c.

References GPIO_OUTSET.

◆ gpio_set_options()

void gpio_set_options ( uint32_t  gpioport,
uint32_t  drive,
uint32_t  sense,
uint32_t  gpios 
)

Configure GPIO pin input and output specifics.

Configure drive strength and input sensing for given GPIO port.

Parameters
[in]gpioportGPIO port identifier, see GPIO ports
[in]driveDrive schema used to drive pin, see GPIO drive configuration
[in]sensePin sensing mechanism, see GPIO sensing mechanism
[in]gpiosPin identifiers GPIO Pin Identifiers If multiple pins are to be set, use bitwise OR '|' to separate them.

Definition at line 125 of file gpio.c.

References GPIO_CNF_DRIVE_MASK, GPIO_CNF_DRIVE_SHIFT, GPIO_CNF_SENSE_MASK, GPIO_CNF_SENSE_SHIFT, and GPIO_PIN_CNF.

◆ gpio_toggle()

void gpio_toggle ( uint32_t  gpioport,
uint32_t  gpios 
)

Toggle output.

Parameters
[in]gpioportPort identifier GPIO ports
[in]gpiosPin identifiers GPIO Pin Identifiers

Definition at line 63 of file gpio.c.

References GPIO_OUT, GPIO_OUTCLR, and GPIO_OUTSET.