periph_conf.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2015-2020 Freie Universität Berlin
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
19 #include "cpu.h"
20 #include "periph_cpu.h"
21 #include "em_cmu.h"
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
31 #ifndef CLOCK_HF
32 #define CLOCK_HF cmuSelect_HFXO
33 #endif
34 #ifndef CLOCK_CORE_DIV
35 #define CLOCK_CORE_DIV cmuClkDiv_1
36 #endif
37 #ifndef CLOCK_LFA
38 #define CLOCK_LFA cmuSelect_LFXO
39 #endif
40 #ifndef CLOCK_LFB
41 #define CLOCK_LFB cmuSelect_LFXO
42 #endif
43 #ifndef CLOCK_LFE
44 #define CLOCK_LFE cmuSelect_LFXO
45 #endif
52 #ifdef EMU_DCDCINIT_OFF
53 #error "This option will soft-brick your board. Please remove it."
54 #endif
61 static const adc_conf_t adc_config[] = {
62  {
63  .dev = ADC0,
64  .cmu = cmuClock_ADC0,
65  }
66 };
67 
68 static const adc_chan_conf_t adc_channel_config[] = {
69  {
70  .dev = 0,
71  .input = adcPosSelTEMP,
72  .reference = adcRef1V25,
73  .acq_time = adcAcqTime8
74  },
75  {
76  .dev = 0,
77  .input = adcPosSelAVDD,
78  .reference = adcRef5V,
79  .acq_time = adcAcqTime8
80  }
81 };
82 
83 #define ADC_DEV_NUMOF ARRAY_SIZE(adc_config)
84 #define ADC_NUMOF ARRAY_SIZE(adc_channel_config)
91 static const i2c_conf_t i2c_config[] = {
92  {
93  .dev = I2C0,
94  .sda_pin = GPIO_PIN(PC, 10),
95  .scl_pin = GPIO_PIN(PC, 11),
96  .loc = I2C_ROUTELOC0_SDALOC_LOC15 |
97  I2C_ROUTELOC0_SCLLOC_LOC15,
98  .cmu = cmuClock_I2C0,
99  .irq = I2C0_IRQn,
100  .speed = I2C_SPEED_NORMAL
101  }
102 };
103 
104 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
105 #define I2C_0_ISR isr_i2c0
112 #ifndef RTT_FREQUENCY
113 #define RTT_FREQUENCY (1U) /* in Hz */
114 #endif
121 static const spi_dev_t spi_config[] = {
122  {
123  .dev = USART1,
124  .mosi_pin = GPIO_PIN(PC, 6),
125  .miso_pin = GPIO_PIN(PC, 7),
126  .clk_pin = GPIO_PIN(PC, 8),
127  .loc = USART_ROUTELOC0_RXLOC_LOC11 |
128  USART_ROUTELOC0_TXLOC_LOC11 |
129  USART_ROUTELOC0_CLKLOC_LOC11,
130  .cmu = cmuClock_USART1,
131  .irq = USART1_RX_IRQn
132  }
133 };
134 
135 #define SPI_NUMOF ARRAY_SIZE(spi_config)
144 static const timer_conf_t timer_config[] = {
145  {
146  .prescaler = {
147  .dev = TIMER0,
148  .cmu = cmuClock_TIMER0
149  },
150  .timer = {
151  .dev = TIMER1,
152  .cmu = cmuClock_TIMER1
153  },
154  .irq = TIMER1_IRQn,
155  .channel_numof = 3
156  },
157  {
158  .prescaler = {
159  .dev = NULL,
160  .cmu = cmuClock_LETIMER0
161  },
162  .timer = {
163  .dev = LETIMER0,
164  .cmu = cmuClock_LETIMER0
165  },
166  .irq = LETIMER0_IRQn,
167  .channel_numof = 2
168  }
169 };
170 
171 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
172 #define TIMER_0_ISR isr_timer1
173 #define TIMER_1_ISR isr_letimer0
180 static const uart_conf_t uart_config[] = {
181  {
182  .dev = USART0,
183  .rx_pin = GPIO_PIN(PA, 1),
184  .tx_pin = GPIO_PIN(PA, 0),
185  .loc = USART_ROUTELOC0_RXLOC_LOC0 |
186  USART_ROUTELOC0_TXLOC_LOC0,
187  .cmu = cmuClock_USART0,
188  .irq = USART0_RX_IRQn
189  },
190  {
191  .dev = LEUART0,
192  .rx_pin = GPIO_PIN(PD, 11),
193  .tx_pin = GPIO_PIN(PD, 10),
194  .loc = LEUART_ROUTELOC0_RXLOC_LOC18 |
195  LEUART_ROUTELOC0_TXLOC_LOC18,
196  .cmu = cmuClock_LEUART0,
197  .irq = LEUART0_IRQn
198  }
199 };
200 
201 #define UART_NUMOF ARRAY_SIZE(uart_config)
202 #define UART_0_ISR_RX isr_usart0_rx
203 #define UART_1_ISR_RX isr_leuart0
206 #ifdef __cplusplus
207 }
208 #endif
209 
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:42
static const uart_conf_t uart_config[]
UART configuration.
Definition: periph_conf.h:35
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:93
static const i2c_conf_t i2c_config[]
I2C configuration.
Definition: periph_conf.h:65
static const timer_conf_t timer_config[]
All timers on board.
Definition: periph_conf.h:36
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:247
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:274
@ PC
port C
@ PA
port A
@ PD
port D
ADC channel configuration.
Definition: periph_cpu.h:382
uint8_t dev
device index
Definition: periph_cpu.h:383
ADC device configuration.
Definition: periph_cpu.h:374
ADC_TypeDef * dev
ADC device used.
Definition: periph_cpu.h:375
I2C configuration structure.
Definition: periph_cpu.h:295
TWI_t * dev
Pointer to hardware module registers.
Definition: periph_cpu.h:296
SPI_t * dev
pointer to the used SPI device
Definition: periph_cpu.h:334
SPI device configuration.
Definition: periph_cpu.h:513
Timer device configuration.
Definition: periph_cpu.h:260
timer_dev_t prescaler
the lower neighboring timer (not initialized for LETIMER)
Definition: periph_cpu.h:552
void * dev
TIMER_TypeDef or LETIMER_TypeDef device used.
Definition: periph_cpu.h:545
UART device configuration.
Definition: periph_cpu.h:214
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:215