1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

boards/esp32c3: add ESP32-C3-DevKit board definition

This commit is contained in:
Gunar Schorcht 2022-03-21 02:28:59 +01:00
parent f8c060e291
commit aa55f90311
12 changed files with 611 additions and 0 deletions

View File

@ -0,0 +1,23 @@
# Copyright (c) 2020 HAW Hamburg
# 2022 Gunar Schorcht
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.
config BOARD
default "esp32c3-devkit" if BOARD_ESP32C3_DEVKIT
config BOARD_ESP32C3_DEVKIT
bool
default y
select BOARD_COMMON_ESP32C3
select CPU_MODEL_ESP32C3_MINI_1X
select HAS_ARDUINO
select HAS_ESP_JTAG
select HAS_PERIPH_ADC
select HAS_PERIPH_I2C
select HAS_PERIPH_PWM
select HAS_PERIPH_SPI
source "$(RIOTBOARD)/common/esp32c3/Kconfig"

View File

@ -0,0 +1,5 @@
MODULE = board
DIRS = $(RIOTBOARD)/common/esp32c3
include $(RIOTBASE)/Makefile.base

View File

@ -0,0 +1 @@
include $(RIOTBOARD)/common/esp32c3/Makefile.dep

View File

@ -0,0 +1,15 @@
CPU_MODEL = esp32c3_mini_1x
# common board and CPU features
include $(RIOTBOARD)/common/esp32c3/Makefile.features
# additional features provided by the board
FEATURES_PROVIDED += periph_adc
FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_pwm
FEATURES_PROVIDED += periph_spi
# unique features provided by the board
FEATURES_PROVIDED += esp_jtag
FEATURES_PROVIDED += arduino

View File

@ -0,0 +1 @@
include $(RIOTBOARD)/common/esp32c3/Makefile.include

View File

