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 
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)
77 
83 static const dac_conf_t dac_config[] = {
84  {
85  .dev = DAC0,
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  .ref = dacRefVDD,
95  }
96 };
97 
98 #define DAC_DEV_NUMOF ARRAY_SIZE(dac_config)
99 #define DAC_NUMOF ARRAY_SIZE(dac_channel_config)
100 
106 static const i2c_conf_t i2c_config[] = {
107  {
108  .dev = I2C0,
109  .sda_pin = GPIO_PIN(PD, 6),
110  .scl_pin = GPIO_PIN(PD, 7),
111  .loc = I2C_ROUTE_LOCATION_LOC1,
112  .cmu = cmuClock_I2C0,
113  .irq = I2C0_IRQn,
114  .speed = I2C_SPEED_NORMAL
115  },
116  {
117  .dev = I2C1,
118  .sda_pin = GPIO_PIN(PC, 4),
119  .scl_pin = GPIO_PIN(PC, 5),
120  .loc = I2C_ROUTE_LOCATION_LOC0,
121  .cmu = cmuClock_I2C1,
122  .irq = I2C1_IRQn,
123  .speed = I2C_SPEED_NORMAL
124  }
125 };
126 
127 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
128 #define I2C_0_ISR isr_i2c0
129 #define I2C_1_ISR isr_i2c1
130 
136 static const pwm_chan_conf_t pwm_channel_config[] = {
137  {
138  .index = 2,
139  .pin = GPIO_PIN(PE, 2),
140  .loc = TIMER_ROUTE_LOCATION_LOC1
141  }
142 };
143 
144 static const pwm_conf_t pwm_config[] = {
145  {
146  .dev = TIMER3,
147  .cmu = cmuClock_TIMER3,
148  .irq = TIMER3_IRQn,
149  .channels = 1,
150  .channel = pwm_channel_config
151  }
152 };
153 
154 #define PWM_DEV_NUMOF ARRAY_SIZE(pwm_config)
155 #define PWM_NUMOF ARRAY_SIZE(pwm_channel_config)
156 
162 #define RTT_MAX_VALUE (0xFFFFFF)
163 #define RTT_FREQUENCY (1U)
164 
170 static const spi_dev_t spi_config[] = {
171  {
172  .dev = USART1,
173  .mosi_pin = GPIO_PIN(PD, 0),
174  .miso_pin = GPIO_PIN(PD, 1),
175  .clk_pin = GPIO_PIN(PD, 2),
176  .loc = USART_ROUTE_LOCATION_LOC1,
177  .cmu = cmuClock_USART1,
178  .irq = USART1_RX_IRQn
179  },
180  {
181  .dev = USART2,
182  .mosi_pin = GPIO_UNDEF,
183  .miso_pin = GPIO_PIN(PC, 3),
184  .clk_pin = GPIO_PIN(PC, 4),
185  .loc = USART_ROUTE_LOCATION_LOC0,
186  .cmu = cmuClock_USART2,
187  .irq = USART2_RX_IRQn
188  }
189 };
190 
191 #define SPI_NUMOF ARRAY_SIZE(spi_config)
192 
200 static const timer_conf_t timer_config[] = {
201  {
202  .prescaler = {
203  .dev = TIMER0,
204  .cmu = cmuClock_TIMER0
205  },
206  .timer = {
207  .dev = TIMER1,
208  .cmu = cmuClock_TIMER1
209  },
210  .irq = TIMER1_IRQn,
211  .channel_numof = 3
212  },
213  {
214  .prescaler = {
215  .dev = NULL,
216  .cmu = cmuClock_LETIMER0
217  },
218  .timer = {
219  .dev = LETIMER0,
220  .cmu = cmuClock_LETIMER0
221  },
222  .irq = LETIMER0_IRQn,
223  .channel_numof = 2
224  }
225 };
226 
227 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
228 #define TIMER_0_ISR isr_timer1
229 #define TIMER_1_ISR isr_letimer0
230 
236 static const uart_conf_t uart_config[] = {
237  {
238  .dev = UART0,
239  .rx_pin = GPIO_PIN(PE, 1),
240  .tx_pin = GPIO_PIN(PE, 0),
241  .loc = UART_ROUTE_LOCATION_LOC1,
242  .cmu = cmuClock_UART0,
243  .irq = UART0_RX_IRQn
244  },
245  {
246  .dev = LEUART0,
247  .rx_pin = GPIO_PIN(PD, 5),
248  .tx_pin = GPIO_PIN(PD, 4),
249  .loc = LEUART_ROUTE_LOCATION_LOC0,
250  .cmu = cmuClock_LEUART0,
251  .irq = LEUART0_IRQn
252  }
253 };
254 
255 #define UART_NUMOF ARRAY_SIZE(uart_config)
256 #define UART_0_ISR_RX isr_uart0_rx
257 #define UART_1_ISR_RX isr_leuart0
258 
260 #ifdef __cplusplus
261 }
262 #endif
263 
264 #endif /* PERIPH_CONF_H */
265 
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
pwm_chan_conf_t
PWM channel configuration.
Definition: periph_cpu.h:281
pwm_conf_t::dev
mini_timer_t * dev
Timer used.
Definition: periph_cpu_common.h:154
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
UART0
#define UART0
UART0 register bank.
Definition: cc26xx_cc13xx_uart.h:134
pwm_conf_t
PWM device configuration.
Definition: periph_cpu_common.h:153
pwm_chan_conf_t::index
uint8_t index
TIMER channel to use.
Definition: periph_cpu.h:282
GPIO_UNDEF
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
Definition: periph_cpu_common.h:52
uart_conf_t
UART device configuration.
Definition: periph_cpu.h:166
dac_conf_t
DAC line configuration data.
Definition: periph_cpu.h:518
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
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