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
19#ifndef PERIPH_CONF_H
20#define PERIPH_CONF_H
21
22#include <stdint.h>
23
24#include "kernel_defines.h"
25#include "cpu.h"
26#include "periph_cpu.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
37static inline unsigned _periph_numof_is_unsigned_0(void)
38{
39 return 0;
40}
41
42static const uart_conf_t uart_config[] = {
43 {
44 .dev = UART0,
45 .rx_pin = GPIO_PIN(0, 1),
46 .tx_pin = GPIO_PIN(0, 0),
47 .irqn = UART0_IRQ_IRQn
48 },
49 {
50 .dev = UART1,
51 .rx_pin = GPIO_PIN(0, 9),
52 .tx_pin = GPIO_PIN(0, 8),
53 .irqn = UART1_IRQ_IRQn
54 }
55};
56
57#define UART_0_ISR (isr_uart0)
58#define UART_1_ISR (isr_uart1)
59
60#define UART_NUMOF ARRAY_SIZE(uart_config)
61
62static const spi_conf_t spi_config[] = {
63 {
64 .dev = SPI0,
65 .miso_pin = GPIO_PIN(0, 4),
66 .mosi_pin = GPIO_PIN(0, 3),
67 .clk_pin = GPIO_PIN(0, 2)
68 },
69 {
70 .dev = SPI1,
71 .miso_pin = GPIO_PIN(0, 12),
72 .mosi_pin = GPIO_PIN(0, 11),
73 .clk_pin = GPIO_PIN(0, 10)
74 }
75};
76
77#define SPI_NUMOF ARRAY_SIZE(spi_config)
78
79static const timer_channel_conf_t timer0_channel_config[] = {
80 {
81 .irqn = TIMER_IRQ_0_IRQn
82 },
83 {
84 .irqn = TIMER_IRQ_1_IRQn
85 },
86 {
87 .irqn = TIMER_IRQ_2_IRQn
88 },
89 {
90 .irqn = TIMER_IRQ_3_IRQn
91 }
92};
93
94static const timer_conf_t timer_config[] = {
95 {
96 .dev = TIMER,
97 .ch = timer0_channel_config,
98 .ch_numof = ARRAY_SIZE(timer0_channel_config)
99 }
100};
101
102#define TIMER_0_ISRA isr_timer0
103#define TIMER_0_ISRB isr_timer1
104#define TIMER_0_ISRC isr_timer2
105#define TIMER_0_ISRD isr_timer3
106
107#define TIMER_NUMOF ARRAY_SIZE(timer_config)
108
115static const adc_conf_t adc_config[] = {
116 { .pin = GPIO_PIN(0, 26), .chan = 0},
117 { .pin = GPIO_PIN(0, 27), .chan = 1},
118 { .pin = GPIO_PIN(0, 28), .chan = 2},
119 };
120
121#define ADC_NUMOF ARRAY_SIZE(adc_config)
131#define I2C_NUMOF _periph_numof_is_unsigned_0()
141static const pio_conf_t pio_config[] = {
142 {
143 .dev = PIO0,
144 .irqn0 = PIO0_IRQ_0_IRQn,
145 .irqn1 = PIO0_IRQ_1_IRQn
146 },
147 {
148 .dev = PIO1,
149 .irqn0 = PIO1_IRQ_0_IRQn,
150 .irqn1 = PIO1_IRQ_1_IRQn
151 }
152};
153
154#define PIO_0_ISR0 isr_pio00
155#define PIO_0_ISR1 isr_pio01
156#define PIO_1_ISR0 isr_pio10
157#define PIO_1_ISR1 isr_pio11
159#define PIO_NUMOF ARRAY_SIZE(pio_config)
161#if defined(PIO_I2C_CONFIG) || defined(DOXYGEN)
169 PIO_I2C_CONFIG
170};
174#define PIO_I2C_NUMOF ARRAY_SIZE(pio_i2c_config)
175#else
176#define pio_i2c_config ((pio_i2c_conf_t *)NULL)
177#endif
184static const pwm_conf_t pwm_config[] = {
185 {
186 .pwm_slice = 4,
187 .chan = {
188 { .pin = GPIO_PIN(0, 25), .cc_chan = 1 }, /* rpi-pico onboard LED */
189 { .pin = GPIO_UNDEF, .cc_chan = 0 },
190 },
191 },
192};
193
194#define PWM_NUMOF ARRAY_SIZE(pwm_config)
197#ifdef __cplusplus
198}
199#endif
200
201#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:37
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
PIO configuration type.
Definition periph_cpu.h:466
PIO I2C configuration type.
Definition periph_cpu.h:475
PWM device configuration.
SPI device configuration.
Definition periph_cpu.h:337
Configuration type of a timer channel.
Definition periph_cpu.h:448
Timer device configuration.
Definition periph_cpu.h:264
UART device configuration.
Definition periph_cpu.h:218