@ -0,0 +1,154 @@
/*
* Copyright (C) 2022 Gunar Schorcht
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup boards_esp32c3_devkit ESP32-C3-DevKit Board
* @ingroup boards_esp32c3
* @brief Support for generic ESP32-C3 boards
* @author Gunar Schorcht <gunar@schorcht.net>
\section esp32c3_devkit ESP32-C3-DevKit
## Table of Contents {#esp32c3_devkit_toc}
1. [Overview](#esp32c3_devkit_overview)
2. [Hardware](#esp32c3_devkit_hardware)
1. [MCU](#esp32c3_devkit_mcu)
2. [Board Configuration](#esp32c3_devkit_board_configuration)
3. [Board Pinout](#esp32c3_devkit_pinout)
3. [Flashing the Device](#esp32c3_devkit_flashing)
## Overview {#esp32c3_devkit_overview}
The Espressif ESP32-C3-DevKit boards are a couple of boards that use one of
the following modules:
- ESP32-C3-MINI-1x module (ESP32-C3-DevKitM-1 board)
- ESP32-C3-WROOM-02x module (ESP32-C3-DevKitC-02 board)
Since the number of GPIOs and their possible uses on the ESP32-C3 are quite
limited, the ESP32-C3-DevKit should also work for most other ESP32-C3 boards.
Any modifications required for specific applications could be overridden by
\ref esp32_application_specific_configurations "application-specific board configuration".
\image html "https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/_images/esp32-c3-devkitm-1-v1-annotated-photo.png" "Espressif ESP32-C3-DevKitM-1" width=800px
[Back to table of contents](#esp32c3_devkit_toc)
## Hardware {#esp32c3_devkit_hardware}
This section describes
- the [MCU](#esp32c3_devkit_mcu),
- the default [board configuration](#esp32c3_devkit_board_configuration),
- [optional hardware configurations](#esp32c3_devkit_optional_hardware),
- the [board pinout](#esp32c3_devkit_pinout).
[Back to table of contents](#esp32c3_devkit_toc)
### MCU {#esp32c3_devkit_mcu}
Most features of the board are provided by the ESP32-C3 SoC. For detailed
information about the ESP32-C3 variant (family) and ESP32x SoCs,
see section \ref esp32_mcu_esp32 "ESP32 SoC Series".
[Back to table of contents](#esp32c3_devkit_toc)
### Board Configuration {#esp32c3_devkit_board_configuration}
ESP32-C3-DevKit boards have no special hardware on board with the exception
of a single pin RGB-LED that uses a special bit-oriented protocol to
control the RGB-LED by 24-bit RGB values which is not supported yet.
All GPIOs are simply broken out for flexibility. Therefore, the board
configuration is the most flexible one which provides:
- 6 x ADC channels at maximum
- 1 x SPI
- 1 x I2C
- 2 x UART
- 1 RGB-LED
Since all GPIOs have broken out, GPIOs can be used for different purposes
in different applications. For flexibility, GPIOs can be listed in multiple
peripheral configurations, but they can only be used for one peripheral
at a time. For example, GPIO4 is used in the ADC channel definition, the
PWM channel definition and the definition of the SCL signal for I2C_DEV(0).
This is possible because GPIOs are only used for a specific peripheral
interface when either
- the corresponding peripheral module is used, e.g. `periph_i2c` and
`periph_spi`, or
- the corresponding init function is called, e.g. `adc_init` and
`pwm_init`.
That is, the purpose for which a GPIO is used depends on which module
or function is used first.
For example, if module `periph_i2c` is not used, the GPIOs listed in I2C
configuration can be used for the other purposes, that is, GPIO4 can be
used as ADC channel or PWM channel.
The following table shows the default board configuration, which is sorted
according to the defined functionality of GPIOs. This configuration can be
overridden by \ref esp32_application_specific_configurations
"application-specific configurations".
<center>
Function | GPIOs | Remarks |Configuration
:---------------|:-------|:--------|:----------------------------------
BUTTON0 | GPIO9 | | |
ADC | GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5 | | see \ref esp32_adc_channels "ADC Channels"
PWM_DEV(0) | GPIO3, GPIO4 | - | \ref esp32_pwm_channels "PWM Channels"
I2C_DEV(0):SCL | GPIO4 | | \ref esp32_i2c_interfaces "I2C Interfaces"
I2C_DEV(0):SDA | GPIO5 | | \ref esp32_i2c_interfaces "I2C Interfaces"
SPI_DEV(0):CLK | GPIO6 | SPI2_HOST (FSPI) is used | \ref esp32_spi_interfaces "SPI Interfaces"
SPI_DEV(0):MISO | GPIO2 | SPI2_HOST (FSPI) is used | \ref esp32_spi_interfaces "SPI Interfaces"
SPI_DEV(0):MOSI | GPIO7 | SPI2_HOST (FSPI) is used | \ref esp32_spi_interfaces "SPI Interfaces"
SPI_DEV(0):CS0 | GPIO10 | SPI2_HOST (FSPI) is used | \ref esp32_spi_interfaces "SPI Interfaces"
UART_DEV(0):TxD | GPIO21 | Console (configuration is fixed) | \ref esp32_uart_interfaces "UART interfaces"
UART_DEV(0):RxD | GPIO20 | Console (configuration is fixed) | \ref esp32_uart_interfaces "UART interfaces"
</center>
\n
@note The configuration of ADC channels contains all ESP32-C3 GPIOs that could
be used as ADC channels.
For detailed information about the peripheral configurations of ESP32-C3
boards, see section \ref esp32_peripherals "Common Peripherals".
[Back to table of contents](#esp32c3_devkit_toc)
### Board Pinout {#esp32c3_devkit_pinout}
The following figures show the pinouts as configured by default board
definition.
@image html https://gitlab.com/gschorcht/RIOT.wiki-Images/-/raw/master/esp32/ESP32-C3-DevKitM-1_pinout.png "EPS32-C3-DevKitM-1x Pinout"
@image html https://gitlab.com/gschorcht/RIOT.wiki-Images/-/raw/master/esp32/ESP32-C3-DevKitC-02_pinout.png "EPS32-C3-DevKitC-02x Pinout"
The corresponding board schematics can be found:
- [ESP32-C3-DevKitM-1](https://dl.espressif.com/dl/schematics/SCH_ESP32-C3-DEVKITM-1_V1_20200915A.pdf)
- [ESP32-C3-DevKitC-02](https://dl.espressif.com/dl/schematics/SCH_ESP32-C3-DEVKITC-02_V1_1_20210126A.pdf)
[Back to table of contents](#esp32c3_devkit_toc)
## Flashing the Device {#esp32c3_devkit_flashing}
Flashing RIOT is quite easy. The board has a Micro-USB connector with
reset/boot/flash logic. Just connect the board to your host computer
and type using the programming port:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make flash BOARD=esp32c3-devkit ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For detailed information about ESP32-C3 as well as configuring and compiling
RIOT for ESP32-C3 boards, see \ref esp32_riot.
[Back to table of contents](#esp32c3_devkit_toc)
*/

View File

