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 
static const spi_conf_t spi_config[]
Static array with configuration for declared SPI devices.
#define I2C0_SPEED
I2C bus speed of I2C_DEV(0)
Definition: periph_conf.h:81
I2C configuration options.
Definition: periph_cpu.h:128
#define DAC_GPIOS
Declaration of GPIOs that can be used as DAC channels.
#define UART0_TXD
TxD of UART_DEV(0) used on all ESP32 boards.
#define SPI0_MISO
HSPI / SPI_DEV(0) MISO pin.
static const gpio_t adc_channels[]
Static array with declared ADC channels.
#define SPI0_MOSI
HSPI / SPI_DEV(0) MOSI pin.
#define SPI0_CS0
HSPI / SPI_DEV(0) CS default pin, only used when cs parameter in spi_acquire is GPIO_UNDEF.
UART1 RXD.
Definition: cc2538_gpio.h:282
static const gpio_t pwm0_channels[]
Static array of GPIOs that can be used as channels of PWM_DEV(0)
#define SPI1_SCK
HSPI SCK.
Definition: periph_conf.h:158
#define SPI1_MOSI
HSPI MOSI.
Definition: periph_conf.h:164
#define ADC_GPIOS
Declaration of GPIOs that can be used as ADC channels.
#define SPI0_CTRL
HSPI / SPI_DEV(0) controller.
gpio_t txd
GPIO used as TxD pin.
Definition: periph_cpu.h:508
static const i2c_conf_t i2c_config[]
Static array with configuration for declared I2C devices.
#define I2C0_SDA
SDA signal of I2C_DEV(0) [UEXT1].
Definition: periph_conf.h:87
spi_ctrl_t ctrl
SPI controller used for the interface.
Definition: periph_cpu.h:434
#define UART0_RXD
RxD of UART_DEV(0) used on all ESP32 boards.
#define SPI1_CS0
HSPI CS0.
Definition: periph_conf.h:167
UART1 TXD.
Definition: cc2538_gpio.h:253
static const uart_conf_t uart_config[]
Static array with configuration for declared UART devices.
i2c_speed_t speed
baudrate used for the bus
Definition: periph_cpu.h:129
#define I2C0_SCL
SCL signal of I2C_DEV(0) [UEXT1].
Definition: periph_conf.h:84
Common macros and compiler attributes/pragmas configuration.
UART device configuration.
Definition: periph_cpu.h:166
#define SPI1_CTRL
HSPI is used as SPI_DEV(1)
Definition: periph_conf.h:155
#define PWM1_GPIOS
PWM_DEV(1) is not used.
Definition: periph_conf.h:108
#define PWM0_GPIOS
PWM channels for device PWM_DEV(0)
Definition: periph_conf.h:103
#define SPI0_SCK
HSPI / SPI_DEV(0) SCK pin.
SPI configuration structure type.
Definition: periph_cpu.h:271
#define SPI1_MISO
HSPI MISO.
Definition: periph_conf.h:161
static const gpio_t dac_channels[]
Static array with declared DAC channels.