periph_conf.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015-2020 Freie Universität Berlin
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 
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_HFXO
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_LFXO
42 #endif
43 #ifndef CLOCK_LFB
44 #define CLOCK_LFB cmuSelect_LFXO
45 #endif
46 #ifndef CLOCK_LFE
47 #define CLOCK_LFE cmuSelect_LFXO
48 #endif
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)
85 static const i2c_conf_t i2c_config[] = {
86  {
87  .dev = I2C0,
88  .sda_pin = GPIO_PIN(PC, 10),
89  .scl_pin = GPIO_PIN(PC, 11),
90  .loc = I2C_ROUTELOC0_SDALOC_LOC15 |
91  I2C_ROUTELOC0_SCLLOC_LOC15,
92  .cmu = cmuClock_I2C0,
93  .irq = I2C0_IRQn,
94  .speed = I2C_SPEED_NORMAL
95  }
96 };
97 
98 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
99 #define I2C_0_ISR isr_i2c0
106 #ifndef RTT_FREQUENCY
107 #define RTT_FREQUENCY (1U) /* in Hz */
108 #endif
115 static const spi_dev_t spi_config[] = {
116  {
117  .dev = USART2,
118  .mosi_pin = GPIO_PIN(PA, 6),
119  .miso_pin = GPIO_PIN(PA, 7),
120  .clk_pin = GPIO_PIN(PA, 8),
121  .loc = USART_ROUTELOC0_RXLOC_LOC1 |
122  USART_ROUTELOC0_TXLOC_LOC1 |
123  USART_ROUTELOC0_CLKLOC_LOC1,
124  .cmu = cmuClock_USART2,
125  .irq = USART2_RX_IRQn
126  }
127 };
128 
129 #define SPI_NUMOF ARRAY_SIZE(spi_config)
138 static const timer_conf_t timer_config[] = {
139  {
140  .prescaler = {
141  .dev = WTIMER0,
142  .cmu = cmuClock_WTIMER0
143  },
144  .timer = {
145  .dev = WTIMER1,
146  .cmu = cmuClock_WTIMER1
147  },
148  .irq = WTIMER1_IRQn,
149  .channel_numof = 3
150  },
151  {
152  .prescaler = {
153  .dev = TIMER0,
154  .cmu = cmuClock_TIMER0
155  },
156  .timer = {
157  .dev = TIMER1,
158  .cmu = cmuClock_TIMER1
159  },
160  .irq = TIMER1_IRQn,
161  .channel_numof = 3
162  },
163  {
164  .prescaler = {
165  .dev = NULL,
166  .cmu = cmuClock_LETIMER0
167  },
168  .timer = {
169  .dev = LETIMER0,
170  .cmu = cmuClock_LETIMER0
171  },
172  .irq = LETIMER0_IRQn,
173  .channel_numof = 2
174  }
175 };
176 
177 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
178 #define TIMER_0_ISR isr_wtimer1
179 #define TIMER_1_ISR isr_timer1
180 #define TIMER_2_ISR isr_letimer0
187 static const uart_conf_t uart_config[] = {
188  {
189  .dev = USART0,
190  .rx_pin = GPIO_PIN(PA, 1),
191  .tx_pin = GPIO_PIN(PA, 0),
192  .loc = USART_ROUTELOC0_RXLOC_LOC0 |
193  USART_ROUTELOC0_TXLOC_LOC0,
194  .cmu = cmuClock_USART0,
195  .irq = USART0_RX_IRQn
196  },
197  {
198  .dev = LEUART0,
199  .rx_pin = GPIO_PIN(PD, 11),
200  .tx_pin = GPIO_PIN(PD, 10),
201  .loc = LEUART_ROUTELOC0_RXLOC_LOC18 |
202  LEUART_ROUTELOC0_TXLOC_LOC18,
203  .cmu = cmuClock_LEUART0,
204  .irq = LEUART0_IRQn
205  }
206 };
207 
208 #define UART_NUMOF ARRAY_SIZE(uart_config)
209 #define UART_0_ISR_RX isr_usart0_rx
210 #define UART_1_ISR_RX isr_leuart0
213 #ifdef __cplusplus
214 }
215 #endif
216 
#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 i2c_conf_t i2c_config[]
I2C configuration.
Definition: periph_conf.h:68
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
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:277
@ PC
port C
@ PA
port A
@ 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
I2C configuration structure.
Definition: periph_cpu.h:298
TWI_t * dev
Pointer to hardware module registers.
Definition: periph_cpu.h:299
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