@ -0,0 +1,38 @@
/*
* Copyright (C) 2022 Gunar Schorcht
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup boards_esp32c3_devkit
* @{
*
* @file
* @brief Board specific configuration for the Arduino API
*
* @author Gunar Schorcht <gunar@schorcht.net>
*/
#ifndef ARDUINO_BOARD_H
#define ARDUINO_BOARD_H
#include "arduino_board_common.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief The on-board LED is not available
*/
#define ARDUINO_LED (0)
#ifdef __cplusplus
}
#endif
#endif /* ARDUINO_BOARD_H */
/** @} */

View File

@ -0,0 +1,71 @@
/*
* Copyright (C) 2022 Gunar Schorcht
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup boards_esp32c3_devkit
* @{
*
* @file
* @brief Mapping from MCU pins to Arduino pins
*
* @author Gunar Schorcht <gunar@schorcht.net>
*/
#ifndef ARDUINO_PINMAP_H
#define ARDUINO_PINMAP_H
#include "periph/gpio.h"
#include "periph/adc.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name Mapping of MCU pins to Arduino pins
* @{
*/
#define ARDUINO_PIN_0 GPIO20 /**< Arduino Uno pin 0 (RxD) */
#define ARDUINO_PIN_1 GPIO21 /**< Arduino Uno pin 1 (TxD) */
#if !defined(MODULE_ESP_RTC_TIMER_32K)
#define ARDUINO_PIN_2 GPIO0 /**< Arduino Uno pin 2 */
#define ARDUINO_PIN_3 GPIO1 /**< Arduino Uno pin 3 (PWM) */
#else
#define ARDUINO_PIN_2 GPIO_UNDEF /**< Arduino Uno pin 2 */
#endif
#define ARDUINO_PIN_4 GPIO_UNDEF /**< Arduino Uno pin 4 */
#define ARDUINO_PIN_5 GPIO3 /**< Arduino Uno pin 5 (PWM) */
#define ARDUINO_PIN_6 GPIO4 /**< Arduino Uno pin 6 (PWM) */
#define ARDUINO_PIN_7 GPIO8 /**< Arduino Uno pin 7 */
#define ARDUINO_PIN_8 GPIO_UNDEF /**< Arduino Uno pin 8 */
#define ARDUINO_PIN_9 GPIO_UNDEF /**< Arduino Uno pin 9 (PWM) */
#define ARDUINO_PIN_10 GPIO10 /**< Arduino Uno pin 10 (CS0 / PWM) */
#define ARDUINO_PIN_11 GPIO7 /**< Arduino Uno pin 11 (MOSI / PWM) */
#define ARDUINO_PIN_12 GPIO2 /**< Arduino Uno pin 12 (MISO) */
#define ARDUINO_PIN_13 GPIO6 /**< Arduino Uno pin 13 (SCK) */
#define ARDUINO_PIN_A0 GPIO0 /**< Arduino Uno pin A0 */
#if !defined(MODULE_ESP_RTC_TIMER_32K)
#define ARDUINO_PIN_A1 GPIO1 /**< Arduino Uno pin A1 */
#else
#define ARDUINO_PIN_A1 GPIO_UNDEF /**< Arduino Uno pin A1 */
#endif
#define ARDUINO_PIN_A2 GPIO2 /**< Arduino Uno pin A2 */
#define ARDUINO_PIN_A3 GPIO3 /**< Arduino Uno pin A3 */
#define ARDUINO_PIN_A4 GPIO5 /**< Arduino Uno pin A4 (SDA) */
#define ARDUINO_PIN_A5 GPIO4 /**< Arduino Uno pin A5 (SCL) */
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* ARDUINO_PINMAP_H */
/** @} */

View File

@ -0,0 +1,95 @@
/*
* Copyright (C) 2022 Gunar Schorcht
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup boards_esp32c3_devkit
* @brief Board definitions for ESP32-C3-DevKit boards
* @{
*
* The board definitions in this file are valid for Espressif
* ESP32-C3-DevKitx boards that use one of the following modules:
*
* - ESP32-C3-MINI-1x module (ESP32-C3-DevKitM-1 board)
* - ESP32-C3-WROOM-02x module (ESP32-C3-DevKitC-02 board)
*
* Since the number of GPIOs and their possible uses on the ESP32-C3 are quite
* limited, these board definitions can also be used for most other
* ESP32-C3 boards. Any modifications required for specific applications
* can be overridden by \ref esp32_application_specific_configurations
* "application-specific board configuration".
*
* @file
* @author Gunar Schorcht <gunar@schorcht.net>
*/
#ifndef BOARD_H
#define BOARD_H
#include <stdint.h>
/**
* @name Button pin definitions
* @{
*/
/**
* @brief Default button GPIO pin definition
*
* ESP32-C3-DevKit boards have a BOOT button connected to GPIO9, which can be
* used as button during normal operation. Since the GPIO9 pin is pulled up,
* the button signal is inverted, i.e., pressing the button will give a
* low signal.
*/
#define BTN0_PIN GPIO9
/**
* @brief Default button GPIO mode definition
*
* Since the GPIO of the button is pulled up with an external resistor, the
* mode for the GPIO pin has to be GPIO_IN.
*/
#define BTN0_MODE GPIO_IN_PU
/**
* @brief Default interrupt flank definition for the button GPIO
*/
#ifndef BTN0_INT_FLANK
#define BTN0_INT_FLANK GPIO_FALLING
#endif
/**
* @brief Definition for compatibility with previous versions
*/
#define BUTTON0_PIN BTN0_PIN
/** @} */
/**
* @name LED (on-board) configuration
*
* ESP32-C3-DevKit boards have a SK68XXMINI-HS smart RGB-LED connected to
* GPIO8 on-board. This RGB-LEDs uses a special bit-oriented protocol to
* control the RGB-LED by 24-bit RGB values. Therefore, it can't be used as
* default LED definition for RIOT.
* @{
*/
/** @} */
/* include common board definitions as last step */
#include "board_common.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __cplusplus
} /* end extern "C" */
#endif
#endif /* BOARD_H */
/** @} */

