sam0_common/include/periph_cpu_common.h

Common CPU specific definitions for all SAMx21 based CPUs.

Common CPU specific definitions for all SAMx21 based CPUs

CPUID_LEN

Length of the CPU_ID in octets.

1
(16U)
PERIPH_SPI_NEEDS_INIT_CS

Use shared SPI functions.

PERIPH_SPI_NEEDS_TRANSFER_BYTE
PERIPH_SPI_NEEDS_TRANSFER_REG
PERIPH_SPI_NEEDS_TRANSFER_REGS
PERIPH_I2C_NEED_READ_REG
PERIPH_I2C_NEED_READ_REGS
PERIPH_I2C_NEED_WRITE_REG
PERIPH_I2C_NEED_WRITE_REGS
HAVE_GPIO_T

Override GPIO type.

uint32_t gpio_t
GPIO_PIN( x, y)

Macro for accessing GPIO pins.

1
(((gpio_t)(&PORT->Group[x])) | y)
GPIO_MODE( pr, ie, pe)

Generate GPIO mode bitfields.

1
(pr | (ie << 1) | (pe << 2))

We use 3 bit to determine the pin functions:

  • bit 0: PD(0) or PU(1)
  • bit 1: input enable
  • bit 2: pull enable

enum @79
PA = 0
port A
PB = 1
port B
PC = 2
port C
PM_NUM_MODES
1
(3)
HAVE_SPI_MODE_T

Override SPI modes.

enum spi_mode_t
SPI_MODE_0 = SPI_MODE_SEL(0, 0)
mode 0
SPI_MODE_1 = SPI_MODE_SEL(0, 1)
mode 1
SPI_MODE_2 = SPI_MODE_SEL(1, 0)
mode 2
SPI_MODE_3 = SPI_MODE_SEL(1, 1)
mode 3
HAVE_SPI_CLK_T

Override SPI clock speed values.

enum spi_clk_t
SPI_CLK_4MHZ = 4000000
drive the SPI bus with 4MHz
SPI_CLK_100KHZ = SPI_CLK_SEL(0, 1, 1)
16/128 -> 125KHz
SPI_CLK_400KHZ = SPI_CLK_SEL(1, 1, 0)
16/32 -> 500KHz
SPI_CLK_1MHZ = SPI_CLK_SEL(0, 0, 1)
16/16 -> 1MHz
SPI_CLK_5MHZ = SPI_CLK_SEL(0, 0, 0)
16/4 -> 4MHz
SPI_CLK_10MHZ = SPI_CLK_SEL(1, 0, 0)
16/2 -> 8MHz
HAVE_I2C_SPEED_T
enum i2c_speed_t
I2C_SPEED_LOW = 0x01
not supported
I2C_SPEED_NORMAL = 100000U
normal mode: ~100kbit/s
I2C_SPEED_FAST = 400000U
fast mode: ~400kbit/s
I2C_SPEED_FAST_PLUS = 0x02
not supported
I2C_SPEED_HIGH = 0x03
not supported
GPIO_UNDEF

Definition of a fitting UNDEF value.

1
(0xffffffff)
enum gpio_mux_t
GPIO_MUX_A = 0x0
select peripheral function A
GPIO_MUX_B = 0x1
select peripheral function B
GPIO_MUX_C = 0x2
select peripheral function C
GPIO_MUX_D = 0x3
select peripheral function D
GPIO_MUX_E = 0x4
select peripheral function E
GPIO_MUX_F = 0x5
select peripheral function F
GPIO_MUX_G = 0x6
select peripheral function G
GPIO_MUX_H = 0x7
select peripheral function H
GPIO_MUX_A = 0
alternate function A
GPIO_MUX_B = 1
alternate function B
enum uart_rxpad_t
UART_PAD_RX_0 = 0x0
use pad 0 for RX line
UART_PAD_RX_1 = 0x1
select pad 1
UART_PAD_RX_2 = 0x2
select pad 2
UART_PAD_RX_3 = 0x3
select pad 3
enum uart_txpad_t
UART_PAD_TX_0 = 0x0
select pad 0
UART_PAD_TX_2 = 0x1
select pad 2
UART_PAD_TX_0_RTS_2_CTS_3 = 0x2
TX is pad 0, on top RTS on pad 2 and CTS on pad 3.
enum uart_flag_t
UART_FLAG_NONE = 0x0
No flags set.
UART_FLAG_RUN_STANDBY = 0x1
run SERCOM in standby mode
UART_FLAG_WAKEUP = 0x2
wake from sleep on receive
enum spi_misopad_t
SPI_PAD_MISO_0 = 0x0
use pad 0 for MISO line
SPI_PAD_MISO_1 = 0x1
use pad 0 for MISO line
SPI_PAD_MISO_2 = 0x2
use pad 0 for MISO line
SPI_PAD_MISO_3 = 0x3
use pad 0 for MISO line
enum spi_mosipad_t
SPI_PAD_MOSI_0_SCK_1 = 0x0
use pad 0 for MOSI, pad 1 for SCK
SPI_PAD_MOSI_2_SCK_3 = 0x1
use pad 2 for MOSI, pad 3 for SCK
SPI_PAD_MOSI_3_SCK_1 = 0x2
use pad 3 for MOSI, pad 1 for SCK
SPI_PAD_MOSI_0_SCK_3 = 0x3
use pad 0 for MOSI, pad 3 for SCK
enum i2c_flag_t
I2C_FLAG_NONE = 0x0
No flags set.
I2C_FLAG_RUN_STANDBY = 0x1
run SERCOM in standby mode
void gpio_init_mux(gpio.h::gpio_t pin, sam0_common/include/periph_cpu_common.h::gpio_mux_t mux)

