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 "mii.h"
21#include "periph_cpu.h"
22#include "em_cmu.h"
23#include "usbdev_cfg_otg_fs.h"
24
25#ifdef __cplusplus
26extern "C" {
27#endif
28
33#ifndef CLOCK_HF
34#define CLOCK_HF cmuSelect_HFXO
35#endif
36#ifndef CLOCK_CORE_DIV
37#define CLOCK_CORE_DIV cmuClkDiv_1
38#endif
39#ifndef CLOCK_LFA
40#define CLOCK_LFA cmuSelect_LFXO
41#endif
42#ifndef CLOCK_LFB
43#define CLOCK_LFB cmuSelect_LFXO
44#endif
45#ifndef CLOCK_LFE
46#define CLOCK_LFE cmuSelect_LFXO
47#endif
49
54static const adc_conf_t adc_config[] = {
55 {
56 .dev = ADC0,
57 .cmu = cmuClock_ADC0,
58 }
59};
60
61static const adc_chan_conf_t adc_channel_config[] = {
62 {
63 .dev = 0,
64 .input = adcPosSelTEMP,
65 .reference = adcRef1V25,
66 .acq_time = adcAcqTime8
67 },
68 {
69 .dev = 0,
70 .input = adcPosSelAVDD,
71 .reference = adcRef5V,
72 .acq_time = adcAcqTime8
73 }
74};
75
76#define ADC_DEV_NUMOF ARRAY_SIZE(adc_config)
77#define ADC_NUMOF ARRAY_SIZE(adc_channel_config)
79
84static const dac_conf_t dac_config[] = {
85 {
86 .dev = VDAC0,
87 .ref = vdacRefAvdd,
88 .cmu = cmuClock_VDAC0,
89 },
90};
91
92static const dac_chan_conf_t dac_channel_config[] = {
93 {
94 .dev = 0,
95 .index = 0,
96 },
97};
98
99#define DAC_DEV_NUMOF ARRAY_SIZE(dac_config)
100#define DAC_NUMOF ARRAY_SIZE(dac_channel_config)
102
107static const i2c_conf_t i2c_config[] = {
108 {
109 .dev = I2C0,
110 .sda_pin = GPIO_PIN(PC, 0),
111 .scl_pin = GPIO_PIN(PC, 1),
112 .loc = I2C_ROUTELOC0_SDALOC_LOC4 |
113 I2C_ROUTELOC0_SCLLOC_LOC4,
114 .speed = I2C_SPEED_NORMAL,
115 .cmu = cmuClock_I2C0,
116 .irq = I2C0_IRQn,
117 .use_internal_pull_ups = true
118 },
119 {
120 .dev = I2C1,
121 .sda_pin = GPIO_PIN(PC, 4),
122 .scl_pin = GPIO_PIN(PC, 5),
123 .loc = I2C_ROUTELOC0_SDALOC_LOC0 |
124 I2C_ROUTELOC0_SCLLOC_LOC0,
125 .speed = I2C_SPEED_NORMAL,
126 .cmu = cmuClock_I2C1,
127 .irq = I2C1_IRQn,
128 .use_internal_pull_ups = true
129 },
130 {
131 .dev = I2C2,
132 .sda_pin = GPIO_PIN(PI, 4),
133 .scl_pin = GPIO_PIN(PI, 5),
134 .loc = I2C_ROUTELOC0_SDALOC_LOC7 |
135 I2C_ROUTELOC0_SCLLOC_LOC7,
136 .speed = I2C_SPEED_NORMAL,
137 .cmu = cmuClock_I2C2,
138 .irq = I2C2_IRQn,
139 .use_internal_pull_ups = true
140 }
141};
142
143#define I2C_NUMOF ARRAY_SIZE(i2c_config)
144#define I2C_0_ISR isr_i2c0
145#define I2C_1_ISR isr_i2c1
146#define I2C_2_ISR isr_i2c2
148
153#ifndef RTT_FREQUENCY
154#define RTT_FREQUENCY (1U)
155#endif
157
162static const spi_dev_t spi_config[] = {
163 {
164 .dev = USART0,
165 .mosi_pin = GPIO_PIN(PE, 10),
166 .miso_pin = GPIO_PIN(PE, 11),
167 .clk_pin = GPIO_PIN(PE, 12),
168 .loc = USART_ROUTELOC0_TXLOC_LOC0 |
169 USART_ROUTELOC0_RXLOC_LOC0 |
170 USART_ROUTELOC0_CLKLOC_LOC0,
171 .cmu = cmuClock_USART0,
172 .irq = USART0_RX_IRQn
173 },
174 {
175 .dev = USART1,
176 .mosi_pin = GPIO_PIN(PA, 14),
177 .miso_pin = GPIO_PIN(PC, 2),
178 .clk_pin = GPIO_PIN(PC, 15),
179 .loc = USART_ROUTELOC0_TXLOC_LOC6 |
180 USART_ROUTELOC0_RXLOC_LOC4 |
181 USART_ROUTELOC0_CLKLOC_LOC3,
182 .cmu = cmuClock_USART1,
183 .irq = USART1_RX_IRQn
184 }
185};
186
187#define SPI_NUMOF ARRAY_SIZE(spi_config)
189
196static const timer_conf_t timer_config[] = {
197 {
198 .prescaler = {
199 .dev = WTIMER0,
200 .cmu = cmuClock_WTIMER0
201 },
202 .timer = {
203 .dev = WTIMER1,
204 .cmu = cmuClock_WTIMER1
205 },
206 .irq = WTIMER1_IRQn,
207 .channel_numof = 3
208 },
209 {
210 .prescaler = {
211 .dev = TIMER0,
212 .cmu = cmuClock_TIMER0
213 },
214 .timer = {
215 .dev = TIMER1,
216 .cmu = cmuClock_TIMER1
217 },
218 .irq = TIMER1_IRQn,
219 .channel_numof = 3
220 },
221 {
222 .prescaler = {
223 .dev = NULL,
224 .cmu = cmuClock_LETIMER0
225 },
226 .timer = {
227 .dev = LETIMER0,
228 .cmu = cmuClock_LETIMER0
229 },
230 .irq = LETIMER0_IRQn,
231 .channel_numof = 2
232 }
233};
234
235#define TIMER_NUMOF ARRAY_SIZE(timer_config)
236#define TIMER_0_ISR isr_wtimer1
237#define TIMER_1_ISR isr_timer1
238#define TIMER_2_ISR isr_letimer0
240
245static const uart_conf_t uart_config[] = {
246 {
247 .dev = USART4,
248 .rx_pin = GPIO_PIN(PH, 5),
249 .tx_pin = GPIO_PIN(PH, 4),
250 .loc = USART_ROUTELOC0_RXLOC_LOC4 |
251 USART_ROUTELOC0_TXLOC_LOC4,
252 .cmu = cmuClock_USART4,
253 .irq = USART4_RX_IRQn,
254 },
255 {
256 .dev = USART5,
257 .rx_pin = GPIO_PIN(PE, 9),
258 .tx_pin = GPIO_PIN(PE, 8),
259 .loc = USART_ROUTELOC0_RXLOC_LOC4 |
260 USART_ROUTELOC0_TXLOC_LOC4,
261 .cmu = cmuClock_USART5,
262 .irq = USART5_RX_IRQn,
263 }
264};
265
266#define UART_NUMOF ARRAY_SIZE(uart_config)
267#define UART_0_ISR_RX isr_usart4_rx
268#define UART_1_ISR_RX isr_usart5_rx
270
278static const eth_conf_t eth_config = {
279 .phy_en_pin = GPIO_PIN(PI, 10),
280 .phy_rst_pin = GPIO_UNDEF,
281 .routeloc1 = ETH_ROUTELOC1_RMIILOC_LOC1 | ETH_ROUTELOC1_MDIOLOC_LOC1,
283 .phy_addr = 0, /* Microchip KSZ8091-RNDCA */
284};
286
287#ifdef __cplusplus
288}
289#endif
290
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition periph_cpu.h:42
#define GPIO_UNDEF
Definition of a fitting UNDEF value.
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition periph_cpu.h:274
#define MII_BMCR_FULL_DPLX
Set for full duplex.
Definition mii.h:65
#define MII_BMCR_SPEED_100
Set speed to 100 Mbps.
Definition mii.h:69
Interface definition for MII/RMII h.
@ PC
port C
@ PA
port A
ADC channel configuration.
Definition periph_cpu.h:383
ADC device configuration.
Definition periph_cpu.h:375
DAC line configuration data.
Definition periph_cpu.h:297
Ethernet peripheral configuration.
Definition periph_cpu.h:657
I2C configuration structure.
Definition periph_cpu.h:295
SPI device configuration.
Definition periph_cpu.h:515
Timer device configuration.
Definition periph_cpu.h:260
UART device configuration.
Definition periph_cpu.h:214
Common configuration for EFM32 OTG FS peripheral.