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

SWM050 GPIO API. More...

Collaboration diagram for GPIO peripheral API:

Functions

void gpio_set (uint16_t gpios)
 Set a Group of Pins. More...
 
void gpio_clear (uint16_t gpios)
 Clear a Group of Pins. More...
 
uint16_t gpio_get (uint16_t gpios)
 Read a Group of Pins. More...
 
void gpio_toggle (uint16_t gpios)
 Toggle a Group of Pins. More...
 
void gpio_input (uint16_t gpios)
 Set the direction of a Group of Pins to Input. More...
 
void gpio_output (uint16_t gpios)
 Set the direction of a Group of Pins to Output. More...
 
void gpio_int_enable (uint16_t gpios, bool en)
 Sets the pins as external interrupts, rather than normal GPIO. More...
 
void gpio_int_mask (uint16_t gpios, enum gpio_int_masked masked)
 Sets bits in the interrupt mask. More...
 
void gpio_int_type (uint16_t gpios, enum gpio_trig_type type)
 Sets whether the pins are edge triggered or level triggered. More...
 
void gpio_int_pol (uint16_t gpios, enum gpio_pol pol)
 Sets the interrupt trigger polarity. More...
 
uint16_t gpio_int_status (void)
 Gets the masked interrupt status. More...
 
uint16_t gpio_int_raw_status (void)
 Gets the raw unmasked interrupt status. More...
 
void gpio_int_clear (uint16_t gpios)
 Clear the specified pin interrupts. More...
 

Detailed Description

SWM050 GPIO API.

LGPL License Terms libopencm3 License

Author
© 2019 Icenowy Zheng iceno.nosp@m.wy@a.nosp@m.osc.i.nosp@m.o
© 2019 Caleb Szalacinski conta.nosp@m.ct@s.nosp@m.kiboy.nosp@m..net

Function Documentation

◆ gpio_clear()

void gpio_clear ( uint16_t  gpios)

Clear a Group of Pins.

Set one or more pins of GPIO to 0. Please note that this chip doesn't support atomic pin setting.

Parameters
[in]gpiosPin identifiers GPIO Pin Identifiers If multiple pins are to be changed, use bitwise OR '|' to separate them.

Definition at line 57 of file gpio.c.

References GPIO_ADATA.

◆ gpio_get()

uint16_t gpio_get ( uint16_t  gpios)

Read a Group of Pins.

Parameters
[in]gpiosPin identifiers GPIO Pin Identifiers If multiple pins are to be read, use bitwise OR '|' to separate them.
Returns
The pin values as a bitfield. The bit position of the pin value returned corresponds to the pin number.

Definition at line 71 of file gpio.c.

References GPIO_AEXT.

◆ gpio_input()

void gpio_input ( uint16_t  gpios)

Set the direction of a Group of Pins to Input.

Set the direction of one or more pins of GPIO to input.

Parameters
[in]gpiosPin identifiers GPIO Pin Identifiers If multiple pins are to be changed, use bitwise OR '|' to separate them.

Definition at line 100 of file gpio.c.

References GPIO_ADIR.

◆ gpio_int_clear()

void gpio_int_clear ( uint16_t  gpios)

Clear the specified pin interrupts.

Clears the specified pin interrupts. Edge-triggered interrupts must be cleared by software.

Parameters
[in]gpiosPin identifiers GPIO Pin Identifiers If multiple pins are to be changed, use bitwise OR '|' to separate them.

Definition at line 249 of file gpio.c.

References GPIO_INTEOI_A.

◆ gpio_int_enable()

void gpio_int_enable ( uint16_t  gpios,
bool  en 
)

Sets the pins as external interrupts, rather than normal GPIO.

Enable interrupts on the selected pins. If you want to quickly switch on and off interrupts, use gpio_int_mask() after calling this.