Set up alternate function (PMUX setting) for a PORT pin.

Parameters

pin:Pin to set the multiplexing for
mux:Mux value

int sercom_id(void * sercom)

Return the numeric id of a SERCOM device derived from its address.

Parameters

sercom:SERCOM device

Return values

  • numeric id of the given SERCOM device
void sercom_clk_en(void * sercom)

Enable peripheral clock for given SERCOM device.

Parameters

sercom:SERCOM device

void sercom_clk_dis(void * sercom)

Disable peripheral clock for given SERCOM device.

Parameters

sercom:SERCOM device

void sercom_set_gen(void * sercom, uint32_t gclk)

Configure generator clock for given SERCOM device.

Parameters

sercom:SERCOM device
gclk:Generator clock

struct uart_conf_t

UART device configuration.

Structure for UART configuration data.

UART configuration data.

UART module configuration options.

cc2538_uart_t * dev

pointer to the used UART device

UART device base register address.

Pointer to module hardware registers.

gpio.h::gpio_t rx_pin

pin used for RX

RX pin.

Pin used for RX.

gpio.h::gpio_t tx_pin

pin used for TX

TX pin.

Pin used for TX.

gpio.h::gpio_t cts_pin

CTS pin - set to GPIO_UNDEF when not using.

gpio.h::gpio_t rts_pin

RTS pin - set to GPIO_UNDEF when not using.

void * dev

UART, USART or LEUART device used.

Pointer to module hardware registers.

uint32_t loc

location of UART pins

CMU_Clock_TypeDef cmu

the device CMU channel

cc2538.h::IRQn_Type irq

the devices base IRQ channel

USART_TypeDef * dev

USART device used.

UART device base register address.

uint8_t loc

location of USART pins (AF)

uint8_t cmu

the device CMU channel

uint8_t irq

the devices base IRQ channel

uint32_t freq

Module clock frequency, usually CLOCK_CORECLOCK or CLOCK_BUSCLOCK.

gpio.h::gpio_t pin_rx

RX pin, GPIO_UNDEF disables RX.

gpio.h::gpio_t pin_tx

TX pin.

uint32_t pcr_rx

Pin configuration register bits for RX.

uint32_t pcr_tx

Pin configuration register bits for TX.

uint32_t * scgc_addr

Clock enable register, in SIM module.

uint8_t scgc_bit

Clock enable bit, within the register.

kinetis/include/periph_cpu.h::uart_mode_t mode

UART mode: data bits, parity, stop bits.

kinetis/include/periph_cpu.h::uart_type_t type

Hardware module type (KINETIS_UART or KINETIS_LPUART)

SercomUsart * dev

pointer to the used UART device

sam0_common/include/periph_cpu_common.h::gpio_mux_t mux

alternative function for pins

MUX used for pins.

sam0_common/include/periph_cpu_common.h::uart_rxpad_t rx_pad

pad selection for RX line

sam0_common/include/periph_cpu_common.h::uart_txpad_t tx_pad

pad selection for TX line

sam0_common/include/periph_cpu_common.h::uart_flag_t flags

set optional SERCOM flags

uint32_t gclk_src

GCLK source which supplys SERCOM.

Uart * dev

U(S)ART device used.

uint8_t pmc_id

bit in the PMC register of the device

cc2538.h::IRQn_Type irqn

IRQ number for this module.

IRQ channel.

uint32_t rcc_mask

bit in clock enable register

stm32_common/include/periph_cpu_common.h::gpio_af_t rx_af

alternate function for RX pin

stm32_common/include/periph_cpu_common.h::gpio_af_t tx_af

alternate function for TX pin

uint8_t bus

APB bus.

struct spi_conf_t

SPI module configuration options.

Structure for SPI configuration data.

SPI configuration data.

SPI device configuration.

SPI configuration values.

SPI configuration data structure.

uint8_t num

number of SSI device, i.e.

0 or 1

gpio.h::gpio_t mosi_pin

pin used for MOSI

MOSI pin.

used MOSI pin

gpio.h::gpio_t miso_pin

pin used for MISO

MISO pin.

used MISO pin

gpio.h::gpio_t sck_pin

pin used for SCK

gpio.h::gpio_t cs_pin

pin used for CS

