1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 05:12:57 +01:00

boards/esp8266: changes for RTOS SDK

This commit is contained in:
Gunar Schorcht 2019-09-05 14:32:59 +02:00
parent ddc91df4ca
commit 7d9a3a79a2
12 changed files with 259 additions and 100 deletions

View File

@ -10,3 +10,4 @@ FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_pwm
FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += periph_uart_modecfg

View File

@ -16,9 +16,12 @@
* @author Gunar Schorcht <gunar@schorcht.net>
*/
#include "board_common.h"
#include "board.h"
#include "esp_common.h"
#include "log.h"
#include "periph/gpio.h"
#include "esp_libc.h"
#include "rom/ets_sys.h"
#ifdef __cplusplus
extern "C" {
@ -40,35 +43,69 @@ void board_init(void)
#endif
}
extern void adc_print_config(void);
extern void dac_print_config(void);
extern void pwm_print_config(void);
extern void i2c_print_config(void);
extern void spi_print_config(void);
extern void uart_print_config(void);
extern void timer_print_config(void);
extern void can_print_config(void);
void board_print_config (void)
{
LOG_INFO("\nBoard configuration:\n");
ets_printf("\nBoard configuration:\n");
#if MODULE_PERIPH_ADC
adc_print_config();
#endif
#if MODULE_PERIPH_DAC
dac_print_config();
#endif
#if MODULE_PERIPH_PWM
pwm_print_config();
#endif
#if MODULE_PERIPH_I2C
i2c_print_config();
#endif
#if MODULE_PERIPH_SPI
spi_print_config();
#endif
#if MODULE_PERIPH_UART
uart_print_config();
#endif
#if MODULE_PERIPH_TIMER
timer_print_config();
#endif
#ifdef MODULE_ESP_CAN
can_print_config();
#endif
LOG_INFO("\tLED: pins=[ ");
ets_printf("\tLED\t\tpins=[ ");
#ifdef LED0_PIN
LOG_INFO("%d ", LED0_PIN);
ets_printf("%d ", LED0_PIN);
#endif
#ifdef LED1_PIN
LOG_INFO("%d ", LED1_PIN);
ets_printf("%d ", LED1_PIN);
#endif
#ifdef LED2_PIN
LOG_INFO("%d ", LED2_PIN);
ets_printf("%d ", LED2_PIN);
#endif
LOG_INFO("]\n");
ets_printf("]\n");
LOG_INFO("\n\n");
ets_printf("\tBUTTON\t\tpins=[ ");
#ifdef BUTTON0_PIN
ets_printf("%d ", BUTTON0_PIN);
#endif
#ifdef BUTTON2_PIN
ets_printf("%d ", BUTTON1_PIN);
#endif
#ifdef BUTTON3_PIN
ets_printf("%d ", BUTTON2_PIN);
#endif
ets_printf("]\n");
ets_printf("\n");
}
#ifdef __cplusplus

View File