Parameters
[in]gpiosPin identifiers GPIO Pin Identifiers If multiple pins are to be changed, use bitwise OR '|' to separate them.
[in]enTrue to enable, false to disable.

Definition at line 132 of file gpio.c.

References GPIO_INTEN_A.

◆ gpio_int_mask()

void gpio_int_mask ( uint16_t  gpios,
enum gpio_int_masked  masked 
)

Sets bits in the interrupt mask.

When interrupts are masked, it prevents them from being received, which is a quicker way to turn on and off GPIO interrupts (after calling gpio_int_en()).

Parameters
[in]gpiosPin identifiers GPIO Pin Identifiers If multiple pins are to be changed, use bitwise OR '|' to separate them.
[in]maskedPin mask selection GPIO Interrupt Mask Whether to mask or unmask pins.

Definition at line 155 of file gpio.c.

References GPIO_INTMASK_A.

◆ gpio_int_pol()

void gpio_int_pol ( uint16_t  gpios,
enum gpio_pol  pol 
)

Sets the interrupt trigger polarity.

Sets whether the interrupt is triggered by a high or low level/edge.

Parameters
[in]gpiosPin identifiers GPIO Pin Identifiers If multiple pins are to be changed, use bitwise OR '|' to separate them.
[in]polPolarity GPIO Polarity High or low level/edge

Definition at line 200 of file gpio.c.

References GPIO_INTPOLARITY_A.

◆ gpio_int_raw_status()

uint16_t gpio_int_raw_status ( void  )

Gets the raw unmasked interrupt status.

Returns the raw unmasked interrupt status.

Returns
The unmasked pin interrupt status as a bitfield. The bit position of the pin value returned corresponds to the pin number.

Definition at line 233 of file gpio.c.

References GPIO_RAWINTSTAT_A.

◆ gpio_int_status()

uint16_t gpio_int_status ( void  )

Gets the masked interrupt status.

Returns the pin interrupt status masked with the mask set in gpio_int_mask().

Returns
The masked pin interrupt status as a bitfield. The bit position of the pin value returned corresponds to the pin number.

Definition at line 219 of file gpio.c.

References GPIO_INTSTAT_A.

◆ gpio_int_type()

void gpio_int_type ( uint16_t  gpios,
enum gpio_trig_type  type 
)

Sets whether the pins are edge triggered or level triggered.

Sets whether the pins are edge triggered or level triggered. Edge-triggered interrupt bits must be cleared by software.

Parameters
[in]gpiosPin identifiers GPIO Pin Identifiers If multiple pins are to be changed, use bitwise OR '|' to separate them.
[in]typeTrigger Type GPIO Interrupt Trigger Type Level or edge triggered

Definition at line 178 of file gpio.c.

References GPIO_INTLEVEL_A.

◆ gpio_output()

void gpio_output ( uint16_t  gpios)

Set the direction of a Group of Pins to Output.

Set the direction of one or more pins of GPIO to output.

Parameters
[in]gpiosPin identifiers GPIO Pin Identifiers If multiple pins are to be changed, use bitwise OR '|' to separate them.

Definition at line 114 of file gpio.c.

References GPIO_ADIR.

◆ gpio_set()

void gpio_set ( uint16_t  gpios)

Set a Group of Pins.

Set one or more pins of GPIO to 1. Please note that this chip doesn't support atomic pin setting.

Parameters
[in]gpiosPin identifiers GPIO Pin Identifiers If multiple pins are to be changed, use bitwise OR '|' to separate them.

Definition at line 42 of file gpio.c.

References GPIO_ADATA.

◆ gpio_toggle()

void gpio_toggle ( uint16_t  gpios)

Toggle a Group of Pins.

Toggle one or more pins of GPIO. The non-toggled pins are not affected.

Parameters
[in]gpiosPin identifiers GPIO Pin Identifiers If multiple pins are to be changed, use bitwise OR '|' to separate them.

Definition at line 85 of file gpio.c.

References GPIO_ADATA.