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 
9 #pragma once
10 
20 /* include board.h and periph_cpu.h to make them visible in any case */
21 #include "periph_cpu.h"
22 #include "kernel_defines.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #ifndef BIT
29 #define BIT(X) (1<<(X))
30 #endif
31 
38 #define ADC_NUMOF (1)
47 #define DAC_NUMOF (0)
58 static const i2c_conf_t i2c_config[] = {
59  #if defined(I2C0_SCL) && defined(I2C0_SDA) && defined(I2C0_SPEED)
60  {
61  .speed = I2C0_SPEED,
62  .scl = I2C0_SCL,
63  .sda = I2C0_SDA,
64  },
65  #endif
66  #if defined(I2C1_SCL) && defined(I2C1_SDA) && defined(I2C1_SPEED)
67  {
68  .speed = I2C1_SPEED,
69  .scl = I2C1_SCL,
70  .sda = I2C1_SDA,
71  },
72  #endif
73 };
74 
83 #define I2C_NUMOF ARRAY_SIZE(i2c_config)
84 
104 #if defined(PWM0_GPIOS) || defined(DOXYGEN)
108 static const gpio_t pwm0_channels[] = PWM0_GPIOS;
109 
117 #define PWM_NUMOF (1)
119 #endif /* defined(PWM0_GPIOS) || defined(DOXYGEN) */
147 #define SPI0_DEV SPI_DEV(0)
148 #define SPI0_CTRL HSPI
149 #define SPI0_MISO GPIO12
150 #define SPI0_MOSI GPIO13
151 #define SPI0_SCK GPIO14
153 #ifndef SPI0_CS0
154 #define SPI0_CS0 GPIO15
156 #endif
157 
161 static const spi_conf_t spi_config[] = {
162 #ifdef SPI0_CTRL
163  {
164  .ctrl = SPI0_CTRL,
165  .sck = SPI0_SCK,
166  .mosi = SPI0_MOSI,
167  .miso = SPI0_MISO,
168  .cs = SPI0_CS0,
169  },
170 #endif
171 };
172 
181 #define SPI_NUMOF ARRAY_SIZE(spi_config)
182 
189 #if defined(MODULE_ESP_SW_TIMER)
190 
191 /* software timer */
192 #define TIMER_NUMOF (1U)
193 #define TIMER_CHANNEL_NUMOF (10U)
195 #else /* MODULE_ESP_SW_TIMER */
196 
197 /* hardware timer */
198 #define TIMER_NUMOF (1U)
199 #define TIMER_CHANNEL_NUMOF (1U)
201 #endif /* MODULE_ESP_SW_TIMER */
227 #ifndef UART0_TXD
228 #define UART0_TXD GPIO1
229 #endif /* UART0_TXD */
230 
231 #ifndef UART0_RXD
232 #define UART0_RXD GPIO3
233 #endif /* UART0_RXD */
234 
235 #ifdef DOXYGEN
236 #define UART1_TXD GPIO2
237 #endif /* DOXYGEN */
238 
239 #ifndef UART1_RXD
240 #define UART1_RXD GPIO_UNDEF
241 #endif /* UART1_RXD */
242 
246 static const uart_conf_t uart_config[] = {
247  {
248  .txd = UART0_TXD,
249  .rxd = UART0_RXD,
250  },
251 #ifdef UART1_TXD
252  {
253  .txd = UART1_TXD,
254  .rxd = UART1_RXD,
255  },
256 #endif /* UART1_TXD */
257 };
258 
267 #define UART_NUMOF ARRAY_SIZE(uart_config)
270 #ifdef __cplusplus
271 } /* end extern "C" */
272 #endif
273 
#define I2C0_SPEED
I2C bus speed of I2C_DEV(0)
Definition: periph_conf.h:65
#define I2C0_SCL
SCL signal of I2C_DEV(0)
Definition: periph_conf.h:68
#define I2C0_SDA
SDA signal of I2C_DEV(0)
Definition: periph_conf.h:71
static const gpio_t pwm0_channels[]
Static array of GPIOs that can be used as channels of PWM_DEV(0)
static const uart_conf_t uart_config[]
Static array with configuration for declared UART devices.
#define SPI0_MOSI
HSPI / SPI_DEV(0) MOSI pin.
#define UART0_RXD
RxD pin of UART_DEV(0)
#define UART1_TXD
TxD pin of UART_DEV(1)
#define SPI0_CTRL
HSPI / SPI_DEV(0) controller.
#define SPI0_CS0
HSPI / SPI_DEV(0) CS default pin, only used when cs parameter in spi_acquire is GPIO_UNDEF.
#define SPI0_SCK
HSPI / SPI_DEV(0) SCK pin.
static const spi_conf_t spi_config[]
Static array with configuration for declared SPI devices.
#define UART1_RXD
RxD pin of UART_DEV(1)
static const i2c_conf_t i2c_config[]
Static array with configuration for declared I2C devices.
#define SPI0_MISO
HSPI / SPI_DEV(0) MISO pin.
#define UART0_TXD
TxD pin of UART_DEV(0)
Common macros and compiler attributes/pragmas configuration.
I2C configuration structure.
Definition: periph_cpu.h:298
i2c_speed_t speed
Configured bus speed, actual speed may be lower but never higher.
Definition: periph_cpu.h:303
SPI device configuration.
Definition: periph_cpu.h:336
spi_ctrl_t ctrl
SPI controller used for the interface.
Definition: periph_cpu.h:860
UART device configuration.
Definition: periph_cpu.h:217
gpio_t txd
GPIO used as TxD pin.
Definition: periph_cpu.h:973