Loading...
Searching...
No Matches
periph_conf_common.h File Reference

Configurations of the MCU periphery that are common for all ESP8266 boards. More...

Detailed Description

Configurations of the MCU periphery that are common for all ESP8266 boards.

Author
Gunar Schorcht gunar.nosp@m.@sch.nosp@m.orcht.nosp@m..net

Definition in file periph_conf_common.h.

#include "periph_cpu.h"
#include "kernel_defines.h"
+ Include dependency graph for periph_conf_common.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

#define BIT(X)   (1<<(X))
 

ADC configuration

ESP8266 provides one ADC pin that is broken out on all boards.

#define ADC_NUMOF   (1)
 number of ADC channels
 

DAC configuration

ESP8266 provides no DAC.

#define DAC_NUMOF   (0)
 number of DAC channels
 

I2C configuration

#define I2C_NUMOF   ARRAY_SIZE(i2c_config)
 Number of I2C interfaces.
 
static const i2c_conf_t i2c_config []
 Static array with configuration for declared I2C devices.
 

PWM configuration

The hardware implementation of ESP8266 PWM supports only frequencies as power of two.

Therefore a software implementation of one PWM device PWM_DEV(0) with up to 8 PWM channels (PWM_CHANNEL_NUM_MAX) is used. The GPIOs that can be used as PWM channels are defined by PWM0_GPIOS in board definition.

Note
The minimum PWM period that can be realized is 10 us or 100.000 PWM clock cycles per second. Therefore, the product of frequency and resolution should not be greater than 100.000. Otherwise the frequency is scaled down automatically.
#define PWM_NUMOF   (1)
 Number of PWM devices.
 
static const gpio_t pwm0_channels [] = PWM0_GPIOS
 Static array of GPIOs that can be used as channels of PWM_DEV(0)
 

SPI configuration

ESP8266 has two SPI controllers:

  • CSPI for caching and accessing the flash memory
  • HSPI for peripherals

Thus, HSPI is the only SPI interface that is available for peripherals. It is exposed as RIOT's SPI_DEV(0). Furthermore, the pin configuration of the HSPI interface is fixed as shown in following table.

Signal Pin
SPI0_MISO GPIO12
SPI0_MOSI GPIO13
SPI0_SCK GPIO14
SPI0_CS0 GPIOn with n = 0, 2, 4, 5, 15, 16 (additionally 9, 10 in DOUT flash mode)

The only pin definition that can be overridden by an application-specific board configuration is the CS signal defined by SPI0_CS0.

#define SPI0_DEV   SPI_DEV(0)
 HSPI / SPI_DEV(0) device.
 
#define SPI0_CTRL   HSPI
 HSPI / SPI_DEV(0) controller.
 
#define SPI0_MISO   GPIO12
 HSPI / SPI_DEV(0) MISO pin.
 
#define SPI0_MOSI   GPIO13
 HSPI / SPI_DEV(0) MOSI pin.
 
#define SPI0_SCK   GPIO14
 HSPI / SPI_DEV(0) SCK pin.
 
#define SPI0_CS0   GPIO15
 HSPI / SPI_DEV(0) CS default pin, only used when cs parameter in spi_acquire is GPIO_UNDEF.
 
#define SPI_NUMOF   ARRAY_SIZE(spi_config)
 Number of SPI interfaces.
 
static const spi_conf_t spi_config []
 Static array with configuration for declared SPI devices.
 

Timer configuration

#define TIMER_NUMOF   (1U)
 number of timer devices
 
#define TIMER_CHANNEL_NUMOF   (1U)
 number of channels per timer device
 

UART configuration

All ESP8266 boards have two UART devices with two options of pin mappings each, however most board will only expose only UART0 and in the GPIO1 and GPIO3 pins, although other combinations are possible.

In particular, the boot ROM will map both GPIO1 and GPIO2 as TX for UART0 on boot, so either one can be used for serial communication or flashing the device. While UART1 is also available, the only option for UART1 RX pin (GPIO8) is used for the board flash, but UART1 TX can be used separately

Pin mapping available: UART0 TX: GPIO1 and GPIO2 (both enabled by the boot ROM) UART0 RX: GPIO3 UART1 TX: GPIO2 and GPIO7 (GPIO7 is used by the flash) UART0 RX: GPIO8 (GPIO8 is used by the flash)

UART0 device is used for flashing and as a console interface. UART1 if UART1_TXD is defined can be used for communication with other peripherals at a different baudrate if desired.

#define UART0_TXD   GPIO1
 TxD pin of UART_DEV(0)
 
#define UART0_RXD   GPIO3
 RxD pin of UART_DEV(0)
 
#define UART1_TXD   GPIO2
 TxD pin of UART_DEV(1)
 
#define UART1_RXD   GPIO_UNDEF
 RxD pin of UART_DEV(1)
 
#define UART_NUMOF   ARRAY_SIZE(uart_config)
 Number of UART interfaces.
 
static const uart_conf_t uart_config []
 Static array with configuration for declared UART devices.
 

Macro Definition Documentation

◆ ADC_NUMOF

#define ADC_NUMOF   (1)

number of ADC channels

Definition at line 39 of file periph_conf_common.h.

◆ BIT

#define BIT (   X)    (1<<(X))

