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
52 static const adc_conf_t adc_config[] = {
53  {
54  .dev = ADC0,
55  .cmu = cmuClock_ADC0,
56  }
57 };
58 
59 static const adc_chan_conf_t adc_channel_config[] = {
60  {
61  .dev = 0,
62  .input = adcSingleInputTemp,
63  .reference = adcRef1V25,
64  .acq_time = adcAcqTime8
65  },
66  {
67  .dev = 0,
68  .input = adcSingleInputVDDDiv3,
69  .reference = adcRef1V25,
70  .acq_time = adcAcqTime8
71  }
72 };
73 
74 #define ADC_DEV_NUMOF ARRAY_SIZE(adc_config)
75 #define ADC_NUMOF ARRAY_SIZE(adc_channel_config)
82 static const dac_conf_t dac_config[] = {
83  {
84  .dev = DAC0,
85  .ref = dacRefVDD,
86  .cmu = cmuClock_DAC0,
87  }
88 };
89 
90 static const dac_chan_conf_t dac_channel_config[] = {
91  {
92  .dev = 0,
93  .index = 1,
94  }
95 };
96 
97 #define DAC_DEV_NUMOF ARRAY_SIZE(dac_config)
98 #define DAC_NUMOF ARRAY_SIZE(dac_channel_config)
105 static const i2c_conf_t i2c_config[] = {
106  {
107  .dev = I2C1,
108  .sda_pin = GPIO_PIN(PE, 0),
109  .scl_pin = GPIO_PIN(PE, 1),
110  .loc = I2C_ROUTE_LOCATION_LOC2,
111  .cmu = cmuClock_I2C1,
112  .irq = I2C1_IRQn,
113  .speed = I2C_SPEED_NORMAL
114  }
115 };
116 
117 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
118 #define I2C_0_ISR isr_i2c1
125 static const pwm_chan_conf_t pwm_channel_config[] = {
126  {
127  .index = 0,
128  .pin = GPIO_PIN(PF, 6),
129  .loc = TIMER_ROUTE_LOCATION_LOC2
130  },
131  {
132  .index = 1,
133  .pin = GPIO_PIN(PF, 7),
134  .loc = TIMER_ROUTE_LOCATION_LOC2
135  }
136 };
137 
138 static const pwm_conf_t pwm_config[] = {
139  {
140  .dev = TIMER0,
141  .cmu = cmuClock_TIMER0,
142  .irq = TIMER0_IRQn,
143  .channels = 2,
144  .channel = pwm_channel_config
145  }
146 };
147 
148 #define PWM_DEV_NUMOF ARRAY_SIZE(pwm_config)
149 #define PWM_NUMOF ARRAY_SIZE(pwm_channel_config)
156 #ifndef RTT_FREQUENCY
157 #define RTT_FREQUENCY (1U) /* in Hz */
158 #endif
165 static const spi_dev_t spi_config[] = {
166  {
167  .dev = USART1,
168  .mosi_pin = GPIO_PIN(PD, 0),
169  .miso_pin = GPIO_PIN(PD, 1),
170  .clk_pin = GPIO_PIN(PD, 2),
171  .loc = USART_ROUTE_LOCATION_LOC1,
172  .cmu = cmuClock_USART1,
173  .irq = USART1_RX_IRQn
174  }
175 };
176 
177 #define SPI_NUMOF ARRAY_SIZE(spi_config)
186 static const timer_conf_t timer_config[] = {
187  {
188  .prescaler = {
189  .dev = TIMER1,
190  .cmu = cmuClock_TIMER1
191  },
192  .timer = {
193  .dev = TIMER2,
194  .cmu = cmuClock_TIMER2
195  },
196  .irq = TIMER2_IRQn,
197  .channel_numof = 3
198  },
199  {
200  .prescaler = {
201  .dev = NULL,
202  .cmu = cmuClock_LETIMER0
203  },
204  .timer = {
205  .dev = LETIMER0,
206  .cmu = cmuClock_LETIMER0
207  },
208  .irq = LETIMER0_IRQn,
209  .channel_numof = 2
210  }
211 };
212 
213 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
214 #define TIMER_0_ISR isr_timer2
215 #define TIMER_1_ISR isr_letimer0
222 static const uart_conf_t uart_config[] = {
223  {
224  .dev = USART2,
225  .rx_pin = GPIO_PIN(PB, 4),
226  .tx_pin = GPIO_PIN(PB, 3),
227  .loc = USART_ROUTE_LOCATION_LOC1,
228  .cmu = cmuClock_USART2,
229  .irq = USART2_RX_IRQn
230  },
231  {
232  .dev = LEUART0,
233  .rx_pin = GPIO_PIN(PD, 5),
234  .tx_pin = GPIO_PIN(PD, 4),
235  .loc = LEUART_ROUTE_LOCATION_LOC0,
236  .cmu = cmuClock_LEUART0,
237  .irq = LEUART0_IRQn
238  }
239 };
240 
241 #define UART_NUMOF ARRAY_SIZE(uart_config)
242 #define UART_0_ISR_RX isr_usart2_rx
243 #define UART_1_ISR_RX isr_leuart0
246 #ifdef __cplusplus
247 }
248 #endif
249 
#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
static const pwm_conf_t pwm_config[]
Actual PWM configuration.
Definition: periph_conf.h:221
static const dac_conf_t dac_config[]
DAC configuration.
Definition: periph_conf.h:252
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:277
@ 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
DAC line configuration data.
Definition: periph_cpu.h:300
I2C configuration structure.
Definition: periph_cpu.h:298
TWI_t * dev
Pointer to hardware module registers.
Definition: periph_cpu.h:299
PWM channel configuration.
Definition: periph_cpu.h:467
uint8_t index
TIMER channel to use.
Definition: periph_cpu.h:468
PWM device configuration.
mini_timer_t * dev
Timer used.
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