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 
18 #ifndef PERIPH_CONF_COMMON_H
19 #define PERIPH_CONF_COMMON_H
20 
21 /* include board.h and periph_cpu.h to make them visible in any case */
22 #include "periph_cpu.h"
23 #include "kernel_defines.h"
24 
25 #ifdef __cplusplus
26 extern "C" {
27 #endif
28 
29 #ifndef BIT
30 #define BIT(X) (1<<(X))
31 #endif
32 
39 #define ADC_NUMOF (1)
49 #define DAC_NUMOF (0)
61 static const i2c_conf_t i2c_config[] = {
62  #if defined(I2C0_SCL) && defined(I2C0_SDA) && defined(I2C0_SPEED)
63  {
64  .speed = I2C0_SPEED,
65  .scl = I2C0_SCL,
66  .sda = I2C0_SDA,
67  },
68  #endif
69  #if defined(I2C1_SCL) && defined(I2C1_SDA) && defined(I2C1_SPEED)
70  {
71  .speed = I2C1_SPEED,
72  .scl = I2C1_SCL,
73  .sda = I2C1_SDA,
74  },
75  #endif
76 };
77 
86 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
87 
107 #if defined(PWM0_GPIOS) || defined(DOXYGEN)
108 
111 static const gpio_t pwm0_channels[] = PWM0_GPIOS;
112 
120 #define PWM_NUMOF (1)
122 #endif /* defined(PWM0_GPIOS) || defined(DOXYGEN) */
123 
150 #define SPI0_DEV SPI_DEV(0)
151 #define SPI0_CTRL HSPI
152 #define SPI0_MISO GPIO12
153 #define SPI0_MOSI GPIO13
154 #define SPI0_SCK GPIO14
156 #ifndef SPI0_CS0
157 #define SPI0_CS0 GPIO15
159 #endif
160 
164 static const spi_conf_t spi_config[] = {
165 #ifdef SPI0_CTRL
166  {
167  .ctrl = SPI0_CTRL,
168  .sck = SPI0_SCK,
169  .mosi = SPI0_MOSI,
170  .miso = SPI0_MISO,
171  .cs = SPI0_CS0,
172  },
173 #endif
174 };
175 
184 #define SPI_NUMOF ARRAY_SIZE(spi_config)
185 
192 #if defined(MODULE_ESP_SW_TIMER)
193 
194 /* software timer */
195 #define TIMER_NUMOF (1U)
196 #define TIMER_CHANNEL_NUMOF (10U)
198 #else /* MODULE_ESP_SW_TIMER */
199 
200 /* hardware timer */
201 #define TIMER_NUMOF (1U)
202 #define TIMER_CHANNEL_NUMOF (1U)
204 #endif /* MODULE_ESP_SW_TIMER */
205 
220 #define UART0_TXD GPIO1
221 #define UART0_RXD GPIO3
226 static const uart_conf_t uart_config[] = {
227  {
228  .txd = UART0_TXD,
229  .rxd = UART0_RXD,
230  },
231 };
232 
241 #define UART_NUMOF ARRAY_SIZE(uart_config)
242 
244 #ifdef __cplusplus
245 } /* end extern "C" */
246 #endif
247 
248 #endif /* PERIPH_CONF_COMMON_H */
249 
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
kernel_defines.h
Common macros and compiler attributes/pragmas configuration.
I2C0_SPEED
#define I2C0_SPEED
I2C bus speed of I2C_DEV(0)
Definition: periph_conf.h:84
I2C0_SCL
#define I2C0_SCL
SCL signal of I2C_DEV(0) [UEXT1].
Definition: periph_conf.h:87
SPI0_MOSI
#define SPI0_MOSI
HSPI / SPI_DEV(0) MOSI pin.
Definition: periph_conf_common.h:153
spi_conf_t::ctrl
spi_ctrl_t ctrl
SPI controller used for the interface.
Definition: periph_cpu.h:482
PWM0_GPIOS
#define PWM0_GPIOS
PWM channels for device PWM_DEV(0)
Definition: periph_conf.h:106
UART0_RXD
#define UART0_RXD
RxD pin of UART_DEV(0)
Definition: periph_conf_common.h:221
UART0_TXD
#define UART0_TXD
TxD pin of UART_DEV(0)
Definition: periph_conf_common.h:220
SPI0_MISO
#define SPI0_MISO
HSPI / SPI_DEV(0) MISO pin.
Definition: periph_conf_common.h:152
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:164
I2C0_SDA
#define I2C0_SDA
SDA signal of I2C_DEV(0) [UEXT1].
Definition: periph_conf.h:90
spi_conf_t
SPI configuration structure type.
Definition: periph_cpu.h:273