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 
20 #ifndef PERIPH_CONF_H
21 #define PERIPH_CONF_H
22 
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
47 #ifndef CLOCK_LFE
48 #define CLOCK_LFE cmuSelect_LFXO
49 #endif
50 
56 #ifdef EMU_DCDCINIT_OFF
57 #error "This option will soft-brick your board. Please remove it."
58 #endif
59 
65 static const adc_conf_t adc_config[] = {
66  {
67  .dev = ADC0,
68  .cmu = cmuClock_ADC0,
69  }
70 };
71 
72 static const adc_chan_conf_t adc_channel_config[] = {
73  {
74  .dev = 0,
75  .input = adcPosSelTEMP,
76  .reference = adcRef1V25,
77  .acq_time = adcAcqTime8
78  },
79  {
80  .dev = 0,
81  .input = adcPosSelAVDD,
82  .reference = adcRef5V,
83  .acq_time = adcAcqTime8
84  }
85 };
86 
87 #define ADC_DEV_NUMOF ARRAY_SIZE(adc_config)
88 #define ADC_NUMOF ARRAY_SIZE(adc_channel_config)
89 
95 static const i2c_conf_t i2c_config[] = {
96  {
97  .dev = I2C0,
98  .sda_pin = GPIO_PIN(PC, 10),
99  .scl_pin = GPIO_PIN(PC, 11),
100  .loc = I2C_ROUTELOC0_SDALOC_LOC15 |
101  I2C_ROUTELOC0_SCLLOC_LOC15,
102  .cmu = cmuClock_I2C0,
103  .irq = I2C0_IRQn,
104  .speed = I2C_SPEED_NORMAL
105  }
106 };
107 
108 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
109 #define I2C_0_ISR isr_i2c0
110 
116 #define RTT_MAX_VALUE (0xFFFFFFFF)
117 #define RTT_FREQUENCY (1U)
118 
124 static const spi_dev_t spi_config[] = {
125  {
126  .dev = USART1,
127  .mosi_pin = GPIO_PIN(PC, 6),
128  .miso_pin = GPIO_PIN(PC, 7),
129  .clk_pin = GPIO_PIN(PC, 8),
130  .loc = USART_ROUTELOC0_RXLOC_LOC11 |
131  USART_ROUTELOC0_TXLOC_LOC11 |
132  USART_ROUTELOC0_CLKLOC_LOC11,
133  .cmu = cmuClock_USART1,
134  .irq = USART1_RX_IRQn
135  }
136 };
137 
138 #define SPI_NUMOF ARRAY_SIZE(spi_config)
139 
147 static const timer_conf_t timer_config[] = {
148  {
149  .prescaler = {
150  .dev = TIMER0,
151  .cmu = cmuClock_TIMER0
152  },
153  .timer = {
154  .dev = TIMER1,
155  .cmu = cmuClock_TIMER1
156  },
157  .irq = TIMER1_IRQn,
158  .channel_numof = 3
159  },
160  {
161  .prescaler = {
162  .dev = NULL,
163  .cmu = cmuClock_LETIMER0
164  },
165  .timer = {
166  .dev = LETIMER0,
167  .cmu = cmuClock_LETIMER0
168  },
169  .irq = LETIMER0_IRQn,
170  .channel_numof = 2
171  }
172 };
173 
174 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
175 #define TIMER_0_ISR isr_timer1
176 #define TIMER_1_ISR isr_letimer0
177 
183 static const uart_conf_t uart_config[] = {
184  {
185  .dev = USART0,
186  .rx_pin = GPIO_PIN(PA, 1),
187  .tx_pin = GPIO_PIN(PA, 0),
188  .loc = USART_ROUTELOC0_RXLOC_LOC0 |
189  USART_ROUTELOC0_TXLOC_LOC0,
190  .cmu = cmuClock_USART0,
191  .irq = USART0_RX_IRQn
192  },
193  {
194  .dev = LEUART0,
195  .rx_pin = GPIO_PIN(PD, 11),
196  .tx_pin = GPIO_PIN(PD, 10),
197  .loc = LEUART_ROUTELOC0_RXLOC_LOC18 |
198  LEUART_ROUTELOC0_TXLOC_LOC18,
199  .cmu = cmuClock_LEUART0,
200  .irq = LEUART0_IRQn
201  }
202 };
203 
204 #define UART_NUMOF ARRAY_SIZE(uart_config)
205 #define UART_0_ISR_RX isr_usart0_rx
206 #define UART_1_ISR_RX isr_leuart0
207 
209 #ifdef __cplusplus
210 }
211 #endif
212 
213 #endif /* PERIPH_CONF_H */
214 
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
I2C_SPEED_NORMAL
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: i2c.h:177
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
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
PC
@ PC
port C
Definition: periph_cpu_common.h:90
PA
@ PA
port A
Definition: periph_cpu_common.h:88
i2c_conf_t
I2C configuration options.
Definition: periph_cpu.h:128
i2c_conf_t::dev
I2C_TypeDef * dev
USART device used.
Definition: periph_cpu.h:247