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 
19 #include "cpu.h"
20 #include "periph_cpu.h"
21 #include "em_cmu.h"
22 
23 #ifdef __cplusplus
24 extern "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_CORELEDIV2
42 #endif
49 static const adc_conf_t adc_config[] = {
50  {
51  .dev = ADC0,
52  .cmu = cmuClock_ADC0,
53  }
54 };
55 
56 static const adc_chan_conf_t adc_channel_config[] = {
57  {
58  .dev = 0,
59  .input = adcSingleInputTemp,
60  .reference = adcRef1V25,
61  .acq_time = adcAcqTime8
62  },
63  {
64  .dev = 0,
65  .input = adcSingleInputVDDDiv3,
66  .reference = adcRef1V25,
67  .acq_time = adcAcqTime8
68  }
69 };
70 
71 #define ADC_DEV_NUMOF ARRAY_SIZE(adc_config)
72 #define ADC_NUMOF ARRAY_SIZE(adc_channel_config)
79 static const i2c_conf_t i2c_config[] = {
80  {
81  .dev = I2C0,
82  .sda_pin = GPIO_PIN(PE, 12),
83  .scl_pin = GPIO_PIN(PE, 13),
84  .loc = I2C_ROUTE_LOCATION_LOC6,
85  .cmu = cmuClock_I2C0,
86  .irq = I2C0_IRQn,
87  .speed = I2C_SPEED_NORMAL
88  }
89 };
90 
91 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
92 #define I2C_0_ISR isr_i2c0
99 #ifndef RTT_FREQUENCY
100 #define RTT_FREQUENCY (1U) /* in Hz */
101 #endif
109 static const spi_dev_t spi_config[] = {
110  {
111  .dev = USART1,
112  .mosi_pin = GPIO_PIN(PD, 7),
113  .miso_pin = GPIO_PIN(PD, 6),
114  .clk_pin = GPIO_PIN(PC, 15),
115 /* page 81 https://www.silabs.com/documents/public/data-sheets/efm32zg-datasheet.pdf */
116  .loc = USART_ROUTE_LOCATION_LOC3,
117  .cmu = cmuClock_USART1,
118  .irq = USART1_RX_IRQn
119  }
120 };
121 
122 #define SPI_NUMOF ARRAY_SIZE(spi_config)
131 static const timer_conf_t timer_config[] = {
132  {
133  .prescaler = {
134  .dev = TIMER0,
135  .cmu = cmuClock_TIMER0
136  },
137  .timer = {
138  .dev = TIMER1,
139  .cmu = cmuClock_TIMER1
140  },
141  .irq = TIMER1_IRQn,
142  .channel_numof = 3
143  }
144 };
145 
146 #define TIMER_NUMOF ARRAY_SIZE(timer_config)
147 #define TIMER_0_ISR isr_timer1
154 static const uart_conf_t uart_config[] = {
155  {
156  .dev = LEUART0,
157  .rx_pin = GPIO_PIN(PD, 5),
158  .tx_pin = GPIO_PIN(PD, 4),
159  .loc = LEUART_ROUTE_LOCATION_LOC0,
160  .cmu = cmuClock_LEUART0,
161  .irq = LEUART0_IRQn
162  }
163 };
164 
165 #define UART_NUMOF ARRAY_SIZE(uart_config)
166 #define UART_0_ISR_RX isr_leuart0
169 #ifdef __cplusplus
170 }
171 #endif
172 
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition: periph_cpu.h:42
static const uart_conf_t uart_config[]
UART configuration.
Definition: periph_conf.h:35
static const spi_conf_t spi_config[]
SPI configuration.
Definition: periph_conf.h:93
static const i2c_conf_t i2c_config[]
I2C configuration.
Definition: periph_conf.h:65
static const timer_conf_t timer_config[]
All timers on board.
Definition: periph_conf.h:36
static const adc_conf_t adc_config[]
ADC configuration.
Definition: periph_conf.h:247
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: periph_cpu.h:274
@ PC
port C
@ PD
port D
ADC channel configuration.
Definition: periph_cpu.h:382
uint8_t dev
device index
Definition: periph_cpu.h:383
ADC device configuration.
Definition: periph_cpu.h:374
ADC_TypeDef * dev
ADC device used.
Definition: periph_cpu.h:375
I2C configuration structure.
Definition: periph_cpu.h:295
TWI_t * dev
Pointer to hardware module registers.
Definition: periph_cpu.h:296
SPI_t * dev
pointer to the used SPI device
Definition: periph_cpu.h:334
SPI device configuration.
Definition: periph_cpu.h:513
Timer device configuration.
Definition: periph_cpu.h:260
timer_dev_t prescaler
the lower neighboring timer (not initialized for LETIMER)
Definition: periph_cpu.h:552
void * dev
TIMER_TypeDef or LETIMER_TypeDef device used.
Definition: periph_cpu.h:545
UART device configuration.
Definition: periph_cpu.h:214
USART_t * dev
pointer to the used UART device
Definition: periph_cpu.h:215