View File

@ -0,0 +1,45 @@
/*
* Copyright (C) 2018 Gunar Schorcht
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
#ifndef GPIO_PARAMS_H
#define GPIO_PARAMS_H
/**
* @ingroup boards_esp32c3_devkit
* @brief Board specific configuration of direct mapped GPIOs
* @file
* @author Gunar Schorcht <gunar@schorcht.net>
* @{
*/
#include "board.h"
#include "saul/periph.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief LED and Button configuration
*/
static const saul_gpio_params_t saul_gpio_params[] =
{
{
.name = "BOOT",
.pin = BTN0_PIN,
.mode = BTN0_MODE,
.flags = SAUL_GPIO_INVERTED
},
};
#ifdef __cplusplus
}
#endif
#endif /* GPIO_PARAMS_H */
/** @} */

View File

@ -0,0 +1,161 @@
/*
* Copyright (C) 2022 Gunar Schorcht
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @ingroup boards_esp32c3_devkit
* @brief Peripheral configurations for ESP32-C3-DevKit boards
* @{
*
* The peripheral configurations in this file are valid for Espressif
* ESP32-C3-DevKitx boards that use one of the following modules:
*
* - ESP32-C3-MINI-1x module (ESP32-C3-DevKitM-1 board)
* - ESP32-C3-WROOM-02x module (ESP32-C3-DevKitC-02 board)
*
* Since the number of GPIOs and their possible uses on the ESP32-C3 are quite
* limited, these peripheral configurations can also be used for most other
* ESP32-C3 boards. Any modifications required for specific applications
* can be overridden by \ref esp32_application_specific_configurations
* "application-specific board configuration".
*
* For detailed information about the peripheral configuration for ESP32-C3
* boards, see section \ref esp32_peripherals "Common Peripherals".
*
* @note
* Most definitions can be overridden by an \ref esp32_application_specific_configurations
* "application-specific board configuration" if necessary.
*
* @file
* @author Gunar Schorcht <gunar@schorcht.net>
*/
#ifndef PERIPH_CONF_H
#define PERIPH_CONF_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name ADC and DAC channel configuration
* @{
*/
/**
* @brief Declaration of GPIOs that can be used as ADC channels
*
* For generic boards, all ADC pins that have broken out are declared as ADC
* channels.
*
* @note As long as the GPIOs listed in ADC_GPIOS are not initialized as ADC
* channels with the `adc_init` function, they can be used for other
* purposes.
*/
#ifndef ADC_GPIOS
#define ADC_GPIOS { GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5 }
#endif
/** @} */
/**
* @name I2C configuration
*
* For generic boards, only one I2C interface I2C_DEV(0) is defined.
*
* The GPIOs listed in the configuration are only initialized as I2C signals
* when module `periph_i2c` is used. Otherwise they are not allocated and
* can be used for other purposes.
*
* @{
*/
#ifndef I2C0_SPEED
#define I2C0_SPEED I2C_SPEED_FAST /**< I2C bus speed of I2C_DEV(0) */
#endif
#ifndef I2C0_SCL
#define I2C0_SCL GPIO4 /**< SCL signal of I2C_DEV(0) */
#endif
#ifndef I2C0_SDA
#define I2C0_SDA GPIO5 /**< SDA signal of I2C_DEV(0) */
#endif
/** @} */
/**
* @name PWM channel configuration
*
* For generic boards, two PWM devices are configured. These devices
* contain all GPIOs that are not defined as I2C, SPI or UART for this board.
* Generally, all outputs pins could be used as PWM channels.
*
* @note As long as the according PWM device is not initialized with
* the `pwm_init`, the GPIOs declared for this device can be used
* for other purposes.
*
* @{
*/
/**
* @brief Declaration of the channels for device PWM_DEV(0),
* at maximum PWM_CHANNEL_NUM_DEV_MAX.
*/
#ifndef PWM0_GPIOS
#define PWM0_GPIOS { GPIO3, GPIO4 }
#endif
/** @} */
/**
* @name SPI configuration
*
* @note The GPIOs listed in the configuration are first initialized as SPI
* signals when the corresponding SPI interface is used for the first time
* by either calling the `spi_init_cs` function or the `spi_acquire`
* function. That is, they are not allocated as SPI signals before and can
* be used for other purposes as long as the SPI interface is not used.
* @{
*/
#ifndef SPI0_CTRL
#define SPI0_CTRL FSPI /**< FSPI is used as SPI_DEV(0) */
#endif
#ifndef SPI0_SCK
#define SPI0_SCK GPIO6 /**< FSPI SCK (pin FSPICLK) */
#endif
#ifndef SPI0_MISO
#define SPI0_MISO GPIO2 /**< FSPI MISO (pin FSPIQ) */
#endif
#ifndef SPI0_MOSI
#define SPI0_MOSI GPIO7 /**< FSPI MOSI (pin FSPID) */
#endif
#ifndef SPI0_CS0
#define SPI0_CS0 GPIO10 /**< FSPI CS0 (pin FSPICS0) */
#endif
/** @} */
/**
* @name UART configuration
*
* ESP32-C3 provides 2 UART interfaces at maximum:
*
* UART_DEV(0) uses fixed standard configuration.<br>
* UART_DEV(1) is not used.<br>
*
* @{
*/
#define UART0_TXD GPIO21 /**< direct I/O pin for UART_DEV(0) TxD, can't be changed */
#define UART0_RXD GPIO20 /**< direct I/O pin for UART_DEV(0) RxD, can't be changed */
/** @} */
#ifdef __cplusplus
} /* end extern "C" */
#endif
/* include common peripheral definitions as last step */
#include "periph_conf_common.h"
#endif /* PERIPH_CONF_H */
/** @} */

