Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2019 Lokotius Filzer
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
19#ifndef PERIPH_CONF_H
20#define PERIPH_CONF_H
21
22#include "periph_cpu.h"
23#include "macros/units.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
32#define CLOCK_CORECLOCK MHZ(48)
33
38#define USE_VREG_BUCK (1)
39
44static const tc32_conf_t timer_config[] = {
45 { /* Timer 0 - System Clock */
46 .dev = TC0,
47 .irq = TC0_IRQn,
48 .mclk = &MCLK->APBCMASK.reg,
49 .mclk_mask = MCLK_APBCMASK_TC0_Msk | MCLK_APBCMASK_TC1_Msk,
50 .gclk_id = TC0_GCLK_ID,
51 .gclk_src = SAM0_GCLK_TIMER,
52 .flags = TC_CTRLA_MODE_COUNT32,
53 }
54};
55
56/* Timer 0 configuration */
57#define TIMER_0_CHANNELS 2
58#define TIMER_0_ISR isr_tc0
59#define TIMER_NUMOF ARRAY_SIZE(timer_config)
66static const uart_conf_t uart_config[] = {
67 { /* Virtual COM Port */
68 .dev = &SERCOM3->USART,
69 .rx_pin = GPIO_PIN(PA, 18),
70 .tx_pin = GPIO_PIN(PA, 19),
71#ifdef MODULE_PERIPH_UART_HW_FC
72 .rts_pin = GPIO_UNDEF,
73 .cts_pin = GPIO_UNDEF,
74#endif
75 .mux = GPIO_MUX_D,
76 .rx_pad = UART_PAD_RX_3,
77 .tx_pad = UART_PAD_TX_2,
78 .flags = UART_FLAG_NONE,
79 .gclk_src = SAM0_GCLK_MAIN,
80 }
81};
82
83/* interrupt function name mapping */
84#define UART_0_ISR isr_sercom3
85#define UART_NUMOF ARRAY_SIZE(uart_config)
92/* SERCOM5 does not support DMA at the moment. See Datasheet samr34, Figure 4-2 */
93static const spi_conf_t spi_config[] = {
94 {
95 .dev = &(SERCOM5->SPI),
96 .miso_pin = GPIO_PIN(PA, 23),
97 .mosi_pin = GPIO_PIN(PB, 02),
98 .clk_pin = GPIO_PIN(PB, 23),
99 .miso_mux = GPIO_MUX_D,
100 .mosi_mux = GPIO_MUX_D,
101 .clk_mux = GPIO_MUX_D,
102 .miso_pad = SPI_PAD_MISO_1,
103 .mosi_pad = SPI_PAD_MOSI_0_SCK_3,
104 .gclk_src = SAM0_GCLK_MAIN,
105#ifdef MODULE_PERIPH_DMA
106 .tx_trigger = DMA_TRIGGER_DISABLED,
107 .rx_trigger = DMA_TRIGGER_DISABLED,
108#endif
109 },
110 {
111 .dev = &(SERCOM4->SPI),
112 .miso_pin = GPIO_PIN(PC, 19),
113 .mosi_pin = GPIO_PIN(PB, 30),
114 .clk_pin = GPIO_PIN(PC, 18),
115 .miso_mux = GPIO_MUX_F,
116 .mosi_mux = GPIO_MUX_F,
117 .clk_mux = GPIO_MUX_F,
118 .miso_pad = SPI_PAD_MISO_0,
119 .mosi_pad = SPI_PAD_MOSI_2_SCK_3,
120 .gclk_src = SAM0_GCLK_MAIN,
121#ifdef MODULE_PERIPH_DMA
122 .tx_trigger = SERCOM4_DMAC_ID_TX,
123 .rx_trigger = SERCOM4_DMAC_ID_RX,
124#endif
125 }
126};
127
128#define SPI_NUMOF ARRAY_SIZE(spi_config)
135static const i2c_conf_t i2c_config[] = {
136 {
137 .dev = &(SERCOM1->I2CM),
138 .speed = I2C_SPEED_NORMAL,
139 .scl_pin = GPIO_PIN(PA, 17),
140 .sda_pin = GPIO_PIN(PA, 16),
141 .mux = GPIO_MUX_C,
142 .gclk_src = SAM0_GCLK_MAIN,
143 .flags = I2C_FLAG_NONE
144 }
145};
146#define I2C_NUMOF ARRAY_SIZE(i2c_config)
152#define EXTERNAL_OSC32_SOURCE 1
153#define INTERNAL_OSC32_SOURCE 0
154#define ULTRA_LOW_POWER_INTERNAL_OSC_SOURCE 0
161#ifndef RTT_FREQUENCY
162#define RTT_FREQUENCY (32768U)
163#endif
171/* ADC 0 Default values */
172#define ADC_PRESCALER ADC_CTRLB_PRESCALER_DIV256
173
174#define ADC_NEG_INPUT ADC_INPUTCTRL_MUXNEG(0x18u)
175#define ADC_REF_DEFAULT ADC_REFCTRL_REFSEL_INTVCC2
176
177static const adc_conf_chan_t adc_channels[] = {
178 /* port, pin, muxpos */
180 { .inputctrl = ADC_INPUTCTRL_MUXPOS_PA08 },
181 { .inputctrl = ADC_INPUTCTRL_MUXPOS_PA07 },
182 { .inputctrl = ADC_INPUTCTRL_MUXPOS_PA06 },
183 { .inputctrl = ADC_INPUTCTRL_MUXPOS_PA04 }
184};
185
186#define ADC_NUMOF ARRAY_SIZE(adc_channels)
193static const sam0_common_usb_config_t sam_usbdev_config[] = {
194 {
195 .dm = GPIO_PIN(PA, 24),
196 .dp = GPIO_PIN(PA, 25),
197 .d_mux = GPIO_MUX_G,
198 .device = &USB->DEVICE,
199 .gclk_src = SAM0_GCLK_48MHZ,
200 }
201};
204#ifdef __cplusplus
205}
206#endif
207
208#endif /* PERIPH_CONF_H */
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition periph_cpu.h:46
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition periph_cpu.h:278
@ UART_PAD_RX_3
select pad 3
@ PB
port B
@ PC
port C
@ PA
port A
@ I2C_FLAG_NONE
No flags set.
@ SPI_PAD_MISO_1
use pad 1 for MISO line
@ SPI_PAD_MISO_0
use pad 0 for MISO line
#define DMA_TRIGGER_DISABLED
Indicates that the peripheral doesn't utilize the DMA controller.
@ UART_FLAG_NONE
No flags set.
@ UART_PAD_TX_2
select pad 2
@ GPIO_MUX_D
select peripheral function D
@ GPIO_MUX_G
select peripheral function G
@ GPIO_MUX_C
select peripheral function C
@ GPIO_MUX_F
select peripheral function F
@ SPI_PAD_MOSI_2_SCK_3
use pad 2 for MOSI, pad 3 for SCK
@ SPI_PAD_MOSI_0_SCK_3
use pad 0 for MOSI, pad 3 for SCK
#define ADC_INPUTCTRL_MUXPOS_PA08
Alias for PIN16.
Definition periph_cpu.h:135
#define ADC_INPUTCTRL_MUXPOS_PA09
Alias for PIN17.
Definition periph_cpu.h:136
#define ADC_INPUTCTRL_MUXPOS_PA07
Alias for PIN7.
Definition periph_cpu.h:126
#define ADC_INPUTCTRL_MUXPOS_PA04
Alias for PIN4.
Definition periph_cpu.h:123
#define ADC_INPUTCTRL_MUXPOS_PA06
Alias for PIN6.
Definition periph_cpu.h:125
#define SAM0_GCLK_MAIN
120 MHz main clock
Definition periph_cpu.h:74
#define SAM0_GCLK_TIMER
4-8 MHz clock for xTimer
Definition periph_cpu.h:79
ADC Channel Configuration.
uint32_t inputctrl
ADC channel pin multiplexer value
I2C configuration structure.
Definition periph_cpu.h:299
TWI_t * dev
Pointer to hardware module registers.
Definition periph_cpu.h:300
USB peripheral parameters.
SPI device configuration.
Definition periph_cpu.h:337
SPI_t * dev
pointer to the used SPI device
Definition periph_cpu.h:338
Timer device configuration.
Tc * dev
pointer to the used Timer device
UART device configuration.
Definition periph_cpu.h:218
USART_t * dev
pointer to the used UART device
Definition periph_cpu.h:219
Unit helper macros.