periph_cpu.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 
19 #ifndef PERIPH_CPU_H
20 #define PERIPH_CPU_H
21 
22 #include <stdint.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
32 #define PROVIDES_PM_SET_LOWEST
33 #define PROVIDES_PM_RESTART
34 #define PROVIDES_PM_OFF
35 #define PROVIDES_PM_LAYERED_OFF
36 
40 #define PM_NUM_MODES (2U)
41 
46 #define ESP_PM_MODEM_SLEEP (2U)
47 #define ESP_PM_LIGHT_SLEEP (1U)
48 #define ESP_PM_DEEP_SLEEP (0U)
49 
56 #define CPUID_LEN (7U)
57 
69 #define HAVE_GPIO_T
70 typedef unsigned int gpio_t;
77 #define GPIO_UNDEF (0xffffffff)
78 
84 #define GPIO_PIN(x, y) ((x & 0) | y)
85 
91 #define PORT_GPIO (0)
92 
98 #define GPIO_PIN_NUMOF (40)
99 
101 #ifndef DOXYGEN
102 
107 #define HAVE_GPIO_FLANK_T
108 typedef enum {
109  GPIO_NONE = 0,
110  GPIO_RISING = 1,
111  GPIO_FALLING = 2,
112  GPIO_BOTH = 3,
113  GPIO_LOW = 4,
114  GPIO_HIGH = 5
115 } gpio_flank_t;
116 
124 #define HAVE_GPIO_MODE_T
125 typedef enum {
126  GPIO_IN,
127  GPIO_IN_PD,
128  GPIO_IN_PU,
129  GPIO_OUT,
130  GPIO_OD,
131  GPIO_OD_PU,
132  GPIO_IN_OUT,
133  GPIO_IN_OD,
134  GPIO_IN_OD_PU
135 } gpio_mode_t;
137 #endif /* ndef DOXYGEN */
138 
144 #define GPIO0 (GPIO_PIN(PORT_GPIO,0))
145 #define GPIO1 (GPIO_PIN(PORT_GPIO,1))
146 #define GPIO2 (GPIO_PIN(PORT_GPIO,2))
147 #define GPIO3 (GPIO_PIN(PORT_GPIO,3))
148 #define GPIO4 (GPIO_PIN(PORT_GPIO,4))
149 #define GPIO5 (GPIO_PIN(PORT_GPIO,5))
150 #define GPIO6 (GPIO_PIN(PORT_GPIO,6))
151 #define GPIO7 (GPIO_PIN(PORT_GPIO,7))
152 #define GPIO8 (GPIO_PIN(PORT_GPIO,8))
153 #define GPIO9 (GPIO_PIN(PORT_GPIO,9))
154 #define GPIO10 (GPIO_PIN(PORT_GPIO,10))
155 #define GPIO11 (GPIO_PIN(PORT_GPIO,11))
156 #define GPIO12 (GPIO_PIN(PORT_GPIO,12))
157 #define GPIO13 (GPIO_PIN(PORT_GPIO,13))
158 #define GPIO14 (GPIO_PIN(PORT_GPIO,14))
159 #define GPIO15 (GPIO_PIN(PORT_GPIO,15))
160 #define GPIO16 (GPIO_PIN(PORT_GPIO,16))
161 #define GPIO17 (GPIO_PIN(PORT_GPIO,17))
162 #define GPIO18 (GPIO_PIN(PORT_GPIO,18))
163 #define GPIO19 (GPIO_PIN(PORT_GPIO,19))
164 /* GPIO 20 is not available */
165 #define GPIO21 (GPIO_PIN(PORT_GPIO,21))
166 #define GPIO22 (GPIO_PIN(PORT_GPIO,22))
167 #define GPIO23 (GPIO_PIN(PORT_GPIO,23))
168 /* GPIO 24 is not available */
169 #define GPIO25 (GPIO_PIN(PORT_GPIO,25))
170 #define GPIO26 (GPIO_PIN(PORT_GPIO,26))
171 #define GPIO27 (GPIO_PIN(PORT_GPIO,27))
172 /* GPIOs 28 ...32 are not available */
173 #define GPIO32 (GPIO_PIN(PORT_GPIO,32))
174 #define GPIO33 (GPIO_PIN(PORT_GPIO,33))
175 /* GPIOs 34 ... 39 can only be used as inputs and do not have pullups/pulldowns */
176 #define GPIO34 (GPIO_PIN(PORT_GPIO,34))
177 #define GPIO35 (GPIO_PIN(PORT_GPIO,35))
178 #define GPIO36 (GPIO_PIN(PORT_GPIO,36))
179 #define GPIO37 (GPIO_PIN(PORT_GPIO,37))
180 #define GPIO38 (GPIO_PIN(PORT_GPIO,38))
181 #define GPIO39 (GPIO_PIN(PORT_GPIO,39))
182 
240 #ifndef DOXYGEN
241 
244 #define HAVE_ADC_RES_T
245 typedef enum {
246  ADC_RES_6BIT = 0xf0,
247  ADC_RES_8BIT = 0xf1,
248  ADC_RES_9BIT = 0,
249  ADC_RES_10BIT = 1,
250  ADC_RES_11BIT = 2,
251  ADC_RES_12BIT = 3,
252  ADC_RES_14BIT = 0xf2,
253  ADC_RES_16BIT = 0xf3,
254 } adc_res_t;
256 #endif /* ndef DOXYGEN */
257 
265 #define ADC_NUMOF_MAX 16
266 
296 #define DAC_NUMOF_MAX 2
297 
324 #ifndef DOXYGEN
325 
331 #define HAVE_I2C_SPEED_T
332 typedef enum {
333  I2C_SPEED_LOW = 0,
338 } i2c_speed_t;
340 #endif /* ndef DOXYGEN */
341 
345 typedef struct {
346  i2c_speed_t speed;
347  gpio_t scl;
348  gpio_t sda;
349 } i2c_conf_t;
350 
354 #define I2C_NUMOF_MAX (2)
355 
356 #define PERIPH_I2C_NEED_READ_REG
357 #define PERIPH_I2C_NEED_READ_REGS
358 #define PERIPH_I2C_NEED_WRITE_REG
359 #define PERIPH_I2C_NEED_WRITE_REGS
392 #define PWM_NUMOF_MAX (2)
393 
397 #define PWM_CHANNEL_NUM_DEV_MAX (6)
398 
409 #define RNG_DATA_REG_ADDR (0x3ff75144)
410 
424 #define RTT_FREQUENCY (32768UL)
425 
429 #define RTT_MAX_VALUE (0xFFFFFFFFUL)
430 
473 typedef enum {
474  HSPI = 2,
475  VSPI = 3,
476 } spi_ctrl_t;
477 
481 typedef struct {
483  gpio_t sck;
484  gpio_t mosi;
485  gpio_t miso;
486  gpio_t cs;
487 } spi_conf_t;
488 
492 #define SPI_NUMOF_MAX 2
493 
494 #define PERIPH_SPI_NEEDS_TRANSFER_BYTE
495 #define PERIPH_SPI_NEEDS_TRANSFER_REG
496 #define PERIPH_SPI_NEEDS_TRANSFER_REGS
507 #ifdef MODULE_ESP_HW_COUNTER
508 
509 #define TIMER_NUMOF (2)
510 #define TIMER_CHANNEL_NUMOF (1)
511 #else
512 
513 #define TIMER_NUMOF (3)
514 #define TIMER_CHANNEL_NUMOF (1)
515 #endif
516 
518 #define TIMER_SYSTEM TIMERG0.hw_timer[0]
519 
525 #define PERIPH_TIMER_PROVIDES_SET
526 
555 typedef struct {
556  gpio_t txd;
557  gpio_t rxd;
558 } uart_conf_t;
559 
563 #define UART_NUMOF_MAX (3)
564 
566 #ifdef MODULE_PERIPH_CAN
567 #include "can_esp.h"
568 #endif
569 
570 #ifdef __cplusplus
571 }
572 #endif
573 
574 #endif /* PERIPH_CPU_H */
575 
ADC_RES_6BIT
@ ADC_RES_6BIT
ADC resolution: 6 bit.
Definition: adc.h:94
I2C_SPEED_LOW
@ I2C_SPEED_LOW
low speed mode: ~10 kbit/s
Definition: i2c.h:176
GPIO_IN_PD
@ GPIO_IN_PD
configure as input with pull-down resistor
Definition: gpio.h:120
GPIO_OD
@ GPIO_OD
configure as output in open-drain mode without pull resistor
Definition: gpio.h:123
I2C_SPEED_NORMAL
@ I2C_SPEED_NORMAL
normal mode: ~100 kbit/s
Definition: i2c.h:177
spi_ctrl_t
spi_ctrl_t
SPI controllers that can be used for peripheral interfaces.
Definition: periph_cpu.h:473
uart_conf_t::txd
gpio_t txd
GPIO used as TxD pin.
Definition: periph_cpu.h:556
ADC_RES_14BIT
@ ADC_RES_14BIT
ADC resolution: 14 bit.
Definition: adc.h:98
adc_res_t
adc_res_t
Possible ADC resolution settings.
Definition: adc.h:93
GPIO_OUT
@ GPIO_OUT
configure as output in push-pull mode
Definition: gpio.h:122
spi_conf_t::miso
gpio_t miso
GPIO used as MISO pin.
Definition: periph_cpu.h:485
ADC_RES_16BIT
@ ADC_RES_16BIT
ADC resolution: 16 bit.
Definition: adc.h:99
HSPI
@ HSPI
HSPI interface controller.
Definition: periph_cpu.h:474
i2c_speed_t
i2c_speed_t
Default mapping of I2C bus speed values.
Definition: i2c.h:175
spi_conf_t::ctrl
spi_ctrl_t ctrl
SPI controller used for the interface.
Definition: periph_cpu.h:482
ADC_RES_8BIT
@ ADC_RES_8BIT
ADC resolution: 8 bit.
Definition: adc.h:95
GPIO_FALLING
@ GPIO_FALLING
emit interrupt on falling flank
Definition: periph_cpu.h:81
spi_conf_t::mosi
gpio_t mosi
GPIO used as MOSI pin.
Definition: periph_cpu.h:484
GPIO_IN_PU
@ GPIO_IN_PU
configure as input with pull-up resistor
Definition: gpio.h:121
GPIO_RISING
@ GPIO_RISING
emit interrupt on rising flank
Definition: periph_cpu.h:82
GPIO_IN
@ GPIO_IN
configure as input without pull resistor
Definition: gpio.h:119
uart_conf_t
UART device configuration.
Definition: periph_cpu.h:166
i2c_conf_t::sda
gpio_t sda
GPIO used as SDA pin.
Definition: periph_cpu.h:348
uart_conf_t::rxd
gpio_t rxd
GPIO used as RxD pin.
Definition: periph_cpu.h:557
can_esp.h
gpio_flank_t
gpio_flank_t
Definition: periph_cpu.h:80
GPIO_OD_PU
@ GPIO_OD_PU
configure as output in open-drain mode with pull resistor enabled
Definition: gpio.h:125
i2c_conf_t::scl
gpio_t scl
GPIO used as SCL pin.
Definition: periph_cpu.h:347
spi_conf_t::sck
gpio_t sck
GPIO used as SCK pin.
Definition: periph_cpu.h:483
GPIO_BOTH
@ GPIO_BOTH
emit interrupt on both flanks
Definition: periph_cpu.h:83
gpio_mode_t
gpio_mode_t
Available pin modes.
Definition: periph_cpu.h:70
ADC_RES_10BIT
@ ADC_RES_10BIT
ADC resolution: 10 bit.
Definition: adc.h:96
ADC_RES_12BIT
@ ADC_RES_12BIT
ADC resolution: 12 bit.
Definition: adc.h:97
gpio_t
unsigned int gpio_t
GPIO type identifier.
Definition: gpio.h:91
i2c_conf_t
I2C configuration options.
Definition: periph_cpu.h:128
I2C_SPEED_FAST_PLUS
@ I2C_SPEED_FAST_PLUS
fast plus mode: ~1000 kbit/s
Definition: i2c.h:179
I2C_SPEED_FAST
@ I2C_SPEED_FAST
fast mode: ~400 kbit/s
Definition: i2c.h:178
VSPI
@ VSPI
VSPI interface controller.
Definition: periph_cpu.h:475
I2C_SPEED_HIGH
@ I2C_SPEED_HIGH
high speed mode: ~3400 kbit/s
Definition: i2c.h:180
spi_conf_t
SPI configuration structure type.
Definition: periph_cpu.h:273
spi_conf_t::cs
gpio_t cs
GPIO used as CS0 pin.
Definition: periph_cpu.h:486