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 
23 #include "cpu.h"
24 #include "periph_cpu.h"
25 #include "em_cmu.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
35 #ifndef CLOCK_HF
36 #define CLOCK_HF cmuSelect_HFXO
37 #endif
38 #ifndef CLOCK_CORE_DIV
39 #define CLOCK_CORE_DIV cmuClkDiv_1
40 #endif
41 #ifndef CLOCK_LFA
42 #define CLOCK_LFA cmuSelect_LFXO
43 #endif
44 #ifndef CLOCK_LFB
45 #define CLOCK_LFB cmuSelect_LFXO
46 #endif
53 static const adc_conf_t adc_config[] = {
54  {
55  .dev = ADC0,
56  .cmu = cmuClock_ADC0,
57  }
58 };
59 
60 static const adc_chan_conf_t adc_channel_config[] = {
61  {
62  .dev = 0,
63  .input = adcSingleInputTemp,
64  .reference = adcRef1V25,
65  .acq_time = adcAcqTime8
66  },
67  {
68  .dev = 0,
69  .input = adcSingleInputVDDDiv3,
70  .reference = adcRef1V25,
71  .acq_time = adcAcqTime8
72  }
73 };
74 
75 #define ADC_DEV_NUMOF ARRAY_SIZE(adc_config)
76 #define ADC_NUMOF ARRAY_SIZE(adc_channel_config)
83 static const i2c_conf_t i2c_config[] = {
84  {
85  .dev = I2C0,
86  .sda_pin = GPIO_PIN(PD, 6),
87  .scl_pin = GPIO_PIN(PD, 7),
88  .loc = I2C_ROUTE_LOCATION_LOC1,
89  .cmu = cmuClock_I2C0,
90  .irq = I2C0_IRQn,
91  .speed = I2C_SPEED_NORMAL
92  }
93 };
94 
95 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
96 #define I2C_0_ISR isr_i2c0
103 #ifndef RTT_FREQUENCY
104 #define RTT_FREQUENCY (1U) /* in Hz */
105 #endif
112 static const spi_dev_t spi_config[] = {
113  {
114  .dev = USART0,
115  .mosi_pin = GPIO_PIN(PE, 10),
116  .miso_pin = GPIO_PIN(PE, 11),
117  .clk_pin = GPIO_PIN(PE, 12),
118  .loc = USART_ROUTE_LOCATION_LOC0,
119  .cmu = cmuClock_USART0,
120  .irq = USART0_RX_IRQn
121  }
122 };
123 
124 #define SPI_NUMOF ARRAY_SIZE(spi_config)
133 static const timer_conf_t timer_config[] = {
134  {
135  .prescaler = {
136  .dev = TIMER0,
137  .cmu = cmuClock_TIMER0
138  },
139  .timer = {
140  .dev = TIMER1,
141  .cmu = cmuClock_TIMER1
142  },
143  .irq = TIMER1_IRQn,
144  .channel_numof = 3
145  }
146 };
147 
148 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
149 #define TIMER_0_ISR isr_timer1
156 static const uart_conf_t uart_config[] = {
157  {
158  .dev = USART1,
159  .rx_pin = GPIO_PIN(PA, 0),
160  .tx_pin = GPIO_PIN(PF, 2),
161  .loc = USART_ROUTE_LOCATION_LOC4,
162  .cmu = cmuClock_USART1,
163  .irq = USART1_RX_IRQn
164  },
165  {
166  .dev = LEUART0,
167  .rx_pin = GPIO_PIN(PD, 5),
168  .tx_pin = GPIO_PIN(PD, 4),
169  .loc = LEUART_ROUTE_LOCATION_LOC0,
170  .cmu = cmuClock_LEUART0,
171  .irq = LEUART0_IRQn
172  }
173 };
174 
175 #define UART_NUMOF ARRAY_SIZE(uart_config)
176 #define UART_0_ISR_RX isr_usart1_rx
177 #define UART_1_ISR_RX isr_leuart0
180 #ifdef __cplusplus
181 }
182 #endif
183 
#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
@ 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