Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2022 SSV Software Systems GmbH
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
17
18#include <stdint.h>
19
20#include "cpu.h"
21#include "periph_cpu.h"
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
31#define CMU_HFXOINIT CMU_HFXOINIT_DEFAULT
32#define CMU_LFXOINIT CMU_LFXOINIT_DEFAULT
33
34static const clk_mux_t clk_mux_config[] = {
35 { .clk = cmuClock_SYSCLK, .src = cmuSelect_HFXO },
36 { .clk = cmuClock_EM01GRPACLK, .src = cmuSelect_HFXO },
37 { .clk = cmuClock_EM01GRPCCLK, .src = cmuSelect_HFXO },
38 { .clk = cmuClock_EM23GRPACLK, .src = cmuSelect_LFXO },
39 { .clk = cmuClock_EUSART0CLK, .src = cmuSelect_HFXO },
40};
41#define CLK_MUX_NUMOF ARRAY_SIZE(clk_mux_config)
42
43static const clk_div_t clk_div_config[] = {
44 { .clk = cmuClock_HCLK, .div = 1 },
45 { .clk = cmuClock_PCLK, .div = 1 },
46 { .clk = cmuClock_LSPCLK, .div = 2 },
47};
48#define CLK_DIV_NUMOF ARRAY_SIZE(clk_div_config)
50
55static const adc_conf_t adc_config[] = {
56 {
57 .dev = IADC0,
58 .cmu = cmuClock_IADC0,
59 .reference = iadcCfgReferenceInt1V2,
60 .reference_mV = 1210,
61 .gain = iadcCfgAnalogGain0P5x,
62 .available_res = { ADC_RES_10BIT, ADC_RES_16BIT }
63 }
64};
65
66static const adc_chan_conf_t adc_channel_config[] = {
67 {
68 .dev = 0,
69 .input_pos = GPIO_PIN(PA, 10),
70 .input_neg = GPIO_UNDEF
71 },
72 {
73 .dev = 0,
74 .input_pos = GPIO_PIN(PA, 0),
75 .input_neg = GPIO_PIN(PA, 5)
76 },
77};
78
79#define ADC_DEV_NUMOF ARRAY_SIZE(adc_config)
80#define ADC_NUMOF ARRAY_SIZE(adc_channel_config)
82
87static const i2c_conf_t i2c_config[] = {
88 {
89 .dev = I2C0,
90 .sda_pin = GPIO_PIN(PC, 7),
91 .scl_pin = GPIO_PIN(PC, 5),
92 .speed = I2C_SPEED_NORMAL,
93 .cmu = cmuClock_I2C0,
94 .irq = I2C0_IRQn,
95 .use_internal_pull_ups = true
96 }
97};
98
99#define I2C_NUMOF ARRAY_SIZE(i2c_config)
100#define I2C_0_ISR isr_i2c0
102
107static const spi_dev_t spi_config[] = {
108 {
109 .dev = USART0,
110 .mosi_pin = GPIO_PIN(PC, 1),
111 .miso_pin = GPIO_PIN(PC, 2),
112 .clk_pin = GPIO_PIN(PC, 3),
113 .cmu = cmuClock_USART0,
114 .irq = USART0_RX_IRQn
115 }
116};
117
118#define SPI_NUMOF ARRAY_SIZE(spi_config)
120
128static const timer_conf_t timer_config[] = {
129 {
130 .dev = TIMER0,
131 .cmu = cmuClock_TIMER0,
132 .irq = TIMER0_IRQn
133 },
134 {
135 .dev = LETIMER0,
136 .cmu = cmuClock_LETIMER0,
137 .irq = LETIMER0_IRQn
138 }
139};
140
141#define TIMER_0_ISR isr_timer0
142#define TIMER_1_ISR isr_letimer0
143
144#define TIMER_0_MAX_VALUE TIMER_MAX_VALUE
145#define TIMER_1_MAX_VALUE LETIMER_MAX_VALUE
146
147#define TIMER_NUMOF ARRAY_SIZE(timer_config)
149
154static const uart_conf_t uart_config[] = {
155 {
156 .dev = EUSART1,
157 .rx_pin = GPIO_PIN(PA, 9),
158 .tx_pin = GPIO_PIN(PA, 8),
159 .cmu = cmuClock_EUSART1,
160 .irq = EUSART1_RX_IRQn
161 }
162};
163#define UART_0_ISR_RX isr_eusart1_rx
164
165#define UART_NUMOF ARRAY_SIZE(uart_config)
167
168#ifdef __cplusplus
169}
170#endif
171
#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
@ ADC_RES_16BIT
ADC resolution: 16 bit.
Definition adc.h:95
@ ADC_RES_10BIT
ADC resolution: 10 bit.
Definition adc.h:92
@ PC
port C
@ PA
port A
ADC channel configuration.
Definition periph_cpu.h:383
ADC device configuration.
Definition periph_cpu.h:375
Clock divider configuration.
Definition periph_cpu.h:59
Clock mux configuration.
Definition periph_cpu.h:51
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