@ -17,6 +17,9 @@
* @{
*/
/* not required when compiling ESP vendor code parts */
#ifndef ESP_PLATFORM
#include <stdint.h>
#include "cpu.h"
@ -124,7 +127,7 @@ extern mtd_dev_t *mtd0;
* initializations are done during the CPU initialization that is called from
* boot loader.
*/
extern void board_init(void);
void board_init (void);
/**
* @brief Print the board configuration in a human readable format
@ -140,4 +143,5 @@ void board_print_config (void);
/** @} */
#endif /* ESP_PLATFORM */
#endif /* BOARD_COMMON_H */

View File

@ -53,13 +53,13 @@ extern "C" {
#define ENC28J60_PARAM_SPI SPI_DEV(0) /**< SPI_DEV(0) is used (fixed) */
#ifndef ENC28J60_PARAM_CS
#define ENC28J60_PARAM_CS GPIO4 /**< ENC28J60 CS signal (can be overriden) */
#define ENC28J60_PARAM_CS GPIO4 /**< ENC28J60 CS signal (can be overridden) */
#endif
#ifndef ENC28J60_PARAM_INT
#define ENC28J60_PARAM_INT GPIO9 /**< ENC28J60 INT signal (can be overriden) */
#define ENC28J60_PARAM_INT GPIO9 /**< ENC28J60 INT signal (can be overridden) */
#endif
#ifndef ENC28J60_PARAM_RESET
#define ENC28J60_PARAM_RESET GPIO10 /**< ENC28J60 RESET signal (can be overriden) */
#define ENC28J60_PARAM_RESET GPIO10 /**< ENC28J60 RESET signal (can be overridden) */
#endif
/** @} */
#endif /* defined(MODULE_ENC28J60) || defined(DOXYGEN) */
@ -82,16 +82,16 @@ extern "C" {
#define MRF24J40_PARAM_SPI SPI_DEV(0) /**< SPI_DEV(0) is used (fixed) */
#ifndef MRF24J40_PARAM_SPI_CLK
#define MRF24J40_PARAM_SPI_CLK SPI_CLK_1MHZ /**< SPI bus speed used (can be overriden) */
#define MRF24J40_PARAM_SPI_CLK SPI_CLK_1MHZ /**< SPI bus speed used (can be overridden) */
#endif
#ifndef MRF24J40_PARAM_CS
#define MRF24J40_PARAM_CS GPIO16 /**< MRF24J40 CS signal (can be overriden) */
#define MRF24J40_PARAM_CS GPIO16 /**< MRF24J40 CS signal (can be overridden) */
#endif
#ifndef MRF24J40_PARAM_INT
#define MRF24J40_PARAM_INT GPIO0 /**< MRF24J40 INT signal (can be overriden) */
#define MRF24J40_PARAM_INT GPIO0 /**< MRF24J40 INT signal (can be overridden) */
#endif
#ifndef MRF24J40_PARAM_RESET
#define MRF24J40_PARAM_RESET GPIO2 /**< MRF24J40 RESET signal (can be overriden) */
#define MRF24J40_PARAM_RESET GPIO2 /**< MRF24J40 RESET signal (can be overridden) */
#endif
/** @} */
#endif /* defined(MODULE_MRF24J40) || defined(DOXYGEN) */
@ -109,14 +109,14 @@ extern "C" {
* If not defined, the default CS signal of SPI_DEV(0) is used.
* @{
*/
#define SDCARD_SPI_PARAM_SPI SPI_DEV(0) /**< SPI_DEV(0) is used (fixed) */
#define SDCARD_SPI_PARAM_CLK SPI0_SCK_GPIO /**< SPI_DEV(0) SCK is used (fixed) */
#define SDCARD_SPI_PARAM_MOSI SPI0_MOSI_GPIO /**< SPI_DEV(0) MOSI is used (fixed) */
#define SDCARD_SPI_PARAM_MISO SPI0_MISO_GPIO /**< SPI_DEV(0) MISO is used (fixed) */
#define SDCARD_SPI_PARAM_POWER GPIO_UNDEF /**< power control is not used (fixed) */
#define SDCARD_SPI_PARAM_SPI SPI_DEV(0) /**< SPI_DEV(0) is used (fixed) */
#define SDCARD_SPI_PARAM_CLK SPI0_SCK /**< SPI_DEV(0) SCK is used (fixed) */
#define SDCARD_SPI_PARAM_MOSI SPI0_MOSI /**< SPI_DEV(0) MOSI is used (fixed) */
#define SDCARD_SPI_PARAM_MISO SPI0_MISO /**< SPI_DEV(0) MISO is used (fixed) */
#define SDCARD_SPI_PARAM_POWER GPIO_UNDEF /**< power control is not used (fixed) */
#ifndef SDCARD_SPI_PARAM_CS
#define SDCARD_SPI_PARAM_CS SPI0_CS0_GPIO /**< SD-Card CS signal (can be overridden) */
#define SDCARD_SPI_PARAM_CS SPI0_CS0 /**< SD-Card CS signal (can be overridden) */
#endif
/** @} */
#endif /* defined(MODULE_SDCARD_SPI) || defined(DOXYGEN) */

View File

@ -19,8 +19,8 @@
#define PERIPH_CONF_COMMON_H
/* include board.h and periph_cpu.h to make them visible in any case */
#include "board.h"
#include "periph_cpu.h"
#include "kernel_defines.h"
#ifdef __cplusplus
extern "C" {
@ -36,16 +36,65 @@ extern "C" {
* ESP8266 provides one ADC pin that is broken out on all boards.
* @{
*/
#define ADC_NUMOF 1 /**< number of ADC channels */
#define ADC_NUMOF (1) /**< number of ADC channels */
/** @} */
/**
* @name DAC configuration
*
* ESP8266 provides no DAC.
* @{
*/
#define DAC_NUMOF (0) /**< number of DAC channels */
/** @} */
/**
* @name I2C configuration
* @{
*/
/**
* @brief Static array with configuration for declared I2C devices
*/
static const i2c_conf_t i2c_config[] = {
#if defined(I2C0_SCL) && defined(I2C0_SDA) && defined(I2C0_SPEED)
{
.speed = I2C0_SPEED,
.scl = I2C0_SCL,
.sda = I2C0_SDA,
},
#endif
#if defined(I2C1_SCL) && defined(I2C1_SDA) && defined(I2C1_SPEED)
{
.speed = I2C1_SPEED,
.scl = I2C1_SCL,
.sda = I2C1_SDA,
},
#endif
};
/**
* @brief 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.
*/
#define I2C_NUMOF ARRAY_SIZE(i2c_config)
/** @} */
/**
* @name 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 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 minumum PWM period that can be realized is 10 us or 100.000 PWM
* clock cycles per second. Therefore, the product of frequency and resolution
@ -55,71 +104,85 @@ extern "C" {
* @{
*/
#if defined(PWM0_GPIOS) || defined(DOXYGEN)
/**
* @brief Static array of GPIOs that can be used as channels of PWM_DEV(0)
*/
static const gpio_t pwm0_channels[] = PWM0_GPIOS;
/**
* @brief Number of PWM devices
*
* The number of PWM devices is determined from the #PWM0_GPIOS definition.
*
* @note #PWM_NUMOF definition must not be changed.
*/
#define PWM_NUMOF (1) /**< Number of PWM devices */
/**
* @brief Maximum number of channels per PWM device.
*/
#define PWM_CHANNEL_NUM_MAX (8)
/**
* @brief Definition of GPIOs that can be used as PWM channels
* of device PWM_DEV(0).
*
* The following definition is just an example configuration. Declare up to
* \ref PWM_CHANNEL_NUM_MAX GPIOs as PWM channels. GPIOs with a duty cycle
* value of 0 can be used as normal GPIOs for other purposes. GPIOs in the
* list that are used for other purposes, e.g., I2C or SPI, are then not
* available as PWM channels.
*/
#ifndef PWM0_CHANNEL_GPIOS
#define PWM0_CHANNEL_GPIOS { GPIO2, GPIO4, GPIO5 }
#endif
/** Alternative device definition */
#define PWM0_DEV PWM_DEV(0)
#endif /* defined(PWM0_GPIOS) || defined(DOXYGEN) */
/** @} */
/**
* @name SPI configuration
* @name SPI configuration
*
* ESP8266 provides two hardware SPI interfaces:
* ESP8266 has two SPI controllers:
*
* _FSPI_ for flash memory and usually simply referred to as _SPI_<br>
* _HSPI_ for peripherals
* - _CSPI_ for caching and accessing the flash memory<br>
* - _HSPI_ for peripherals
*
* Even though _FSPI_ (or simply _SPI_) is a normal SPI interface, it is not
* possible to use it for peripherals. _HSPI_ is therefore the only usable
* SPI interface available for peripherals as RIOT's SPI_DEV(0).
* 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.
*
* The pin configuration of the _HSPI_ interface SPI_DEV(0) is fixed. The
* only pin definition that can be overridden by an application-specific
* board configuration is the CS signal defined by SPI0_CS0_GPIO.
* 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.
*
* Signal | Pin
* ----------------|-------
* SPI_DEV(0).MISO | GPIO12
* SPI_DEV(0).MOSI | GPIO13
* SPI_DEV(0).SCK | GPIO14
* SPI_DEV(0).CS | GPIOn with n = 0, 2, 4, 5, 15, 16 (additionally 9, 10 in DOUT flash mode)
* @{
*/
#if defined(MODULE_PERIPH_SPI) || defined(DOXYGEN)
#define SPI_NUMOF 1 /**< Number of SPI interfaces */
#define SPI_DEV(x) ((unsigned int)(x+1)) /**< SPI_DEV to SPI hardware mapping */
#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_DEV SPI_DEV(0) /**< HSPI / SPI_DEV(0) device */
#define SPI0_MISO_GPIO GPIO12 /**< HSPI / SPI_DEV(0) MISO pin */
#define SPI0_MOSI_GPIO GPIO13 /**< HSPI / SPI_DEV(0) MOSI pin */
#define SPI0_SCK_GPIO GPIO14 /**< HSPI / SPI_DEV(0) SCK pin */
#ifndef SPI0_CS0_GPIO
#define SPI0_CS0_GPIO GPIO15 /**< HSPI / SPI_DEV(0) CS default pin, only used when cs
parameter in spi_acquire is GPIO_UNDEF */
#ifndef SPI0_CS0
#define SPI0_CS0 GPIO15 /**< HSPI / SPI_DEV(0) CS default pin, only used when cs
parameter in spi_acquire is #GPIO_UNDEF */
#endif
#endif /* defined(MODULE_PERIPH_SPI) || defined(DOXYGEN) */
/**
* @brief Static array with configuration for declared SPI devices
*/
static const spi_conf_t spi_config[] = {
#ifdef SPI0_CTRL
{
.ctrl = SPI0_CTRL,
.sck = SPI0_SCK,
.mosi = SPI0_MOSI,
.miso = SPI0_MISO,
.cs = SPI0_CS0,
},
#endif
};
/**
* @brief 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.
*/
#define SPI_NUMOF ARRAY_SIZE(spi_config)
/** @} */
/**
@ -153,9 +216,29 @@ extern "C" {
*
* @{
*/
#define UART_NUMOF 1 /**< Number of UART devices */
#define UART0_TXD GPIO1 /**< TxD pin of UART_DEV(0) */
#define UART0_RXD GPIO3 /**< RxD pin of UART_DEV(0) */
/**
* @brief Static array with configuration for declared UART devices
*/
static const uart_conf_t uart_config[] = {
{
.txd = UART0_TXD,
.rxd = UART0_RXD,
},
};
/**
* @brief 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.
*/
#define UART_NUMOF (sizeof(uart_config)/sizeof(uart_config[0]))
/** @} */
#ifdef __cplusplus

View File

@ -82,7 +82,7 @@ D1 mini Pro | ESP8266EX | 16 MByte | ceramic | |
Following image shows the pinout of all WEMOS LOLIN D1 mini boards. It is compatible with the WEMOS LOLIN D32 Pro ESP32 board.
@image html "https://gitlab.com/gschorcht/RIOT.wiki-Images/raw/master/esp8266/Wemos_D1_mini_pinout.png?inline=false" "WEMOS LOLIN D1 min pinout"<br>
@image html "https://gitlab.com/gschorcht/RIOT.wiki-Images/raw/master/esp8266/Wemos_D1_mini_pinout.png?inline=false" "WEMOS LOLIN D1 mini pinout"<br>
## <a name="nodemcu_devkit_esp8266"> NodeMCU DEVKIT </a>

View File

@ -6,10 +6,6 @@
* directory for more details.
*/
/**
* @ingroup boards_esp8266_esp-12x
*/
/**
* @ingroup boards_esp8266_esp-12x
* @brief Board specific definitions for ESP-12x based boards.

View File

@ -27,9 +27,6 @@ extern "C" {
* @name I2C configuration
* @{
*/
#ifndef I2C_NUMOF
#define I2C_NUMOF (1) /**< Number of I2C interfaces */
#endif
#ifndef I2C0_SPEED
#define I2C0_SPEED I2C_SPEED_FAST /**< I2C bus speed of I2C_DEV(0) */
#endif
@ -41,6 +38,25 @@ extern "C" {
#endif
/** @} */
/**
* @name PWM channel configuration
*
* @{
*/
/**
* @brief Declaration of the channels for device PWM_DEV(0),
* at maximum 8 channels.
*
* @note As long as PWM_DEV(0) is not initialized with \ref pwm_init, the GPIOs
* declared as PWM channels can be used for other purposes.
*/
#ifndef PWM0_GPIOS
#define PWM0_GPIOS { GPIO0, GPIO2, GPIO16 }
#endif
/** @} */
#ifdef __cplusplus
} /* end extern "C" */
#endif

View File

@ -6,10 +6,6 @@
* directory for more details.
*/
/**
* @ingroup boards_esp8266_olimex-mod
*/
/**
* @ingroup boards_esp8266_olimex-mod
* @brief Board specific definitions for

View File

@ -28,9 +28,6 @@
* @name I2C configuration
* @{
*/
#ifndef I2C_NUMOF
#define I2C_NUMOF (1) /**< Number of I2C interfaces */
#endif
#ifndef I2C0_SPEED
#define I2C0_SPEED I2C_SPEED_FAST /**< I2C bus speed of I2C_DEV(0) */
#endif
@ -42,6 +39,23 @@
#endif
/** @} */
/**
* @name PWM channel configuration
*
* @{
*/
/**
* @brief Declaration of the channels for device PWM_DEV(0),
* at maximum 8 channels.
*
* @note As long as PWM_DEV(0) is not initialized with \ref pwm_init, the GPIOs
* declared as PWM channels can be used for other purposes.
*/
#ifndef PWM0_GPIOS
#define PWM0_GPIOS { GPIO0, GPIO5, GPIO16 }
#endif
#ifdef __cplusplus
} /* end extern "C" */
#endif

View File

@ -6,10 +6,6 @@
* directory for more details.
*/
/**
* @ingroup boards_esp8266_sparkfun-thing
*/
/**
* @ingroup boards_esp8266_sparkfun-thing
* @brief Board specific definitions for

View File

@ -28,9 +28,6 @@
* @name I2C configuration
* @{
*/
#ifndef I2C_NUMOF
#define I2C_NUMOF (1) /**< Number of I2C interfaces */
#endif
#ifndef I2C0_SPEED
#define I2C0_SPEED I2C_SPEED_FAST /**< I2C bus speed of I2C_DEV(0) */
#endif
@ -42,6 +39,25 @@
#endif
/** @} */
/**
* @name PWM channel configuration
*
* @{
*/
/**
* @brief Declaration of the channels for device PWM_DEV(0),
* at maximum 8 channels.
*
* @note As long as PWM_DEV(0) is not initialized with \ref pwm_init, the GPIOs
* declared as PWM channels can be used for other purposes.
*/
#ifndef PWM0_GPIOS
#define PWM0_GPIOS { GPIO0, GPIO4, GPIO5 }
#endif
/** @} */
#ifdef __cplusplus
} /* end extern "C" */
#endif