Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2015-2020 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
18
19#include "cpu.h"
20#include "periph_cpu.h"
21#include "em_cmu.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
31#ifndef CLOCK_HF
32#define CLOCK_HF cmuSelect_HFXO
33#endif
34#ifndef CLOCK_CORE_DIV
35#define CLOCK_CORE_DIV cmuClkDiv_1
36#endif
37#ifndef CLOCK_LFA
38#define CLOCK_LFA cmuSelect_LFXO
39#endif
40#ifndef CLOCK_LFB
41#define CLOCK_LFB cmuSelect_LFXO
42#endif
43#ifndef CLOCK_LFE
44#define CLOCK_LFE cmuSelect_LFXO
45#endif
47
52static const adc_conf_t adc_config[] = {
53 {
54 .dev = ADC0,
55 .cmu = cmuClock_ADC0,
56 }
57};
58
59static const adc_chan_conf_t adc_channel_config[] = {
60 {
61 .dev = 0,
62 .input = adcPosSelTEMP,
63 .reference = adcRef1V25,
64 .acq_time = adcAcqTime8
65 },
66 {
67 .dev = 0,
68 .input = adcPosSelAVDD,
69 .reference = adcRef5V,
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)
77
82static const i2c_conf_t i2c_config[] = {
83 {
84 .dev = I2C0,
85 .sda_pin = GPIO_PIN(PC, 10),
86 .scl_pin = GPIO_PIN(PC, 11),
87 .loc = I2C_ROUTELOC0_SDALOC_LOC15 |
88 I2C_ROUTELOC0_SCLLOC_LOC15,
89 .speed = I2C_SPEED_NORMAL,
90 .cmu = cmuClock_I2C0,
91 .irq = I2C0_IRQn,
92 .use_internal_pull_ups = true
93 }
94};
95
96#define I2C_NUMOF ARRAY_SIZE(i2c_config)
97#define I2C_0_ISR isr_i2c0
99
104#ifndef RTT_FREQUENCY
105#define RTT_FREQUENCY (1U) /* in Hz */
106#endif
108
113static const spi_dev_t spi_config[] = {
114 {
115 .dev = USART2,
116 .mosi_pin = GPIO_PIN(PA, 6),
117 .miso_pin = GPIO_PIN(PA, 7),
118 .clk_pin = GPIO_PIN(PA, 8),
119 .loc = USART_ROUTELOC0_RXLOC_LOC1 |
120 USART_ROUTELOC0_TXLOC_LOC1 |
121 USART_ROUTELOC0_CLKLOC_LOC1,
122 .cmu = cmuClock_USART2,
123 .irq = USART2_RX_IRQn
124 },
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)
140
147static const timer_conf_t timer_config[] = {
148 {
149 .prescaler = {
150 .dev = WTIMER0,
151 .cmu = cmuClock_WTIMER0
152 },
153 .timer = {
154 .dev = WTIMER1,
155 .cmu = cmuClock_WTIMER1
156 },
157 .irq = WTIMER1_IRQn,
158 .channel_numof = 3
159 },
160 {
161 .prescaler = {
162 .dev = TIMER0,
163 .cmu = cmuClock_TIMER0
164 },
165 .timer = {
166 .dev = TIMER1,
167 .cmu = cmuClock_TIMER1
168 },
169 .irq = TIMER1_IRQn,
170 .channel_numof = 3
171 },
172 {
173 .prescaler = {
174 .dev = NULL,
175 .cmu = cmuClock_LETIMER0
176 },
177 .timer = {
178 .dev = LETIMER0,
179 .cmu = cmuClock_LETIMER0
180 },
181 .irq = LETIMER0_IRQn,
182 .channel_numof = 2
183 }
184};
185
186#define TIMER_NUMOF ARRAY_SIZE(timer_config)
187#define TIMER_0_ISR isr_wtimer1
188#define TIMER_1_ISR isr_timer1
189#define TIMER_2_ISR isr_letimer0
191
196static const uart_conf_t uart_config[] = {
197 {
198 .dev = USART0,
199 .rx_pin = GPIO_PIN(PA, 1),
200 .tx_pin = GPIO_PIN(PA, 0),
201 .loc = USART_ROUTELOC0_RXLOC_LOC0 |
202 USART_ROUTELOC0_TXLOC_LOC0,
203 .cmu = cmuClock_USART0,
204 .irq = USART0_RX_IRQn
205 },
206 {
207 .dev = LEUART0,
208 .rx_pin = GPIO_PIN(PD, 11),
209 .tx_pin = GPIO_PIN(PD, 10),
210 .loc = LEUART_ROUTELOC0_RXLOC_LOC18 |
211 LEUART_ROUTELOC0_TXLOC_LOC18,
212 .cmu = cmuClock_LEUART0,
213 .irq = LEUART0_IRQn
214 }
215};
216
217#define UART_NUMOF ARRAY_SIZE(uart_config)
218#define UART_0_ISR_RX isr_usart0_rx
219#define UART_1_ISR_RX isr_leuart0
221
222#ifdef __cplusplus
223}
224#endif
225
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition periph_cpu.h:42
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition periph_cpu.h:274
@ PC
port C
@ PA
port A
@ PD
port D
ADC channel configuration.
Definition periph_cpu.h:382
ADC device configuration.
Definition periph_cpu.h:374
I2C configuration structure.
Definition periph_cpu.h:295
SPI device configuration.
Definition periph_cpu.h:514
Timer device configuration.
Definition periph_cpu.h:260
UART device configuration.
Definition periph_cpu.h:214