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 
9 #pragma once
10 
21 #include "cpu.h"
22 #include "periph_cpu.h"
23 #include "em_cmu.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
33 #ifndef CLOCK_HF
34 #define CLOCK_HF cmuSelect_HFRCO
35 #endif
36 #ifndef CLOCK_CORE_DIV
37 #define CLOCK_CORE_DIV cmuClkDiv_1
38 #endif
39 #ifndef CLOCK_LFA
40 #define CLOCK_LFA cmuSelect_LFRCO
41 #endif
42 #ifndef CLOCK_LFB
43 #define CLOCK_LFB cmuSelect_LFRCO
44 #endif
45 #ifndef CLOCK_LFE
46 #define CLOCK_LFE cmuSelect_LFRCO
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 = adcPosSelTEMP,
65  .reference = adcRef1V25,
66  .acq_time = adcAcqTime8
67  },
68  {
69  .dev = 0,
70  .input = adcPosSelAVDD,
71  .reference = adcRef5V,
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 #ifndef RTT_FREQUENCY
85 #define RTT_FREQUENCY (1U) /* in Hz */
86 #endif
93 static const spi_dev_t spi_config[] = {
94  {
95  .dev = USART1,
96  .mosi_pin = GPIO_PIN(PD, 15),
97  .miso_pin = GPIO_PIN(PD, 14),
98  .clk_pin = GPIO_PIN(PD, 13),
99  .loc = USART_ROUTELOC0_RXLOC_LOC21 |
100  USART_ROUTELOC0_TXLOC_LOC23 |
101  USART_ROUTELOC0_CLKLOC_LOC19,
102  .cmu = cmuClock_USART1,
103  .irq = USART1_RX_IRQn
104  }
105 };
106 
107 #define SPI_NUMOF ARRAY_SIZE(spi_config)
117 static const timer_conf_t timer_config[] = {
118  {
119  .prescaler = {
120  .dev = TIMER0,
121  .cmu = cmuClock_TIMER0
122  },
123  .timer = {
124  .dev = TIMER1,
125  .cmu = cmuClock_TIMER1
126  },
127  .irq = TIMER1_IRQn,
128  .channel_numof = 3
129  },
130  {
131  .prescaler = {
132  .dev = NULL,
133  .cmu = cmuClock_LETIMER0
134  },
135  .timer = {
136  .dev = LETIMER0,
137  .cmu = cmuClock_LETIMER0
138  },
139  .irq = LETIMER0_IRQn,
140  .channel_numof = 2
141  }
142 };
143 
144 #define TIMER_0_ISR isr_timer1
145 #define TIMER_1_ISR isr_letimer0
146 
147 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
154 #ifndef EFM32_USE_LEUART
155 #define EFM32_USE_LEUART 0
156 #endif
157 
158 #if EFM32_USE_LEUART
159 
160 #ifndef STDIO_UART_BAUDRATE
161 #define STDIO_UART_BAUDRATE (9600)
162 #endif
163 
164 static const uart_conf_t uart_config[] = {
165  {
166  .dev = LEUART0,
167  .rx_pin = GPIO_PIN(PB, 15),
168  .tx_pin = GPIO_PIN(PB, 14),
169  .loc = USART_ROUTELOC0_RXLOC_LOC9 |
170  USART_ROUTELOC0_TXLOC_LOC9,
171  .cmu = cmuClock_LEUART0,
172  .irq = LEUART0_IRQn
173  }
174 };
175 #define UART_0_ISR_RX isr_leuart0
176 
177 #else /* EFM32_USE_LEUART */
178 
179 static const uart_conf_t uart_config[] = {
180  {
181  .dev = USART0,
182  .rx_pin = GPIO_PIN(PB, 15),
183  .tx_pin = GPIO_PIN(PB, 14),
184  .loc = USART_ROUTELOC0_RXLOC_LOC9 |
185  USART_ROUTELOC0_TXLOC_LOC9,
186  .cmu = cmuClock_USART0,
187  .irq = USART0_RX_IRQn
188  }
189 };
190 #define UART_0_ISR_RX isr_usart0_rx
191 
192 #endif /* EFM32_USE_LEUART */
193 #define UART_NUMOF ARRAY_SIZE(uart_config)
196 #ifdef __cplusplus
197 }
198 #endif
199 
#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 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
@ PB
port B
@ PD
port D
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
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