Loading...
Searching...
No Matches
periph_conf.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021 Otto-von-Guericke-Universität Magdeburg
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
18#ifndef PERIPH_CONF_H
19#define PERIPH_CONF_H
20
21#include <stdint.h>
22
23#include "kernel_defines.h"
24#include "cpu.h"
25#include "periph_cpu.h"
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
36static inline unsigned _periph_numof_is_unsigned_0(void)
37{
38 return 0;
39}
40
41static const uart_conf_t uart_config[] = {
42 {
43 .dev = UART0,
44 .rx_pin = GPIO_PIN(0, 1),
45 .tx_pin = GPIO_PIN(0, 0),
46 .irqn = UART0_IRQ_IRQn
47 },
48 {
49 .dev = UART1,
50 .rx_pin = GPIO_PIN(0, 9),
51 .tx_pin = GPIO_PIN(0, 8),
52 .irqn = UART1_IRQ_IRQn
53 }
54};
55
56#define UART_0_ISR (isr_uart0)
57#define UART_1_ISR (isr_uart1)
58
59#define UART_NUMOF ARRAY_SIZE(uart_config)
60
61static const spi_conf_t spi_config[] = {
62 {
63 .dev = SPI0,
64 .miso_pin = GPIO_PIN(0, 4),
65 .mosi_pin = GPIO_PIN(0, 3),
66 .clk_pin = GPIO_PIN(0, 2)
67 },
68 {
69 .dev = SPI1,
70 .miso_pin = GPIO_PIN(0, 12),
71 .mosi_pin = GPIO_PIN(0, 11),
72 .clk_pin = GPIO_PIN(0, 10)
73 }
74};
75
76#define SPI_NUMOF ARRAY_SIZE(spi_config)
77
78static const timer_channel_conf_t timer0_channel_config[] = {
79 {
80 .irqn = TIMER_IRQ_0_IRQn
81 },
82 {
83 .irqn = TIMER_IRQ_1_IRQn
84 },
85 {
86 .irqn = TIMER_IRQ_2_IRQn
87 },
88 {
89 .irqn = TIMER_IRQ_3_IRQn
90 }
91};
92
93static const timer_conf_t timer_config[] = {
94 {
95 .dev = TIMER,
96 .ch = timer0_channel_config,
97 .ch_numof = ARRAY_SIZE(timer0_channel_config)
98 }
99};
100
101#define TIMER_0_ISRA isr_timer0
102#define TIMER_0_ISRB isr_timer1
103#define TIMER_0_ISRC isr_timer2
104#define TIMER_0_ISRD isr_timer3
105
106#define TIMER_NUMOF ARRAY_SIZE(timer_config)
107
114static const adc_conf_t adc_config[] = {
115 { .pin = GPIO_PIN(0, 26), .chan = 0},
116 { .pin = GPIO_PIN(0, 27), .chan = 1},
117 { .pin = GPIO_PIN(0, 28), .chan = 2},
118 };
119
120#define ADC_NUMOF ARRAY_SIZE(adc_config)
130#define I2C_NUMOF _periph_numof_is_unsigned_0()
140static const pio_conf_t pio_config[] = {
141 {
142 .dev = PIO0,
143 .irqn0 = PIO0_IRQ_0_IRQn,
144 .irqn1 = PIO0_IRQ_1_IRQn
145 },
146 {
147 .dev = PIO1,
148 .irqn0 = PIO1_IRQ_0_IRQn,
149 .irqn1 = PIO1_IRQ_1_IRQn
150 }
151};
152
153#define PIO_0_ISR0 isr_pio00
154#define PIO_0_ISR1 isr_pio01
155#define PIO_1_ISR0 isr_pio10
156#define PIO_1_ISR1 isr_pio11
158#define PIO_NUMOF ARRAY_SIZE(pio_config)
160#if defined(PIO_I2C_CONFIG) || defined(DOXYGEN)
168 PIO_I2C_CONFIG
169};
173#define PIO_I2C_NUMOF ARRAY_SIZE(pio_i2c_config)
174#else
175#define pio_i2c_config ((pio_i2c_conf_t *)NULL)
176#endif
183static const pwm_conf_t pwm_config[] = {
184 {
185 .pwm_slice = 4,
186 .chan = {
187 { .pin = GPIO_PIN(0, 25), .cc_chan = 1 }, /* rpi-pico onboard LED */
188 { .pin = GPIO_UNDEF, .cc_chan = 0 },
189 },
190 },
191};
192
193#define PWM_NUMOF ARRAY_SIZE(pwm_config)
196#ifdef __cplusplus
197}
198#endif
199
200#endif /* PERIPH_CONF_H */
#define GPIO_PIN(x, y)
Define a CPU specific GPIO pin generator macro.
Definition periph_cpu.h:46
#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:36
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:83
#define UART0
UART0 register bank.
#define UART1
UART1 register bank.
Common macros and compiler attributes/pragmas configuration.
ADC device configuration.
Definition periph_cpu.h:379
gpio_t pin
pin connected to the channel
Definition periph_cpu.h:288
PIO configuration type.
Definition periph_cpu.h:466
PIO0_Type * dev
PIO device.
Definition periph_cpu.h:467
PIO I2C configuration type.
Definition periph_cpu.h:475
PWM device configuration.
uint8_t pwm_slice
PWM slice instance, must be < to PWM_SLICE_NUMOF.
Definition periph_cpu.h:424
SPI device configuration.
Definition periph_cpu.h:337
SPI_t * dev
pointer to the used SPI device
Definition periph_cpu.h:338
Configuration type of a timer channel.
Definition periph_cpu.h:448
IRQn_Type irqn
timer channel interrupt number
Definition periph_cpu.h:449
Timer device configuration.
Definition periph_cpu.h:264
TC0_t * dev
Pointer to the used as Timer device.
Definition periph_cpu.h:265
UART device configuration.
Definition periph_cpu.h:218
USART_t * dev
pointer to the used UART device
Definition periph_cpu.h:219