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
27 extern "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
49 
55 static const adc_conf_t adc_config[] = {
56  {
57  .dev = ADC0,
58  .cmu = cmuClock_ADC0,
59  }
60 };
61 
62 static 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)
79 
85 #define RTT_MAX_VALUE (0xFFFFFFFF)
86 #define RTT_FREQUENCY (1U)
87 
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)
108 
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)
148 
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)
194 
196 #ifdef __cplusplus
197 }
198 #endif
199 
200 #endif /* PERIPH_CONF_H */
201 
spi_dev_t::dev
USART_TypeDef * dev
USART device used.
Definition: periph_cpu.h:331
PD
@ PD
port D
Definition: periph_cpu_common.h:91
adc_chan_conf_t
ADC channel configuration.
Definition: periph_cpu.h:82
adc_conf_t::dev
ADC_TypeDef * dev
ADC device used.
Definition: periph_cpu.h:75
timer_dev_t::dev
void * dev
TIMER_TypeDef or LETIMER_TypeDef device used.
Definition: periph_cpu.h:358
spi_dev_t
SPI device configuration.
Definition: periph_cpu.h:330
PB
@ PB
port B
Definition: periph_cpu_common.h:89
timer_conf_t::prescaler
timer_dev_t prescaler
the lower neighboring timer (not initialized for LETIMER)
Definition: periph_cpu.h:363
uart_conf_t
UART device configuration.
Definition: periph_cpu.h:166
uart_conf_t::dev
cc2538_uart_t * dev
pointer to the used UART device
Definition: periph_cpu.h:167
timer_conf_t
Timer configuration.
Definition: periph_cpu.h:288
adc_conf_t
ADC device configuration.
Definition: periph_cpu.h:74
GPIO_PIN
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:35
adc_chan_conf_t::dev
uint8_t dev
device index
Definition: periph_cpu.h:83