Definition at line 30 of file periph_conf_common.h.

◆ DAC_NUMOF

#define DAC_NUMOF   (0)

number of DAC channels

Definition at line 48 of file periph_conf_common.h.

◆ I2C_NUMOF

#define I2C_NUMOF   ARRAY_SIZE(i2c_config)

Number of I2C interfaces.

The number of I2C interfaces is determined automatically from board-specific peripheral definitions.

Note
I2C_NUMOF definition must not be changed.

Definition at line 84 of file periph_conf_common.h.

◆ PWM_NUMOF

#define PWM_NUMOF   (1)

Number of PWM devices.

The number of PWM devices is determined from the PWM0_GPIOS definition.

Note
PWM_NUMOF definition must not be changed. Number of PWM devices

Definition at line 118 of file periph_conf_common.h.

◆ SPI0_CS0

#define SPI0_CS0   GPIO15

HSPI / SPI_DEV(0) CS default pin, only used when cs parameter in spi_acquire is GPIO_UNDEF.

Definition at line 156 of file periph_conf_common.h.

◆ SPI0_CTRL

#define SPI0_CTRL   HSPI

HSPI / SPI_DEV(0) controller.

Definition at line 149 of file periph_conf_common.h.

◆ SPI0_DEV

#define SPI0_DEV   SPI_DEV(0)

HSPI / SPI_DEV(0) device.

Definition at line 148 of file periph_conf_common.h.

◆ SPI0_MISO

#define SPI0_MISO   GPIO12

HSPI / SPI_DEV(0) MISO pin.

Definition at line 150 of file periph_conf_common.h.

◆ SPI0_MOSI

#define SPI0_MOSI   GPIO13

HSPI / SPI_DEV(0) MOSI pin.

Definition at line 151 of file periph_conf_common.h.

◆ SPI0_SCK

#define SPI0_SCK   GPIO14

HSPI / SPI_DEV(0) SCK pin.

Definition at line 152 of file periph_conf_common.h.

◆ SPI_NUMOF

#define SPI_NUMOF   ARRAY_SIZE(spi_config)

Number of SPI interfaces.

The number of SPI interfaces is determined from board-specific peripheral definitions of SPIn_*.

Note
SPI_NUMOF definition must not be changed.

Definition at line 182 of file periph_conf_common.h.

◆ TIMER_CHANNEL_NUMOF

#define TIMER_CHANNEL_NUMOF   (1U)

number of channels per timer device

Definition at line 200 of file periph_conf_common.h.

◆ TIMER_NUMOF

#define TIMER_NUMOF   (1U)

number of timer devices

Definition at line 199 of file periph_conf_common.h.

◆ UART0_RXD

#define UART0_RXD   GPIO3

RxD pin of UART_DEV(0)

Definition at line 233 of file periph_conf_common.h.

◆ UART0_TXD

#define UART0_TXD   GPIO1

TxD pin of UART_DEV(0)

Definition at line 229 of file periph_conf_common.h.

◆ UART1_RXD

#define UART1_RXD   GPIO_UNDEF

RxD pin of UART_DEV(1)

Definition at line 241 of file periph_conf_common.h.

◆ UART1_TXD

#define UART1_TXD   GPIO2

TxD pin of UART_DEV(1)

Definition at line 237 of file periph_conf_common.h.

◆ UART_NUMOF

#define UART_NUMOF   ARRAY_SIZE(uart_config)

Number of UART interfaces.

The number of UART interfaces is determined from board-specific peripheral definitions of UARTn_*.

Note
UART_NUMOF definition must not be changed.

Definition at line 268 of file periph_conf_common.h.

Variable Documentation

◆ i2c_config

const i2c_conf_t i2c_config[]
static
Initial value:
= {
}

Static array with configuration for declared I2C devices.

Definition at line 59 of file periph_conf_common.h.

◆ pwm0_channels

const gpio_t pwm0_channels[] = PWM0_GPIOS
static

Static array of GPIOs that can be used as channels of PWM_DEV(0)

Definition at line 109 of file periph_conf_common.h.

◆ spi_config

const spi_conf_t spi_config[]
static
Initial value:
= {
{
.ctrl = SPI0_CTRL,
.sck = SPI0_SCK,
.mosi = SPI0_MOSI,
.miso = SPI0_MISO,
.cs = SPI0_CS0,
},
}
#define SPI0_MOSI
HSPI / SPI_DEV(0) MOSI pin.
#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.
#define SPI0_MISO
HSPI / SPI_DEV(0) MISO pin.

Static array with configuration for declared SPI devices.

Definition at line 162 of file periph_conf_common.h.

◆ uart_config

const uart_conf_t uart_config[]
static
Initial value:
= {
{
.txd = UART0_TXD,
.rxd = UART0_RXD,
},
{
.txd = UART1_TXD,
.rxd = UART1_RXD,
},
}
#define UART1_TXD
TxD pin of UART_DEV(1)
#define UART1_RXD
RxD pin of UART_DEV(1)
#define UART0_RXD
RxD of UART_DEV(0) used on all ESP32 boards.
#define UART0_TXD
TxD of UART_DEV(0) used on all ESP32 boards.

Static array with configuration for declared UART devices.

Definition at line 247 of file periph_conf_common.h.