View File

@ -14969,6 +14969,8 @@ pkg/nimble/autoadv/include/nimble_autoadv_params\.h:[0-9]+: warning: Member NIMB
pkg/nimble/autoadv/include/nimble_autoadv_params\.h:[0-9]+: warning: Member NIMBLE_AUTOADV_PARAMS \(macro definition\) of file nimble_autoadv_params\.h is not documented\.
cpu/esp32/include/periph_cpu_esp32\.h:[0-9]+: warning: Member GPIO[0-9]+ \(macro definition\) of file periph_cpu_esp32\.h is not documented.
cpu/esp32/include/periph_cpu_esp32c3\.h:[0-9]+: warning: Member GPIO[0-9]+ \(macro definition\) of file periph_cpu_esp32c3\.h is not documented.
boards/common/esp32c3/include/board_common.h:[0-9]+: warning: Member LED[0-9]_[A-Z]+ \(macro definition\) of file board_common\.h is not documented.
boards/common/esp32c3/include/board_common.h:[0-9]+: warning: Member SPIFFS_[_A-Z]+ \(macro definition\) of file board_common\.h is not documented.
boards/waveshare\-nrf52840\-eval\-kit/include/arduino_pinmap\.h:[0-9]+: warning: Member ARDUINO_PIN_[A0-9]+ \(macro definition\) of file arduino_pinmap\.h is not documented.
boards/waveshare\-nrf52840\-eval\-kit/include/arduino_pinmap\.h:[0-9]+: warning: Member ARDUINO_[A0-9]+ \(macro definition\) of file arduino_pinmap\.h is not documented.
boards/waveshare\-nrf52840\-eval\-kit/include/board\.h:[0-9]+: warning: Member LED0_PIN \(macro definition\) of file board\.h is not documented.