periph_conf_common.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Gunar Schorcht
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 
23 #ifndef PERIPH_CONF_COMMON_H
24 #define PERIPH_CONF_COMMON_H
25 
26 /* include periph_cpu.h to make it visible in any case */
27 #include "periph_cpu.h"
28 #include "kernel_defines.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
46 #ifndef ADC_GPIOS
47 #define ADC_GPIOS { }
48 #endif
49 
53 static const gpio_t adc_channels[] = ADC_GPIOS;
54 
63 #define ADC_NUMOF ARRAY_SIZE(adc_channels)
64 
78 #ifndef DAC_GPIOS
79 #define DAC_GPIOS { }
80 #endif
81 
85 static const gpio_t dac_channels[] = DAC_GPIOS;
86 
95 #define DAC_NUMOF ARRAY_SIZE(dac_channels)
96 
106 static const i2c_conf_t i2c_config[] = {
107  #if defined(I2C0_SCL) && defined(I2C0_SDA) && defined(I2C0_SPEED)
108  {
109  .speed = I2C0_SPEED,
110  .scl = I2C0_SCL,
111  .sda = I2C0_SDA,
112  },
113  #endif
114  #if defined(I2C1_SCL) && defined(I2C1_SDA) && defined(I2C1_SPEED)
115  {
116  .speed = I2C1_SPEED,
117  .scl = I2C1_SCL,
118  .sda = I2C1_SDA,
119  },
120  #endif
121 };
122 
131 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
132 
143 #ifdef PWM0_GPIOS
144 static const gpio_t pwm0_channels[] = PWM0_GPIOS;
145 #endif
146 
149 #ifdef PWM1_GPIOS
150 static const gpio_t pwm1_channels[] = PWM1_GPIOS;
151 #endif
152 
161 #if defined(PWM0_GPIOS) && defined(PWM1_GPIOS)
162 #define PWM_NUMOF (2)
163 #elif defined(PWM0_GPIOS) || defined(PWM1_GPIOS)
164 #define PWM_NUMOF (1)
165 #else
166 #define PWM_NUMOF (0)
167 #endif
168 
178 static const spi_conf_t spi_config[] = {
179 #ifdef SPI0_CTRL
180  {
181  .ctrl = SPI0_CTRL,
182  .sck = SPI0_SCK,
183  .mosi = SPI0_MOSI,
184  .miso = SPI0_MISO,
185  .cs = SPI0_CS0,
186  },
187 #endif
188 #ifdef SPI1_CTRL
189  {
190  .ctrl = SPI1_CTRL,
191  .sck = SPI1_SCK,
192  .mosi = SPI1_MOSI,
193  .miso = SPI1_MISO,
194  .cs = SPI1_CS0,
195  },
196 #endif
197 };
198 
207 #define SPI_NUMOF ARRAY_SIZE(spi_config)
208 
215 #ifndef UART0_TXD
216 #define UART0_TXD (GPIO1)
217 #endif
218 #ifndef UART0_RXD
219 #define UART0_RXD (GPIO3)
220 #endif
221 
225 static const uart_conf_t uart_config[] = {
226  {
227  .txd = UART0_TXD,
228  .rxd = UART0_RXD,
229  },
230  #if defined(UART1_TXD) && defined(UART1_RXD)
231  {
232  .txd = UART1_TXD,
233  .rxd = UART1_RXD,
234  },
235  #endif
236  #if defined(UART2_TXD) && defined(UART2_RXD)
237  {
238  .txd = UART2_TXD,
239  .rxd = UART2_RXD,
240  },
241  #endif
242 };
243 
252 #define UART_NUMOF ARRAY_SIZE(uart_config)
253 
255 #ifdef __cplusplus
256 } /* end extern "C" */
257 #endif
258 
259 #endif /* PERIPH_CONF_COMMON_H */
260 
SPI1_MISO
#define SPI1_MISO
HSPI MISO.
Definition: periph_conf.h:161
SPI0_SCK
#define SPI0_SCK
HSPI / SPI_DEV(0) SCK pin.
Definition: periph_conf_common.h:154
SPI0_CS0
#define SPI0_CS0
HSPI / SPI_DEV(0) CS default pin, only used when cs parameter in spi_acquire is GPIO_UNDEF.
Definition: periph_conf_common.h:157
PWM1_GPIOS
#define PWM1_GPIOS
PWM_DEV(1) is not used.
Definition: periph_conf.h:111
kernel_defines.h
Common macros and compiler attributes/pragmas configuration.
dac_channels
static const gpio_t dac_channels[]
Static array with declared DAC channels.
Definition: periph_conf_common.h:85
uart_conf_t::txd
gpio_t txd
GPIO used as TxD pin.
Definition: periph_cpu.h:556
I2C0_SPEED
#define I2C0_SPEED
I2C bus speed of I2C_DEV(0)
Definition: periph_conf.h:84
UART0_RXD
#define UART0_RXD
RxD of UART_DEV(0) used on all ESP32 boards.
Definition: periph_conf_common.h:219
I2C0_SCL
#define I2C0_SCL
SCL signal of I2C_DEV(0) [UEXT1].
Definition: periph_conf.h:87
SPI1_CTRL
#define SPI1_CTRL
HSPI is used as SPI_DEV(1)
Definition: periph_conf.h:155
SPI1_CS0
#define SPI1_CS0
HSPI CS0.
Definition: periph_conf.h:167
SPI0_MOSI
#define SPI0_MOSI
HSPI / SPI_DEV(0) MOSI pin.
Definition: periph_conf_common.h:153
uart_config
static const uart_conf_t uart_config[]
Static array with configuration for declared UART devices.
Definition: periph_conf_common.h:225
spi_conf_t::ctrl
spi_ctrl_t ctrl
SPI controller used for the interface.
Definition: periph_cpu.h:482
SPI1_MOSI
#define SPI1_MOSI
HSPI MOSI.
Definition: periph_conf.h:164
UART1_RXD
@ UART1_RXD
UART1 RXD.
Definition: cc2538_gpio.h:282
UART1_TXD
@ UART1_TXD
UART1 TXD.
Definition: cc2538_gpio.h:253
PWM0_GPIOS
#define PWM0_GPIOS
PWM channels for device PWM_DEV(0)
Definition: periph_conf.h:106
uart_conf_t
UART device configuration.
Definition: periph_cpu.h:166
UART0_TXD
#define UART0_TXD
TxD of UART_DEV(0) used on all ESP32 boards.
Definition: periph_conf_common.h:216
adc_channels
static const gpio_t adc_channels[]
Static array with declared ADC channels.
Definition: periph_conf_common.h:53
SPI0_MISO
#define SPI0_MISO
HSPI / SPI_DEV(0) MISO pin.
Definition: periph_conf_common.h:152
ADC_GPIOS
#define ADC_GPIOS
Declaration of GPIOs that can be used as ADC channels.
Definition: periph_conf_common.h:47
SPI0_CTRL
#define SPI0_CTRL
HSPI / SPI_DEV(0) controller.
Definition: periph_conf_common.h:151
pwm0_channels
static const gpio_t pwm0_channels[]
Static array of GPIOs that can be used as channels of PWM_DEV(0)
Definition: periph_conf_common.h:111
spi_config
static const spi_conf_t spi_config[]
Static array with configuration for declared SPI devices.
Definition: periph_conf_common.h:178
I2C0_SDA
#define I2C0_SDA
SDA signal of I2C_DEV(0) [UEXT1].
Definition: periph_conf.h:90
DAC_GPIOS
#define DAC_GPIOS
Declaration of GPIOs that can be used as DAC channels.
Definition: periph_conf_common.h:79
i2c_config
static const i2c_conf_t i2c_config[]
Static array with configuration for declared I2C devices.
Definition: periph_conf_common.h:106
i2c_conf_t::speed
i2c_speed_t speed
baudrate used for the bus
Definition: periph_cpu.h:129
SPI1_SCK
#define SPI1_SCK
HSPI SCK.
Definition: periph_conf.h:158
i2c_conf_t
I2C configuration options.
Definition: periph_cpu.h:128
spi_conf_t
SPI configuration structure type.
Definition: periph_cpu.h:273