periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2020 Freie Universität Berlin
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 
9 #pragma once
10 
22 #include "cpu.h"
23 #include "periph_cpu.h"
24 #include "em_cmu.h"
25 #include "usbdev_cfg_otg_fs.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
35 #ifndef CLOCK_HF
36 #define CLOCK_HF cmuSelect_HFXO
37 #endif
38 #ifndef CLOCK_CORE_DIV
39 #define CLOCK_CORE_DIV cmuClkDiv_1
40 #endif
41 #ifndef CLOCK_LFA
42 #define CLOCK_LFA cmuSelect_LFXO
43 #endif
44 #ifndef CLOCK_LFB
45 #define CLOCK_LFB cmuSelect_LFXO
46 #endif
47 #ifndef CLOCK_LFE
48 #define CLOCK_LFE cmuSelect_LFXO
49 #endif
56 static const adc_conf_t adc_config[] = {
57  {
58  .dev = ADC0,
59  .cmu = cmuClock_ADC0,
60  }
61 };
62 
63 static const adc_chan_conf_t adc_channel_config[] = {
64  {
65  .dev = 0,
66  .input = adcPosSelTEMP,
67  .reference = adcRef1V25,
68  .acq_time = adcAcqTime8
69  },
70  {
71  .dev = 0,
72  .input = adcPosSelAVDD,
73  .reference = adcRef5V,
74  .acq_time = adcAcqTime8
75  }
76 };
77 
78 #define ADC_DEV_NUMOF ARRAY_SIZE(adc_config)
79 #define ADC_NUMOF ARRAY_SIZE(adc_channel_config)
86 static const dac_conf_t dac_config[] = {
87  {
88  .dev = VDAC0,
89  .ref = vdacRefAvdd,
90  .cmu = cmuClock_VDAC0,
91  },
92 };
93 
94 static const dac_chan_conf_t dac_channel_config[] = {
95  {
96  .dev = 0,
97  .index = 0,
98  },
99 };
100 
101 #define DAC_DEV_NUMOF ARRAY_SIZE(dac_config)
102 #define DAC_NUMOF ARRAY_SIZE(dac_channel_config)
109 static const i2c_conf_t i2c_config[] = {
110  {
111  .dev = I2C0,
112  .sda_pin = GPIO_PIN(PC, 0),
113  .scl_pin = GPIO_PIN(PC, 1),
114  .loc = I2C_ROUTELOC0_SDALOC_LOC4 |
115  I2C_ROUTELOC0_SCLLOC_LOC4,
116  .cmu = cmuClock_I2C0,
117  .irq = I2C0_IRQn,
118  .speed = I2C_SPEED_NORMAL
119  },
120  {
121  .dev = I2C1,
122  .sda_pin = GPIO_PIN(PC, 7),
123  .scl_pin = GPIO_PIN(PC, 5),
124  .loc = I2C_ROUTELOC0_SDALOC_LOC0 |
125  I2C_ROUTELOC0_SCLLOC_LOC0,
126  .cmu = cmuClock_I2C1,
127  .irq = I2C1_IRQn,
128  .speed = I2C_SPEED_NORMAL
129  },
130  {
131  .dev = I2C2,
132  .sda_pin = GPIO_PIN(PI, 4),
133  .scl_pin = GPIO_PIN(PI, 5),
134  .loc = I2C_ROUTELOC0_SDALOC_LOC7 |
135  I2C_ROUTELOC0_SCLLOC_LOC7,
136  .cmu = cmuClock_I2C2,
137  .irq = I2C2_IRQn,
138  .speed = I2C_SPEED_NORMAL
139  }
140 };
141 
142 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
143 #define I2C_0_ISR isr_i2c0
144 #define I2C_1_ISR isr_i2c1
145 #define I2C_2_ISR isr_i2c2
152 #ifndef RTT_FREQUENCY
153 #define RTT_FREQUENCY (1U)
154 #endif
161 static const spi_dev_t spi_config[] = {
162  {
163  .dev = USART0,
164  .mosi_pin = GPIO_PIN(PE, 10),
165  .miso_pin = GPIO_PIN(PE, 11),
166  .clk_pin = GPIO_PIN(PE, 12),
167  .loc = USART_ROUTELOC0_TXLOC_LOC0 |
168  USART_ROUTELOC0_RXLOC_LOC0 |
169  USART_ROUTELOC0_CLKLOC_LOC0,
170  .cmu = cmuClock_USART0,
171  .irq = USART0_RX_IRQn
172  }
173 };
174 
175 #define SPI_NUMOF ARRAY_SIZE(spi_config)
184 static const timer_conf_t timer_config[] = {
185  {
186  .prescaler = {
187  .dev = WTIMER0,
188  .cmu = cmuClock_WTIMER0
189  },
190  .timer = {
191  .dev = WTIMER1,
192  .cmu = cmuClock_WTIMER1
193  },
194  .irq = WTIMER1_IRQn,
195  .channel_numof = 3
196  },
197  {
198  .prescaler = {
199  .dev = TIMER0,
200  .cmu = cmuClock_TIMER0
201  },
202  .timer = {
203  .dev = TIMER1,
204  .cmu = cmuClock_TIMER1
205  },
206  .irq = TIMER1_IRQn,
207  .channel_numof = 3
208  },
209  {
210  .prescaler = {
211  .dev = NULL,
212  .cmu = cmuClock_LETIMER0
213  },
214  .timer = {
215  .dev = LETIMER0,
216  .cmu = cmuClock_LETIMER0
217  },
218  .irq = LETIMER0_IRQn,
219  .channel_numof = 2
220  }
221 };
222 
223 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
224 #define TIMER_0_ISR isr_wtimer1
225 #define TIMER_1_ISR isr_timer1
226 #define TIMER_2_ISR isr_letimer0
233 static const uart_conf_t uart_config[] = {
234  {
235  .dev = USART4,
236  .rx_pin = GPIO_PIN(PH, 5),
237  .tx_pin = GPIO_PIN(PH, 4),
238  .loc = USART_ROUTELOC0_RXLOC_LOC4 |
239  USART_ROUTELOC0_TXLOC_LOC4,
240  .cmu = cmuClock_USART4,
241  .irq = USART4_RX_IRQn,
242  },
243  {
244  .dev = USART5,
245  .rx_pin = GPIO_PIN(PE, 9),
246  .tx_pin = GPIO_PIN(PE, 8),
247  .loc = USART_ROUTELOC0_RXLOC_LOC4 |
248  USART_ROUTELOC0_TXLOC_LOC4,
249  .cmu = cmuClock_USART5,
250  .irq = USART5_RX_IRQn,
251  }
252 };
253 
254 #define UART_NUMOF ARRAY_SIZE(uart_config)
255 #define UART_0_ISR_RX isr_usart4_rx
256 #define UART_1_ISR_RX isr_usart5_rx
259 #ifdef __cplusplus
260 }
261 #endif
262 
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:45
static const uart_conf_t uart_config[]
UART configuration.
Definition: periph_conf.h:38
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:96
static const i2c_conf_t i2c_config[]
I2C configuration.
Definition: periph_conf.h:68
static const timer_conf_t timer_config[]
All timers on board.
Definition: periph_conf.h:39
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:250
static const dac_conf_t dac_config[]
DAC configuration.
Definition: periph_conf.h:252
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:277
@ PC
port C
ADC channel configuration.
Definition: periph_cpu.h:385
uint8_t dev
device index
Definition: periph_cpu.h:386
ADC device configuration.
Definition: periph_cpu.h:377
ADC_TypeDef * dev
ADC device used.
Definition: periph_cpu.h:378
DAC line configuration data.
Definition: periph_cpu.h:300
I2C configuration structure.
Definition: periph_cpu.h:298
TWI_t * dev
Pointer to hardware module registers.
Definition: periph_cpu.h:299
SPI_t * dev
pointer to the used SPI device
Definition: periph_cpu.h:337
SPI device configuration.
Definition: periph_cpu.h:516
Timer device configuration.
Definition: periph_cpu.h:263
timer_dev_t prescaler
the lower neighboring timer (not initialized for LETIMER)
Definition: periph_cpu.h:555
void * dev
TIMER_TypeDef or LETIMER_TypeDef device used.
Definition: periph_cpu.h:548
UART device configuration.
Definition: periph_cpu.h:217
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:218
Common configuration for EFM32 OTG FS peripheral.