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

Defined Constants and Types for the SAMD Port controller. More...

Collaboration diagram for IO Port Definitions:

Modules

 Port Base registers
 
 GPIO Pin Identifiers
 
 GPIO mux configuration
 
 PORT Registers
 
 PortX WRCONFIG Values
 
 GPIO Pin direction
 
 GPIO mode configuration
 

Macros

#define PORT_PMUX_PMUXO(mux)   ((0xf & (mux)) << 4)
 PMUXO: Peripheral Multiplexing for Odd-Numbered Pin: 2*x+1 pin multiplexing. More...
 
#define PORT_PMUX_PMUXE(mux)   ((0xf & (mux)) << 0)
 PMUXE: Peripheral Multiplexing for Even-Numbered Pin: 2*x pin multiplexing. More...
 
#define PORT_PINCFG_DRVSTR   (1 << 6)
 DRVSTR: Output Driver Strength Selection. More...
 
#define PORT_PINCFG_PULLEN   (1 << 2)
 PULLEN: Pull Enable. More...
 
#define PORT_PINCFG_INEN   (1 << 1)
 INEN: Input Enable. More...
 
#define PORT_PINCFG_PMUXEN   (1 << 0)
 PMUXEN: Peripheral Multiplexer Enable. More...
 

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

Defined Constants and Types for the SAMD Port controller.

Author
2016 Karl Palsson karlp.nosp@m.@twe.nosp@m.ak.ne.nosp@m.t.au
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

Macro Definition Documentation

◆ PORT_PINCFG_DRVSTR

#define PORT_PINCFG_DRVSTR   (1 << 6)

DRVSTR: Output Driver Strength Selection.

Definition at line 211 of file port.h.

◆ PORT_PINCFG_INEN

#define PORT_PINCFG_INEN   (1 << 1)

INEN: Input Enable.

Definition at line 217 of file port.h.

◆ PORT_PINCFG_PMUXEN

#define PORT_PINCFG_PMUXEN   (1 << 0)

PMUXEN: Peripheral Multiplexer Enable.

Definition at line 220 of file port.h.

◆ PORT_PINCFG_PULLEN

#define PORT_PINCFG_PULLEN   (1 << 2)

PULLEN: Pull Enable.

Definition at line 214 of file port.h.

◆ PORT_PMUX_PMUXE

#define PORT_PMUX_PMUXE (   mux)    ((0xf & (mux)) << 0)

PMUXE: Peripheral Multiplexing for Even-Numbered Pin: 2*x pin multiplexing.

Definition at line 204 of file port.h.

◆ PORT_PMUX_PMUXO

#define PORT_PMUX_PMUXO (   mux)    ((0xf & (mux)) << 4)

PMUXO: Peripheral Multiplexing for Odd-Numbered Pin: 2*x+1 pin multiplexing.

Definition at line 201 of file port.h.

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.