Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017-2020 Bas Stottelaar <basstottelaar@gmail.com>
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
17
18#include "cpu.h"
19#include "periph_cpu.h"
20#include "em_cmu.h"
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
30#ifndef CLOCK_HF
31#define CLOCK_HF cmuSelect_HFRCO
32#endif
33#ifndef CLOCK_CORE_DIV
34#define CLOCK_CORE_DIV cmuClkDiv_1
35#endif
36#ifndef CLOCK_LFA
37#define CLOCK_LFA cmuSelect_LFRCO
38#endif
39#ifndef CLOCK_LFB
40#define CLOCK_LFB cmuSelect_LFRCO
41#endif
42#ifndef CLOCK_LFE
43#define CLOCK_LFE cmuSelect_LFRCO
44#endif
46
51static const adc_conf_t adc_config[] = {
52 {
53 .dev = ADC0,
54 .cmu = cmuClock_ADC0,
55 }
56};
57
58static const adc_chan_conf_t adc_channel_config[] = {
59 {
60 .dev = 0,
61 .input = adcPosSelTEMP,
62 .reference = adcRef1V25,
63 .acq_time = adcAcqTime8
64 },
65 {
66 .dev = 0,
67 .input = adcPosSelAVDD,
68 .reference = adcRef5V,
69 .acq_time = adcAcqTime8
70 }
71};
72
73#define ADC_DEV_NUMOF ARRAY_SIZE(adc_config)
74#define ADC_NUMOF ARRAY_SIZE(adc_channel_config)
76
81#ifndef RTT_FREQUENCY
82#define RTT_FREQUENCY (1U) /* in Hz */
83#endif
85
90static const spi_dev_t spi_config[] = {
91 {
92 .dev = USART1,
93 .mosi_pin = GPIO_PIN(PD, 15),
94 .miso_pin = GPIO_PIN(PD, 14),
95 .clk_pin = GPIO_PIN(PD, 13),
96 .loc = USART_ROUTELOC0_RXLOC_LOC21 |
97 USART_ROUTELOC0_TXLOC_LOC23 |
98 USART_ROUTELOC0_CLKLOC_LOC19,
99 .cmu = cmuClock_USART1,
100 .irq = USART1_RX_IRQn
101 }
102};
103
104#define SPI_NUMOF ARRAY_SIZE(spi_config)
106
114static const timer_conf_t timer_config[] = {
115 {
116 .prescaler = {
117 .dev = TIMER0,
118 .cmu = cmuClock_TIMER0
119 },
120 .timer = {
121 .dev = TIMER1,
122 .cmu = cmuClock_TIMER1
123 },
124 .irq = TIMER1_IRQn,
125 .channel_numof = 3
126 },
127 {
128 .prescaler = {
129 .dev = NULL,
130 .cmu = cmuClock_LETIMER0
131 },
132 .timer = {
133 .dev = LETIMER0,
134 .cmu = cmuClock_LETIMER0
135 },
136 .irq = LETIMER0_IRQn,
137 .channel_numof = 2
138 }
139};
140
141#define TIMER_0_ISR isr_timer1
142#define TIMER_1_ISR isr_letimer0
143
144#define TIMER_NUMOF ARRAY_SIZE(timer_config)
146
151#ifndef EFM32_USE_LEUART
152#define EFM32_USE_LEUART 0
153#endif
154
155#if EFM32_USE_LEUART
156
157#ifndef STDIO_UART_BAUDRATE
158#define STDIO_UART_BAUDRATE (9600)
159#endif
160
161static const uart_conf_t uart_config[] = {
162 {
163 .dev = LEUART0,
164 .rx_pin = GPIO_PIN(PB, 15),
165 .tx_pin = GPIO_PIN(PB, 14),
166 .loc = USART_ROUTELOC0_RXLOC_LOC9 |
167 USART_ROUTELOC0_TXLOC_LOC9,
168 .cmu = cmuClock_LEUART0,
169 .irq = LEUART0_IRQn
170 }
171};
172#define UART_0_ISR_RX isr_leuart0
173
174#else /* EFM32_USE_LEUART */
175
176static const uart_conf_t uart_config[] = {
177 {
178 .dev = USART0,
179 .rx_pin = GPIO_PIN(PB, 15),
180 .tx_pin = GPIO_PIN(PB, 14),
181 .loc = USART_ROUTELOC0_RXLOC_LOC9 |
182 USART_ROUTELOC0_TXLOC_LOC9,
183 .cmu = cmuClock_USART0,
184 .irq = USART0_RX_IRQn
185 }
186};
187#define UART_0_ISR_RX isr_usart0_rx
188
189#endif /* EFM32_USE_LEUART */
190#define UART_NUMOF ARRAY_SIZE(uart_config)
192
193#ifdef __cplusplus
194}
195#endif
196
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition periph_cpu.h:42
@ PB
port B
@ PD
port D
ADC channel configuration.
Definition periph_cpu.h:382
ADC device configuration.
Definition periph_cpu.h:374
SPI device configuration.
Definition periph_cpu.h:513
Timer device configuration.
Definition periph_cpu.h:260
UART device configuration.
Definition periph_cpu.h:214