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 
20 #ifndef PERIPH_CONF_H
21 #define PERIPH_CONF_H
22 
23 #include "cpu.h"
24 #include "periph_cpu.h"
25 #include "em_cmu.h"
26 #include "usbdev_cfg_otg_fs.h"
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
36 #ifndef CLOCK_HF
37 #define CLOCK_HF cmuSelect_HFXO
38 #endif
39 #ifndef CLOCK_CORE_DIV
40 #define CLOCK_CORE_DIV cmuClkDiv_1
41 #endif
42 #ifndef CLOCK_LFA
43 #define CLOCK_LFA cmuSelect_LFXO
44 #endif
45 #ifndef CLOCK_LFB
46 #define CLOCK_LFB cmuSelect_LFXO
47 #endif
54 static const adc_conf_t adc_config[] = {
55  {
56  .dev = ADC0,
57  .cmu = cmuClock_ADC0,
58  }
59 };
60 
61 static const adc_chan_conf_t adc_channel_config[] = {
62  {
63  .dev = 0,
64  .input = adcSingleInputTemp,
65  .reference = adcRef1V25,
66  .acq_time = adcAcqTime8
67  },
68  {
69  .dev = 0,
70  .input = adcSingleInputVDDDiv3,
71  .reference = adcRef1V25,
72  .acq_time = adcAcqTime8
73  }
74 };
75 
76 #define ADC_DEV_NUMOF ARRAY_SIZE(adc_config)
77 #define ADC_NUMOF ARRAY_SIZE(adc_channel_config)
84 static const dac_conf_t dac_config[] = {
85  {
86  .dev = DAC0,
87  .ref = dacRefVDD,
88  .cmu = cmuClock_DAC0,
89  }
90 };
91 
92 static const dac_chan_conf_t dac_channel_config[] = {
93  {
94  .dev = 0,
95  .index = 1,
96  }
97 };
98 
99 #define DAC_DEV_NUMOF ARRAY_SIZE(dac_config)
100 #define DAC_NUMOF ARRAY_SIZE(dac_channel_config)
107 static const i2c_conf_t i2c_config[] = {
108  {
109  .dev = I2C0,
110  .sda_pin = GPIO_PIN(PD, 6),
111  .scl_pin = GPIO_PIN(PD, 7),
112  .loc = I2C_ROUTE_LOCATION_LOC1,
113  .cmu = cmuClock_I2C0,
114  .irq = I2C0_IRQn,
115  .speed = I2C_SPEED_NORMAL
116  },
117  {
118  .dev = I2C1,
119  .sda_pin = GPIO_PIN(PC, 4),
120  .scl_pin = GPIO_PIN(PC, 5),
121  .loc = I2C_ROUTE_LOCATION_LOC0,
122  .cmu = cmuClock_I2C1,
123  .irq = I2C1_IRQn,
124  .speed = I2C_SPEED_NORMAL
125  }
126 };
127 
128 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
129 #define I2C_0_ISR isr_i2c0
130 #define I2C_1_ISR isr_i2c1
137 static const pwm_chan_conf_t pwm_channel_config[] = {
138  {
139  .index = 2,
140  .pin = GPIO_PIN(PE, 2),
141  .loc = TIMER_ROUTE_LOCATION_LOC1
142  }
143 };
144 
145 static const pwm_conf_t pwm_config[] = {
146  {
147  .dev = TIMER3,
148  .cmu = cmuClock_TIMER3,
149  .irq = TIMER3_IRQn,
150  .channels = 1,
151  .channel = pwm_channel_config
152  }
153 };
154 
155 #define PWM_DEV_NUMOF ARRAY_SIZE(pwm_config)
156 #define PWM_NUMOF ARRAY_SIZE(pwm_channel_config)
163 #ifndef RTT_FREQUENCY
164 #define RTT_FREQUENCY (1U) /* in Hz */
165 #endif
172 static const spi_dev_t spi_config[] = {
173  {
174  .dev = USART1,
175  .mosi_pin = GPIO_PIN(PD, 0),
176  .miso_pin = GPIO_PIN(PD, 1),
177  .clk_pin = GPIO_PIN(PD, 2),
178  .loc = USART_ROUTE_LOCATION_LOC1,
179  .cmu = cmuClock_USART1,
180  .irq = USART1_RX_IRQn
181  },
182  {
183  .dev = USART2,
184  .mosi_pin = GPIO_UNDEF,
185  .miso_pin = GPIO_PIN(PC, 3),
186  .clk_pin = GPIO_PIN(PC, 4),
187  .loc = USART_ROUTE_LOCATION_LOC0,
188  .cmu = cmuClock_USART2,
189  .irq = USART2_RX_IRQn
190  }
191 };
192 
193 #define SPI_NUMOF ARRAY_SIZE(spi_config)
202 static const timer_conf_t timer_config[] = {
203  {
204  .prescaler = {
205  .dev = TIMER0,
206  .cmu = cmuClock_TIMER0
207  },
208  .timer = {
209  .dev = TIMER1,
210  .cmu = cmuClock_TIMER1
211  },
212  .irq = TIMER1_IRQn,
213  .channel_numof = 3
214  },
215  {
216  .prescaler = {
217  .dev = NULL,
218  .cmu = cmuClock_LETIMER0
219  },
220  .timer = {
221  .dev = LETIMER0,
222  .cmu = cmuClock_LETIMER0
223  },
224  .irq = LETIMER0_IRQn,
225  .channel_numof = 2
226  }
227 };
228 
229 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
230 #define TIMER_0_ISR isr_timer1
231 #define TIMER_1_ISR isr_letimer0
238 static const uart_conf_t uart_config[] = {
239  {
240  .dev = UART0,
241  .rx_pin = GPIO_PIN(PE, 1),
242  .tx_pin = GPIO_PIN(PE, 0),
243  .loc = UART_ROUTE_LOCATION_LOC1,
244  .cmu = cmuClock_UART0,
245  .irq = UART0_RX_IRQn
246  },
247  {
248  .dev = LEUART0,
249  .rx_pin = GPIO_PIN(PD, 5),
250  .tx_pin = GPIO_PIN(PD, 4),
251  .loc = LEUART_ROUTE_LOCATION_LOC0,
252  .cmu = cmuClock_LEUART0,
253  .irq = LEUART0_IRQn
254  }
255 };
256 
257 #define UART_NUMOF ARRAY_SIZE(uart_config)
258 #define UART_0_ISR_RX isr_uart0_rx
259 #define UART_1_ISR_RX isr_leuart0
262 #ifdef __cplusplus
263 }
264 #endif
265 
266 #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.
static const uart_conf_t uart_config[]
UART configuration.
Definition: periph_conf.h:39
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:97
static const i2c_conf_t i2c_config[]
I2C configuration.
Definition: periph_conf.h:69
static const timer_conf_t timer_config[]
All timers on board.
Definition: periph_conf.h:40
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:251
static const pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:222
static const dac_conf_t dac_config[]
DAC configuration.
Definition: periph_conf.h:253
#define UART0
UART0 register bank.
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:278
@ PC
port C
@ PD
port D
ADC channel configuration.
Definition: periph_cpu.h:387
uint8_t dev
device index
Definition: periph_cpu.h:388
ADC device configuration.
Definition: periph_cpu.h:379
ADC_TypeDef * dev
ADC device used.
Definition: periph_cpu.h:380
DAC line configuration data.
Definition: periph_cpu.h:301
I2C configuration structure.
Definition: periph_cpu.h:299
TWI_t * dev
Pointer to hardware module registers.
Definition: periph_cpu.h:300
PWM channel configuration.
Definition: periph_cpu.h:469
uint8_t index
TIMER channel to use.
Definition: periph_cpu.h:470
PWM device configuration.
mini_timer_t * dev
Timer used.
SPI_t * dev
pointer to the used SPI device
Definition: periph_cpu.h:338
SPI device configuration.
Definition: periph_cpu.h:518
Timer device configuration.
Definition: periph_cpu.h:264
timer_dev_t prescaler
the lower neighboring timer (not initialized for LETIMER)
Definition: periph_cpu.h:557
void * dev
TIMER_TypeDef or LETIMER_TypeDef device used.
Definition: periph_cpu.h:550
UART device configuration.
Definition: periph_cpu.h:218
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:219
Common configuration for EFM32 OTG FS peripheral.