HWCS pin, set to GPIO_UNDEF if not mapped.

SPI_Type * dev

SPI device to use.

gpio.h::gpio_t pin_miso

MISO pin used.

gpio.h::gpio_t pin_mosi

MOSI pin used.

gpio.h::gpio_t pin_clk

CLK pin used.

gpio.h::gpio_t pin_cs()

pins used for HW cs lines

kinetis/include/periph_cpu.h::gpio_pcr_t pcr

alternate pin function values

uint32_t simmask

bit in the SIM register

unsigned long ssi_sysctl

SSI device in sysctl.

unsigned long ssi_base

SSI base address.

unsigned long gpio_sysctl

GPIO device in sysctl.

unsigned long gpio_port

GPIO port.

unsigned long clk

pin used for SCK

unsigned long fss

pin used for FSS

unsigned long rx

pin used for MISO

unsigned long tx

pin used for MOSI

unsigned long mask

Pin mask.

struct spi_conf_t::@74 pins

Pin setting.

NRF_SPI_Type * dev

SPI device used.

uint8_t sclk

CLK pin.

uint8_t mosi

MOSI pin.

uint8_t miso

MISO pin.

SercomSpi * dev

pointer to the used SPI device

gpio.h::gpio_t clk_pin

used CLK pin

sam0_common/include/periph_cpu_common.h::gpio_mux_t miso_mux

alternate function for MISO pin (mux)

sam0_common/include/periph_cpu_common.h::gpio_mux_t mosi_mux

alternate function for MOSI pin (mux)

sam0_common/include/periph_cpu_common.h::gpio_mux_t clk_mux

alternate function for CLK pin (mux)

sam0_common/include/periph_cpu_common.h::spi_misopad_t miso_pad

pad to use for MISO line

sam0_common/include/periph_cpu_common.h::spi_mosipad_t mosi_pad

pad to use for MOSI and CLK line

Spi * dev

SPI module to use.

uint8_t id

corresponding ID of that module

gpio.h::gpio_t clk

pin mapped to the CLK line

gpio.h::gpio_t mosi

pin mapped to the MOSI line

gpio.h::gpio_t miso

pin mapped to the MISO line

sam0_common/include/periph_cpu_common.h::gpio_mux_t mux

pin MUX setting

SPI_TypeDef * dev

SPI device base register address.

gpio.h::gpio_t sclk_pin

SCLK pin.

stm32_common/include/periph_cpu_common.h::gpio_af_t af

pin alternate function

uint32_t rccmask

bit in the RCC peripheral enable register

uint8_t apbbus

APBx bus the device is connected to.

struct i2c_conf_t

I2C configuration options.

Structure for I2C configuration data.

I2C (TWI) configuration options.

I2C configuration structure.

I2C device configuration.

cc2538/include/periph_cpu.h::i2c_speed_t speed

baudrate used for the bus

i2c bus speed

Bus speed.

bus speed

Configured bus speed, actual speed may be lower but never higher.

gpio.h::gpio_t scl_pin

pin used for SCL

scl pin number

used SCL pin

SCL GPIO pin.

gpio.h::gpio_t sda_pin

pin used for SDA

sda pin number

used MOSI pin

SDA GPIO pin.

I2C_TypeDef * dev

USART device used.

i2c device

uint32_t loc

location of I2C pins

CMU_Clock_TypeDef cmu

the device CMU channel

cc2538.h::IRQn_Type irq

the devices base IRQ channel

uint32_t speed

the bus speed

I2C_Type * i2c

Pointer to hardware module registers.

uint32_t freq

I2C module clock frequency, usually CLOCK_BUSCLOCK or CLOCK_CORECLOCK.

cc2538.h::IRQn_Type irqn

IRQ number for this module.

uint32_t scl_pcr

PORT module PCR setting for the SCL pin.

uint32_t sda_pcr

PORT module PCR setting for the SDA pin.

NRF_TWI_Type * dev

hardware device

uint8_t pin_scl

SCL pin.

uint8_t pin_sda

SDA pin.

uint8_t ppi

PPI channel to use.

NRF_TWIM_Type * dev

TWIM hardware device.

uint8_t scl

SCL pin.

uint8_t sda

SDA pin.

SercomI2cm * dev

pointer to the used I2C device

sam0_common/include/periph_cpu_common.h::gpio_mux_t mux

alternate function (mux)

uint8_t gclk_src

GCLK source which supplys SERCOM.

uint8_t flags

allow SERCOM to run in standby mode

stm32_common/include/periph_cpu_common.h::gpio_af_t scl_af

scl pin alternate function value

stm32_common/include/periph_cpu_common.h::gpio_af_t sda_af

sda pin alternate function value

uint8_t bus

APB bus.

uint32_t rcc_mask

bit in clock enable register

uint8_t irqn

I2C event interrupt number.

struct adc_conf_chan_t

ADC Channel Configuration.

gpio.h::gpio_t pin

ADC channel pin.

uint32_t muxpos

ADC channel pin multiplexer value.