Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017-2020 Bas Stottelaar <basstottelaar@gmail.com>
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 "cpu.h"
23#include "periph_cpu.h"
24#include "em_cmu.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
34#ifndef CLOCK_HF
35#define CLOCK_HF cmuSelect_HFRCO
36#endif
37#ifndef CLOCK_CORE_DIV
38#define CLOCK_CORE_DIV cmuClkDiv_1
39#endif
40#ifndef CLOCK_LFA
41#define CLOCK_LFA cmuSelect_LFRCO
42#endif
43#ifndef CLOCK_LFB
44#define CLOCK_LFB cmuSelect_LFRCO
45#endif
46#ifndef CLOCK_LFE
47#define CLOCK_LFE cmuSelect_LFRCO
48#endif
55static const adc_conf_t adc_config[] = {
56 {
57 .dev = ADC0,
58 .cmu = cmuClock_ADC0,
59 }
60};
61
62static const adc_chan_conf_t adc_channel_config[] = {
63 {
64 .dev = 0,
65 .input = adcPosSelTEMP,
66 .reference = adcRef1V25,
67 .acq_time = adcAcqTime8
68 },
69 {
70 .dev = 0,
71 .input = adcPosSelAVDD,
72 .reference = adcRef5V,
73 .acq_time = adcAcqTime8
74 }
75};
76
77#define ADC_DEV_NUMOF ARRAY_SIZE(adc_config)
78#define ADC_NUMOF ARRAY_SIZE(adc_channel_config)
85#ifndef RTT_FREQUENCY
86#define RTT_FREQUENCY (1U) /* in Hz */
87#endif
94static const spi_dev_t spi_config[] = {
95 {
96 .dev = USART1,
97 .mosi_pin = GPIO_PIN(PD, 15),
98 .miso_pin = GPIO_PIN(PD, 14),
99 .clk_pin = GPIO_PIN(PD, 13),
100 .loc = USART_ROUTELOC0_RXLOC_LOC21 |
101 USART_ROUTELOC0_TXLOC_LOC23 |
102 USART_ROUTELOC0_CLKLOC_LOC19,
103 .cmu = cmuClock_USART1,
104 .irq = USART1_RX_IRQn
105 }
106};
107
108#define SPI_NUMOF ARRAY_SIZE(spi_config)
118static const timer_conf_t timer_config[] = {
119 {
120 .prescaler = {
121 .dev = TIMER0,
122 .cmu = cmuClock_TIMER0
123 },
124 .timer = {
125 .dev = TIMER1,
126 .cmu = cmuClock_TIMER1
127 },
128 .irq = TIMER1_IRQn,
129 .channel_numof = 3
130 },
131 {
132 .prescaler = {
133 .dev = NULL,
134 .cmu = cmuClock_LETIMER0
135 },
136 .timer = {
137 .dev = LETIMER0,
138 .cmu = cmuClock_LETIMER0
139 },
140 .irq = LETIMER0_IRQn,
141 .channel_numof = 2
142 }
143};
144
145#define TIMER_0_ISR isr_timer1
146#define TIMER_1_ISR isr_letimer0
147
148#define TIMER_NUMOF ARRAY_SIZE(timer_config)
155#ifndef EFM32_USE_LEUART
156#define EFM32_USE_LEUART 0
157#endif
158
159#if EFM32_USE_LEUART
160
161#ifndef STDIO_UART_BAUDRATE
162#define STDIO_UART_BAUDRATE (9600)
163#endif
164
165static const uart_conf_t uart_config[] = {
166 {
167 .dev = LEUART0,
168 .rx_pin = GPIO_PIN(PB, 15),
169 .tx_pin = GPIO_PIN(PB, 14),
170 .loc = USART_ROUTELOC0_RXLOC_LOC9 |
171 USART_ROUTELOC0_TXLOC_LOC9,
172 .cmu = cmuClock_LEUART0,
173 .irq = LEUART0_IRQn
174 }
175};
176#define UART_0_ISR_RX isr_leuart0
177
178#else /* EFM32_USE_LEUART */
179
180static const uart_conf_t uart_config[] = {
181 {
182 .dev = USART0,
183 .rx_pin = GPIO_PIN(PB, 15),
184 .tx_pin = GPIO_PIN(PB, 14),
185 .loc = USART_ROUTELOC0_RXLOC_LOC9 |
186 USART_ROUTELOC0_TXLOC_LOC9,
187 .cmu = cmuClock_USART0,
188 .irq = USART0_RX_IRQn
189 }
190};
191#define UART_0_ISR_RX isr_usart0_rx
192
193#endif /* EFM32_USE_LEUART */
194#define UART_NUMOF ARRAY_SIZE(uart_config)
197#ifdef __cplusplus
198}
199#endif
200
201#endif /* PERIPH_CONF_H */
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition periph_cpu.h:46
@ PB
port B
@ 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
SPI device configuration.
Definition periph_cpu.h:518
USART_TypeDef * dev
USART device used.
Definition periph_cpu.h:519
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