Loading...
Searching...
No Matches
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
18
19#include "cpu.h"
20#include "periph_cpu.h"
21#include "em_cmu.h"
22#include "usbdev_cfg_otg_fs.h"
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
32#ifndef CLOCK_HF
33#define CLOCK_HF cmuSelect_HFXO
34#endif
35#ifndef CLOCK_CORE_DIV
36#define CLOCK_CORE_DIV cmuClkDiv_1
37#endif
38#ifndef CLOCK_LFA
39#define CLOCK_LFA cmuSelect_LFXO
40#endif
41#ifndef CLOCK_LFB
42#define CLOCK_LFB cmuSelect_LFXO
43#endif
45
50static const adc_conf_t adc_config[] = {
51 {
52 .dev = ADC0,
53 .cmu = cmuClock_ADC0,
54 }
55};
56
57static const adc_chan_conf_t adc_channel_config[] = {
58 {
59 .dev = 0,
60 .input = adcSingleInputTemp,
61 .reference = adcRef1V25,
62 .acq_time = adcAcqTime8
63 },
64 {
65 .dev = 0,
66 .input = adcSingleInputVDDDiv3,
67 .reference = adcRef1V25,
68 .acq_time = adcAcqTime8
69 }
70};
71
72#define ADC_DEV_NUMOF ARRAY_SIZE(adc_config)
73#define ADC_NUMOF ARRAY_SIZE(adc_channel_config)
75
80static const dac_conf_t dac_config[] = {
81 {
82 .dev = DAC0,
83 .ref = dacRefVDD,
84 .cmu = cmuClock_DAC0,
85 }
86};
87
88static const dac_chan_conf_t dac_channel_config[] = {
89 {
90 .dev = 0,
91 .index = 1,
92 }
93};
94
95#define DAC_DEV_NUMOF ARRAY_SIZE(dac_config)
96#define DAC_NUMOF ARRAY_SIZE(dac_channel_config)
98
103static const i2c_conf_t i2c_config[] = {
104 {
105 .dev = I2C0,
106 .sda_pin = GPIO_PIN(PD, 6),
107 .scl_pin = GPIO_PIN(PD, 7),
108 .loc = I2C_ROUTE_LOCATION_LOC1,
109 .speed = I2C_SPEED_NORMAL,
110 .cmu = cmuClock_I2C0,
111 .irq = I2C0_IRQn,
112 .use_internal_pull_ups = true
113 },
114 {
115 .dev = I2C1,
116 .sda_pin = GPIO_PIN(PC, 4),
117 .scl_pin = GPIO_PIN(PC, 5),
118 .loc = I2C_ROUTE_LOCATION_LOC0,
119 .speed = I2C_SPEED_NORMAL,
120 .cmu = cmuClock_I2C1,
121 .irq = I2C1_IRQn,
122 .use_internal_pull_ups = true
123 }
124};
125
126#define I2C_NUMOF ARRAY_SIZE(i2c_config)
127#define I2C_0_ISR isr_i2c0
128#define I2C_1_ISR isr_i2c1
130
135static const pwm_chan_conf_t pwm_channel_config[] = {
136 {
137 .index = 2,
138 .pin = GPIO_PIN(PE, 2),
139 .loc = TIMER_ROUTE_LOCATION_LOC1
140 }
141};
142
143static const pwm_conf_t pwm_config[] = {
144 {
145 .dev = TIMER3,
146 .cmu = cmuClock_TIMER3,
147 .irq = TIMER3_IRQn,
148 .channels = 1,
149 .channel = pwm_channel_config
150 }
151};
152
153#define PWM_DEV_NUMOF ARRAY_SIZE(pwm_config)
154#define PWM_NUMOF ARRAY_SIZE(pwm_channel_config)
156
161#ifndef RTT_FREQUENCY
162#define RTT_FREQUENCY (1U) /* in Hz */
163#endif
165
170static const spi_dev_t spi_config[] = {
171 {
172 .dev = USART1,
173 .mosi_pin = GPIO_PIN(PD, 0),
174 .miso_pin = GPIO_PIN(PD, 1),
175 .clk_pin = GPIO_PIN(PD, 2),
176 .loc = USART_ROUTE_LOCATION_LOC1,
177 .cmu = cmuClock_USART1,
178 .irq = USART1_RX_IRQn
179 },
180 {
181 .dev = USART2,
182 .mosi_pin = GPIO_UNDEF,
183 .miso_pin = GPIO_PIN(PC, 3),
184 .clk_pin = GPIO_PIN(PC, 4),
185 .loc = USART_ROUTE_LOCATION_LOC0,
186 .cmu = cmuClock_USART2,
187 .irq = USART2_RX_IRQn
188 }
189};
190
191#define SPI_NUMOF ARRAY_SIZE(spi_config)
193
200static const timer_conf_t timer_config[] = {
201 {
202 .prescaler = {
203 .dev = TIMER0,
204 .cmu = cmuClock_TIMER0
205 },
206 .timer = {
207 .dev = TIMER1,
208 .cmu = cmuClock_TIMER1
209 },
210 .irq = TIMER1_IRQn,
211 .channel_numof = 3
212 },
213 {
214 .prescaler = {
215 .dev = NULL,
216 .cmu = cmuClock_LETIMER0
217 },
218 .timer = {
219 .dev = LETIMER0,
220 .cmu = cmuClock_LETIMER0
221 },
222 .irq = LETIMER0_IRQn,
223 .channel_numof = 2
224 }
225};
226
227#define TIMER_NUMOF ARRAY_SIZE(timer_config)
228#define TIMER_0_ISR isr_timer1
229#define TIMER_1_ISR isr_letimer0
231
236static const uart_conf_t uart_config[] = {
237 {
238 .dev = UART0,
239 .rx_pin = GPIO_PIN(PE, 1),
240 .tx_pin = GPIO_PIN(PE, 0),
241 .loc = UART_ROUTE_LOCATION_LOC1,
242 .cmu = cmuClock_UART0,
243 .irq = UART0_RX_IRQn
244 },
245 {
246 .dev = LEUART0,
247 .rx_pin = GPIO_PIN(PD, 5),
248 .tx_pin = GPIO_PIN(PD, 4),
249 .loc = LEUART_ROUTE_LOCATION_LOC0,
250 .cmu = cmuClock_LEUART0,
251 .irq = LEUART0_IRQn
252 }
253};
254
255#define UART_NUMOF ARRAY_SIZE(uart_config)
256#define UART_0_ISR_RX isr_uart0_rx
257#define UART_1_ISR_RX isr_leuart0
259
260#ifdef __cplusplus
261}
262#endif
263
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition periph_cpu.h:42
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition periph_cpu.h:274
#define UART0
UART0 register bank.
@ PC
port C
@ PD
port D
ADC channel configuration.
Definition periph_cpu.h:382
ADC device configuration.
Definition periph_cpu.h:374
DAC line configuration data.
Definition periph_cpu.h:297
I2C configuration structure.
Definition periph_cpu.h:295
PWM channel configuration.
Definition periph_cpu.h:465
PWM device configuration.
SPI device configuration.
Definition periph_cpu.h:514
Timer device configuration.
Definition periph_cpu.h:260
UART device configuration.
Definition periph_cpu.h:214
Common configuration for EFM32 OTG FS peripheral.