Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2021 Otto-von-Guericke-Universität Magdeburg
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
17
18#include <stdint.h>
19
20#include "kernel_defines.h"
21#include "cpu.h"
22#include "periph_cpu.h"
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
33static inline unsigned _periph_numof_is_unsigned_0(void)
34{
35 return 0;
36}
37
38static const uart_conf_t uart_config[] = {
39 {
40 .dev = UART0,
41 .rx_pin = GPIO_PIN(0, 1),
42 .tx_pin = GPIO_PIN(0, 0),
43 .irqn = UART0_IRQ_IRQn
44 },
45 {
46 .dev = UART1,
47 .rx_pin = GPIO_PIN(0, 9),
48 .tx_pin = GPIO_PIN(0, 8),
49 .irqn = UART1_IRQ_IRQn
50 }
51};
52
53#define UART_0_ISR (isr_uart0)
54#define UART_1_ISR (isr_uart1)
55
56#define UART_NUMOF ARRAY_SIZE(uart_config)
57
58static const spi_conf_t spi_config[] = {
59 {
60 .dev = SPI0,
61 .miso_pin = GPIO_PIN(0, 4),
62 .mosi_pin = GPIO_PIN(0, 3),
63 .clk_pin = GPIO_PIN(0, 2)
64 },
65 {
66 .dev = SPI1,
67 .miso_pin = GPIO_PIN(0, 12),
68 .mosi_pin = GPIO_PIN(0, 11),
69 .clk_pin = GPIO_PIN(0, 10)
70 }
71};
72
73#define SPI_NUMOF ARRAY_SIZE(spi_config)
74
75static const timer_channel_conf_t timer0_channel_config[] = {
76 {
77 .irqn = TIMER_IRQ_0_IRQn
78 },
79 {
80 .irqn = TIMER_IRQ_1_IRQn
81 },
82 {
83 .irqn = TIMER_IRQ_2_IRQn
84 },
85 {
86 .irqn = TIMER_IRQ_3_IRQn
87 }
88};
89
90static const timer_conf_t timer_config[] = {
91 {
92 .dev = TIMER,
93 .ch = timer0_channel_config,
94 .ch_numof = ARRAY_SIZE(timer0_channel_config)
95 }
96};
97
98#define TIMER_0_ISRA isr_timer0
99#define TIMER_0_ISRB isr_timer1
100#define TIMER_0_ISRC isr_timer2
101#define TIMER_0_ISRD isr_timer3
102
103#define TIMER_NUMOF ARRAY_SIZE(timer_config)
104
111static const adc_conf_t adc_config[] = {
112 { .pin = GPIO_PIN(0, 26), .chan = 0},
113 { .pin = GPIO_PIN(0, 27), .chan = 1},
114 { .pin = GPIO_PIN(0, 28), .chan = 2},
115 };
116
117#define ADC_NUMOF ARRAY_SIZE(adc_config)
119
127#define I2C_NUMOF _periph_numof_is_unsigned_0()
129
137static const pio_conf_t pio_config[] = {
138 {
139 .dev = PIO0,
140 .irqn0 = PIO0_IRQ_0_IRQn,
141 .irqn1 = PIO0_IRQ_1_IRQn
142 },
143 {
144 .dev = PIO1,
145 .irqn0 = PIO1_IRQ_0_IRQn,
146 .irqn1 = PIO1_IRQ_1_IRQn
147 }
148};
149
150#define PIO_0_ISR0 isr_pio00
151#define PIO_0_ISR1 isr_pio01
152#define PIO_1_ISR0 isr_pio10
153#define PIO_1_ISR1 isr_pio11
154
155#define PIO_NUMOF ARRAY_SIZE(pio_config)
156
157#if defined(PIO_I2C_CONFIG) || defined(DOXYGEN)
165 PIO_I2C_CONFIG
166};
167
170#define PIO_I2C_NUMOF ARRAY_SIZE(pio_i2c_config)
171#else
172#define pio_i2c_config ((pio_i2c_conf_t *)NULL)
173#endif
175
180static const pwm_conf_t pwm_config[] = {
181 {
182 .pwm_slice = 4,
183 .chan = {
184 { .pin = GPIO_PIN(0, 25), .cc_chan = 1 }, /* rpi-pico onboard LED */
185 { .pin = GPIO_UNDEF, .cc_chan = 0 },
186 },
187 },
188};
189
190#define PWM_NUMOF ARRAY_SIZE(pwm_config)
192
193#ifdef __cplusplus
194}
195#endif
196
#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.
static unsigned _periph_numof_is_unsigned_0(void)
Silences the warning when an unsigned value is compared to 0.
Definition periph_conf.h:33
static const pio_conf_t pio_config[]
Array of PIO configurations.
static const pio_i2c_conf_t pio_i2c_config[]
PIO I2C configuration.
#define ARRAY_SIZE(a)
Calculate the number of elements in a static array.
Definition container.h:82
#define UART0
UART0 register bank.
#define UART1
UART1 register bank.
Common macros and compiler attributes/pragmas configuration.
ADC device configuration.
Definition periph_cpu.h:374
PIO configuration type.
Definition periph_cpu.h:465
PIO I2C configuration type.
Definition periph_cpu.h:474
PWM device configuration.
SPI device configuration.
Definition periph_cpu.h:333
Configuration type of a timer channel.
Definition periph_cpu.h:447
Timer device configuration.
Definition periph_cpu.h:260
UART device configuration.
Definition periph_cpu.h:214