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

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

Collaboration diagram for IO Port API:

Functions

void gpio_mode_setup (uint32_t gpioport, uint8_t mode, uint8_t cnf, uint32_t gpios)
 Initialize GPIO pins. More...
 
void gpio_set_af (uint32_t gpioport, uint8_t af, uint32_t gpios)
 Alternate function GPIO pins. More...
 
void gpio_set (uint32_t gpioport, uint32_t gpios)
 Set a group of Pins. More...
 
void gpio_clear (uint32_t gpioport, uint32_t gpios)
 Clear a group of Pins. More...
 
uint32_t gpio_get (uint32_t gpioport, uint32_t gpios)
 Read level of a group of Pins. More...
 
void gpio_toggle (uint32_t gpioport, uint32_t gpios)
 Toggle level of a group of Pins. More...
 
uint32_t port_read (uint32_t port)
 Read level for all pins from a port. More...
 
void port_write (uint32_t port, uint32_t data)
 Set level for all pins from a port. More...
 

Detailed Description

Access functions for the SAMD I/O Controller

Date
10 April 2020
Author
2020 Gwenhael Goavec-Merou gwenh.nosp@m.ael..nosp@m.goave.nosp@m.c-me.nosp@m.rou@t.nosp@m.rabu.nosp@m.cayre.nosp@m..com

Function Documentation

◆ gpio_clear()

void gpio_clear ( uint32_t  gpioport,
uint32_t  gpios 
)

Clear a group of Pins.

Clear a group of Pins for the given port.

Parameters
[in]gpioportport register address base Port Base registers
[in]gpiosGPIO Pin Identifiers. Any combination of pins may be specified by OR'ing then together.

Definition at line 108 of file port.c.

References PORT_OUTCLR.

◆ gpio_get()

uint32_t gpio_get ( uint32_t  gpioport,
uint32_t  gpios 
)

Read level of a group of Pins.

Read the level of a group of Pins for the given port.

Parameters
[in]gpioportport register address base Port Base registers
[in]gpiosGPIO Pin Identifiers. Any combination of pins may be specified by OR'ing then together.

Definition at line 121 of file port.c.

References PORT_IN.

◆ gpio_mode_setup()

void gpio_mode_setup ( uint32_t  gpioport,
uint8_t  mode,
uint8_t  cnf,
uint32_t  gpios 
)

Initialize GPIO pins.

Configure a group of Pins for the given port.

Parameters
[in]gpioportport register address base Port Base registers
[in]modedirection GPIO Pin direction
[in]cnfconfiguration mode GPIO mode configuration
[in]gpiosGPIO Pin Identifiers. Any combination of pins may be specified by OR'ing then together.

Definition at line 23 of file port.c.

References GPIO_CNF_AF, GPIO_CNF_PULLDOWN, GPIO_CNF_PULLUP, GPIO_MODE_INPUT, GPIO_MODE_OUTPUT, PORT_DIRCLR, PORT_DIRSET, PORT_OUTCLR, PORT_OUTSET, PORT_WRCONFIG, PORT_WRCONFIG_HWSEL, PORT_WRCONFIG_INEN, PORT_WRCONFIG_PINMASK, PORT_WRCONFIG_PMUXEN, PORT_WRCONFIG_PULLEN, and PORT_WRCONFIG_WRPINCFG.

◆ gpio_set()

void gpio_set ( uint32_t  gpioport,
uint32_t  gpios 
)

Set a group of Pins.

Set a group of Pins for the given port.

Parameters
[in]gpioportport register address base Port Base registers
[in]gpiosGPIO Pin Identifiers. Any combination of pins may be specified by OR'ing then together.

Definition at line 95 of file port.c.

References PORT_OUTSET.

◆ gpio_set_af()

void gpio_set_af ( uint32_t  gpioport,
uint8_t  af,
uint32_t  gpios 
)

Alternate function GPIO pins.

Configure a group of Pins in alternate function.

Parameters
[in]gpioportport register address base Port Base registers
[in]afpmux configuration GPIO mux configuration
[in]gpiosGPIO Pin Identifiers. Any combination of pins may be specified by OR'ing then together.

Definition at line 73 of file port.c.

References PORT_WRCONFIG, PORT_WRCONFIG_HWSEL, PORT_WRCONFIG_PINMASK, PORT_WRCONFIG_PMUX, PORT_WRCONFIG_PMUXEN, PORT_WRCONFIG_WRPINCFG, and PORT_WRCONFIG_WRPMUX.

◆ gpio_toggle()

void gpio_toggle ( uint32_t  gpioport,
uint32_t  gpios 
)

Toggle level of a group of Pins.

Toggle one or more pins of the givent port.

Parameters
[in]gpioportport register address base Port Base registers
[in]gpiosGPIO Pin Identifiers. Any combination of pins may be specified by OR'ing then together.

Definition at line 134 of file port.c.

References PORT_OUTTGL.

◆ port_read()

uint32_t port_read ( uint32_t  port)

Read level for all pins from a port.

Read the level of all pins of the given port.

Parameters
[in]portregister address base Port Base registers
Returns
The level of all pins on the port.

Definition at line 147 of file port.c.

References PORT_IN.

◆ port_write()

void port_write ( uint32_t  port,
uint32_t  data 
)

Set level for all pins from a port.

Set the level of all pins of the given port.

Parameters
[in]portregister address base Port Base registers
[in]dataGPIO Pin Identifiers. Any combination of pins may be specified by OR'ing then together.

Definition at line 160 of file port.c.

References PORT_OUT.