diff --git a/boards/common/esp32x/include/arduino_board_common.h b/boards/common/esp32x/include/arduino_board_common.h deleted file mode 100644 index 0166c19d4b09..000000000000 --- a/boards/common/esp32x/include/arduino_board_common.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (C) 2023 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_common_esp32x - * @{ - * - * @file - * @brief Definitions for the Arduino API that are common for all ESP32x boards - * - * @author Gunar Schorcht - */ - -#ifndef ARDUINO_BOARD_COMMON_H -#define ARDUINO_BOARD_COMMON_H - -#include "arduino_pinmap.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** - * @brief Look-up table for the Arduino's digital pins - */ -static const gpio_t arduino_pinmap[] = { - ARDUINO_PIN_0, - ARDUINO_PIN_1, - ARDUINO_PIN_2, - ARDUINO_PIN_3, - ARDUINO_PIN_4, - ARDUINO_PIN_5, - ARDUINO_PIN_6, - ARDUINO_PIN_7, - ARDUINO_PIN_8, - ARDUINO_PIN_9, - ARDUINO_PIN_10, - ARDUINO_PIN_11, - ARDUINO_PIN_12, - ARDUINO_PIN_13, - ARDUINO_PIN_A0, - ARDUINO_PIN_A1, - ARDUINO_PIN_A2, - ARDUINO_PIN_A3, - ARDUINO_PIN_A4, - ARDUINO_PIN_A5 -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { - ARDUINO_PIN_A0, - ARDUINO_PIN_A1, - ARDUINO_PIN_A2, - ARDUINO_PIN_A3, - ARDUINO_PIN_A4, - ARDUINO_PIN_A5 -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_COMMON_H */ -/** @} */ diff --git a/boards/esp32-heltec-lora32-v2/Makefile.features b/boards/esp32-heltec-lora32-v2/Makefile.features index b16004dc0da8..221fe023f388 100644 --- a/boards/esp32-heltec-lora32-v2/Makefile.features +++ b/boards/esp32-heltec-lora32-v2/Makefile.features @@ -10,4 +10,9 @@ FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += esp_rtc_timer_32k +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_i2c FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_pwm +FEATURES_PROVIDED += arduino_spi +FEATURES_PROVIDED += arduino_uart diff --git a/boards/esp32-heltec-lora32-v2/doc.txt b/boards/esp32-heltec-lora32-v2/doc.txt index 5faa30f15bb7..e96515f13d3d 100644 --- a/boards/esp32-heltec-lora32-v2/doc.txt +++ b/boards/esp32-heltec-lora32-v2/doc.txt @@ -106,7 +106,7 @@ BTN0 | GPIO0 | low active | | LED0 | GPIO25 | high active | | ADC | GPIO36, GPIO39, GPIO37, GPIO38,\n GPIO0, GPIO2, GPIO12, GPIO13,\n GPIO4, GPIO15 | | \ref esp32_adc_channels "ADC Channels" DAC | | | \ref esp32_dac_channels "DAC Channels" -PWM_DEV(0) | GPIO25, GPIO0, GPIO2, GPIO17 | | \ref esp32_pwm_channels "PWM Channels" +PWM_DEV(0) | GPIO25, GPIO2, GPIO17 | | \ref esp32_pwm_channels "PWM Channels" PWM_DEV(1) | GPIO22, GPIO23 | | \ref esp32_pwm_channels "PWM Channels" I2C_DEV(0):SDA | GPIO4 | | \ref esp32_i2c_interfaces "I2C Interfaces" I2C_DEV(0):SCL | GPIO15 | I2C_SPEED_FAST is used | \ref esp32_i2c_interfaces "I2C Interfaces" @@ -220,7 +220,7 @@ The corresponding board schematics can be found [here for SX1276 version](https: and [here for SX1278 version](https://github.com/Heltec-Aaron-Lee/WiFi_Kit_series/blob/master/SchematicDiagram/WiFi_LoRa_32(V2)/WiFi_LoRa_32_V2(433%2C470-510).PDF). \anchor esp32_heltec_lora_32_v2_pinout_img -@image html "https://gitlab.com/gschorcht/RIOT.wiki-Images/raw/master/esp32/Heltec_WiFi_LoRa_32_V2_pinout.png" "WiFi LoRa 32 V2 Pintout Diagram" +@image html "https://gitlab.com/gschorcht/RIOT.wiki-Images/raw/master/esp32/Heltec_WiFi_LoRa_32_V2_pinout_v2.png" "WiFi LoRa 32 V2 Pintout Diagram" [Back to table of contents](#esp32_heltec_lora32_v2_toc) diff --git a/boards/esp32-heltec-lora32-v2/include/arduino_iomap.h b/boards/esp32-heltec-lora32-v2/include/arduino_iomap.h index 2dd774fa0c35..5eb8fb88aec1 100644 --- a/boards/esp32-heltec-lora32-v2/include/arduino_iomap.h +++ b/boards/esp32-heltec-lora32-v2/include/arduino_iomap.h @@ -26,6 +26,11 @@ extern "C" { #endif +#define ARDUINO_UART_D0D1 UART_DEV(0) /**< Arduino UART interface */ +#define ARDUINO_SPI_D11D12D13 SPI_DEV(0) /**< Arduino SPI bus */ + +#define ARDUINO_LED (3) /**< LED is connected to Arduino pin 3 */ + /** * @name Mapping of MCU pins to Arduino pins * @{ @@ -33,28 +38,28 @@ extern "C" { #define ARDUINO_PIN_0 GPIO3 /**< Arduino pin 0 (RxD) */ #define ARDUINO_PIN_1 GPIO1 /**< Arduino pin 1 (TxD) */ -#define ARDUINO_PIN_2 GPIO12 /**< Arduino pin 2 */ -#define ARDUINO_PIN_3 GPIO25 /**< Arduino pin 3 (PWM) */ -#define ARDUINO_PIN_4 GPIO13 /**< Arduino pin 4 */ -#define ARDUINO_PIN_5 GPIO0 /**< Arduino pin 5 (PWM) */ +#define ARDUINO_PIN_2 GPIO0 /**< Arduino pin 2 (BTN0) */ +#define ARDUINO_PIN_3 GPIO25 /**< Arduino pin 3 (PWM / LED) */ +#define ARDUINO_PIN_4 GPIO12 /**< Arduino pin 4 */ +#define ARDUINO_PIN_5 GPIO17 /**< Arduino pin 5 (PWM) */ #define ARDUINO_PIN_6 GPIO2 /**< Arduino pin 6 (PWM) */ -#define ARDUINO_PIN_7 GPIO22 /**< Arduino pin 7 */ -#define ARDUINO_PIN_8 GPIO23 /**< Arduino pin 8 */ -#define ARDUINO_PIN_9 GPIO17 /**< Arduino pin 9 (PWM) */ +#define ARDUINO_PIN_9 GPIO13 /**< Arduino pin 7 */ +#define ARDUINO_PIN_7 GPIO22 /**< Arduino pin 8 (PWM) */ +#define ARDUINO_PIN_8 GPIO23 /**< Arduino pin 9 (PWM) */ -#define ARDUINO_PIN_10 GPIO18 /**< Arduino pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO27 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_10 GPIO18 /**< Arduino pin 10 (CS0) */ +#define ARDUINO_PIN_11 GPIO27 /**< Arduino pin 11 (MOSI) */ #define ARDUINO_PIN_12 GPIO19 /**< Arduino pin 12 (MISO) */ #define ARDUINO_PIN_13 GPIO5 /**< Arduino pin 13 (SCK) */ /* analog pins as digital pin: */ -#define ARDUINO_PIN_14 GPIO36 /**< Arduino pin A0 */ -#define ARDUINO_PIN_15 GPIO39 /**< Arduino pin A1 */ -#define ARDUINO_PIN_16 GPIO37 /**< Arduino pin A2 */ -#define ARDUINO_PIN_17 GPIO38 /**< Arduino pin A3 */ +#define ARDUINO_PIN_14 GPIO36 /**< Arduino pin 14 (A0) */ +#define ARDUINO_PIN_15 GPIO39 /**< Arduino pin 15 (A1) */ +#define ARDUINO_PIN_16 GPIO37 /**< Arduino pin 16 (A2) */ +#define ARDUINO_PIN_17 GPIO38 /**< Arduino pin 17 (A3) */ -#define ARDUINO_PIN_18 GPIO4 /**< Arduino pin A4 (SDA) */ -#define ARDUINO_PIN_19 GPIO15 /**< Arduino pin A5 (SCL) */ +#define ARDUINO_PIN_18 GPIO4 /**< Arduino pin 18 (A4 / SDA) */ +#define ARDUINO_PIN_19 GPIO15 /**< Arduino pin 19 (A5 / SCL) */ #define ARDUINO_PIN_LAST 19 /** @} */ @@ -63,13 +68,46 @@ extern "C" { * @name Aliases for analog pins * @{ */ -#define ARDUINO_PIN_A0 ARDUINO_PIN_14 -#define ARDUINO_PIN_A1 ARDUINO_PIN_15 -#define ARDUINO_PIN_A2 ARDUINO_PIN_16 -#define ARDUINO_PIN_A3 ARDUINO_PIN_17 +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino pin A3 */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino pin A5 */ +/** @} */ + +/** + * @name Mapping of Arduino analog pins to RIOT ADC lines + * @{ + */ +#define ARDUINO_A0 ADC_LINE(0) /**< ADC line for Arduino pin A0 */ +#define ARDUINO_A1 ADC_LINE(1) /**< ADC line for Arduino pin A1 */ +#define ARDUINO_A2 ADC_LINE(2) /**< ADC line for Arduino pin A2 */ +#define ARDUINO_A3 ADC_LINE(3) /**< ADC line for Arduino pin A3 */ +#define ARDUINO_A4 ADC_LINE(8) /**< ADC line for Arduino pin A4 */ +#define ARDUINO_A5 ADC_LINE(9) /**< ADC line for Arduino pin A5 */ + +#define ARDUINO_ANALOG_PIN_LAST 5 /**< Last Arduino analog pin index */ +/** @} */ + +/** + * @name Mapping of Arduino pins to RIOT PWM dev and channel pairs + * @{ + */ +#define ARDUINO_PIN_3_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 3 */ +#define ARDUINO_PIN_3_PWM_CHAN 0 /**< PWM channel for Arduino pin 3 */ + +#define ARDUINO_PIN_5_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 5 */ +#define ARDUINO_PIN_5_PWM_CHAN 1 /**< PWM channel for Arduino pin 5 */ + +#define ARDUINO_PIN_6_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 6 */ +#define ARDUINO_PIN_6_PWM_CHAN 2 /**< PWM channel for Arduino pin 6 */ + +#define ARDUINO_PIN_8_PWM_DEV PWM_DEV(1) /**< PWM device for Arduino pin 8 */ +#define ARDUINO_PIN_8_PWM_CHAN 0 /**< PWM channel for Arduino pin 8 */ -#define ARDUINO_PIN_A4 ARDUINO_PIN_18 -#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +#define ARDUINO_PIN_9_PWM_DEV PWM_DEV(1) /**< PWM device for Arduino pin 9 */ +#define ARDUINO_PIN_9_PWM_CHAN 1 /**< PWM channel for Arduino pin 9 */ /** @} */ #ifdef __cplusplus diff --git a/boards/esp32-heltec-lora32-v2/include/periph_conf.h b/boards/esp32-heltec-lora32-v2/include/periph_conf.h index 5ec6a49088ba..c92d9301ef01 100644 --- a/boards/esp32-heltec-lora32-v2/include/periph_conf.h +++ b/boards/esp32-heltec-lora32-v2/include/periph_conf.h @@ -101,7 +101,7 @@ */ /** PWM channels for device PWM_DEV(0) */ #ifndef PWM0_GPIOS -#define PWM0_GPIOS { GPIO25, GPIO0, GPIO2, GPIO17 } +#define PWM0_GPIOS { GPIO25, GPIO17, GPIO2 } #endif /** PWM_DEV(1) is not used */ diff --git a/boards/esp32-mh-et-live-minikit/Makefile.features b/boards/esp32-mh-et-live-minikit/Makefile.features index b5c030fcfb01..5ca7345054fd 100644 --- a/boards/esp32-mh-et-live-minikit/Makefile.features +++ b/boards/esp32-mh-et-live-minikit/Makefile.features @@ -10,4 +10,10 @@ FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_spi +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_dac +FEATURES_PROVIDED += arduino_i2c FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_pwm +FEATURES_PROVIDED += arduino_spi +FEATURES_PROVIDED += arduino_uart diff --git a/boards/esp32-mh-et-live-minikit/include/arduino_iomap.h b/boards/esp32-mh-et-live-minikit/include/arduino_iomap.h index 5756668df373..2a74ddde490b 100644 --- a/boards/esp32-mh-et-live-minikit/include/arduino_iomap.h +++ b/boards/esp32-mh-et-live-minikit/include/arduino_iomap.h @@ -26,6 +26,11 @@ extern "C" { #endif +#define ARDUINO_UART_D0D1 UART_DEV(0) /**< Arduino UART interface */ +#define ARDUINO_SPI_D11D12D13 SPI_DEV(0) /**< Arduino SPI bus */ + +#define ARDUINO_LED (3) /**< LED is connected to Arduino pin 3 */ + /** * @name Mapping of MCU pins to Arduino pins * @{ @@ -34,27 +39,28 @@ extern "C" { #define ARDUINO_PIN_1 GPIO1 /**< Arduino pin 1 (TxD) */ #define ARDUINO_PIN_2 GPIO32 /**< Arduino pin 2 */ -#define ARDUINO_PIN_3 GPIO2 /**< Arduino pin 3 (PWM) */ +#define ARDUINO_PIN_3 GPIO2 /**< Arduino pin 3 (PWM / LED0) */ #define ARDUINO_PIN_4 GPIO27 /**< Arduino pin 4 */ #define ARDUINO_PIN_5 GPIO0 /**< Arduino pin 5 (PWM) */ #define ARDUINO_PIN_6 GPIO4 /**< Arduino pin 6 (PWM) */ #define ARDUINO_PIN_7 GPIO33 /**< Arduino pin 7 */ -#define ARDUINO_PIN_8 GPIO25 /**< Arduino pin 8 */ +#define ARDUINO_PIN_8 GPIO25 /**< Arduino pin 8 (DAC0) */ #define ARDUINO_PIN_9 GPIO15 /**< Arduino pin 9 (PWM) */ -#define ARDUINO_PIN_10 GPIO5 /**< Arduino pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO23 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_10 GPIO5 /**< Arduino pin 10 (CS0 / SD Card) */ +#define ARDUINO_PIN_11 GPIO23 /**< Arduino pin 11 (MOSI) */ #define ARDUINO_PIN_12 GPIO19 /**< Arduino pin 12 (MISO) */ -#define ARDUINO_PIN_13 GPIO18 /**< Arduino pin 13 (SCK) */ +#define ARDUINO_PIN_13 GPIO18 /**< Arduino pin 13 (SCK) */ /* analog pins as digital pin: */ -#define ARDUINO_PIN_14 GPIO34 /**< Arduino pin A0 */ -#define ARDUINO_PIN_15 GPIO35 /**< Arduino pin A1 */ -#define ARDUINO_PIN_16 GPIO36 /**< Arduino pin A2 */ -#define ARDUINO_PIN_17 GPIO39 /**< Arduino pin A3 */ +#define ARDUINO_PIN_14 GPIO34 /**< Arduino pin 14 (A0) */ +#define ARDUINO_PIN_15 GPIO35 /**< Arduino pin 15 (A1) */ +#define ARDUINO_PIN_16 GPIO36 /**< Arduino pin 16 (A2) */ +#define ARDUINO_PIN_17 GPIO39 /**< Arduino pin 17 (A3) */ -#define ARDUINO_PIN_18 GPIO21 /**< Arduino pin A4 (SDA) */ -#define ARDUINO_PIN_19 GPIO22 /**< Arduino pin A5 (SCL) */ +/* Arduino Uno IC2 pins */ +#define ARDUINO_PIN_18 GPIO21 /**< Arduino pin 18 (SDA) */ +#define ARDUINO_PIN_19 GPIO22 /**< Arduino pin 19 (SCL) */ #define ARDUINO_PIN_LAST 19 /** @} */ @@ -63,13 +69,50 @@ extern "C" { * @name Aliases for analog pins * @{ */ -#define ARDUINO_PIN_A0 ARDUINO_PIN_14 -#define ARDUINO_PIN_A1 ARDUINO_PIN_15 -#define ARDUINO_PIN_A2 ARDUINO_PIN_16 -#define ARDUINO_PIN_A3 ARDUINO_PIN_17 +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino pin A3 */ + +#define ARDUINO_PIN_DAC0 ARDUINO_PIN_8 /**< Arduino pin DAC0 */ +/** @} */ + +/** + * @name Mapping of Arduino analog pins to RIOT ADC lines + * @{ + */ +#define ARDUINO_A0 ADC_LINE(7) /**< ADC line for Arduino pin A0 */ +#define ARDUINO_A1 ADC_LINE(8) /**< ADC line for Arduino pin A1 */ +#define ARDUINO_A2 ADC_LINE(2) /**< ADC line for Arduino pin A2 */ +#define ARDUINO_A3 ADC_LINE(6) /**< ADC line for Arduino pin A3 */ + +#define ARDUINO_ANALOG_PIN_LAST 3 /**< Last Arduino analog pin index */ +/** @} */ + +/** + * @name Mapping of Arduino DAC pins to RIOT DAC lines + * @{ + */ +#define ARDUINO_DAC0 DAC_LINE(0) /**< DAC line for Arduino pin DAC0 */ + +#define ARDUINO_DAC_PIN_LAST 0 /**< Last Arduino DAC pin index */ +/** @} */ + +/** + * @name Mapping of Arduino pins to RIOT PWM dev and channel pairs + * @{ + */ +#define ARDUINO_PIN_3_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 3 */ +#define ARDUINO_PIN_3_PWM_CHAN 0 /**< PWM channel for Arduino pin 3 */ + +#define ARDUINO_PIN_5_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 5 */ +#define ARDUINO_PIN_5_PWM_CHAN 1 /**< PWM channel for Arduino pin 5 */ + +#define ARDUINO_PIN_6_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 6 */ +#define ARDUINO_PIN_6_PWM_CHAN 2 /**< PWM channel for Arduino pin 6 */ -#define ARDUINO_PIN_A4 ARDUINO_PIN_18 -#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +#define ARDUINO_PIN_9_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 9 */ +#define ARDUINO_PIN_9_PWM_CHAN 3 /**< PWM channel for Arduino pin 9 */ /** @} */ #ifdef __cplusplus diff --git a/boards/esp32-olimex-evb/Makefile.features b/boards/esp32-olimex-evb/Makefile.features index 42f118c15e24..4b23919de136 100644 --- a/boards/esp32-olimex-evb/Makefile.features +++ b/boards/esp32-olimex-evb/Makefile.features @@ -22,4 +22,10 @@ FEATURES_CONFLICT_MSG += "SD/MMC and SPI cannot be used at the same time on this FEATURES_PROVIDED += periph_can # CAN peripheral interface FEATURES_PROVIDED += periph_eth # Ethernet MAC (EMAC) +ifneq (,$(filter olimex_esp32_gateway,$(USEMODULE))) + FEATURES_PROVIDED += arduino_analog +endif +FEATURES_PROVIDED += arduino_i2c FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_spi +FEATURES_PROVIDED += arduino_uart diff --git a/boards/esp32-olimex-evb/include/arduino_iomap.h b/boards/esp32-olimex-evb/include/arduino_iomap.h index cf5719b48a43..714209f8c057 100644 --- a/boards/esp32-olimex-evb/include/arduino_iomap.h +++ b/boards/esp32-olimex-evb/include/arduino_iomap.h @@ -26,6 +26,13 @@ extern "C" { #endif +#define ARDUINO_UART_D0D1 UART_DEV(0) /**< Arduino UART interface */ +#define ARDUINO_SPI_D11D12D13 SPI_DEV(0) /**< Arduino SPI bus */ + +#if MODULE_OLIMEX_ESP32_GATEWAY +# define ARDUINO_LED (3) /**< LED is connected to Arduino pin 3 */ +#endif + /** * @name Mapping of MCU pins to Arduino pins * @{ @@ -33,26 +40,33 @@ extern "C" { #define ARDUINO_PIN_0 GPIO3 /**< Arduino pin 0 (RxD) */ #define ARDUINO_PIN_1 GPIO1 /**< Arduino pin 1 (TxD) */ -#define ARDUINO_PIN_2 GPIO32 /**< Arduino pin 2 */ -#define ARDUINO_PIN_3 GPIO33 /**< Arduino pin 3 (PWM) */ +#define ARDUINO_PIN_2 GPIO34 /**< Arduino pin 2 (BTN0), input only! */ +#define ARDUINO_PIN_3 GPIO33 /**< Arduino pin 3 (LED) */ #define ARDUINO_PIN_4 GPIO4 /**< Arduino pin 4 */ -#define ARDUINO_PIN_5 GPIO9 /**< Arduino pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO10 /**< Arduino pin 6 (PWM) */ -#define ARDUINO_PIN_7 GPIO7 /**< Arduino pin 7 */ -#define ARDUINO_PIN_8 GPIO8 /**< Arduino pin 8 */ +#define ARDUINO_PIN_5 GPIO9 /**< Arduino pin 5 */ +#define ARDUINO_PIN_6 GPIO10 /**< Arduino pin 6 */ + +/* Arduino pins 7 ... 9 are not available */ -#define ARDUINO_PIN_10 GPIO17 /**< Arduino pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO15 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_10 GPIO17 /**< Arduino pin 10 (CS0) */ +#define ARDUINO_PIN_11 GPIO15 /**< Arduino pin 11 (MOSI) */ #define ARDUINO_PIN_12 GPIO2 /**< Arduino pin 12 (MISO) */ -#define ARDUINO_PIN_13 GPIO14 /**< Arduino pin 13 (SCK) */ +#define ARDUINO_PIN_13 GPIO14 /**< Arduino pin 13 (SCK) */ -#define ARDUINO_PIN_14 GPIO34 /**< Arduino pin A0 */ -#define ARDUINO_PIN_15 GPIO35 /**< Arduino pin A1 */ -#define ARDUINO_PIN_16 GPIO36 /**< Arduino pin A2 */ -#define ARDUINO_PIN_17 GPIO39 /**< Arduino pin A3 */ +/* analog pins as digital pin */ +#define ARDUINO_PIN_14 GPIO32 /**< Arduino pin 14 (A0) */ +#define ARDUINO_PIN_15 GPIO35 /**< Arduino pin 15 (A1), input only! */ +#define ARDUINO_PIN_16 GPIO36 /**< Arduino pin 16 (A2), input only! */ +#define ARDUINO_PIN_17 GPIO39 /**< Arduino pin 17 (A3), input only! */ -#define ARDUINO_PIN_18 GPIO13 /**< Arduino pin A4 (SDA) */ -#define ARDUINO_PIN_19 GPIO16 /**< Arduino pin A5 (SCL) */ +/* Arduino I2C pins */ +#if MODULE_OLIMEX_ESP32_GATEWAY +# define ARDUINO_PIN_18 GPIO17 /**< Arduino pin 18 (SDA) */ +# define ARDUINO_PIN_19 GPIO16 /**< Arduino pin 19 (SCL) */ +#else /* ESP32-EVB */ +# define ARDUINO_PIN_18 GPIO13 /**< Arduino pin 18 (SDA) */ +# define ARDUINO_PIN_19 GPIO16 /**< Arduino pin 19 (SCL) */ +#endif #define ARDUINO_PIN_LAST 19 /** @} */ @@ -61,12 +75,26 @@ extern "C" { * @name Aliases for analog pins * @{ */ -#define ARDUINO_PIN_A0 ARDUINO_PIN_14 -#define ARDUINO_PIN_A1 ARDUINO_PIN_15 -#define ARDUINO_PIN_A2 ARDUINO_PIN_16 -#define ARDUINO_PIN_A3 ARDUINO_PIN_17 -#define ARDUINO_PIN_A4 ARDUINO_PIN_18 -#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +#if MODULE_OLIMEX_ESP32_GATEWAY +# define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino pin A0 */ +# define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino pin A1 */ +# define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino pin A2 */ +# define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino pin A3 */ +#endif +/** @} */ + +/** + * @name Mapping of Arduino analog pins to RIOT ADC lines + * @{ + */ +#if MODULE_OLIMEX_ESP32_GATEWAY +# define ARDUINO_A0 ADC_LINE(0) /**< ADC line for Arduino pin A0 */ +# define ARDUINO_A1 ADC_LINE(1) /**< ADC line for Arduino pin A1 */ +# define ARDUINO_A2 ADC_LINE(2) /**< ADC line for Arduino pin A2 */ +# define ARDUINO_A3 ADC_LINE(3) /**< ADC line for Arduino pin A3 */ + +# define ARDUINO_ANALOG_PIN_LAST 3 /**< Last Arduino analog pin index */ +#endif /** @} */ #ifdef __cplusplus diff --git a/boards/esp32-ttgo-t-beam/Makefile.features b/boards/esp32-ttgo-t-beam/Makefile.features index af35e4bf5db5..9c6ecb2b8cc7 100644 --- a/boards/esp32-ttgo-t-beam/Makefile.features +++ b/boards/esp32-ttgo-t-beam/Makefile.features @@ -11,7 +11,13 @@ FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_uart +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_dac +FEATURES_PROVIDED += arduino_i2c FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_pwm +FEATURES_PROVIDED += arduino_spi +FEATURES_PROVIDED += arduino_uart # unique features provided by the board FEATURES_PROVIDED += esp_spi_ram diff --git a/boards/esp32-ttgo-t-beam/doc.txt b/boards/esp32-ttgo-t-beam/doc.txt index 1f6839761349..f399dc542e5c 100644 --- a/boards/esp32-ttgo-t-beam/doc.txt +++ b/boards/esp32-ttgo-t-beam/doc.txt @@ -107,9 +107,9 @@ Function | GPIOs | Remarks |Configuration :---------------|:-------|:--------|:---------------------------------- BUTTON0 | GPIO39 | low active | | LED0 | GPIO14 | high active | | -ADC | GPIO0, GPIO2, GPIO4, GPIO13,\n GPIO25, GPIO32, GPIO33, GPIO34,\n GPIO35 | | \ref esp32_adc_channels "ADC Channels" +ADC | GPIO0, GPIO2, GPIO4, GPIO13,\n GPIO25, GPIO32, GPIO33, GPIO35,\n GPIO36, GPIO34 | | \ref esp32_adc_channels "ADC Channels" DAC | GPIO25 | | \ref esp32_dac_channels "DAC Channels" -PWM_DEV(0) | GPIO0, GPIO2, GPIO25 | | \ref esp32_pwm_channels "PWM Channels" +PWM_DEV(0) | GPIO14, GPIO0, GPIO2, GPIO25 | | \ref esp32_pwm_channels "PWM Channels" I2C_DEV(0):SDA | GPIO21 | | \ref esp32_i2c_interfaces "I2C Interfaces" I2C_DEV(0):SCL | GPIO22 | I2C_SPEED_FAST is used | \ref esp32_i2c_interfaces "I2C Interfaces" SPI_DEV(0):CLK | GPIO5 | VSPI is used | \ref esp32_spi_interfaces "SPI Interfaces" @@ -128,9 +128,9 @@ TTGO- T-Beam V1.0 Function | GPIOs | Remarks |Configuration :---------------|:-------|:--------|:---------------------------------- BUTTON0 | GPIO38 | low active | | -ADC | GPIO0, GPIO2, GPIO4, GPIO13,\n GPIO25, GPIO32, GPIO33, GPIO35 | | \ref esp32_adc_channels "ADC Channels" +ADC | GPIO0, GPIO2, GPIO4, GPIO13,\n GPIO25, GPIO32, GPIO33, GPIO35,\n GPIO36, GPIO39 | | \ref esp32_adc_channels "ADC Channels" DAC | GPIO25 | | \ref esp32_dac_channels "DAC Channels" -PWM_DEV(0) | GPIO0, GPIO2, GPIO25 | | \ref esp32_pwm_channels "PWM Channels" +PWM_DEV(0) | GPIO14, GPIO0, GPIO2, GPIO25 | | \ref esp32_pwm_channels "PWM Channels" I2C_DEV(0):SDA | GPIO21 | | \ref esp32_i2c_interfaces "I2C Interfaces" I2C_DEV(0):SCL | GPIO22 | I2C_SPEED_FAST is used | \ref esp32_i2c_interfaces "I2C Interfaces" SPI_DEV(0):CLK | GPIO5 | VSPI is used | \ref esp32_spi_interfaces "SPI Interfaces" @@ -165,7 +165,7 @@ for TTGO T-Beam boards. The corresponding board schematics can be found on TinyMicros.com for [TTGO T-Beam rev0](http://tinymicros.com/mediawiki/images/b/b9/TTGO_T-Beam_Schematic.pdf) and GitHub for -[TTGO T-Beam V1.0](https://github.com/Xinyuan-LilyGO/LilyGo-LoRa-Series/blob/master/schematic/LilyGo_TBeam_V1.0.pdf) +[TTGO T-Beam V1.0](https://github.com/Xinyuan-LilyGO/LilyGo-LoRa-Series/blob/a45c3b17842c5c377a8bc8475ae529ba0b90f9b4/schematic/LilyGo_TBeam_V1.0.pdf) [Back to table of contents](#esp32_ttgo_t_beam_toc) diff --git a/boards/esp32-ttgo-t-beam/include/arduino_iomap.h b/boards/esp32-ttgo-t-beam/include/arduino_iomap.h index 9f9ddb6f3b77..a93cf84b5e71 100644 --- a/boards/esp32-ttgo-t-beam/include/arduino_iomap.h +++ b/boards/esp32-ttgo-t-beam/include/arduino_iomap.h @@ -26,27 +26,45 @@ extern "C" { #endif +#define ARDUINO_UART_D0D1 UART_DEV(0) /**< Arduino UART interface */ +#define ARDUINO_SPI_D11D12D13 SPI_DEV(0) /**< Arduino SPI bus */ + +#if MODULE_ESP32_TTGO_T_BEAM_V1_0 +# define ARDUINO_LED (3) /**< LED is connected to Arduino pin 3 */ +#endif + /** * @name Mapping of MCU pins to Arduino pins * @{ */ + #define ARDUINO_PIN_0 GPIO3 /**< Arduino pin 0 (RxD) */ #define ARDUINO_PIN_1 GPIO1 /**< Arduino pin 1 (TxD) */ -#define ARDUINO_PIN_2 GPIO0 /**< Arduino pin 2 */ -#define ARDUINO_PIN_3 GPIO2 /**< Arduino pin 3 (PWM) */ +#define ARDUINO_PIN_2 GPIO13 /**< Arduino pin 2 */ +#define ARDUINO_PIN_3 GPIO14 /**< Arduino pin 3 (PWM / LED0) */ #define ARDUINO_PIN_4 GPIO4 /**< Arduino pin 4 */ -#define ARDUINO_PIN_5 GPIO13 /**< Arduino pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO15 /**< Arduino pin 6 (PWM) */ -#define ARDUINO_PIN_7 GPIO21 /**< Arduino pin 7 */ -#define ARDUINO_PIN_8 GPIO22 /**< Arduino pin 8 */ -#define ARDUINO_PIN_9 GPIO23 /**< Arduino pin 9 (PWM) */ -#define ARDUINO_PIN_13 GPIO14 /**< Arduino pin 13 (LED) */ -#define ARDUINO_PIN_14 GPIO25 /**< Arduino pin A0 */ -#define ARDUINO_PIN_15 GPIO32 /**< Arduino pin A1 */ -#define ARDUINO_PIN_16 GPIO33 /**< Arduino pin A2 */ -#define ARDUINO_PIN_17 GPIO35 /**< Arduino pin A3 */ -#define ARDUINO_PIN_18 GPIO36 /**< Arduino pin A4 (SDA) */ -#define ARDUINO_PIN_19 GPIO39 /**< Arduino pin A5 (SCL) */ +#define ARDUINO_PIN_5 GPIO0 /**< Arduino pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO2 /**< Arduino pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO23 /**< Arduino pin 7 */ + +/* Arduino pin 8 is not available */ + +#define ARDUINO_PIN_9 GPIO25 /**< Arduino pin 9 (PWM / DAC0) */ + +#define ARDUINO_PIN_10 GPIO18 /**< Arduino pin 10 (CS0) */ +#define ARDUINO_PIN_11 GPIO27 /**< Arduino pin 11 (MOSI) */ +#define ARDUINO_PIN_12 GPIO19 /**< Arduino pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO5 /**< Arduino pin 13 (SCK) */ + +/* analog pins as digital pin: */ +#define ARDUINO_PIN_14 GPIO32 /**< Arduino pin 14 input only (A0) */ +#define ARDUINO_PIN_15 GPIO33 /**< Arduino pin 15 input only (A1) */ +#define ARDUINO_PIN_16 GPIO35 /**< Arduino pin 16 input only (A2) */ +#define ARDUINO_PIN_17 GPIO36 /**< Arduino pin 17 input only (A3) */ + +/* Arduino I2C signals */ +#define ARDUINO_PIN_18 GPIO21 /**< Arduino pin 18 (SDA) */ +#define ARDUINO_PIN_19 GPIO22 /**< Arduino pin 19 (SCL) */ #define ARDUINO_PIN_LAST 19 /** @} */ @@ -55,12 +73,50 @@ extern "C" { * @name Aliases for analog pins * @{ */ -#define ARDUINO_PIN_A0 ARDUINO_PIN_14 -#define ARDUINO_PIN_A1 ARDUINO_PIN_15 -#define ARDUINO_PIN_A2 ARDUINO_PIN_16 -#define ARDUINO_PIN_A3 ARDUINO_PIN_17 -#define ARDUINO_PIN_A4 ARDUINO_PIN_18 -#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino pin A3 */ + +#define ARDUINO_PIN_DAC0 ARDUINO_PIN_9 /**< Arduino pin DAC0 */ +/** @} */ + +/** + * @name Mapping of Arduino analog pins to RIOT ADC lines + * @{ + */ +#define ARDUINO_A0 ADC_LINE(5) /**< ADC line for Arduino pin A0 */ +#define ARDUINO_A1 ADC_LINE(6) /**< ADC line for Arduino pin A1 */ +#define ARDUINO_A2 ADC_LINE(7) /**< ADC line for Arduino pin A2 */ +#define ARDUINO_A3 ADC_LINE(8) /**< ADC line for Arduino pin A3 */ + +#define ARDUINO_ANALOG_PIN_LAST 3 /**< Last Arduino analog pin index */ +/** @} */ + +/** + * @name Mapping of Arduino DAC pins to RIOT DAC lines + * @{ + */ +#define ARDUINO_DAC0 DAC_LINE(0) /**< DAC line for Arduino pin DAC0 */ + +#define ARDUINO_DAC_PIN_LAST 0 /**< Last Arduino DAC pin index */ +/** @} */ + +/** + * @name Mapping of Arduino pins to RIOT PWM dev and channel pairs + * @{ + */ +#define ARDUINO_PIN_3_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 3 */ +#define ARDUINO_PIN_3_PWM_CHAN 0 /**< PWM channel for Arduino pin 3 */ + +#define ARDUINO_PIN_5_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 5 */ +#define ARDUINO_PIN_5_PWM_CHAN 1 /**< PWM channel for Arduino pin 5 */ + +#define ARDUINO_PIN_6_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 6 */ +#define ARDUINO_PIN_6_PWM_CHAN 2 /**< PWM channel for Arduino pin 6 */ + +#define ARDUINO_PIN_9_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 9 */ +#define ARDUINO_PIN_9_PWM_CHAN 3 /**< PWM channel for Arduino pin 9 */ /** @} */ #ifdef __cplusplus diff --git a/boards/esp32-ttgo-t-beam/include/periph_conf.h b/boards/esp32-ttgo-t-beam/include/periph_conf.h index 76a8173eba7d..b47966d9ddbf 100644 --- a/boards/esp32-ttgo-t-beam/include/periph_conf.h +++ b/boards/esp32-ttgo-t-beam/include/periph_conf.h @@ -51,10 +51,10 @@ #ifndef ADC_GPIOS #if MODULE_ESP32_TTGO_T_BEAM_V1_0 #define ADC_GPIOS { GPIO0, GPIO2, GPIO4, GPIO13, GPIO25, \ - GPIO32, GPIO33, GPIO35 } + GPIO32, GPIO33, GPIO35, GPIO36, GPIO39 } #else #define ADC_GPIOS { GPIO0, GPIO2, GPIO4, GPIO13, GPIO25, \ - GPIO32, GPIO33, GPIO34, GPIO35 } + GPIO32, GPIO33, GPIO35, GPIO36, GPIO34 } #endif #endif diff --git a/boards/esp32-wemos-lolin-d32-pro/Makefile.features b/boards/esp32-wemos-lolin-d32-pro/Makefile.features index e0d61206d805..9c0b61b7857a 100644 --- a/boards/esp32-wemos-lolin-d32-pro/Makefile.features +++ b/boards/esp32-wemos-lolin-d32-pro/Makefile.features @@ -11,4 +11,10 @@ FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += sdcard_spi +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_dac +FEATURES_PROVIDED += arduino_i2c FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_pwm +FEATURES_PROVIDED += arduino_spi +FEATURES_PROVIDED += arduino_uart diff --git a/boards/esp32-wemos-lolin-d32-pro/include/arduino_iomap.h b/boards/esp32-wemos-lolin-d32-pro/include/arduino_iomap.h index 962aba716618..b4a7f456710a 100644 --- a/boards/esp32-wemos-lolin-d32-pro/include/arduino_iomap.h +++ b/boards/esp32-wemos-lolin-d32-pro/include/arduino_iomap.h @@ -26,6 +26,11 @@ extern "C" { #endif +#define ARDUINO_UART_D0D1 UART_DEV(0) /**< Arduino UART interface */ +#define ARDUINO_SPI_D11D12D13 SPI_DEV(0) /**< Arduino SPI bus */ + +#define ARDUINO_LED (10) /**< LED is connected to Arduino pin 10 */ + /** * @name Mapping of MCU pins to Arduino pins * @{ @@ -34,27 +39,27 @@ extern "C" { #define ARDUINO_PIN_1 GPIO1 /**< Arduino pin 1 (TxD) */ #define ARDUINO_PIN_2 GPIO4 /**< Arduino pin 2 */ -#define ARDUINO_PIN_3 GPIO0 /**< Arduino pin 3 (PWM) */ +#define ARDUINO_PIN_3 GPIO0 /**< Arduino pin 3 (PWM / BTN0) */ #define ARDUINO_PIN_4 GPIO13 /**< Arduino pin 4 */ #define ARDUINO_PIN_5 GPIO2 /**< Arduino pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO15 /**< Arduino pin 6 (PWM) */ -#define ARDUINO_PIN_7 GPIO25 /**< Arduino pin 7 */ -#define ARDUINO_PIN_8 GPIO26 /**< Arduino pin 8 */ +#define ARDUINO_PIN_6 GPIO15 /**< Arduino pin 6 */ +#define ARDUINO_PIN_7 GPIO25 /**< Arduino pin 7 (DAC0) */ +#define ARDUINO_PIN_8 GPIO26 /**< Arduino pin 8 (DAC1) */ #define ARDUINO_PIN_9 GPIO32 /**< Arduino pin 9 (PWM) */ -#define ARDUINO_PIN_10 GPIO5 /**< Arduino pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO23 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_10 GPIO5 /**< Arduino pin 10 (CS0 / LED) */ +#define ARDUINO_PIN_11 GPIO23 /**< Arduino pin 11 (MOSI) */ #define ARDUINO_PIN_12 GPIO19 /**< Arduino pin 12 (MISO) */ #define ARDUINO_PIN_13 GPIO18 /**< Arduino pin 13 (SCK) */ /* analog pins as digital pin: */ -#define ARDUINO_PIN_14 GPIO36 /**< Arduino pin A0 */ -#define ARDUINO_PIN_15 GPIO39 /**< Arduino pin A1 */ -#define ARDUINO_PIN_16 GPIO34 /**< Arduino pin A2 */ -#define ARDUINO_PIN_17 GPIO35 /**< Arduino pin A3 */ +#define ARDUINO_PIN_14 GPIO36 /**< Arduino pin 14 (A0) */ +#define ARDUINO_PIN_15 GPIO39 /**< Arduino pin 15 (A1) */ +#define ARDUINO_PIN_16 GPIO34 /**< Arduino pin 16 (A2) */ +#define ARDUINO_PIN_17 GPIO35 /**< Arduino pin 17 (A3) */ -#define ARDUINO_PIN_18 GPIO21 /**< Arduino pin A4 (SDA) */ -#define ARDUINO_PIN_19 GPIO22 /**< Arduino pin A5 (SCL) */ +#define ARDUINO_PIN_18 GPIO21 /**< Arduino pin 18 (SDA) */ +#define ARDUINO_PIN_19 GPIO22 /**< Arduino pin 19 (SCL) */ #define ARDUINO_PIN_LAST 19 /** @} */ @@ -63,13 +68,46 @@ extern "C" { * @name Aliases for analog pins * @{ */ -#define ARDUINO_PIN_A0 ARDUINO_PIN_14 -#define ARDUINO_PIN_A1 ARDUINO_PIN_15 -#define ARDUINO_PIN_A2 ARDUINO_PIN_16 -#define ARDUINO_PIN_A3 ARDUINO_PIN_17 +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino pin A3 */ + +#define ARDUINO_PIN_DAC0 ARDUINO_PIN_7 /**< Arduino pin DAC0 */ +#define ARDUINO_PIN_DAC1 ARDUINO_PIN_8 /**< Arduino pin DAC1 */ +/** @} */ + +/** + * @name Mapping of Arduino analog pins to RIOT ADC lines + * @{ + */ +#define ARDUINO_A0 ADC_LINE(0) /**< ADC line for Arduino pin A0 */ +#define ARDUINO_A1 ADC_LINE(1) /**< ADC line for Arduino pin A1 */ +#define ARDUINO_A2 ADC_LINE(2) /**< ADC line for Arduino pin A2 */ +#define ARDUINO_A3 ADC_LINE(3) /**< ADC line for Arduino pin A3 */ + +#define ARDUINO_ANALOG_PIN_LAST 3 /**< Last Arduino analog pin index */ +/** @} */ + +/** + * @name Mapping of Arduino DAC pins to RIOT DAC lines + * @{ + */ +#define ARDUINO_DAC0 DAC_LINE(0) +#define ARDUINO_DAC1 DAC_LINE(1) + +#define ARDUINO_DAC_PIN_LAST 1 /**< Last Arduino DAC pin index */ +/** @} */ + +/** + * @name Mapping of Arduino pins to RIOT PWM dev and channel pairs + * @{ + */ +#define ARDUINO_PIN_3_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 3 */ +#define ARDUINO_PIN_3_PWM_CHAN 0 /**< PWM channel for Arduino pin 3 */ -#define ARDUINO_PIN_A4 ARDUINO_PIN_18 -#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +#define ARDUINO_PIN_5_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 5 */ +#define ARDUINO_PIN_5_PWM_CHAN 1 /**< PWM channel for Arduino pin 5 */ /** @} */ #ifdef __cplusplus diff --git a/boards/esp32-wroom-32/Makefile.features b/boards/esp32-wroom-32/Makefile.features index b5c030fcfb01..5ca7345054fd 100644 --- a/boards/esp32-wroom-32/Makefile.features +++ b/boards/esp32-wroom-32/Makefile.features @@ -10,4 +10,10 @@ FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_spi +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_dac +FEATURES_PROVIDED += arduino_i2c FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_pwm +FEATURES_PROVIDED += arduino_spi +FEATURES_PROVIDED += arduino_uart diff --git a/boards/esp32-wroom-32/include/arduino_iomap.h b/boards/esp32-wroom-32/include/arduino_iomap.h index c0f1f284bb57..26db760ed6d6 100644 --- a/boards/esp32-wroom-32/include/arduino_iomap.h +++ b/boards/esp32-wroom-32/include/arduino_iomap.h @@ -26,6 +26,9 @@ extern "C" { #endif +#define ARDUINO_UART_D0D1 UART_DEV(0) /**< Arduino UART interface */ +#define ARDUINO_SPI_D11D12D13 SPI_DEV(0) /**< Arduino SPI bus */ + /** * @name Mapping of MCU pins to Arduino pins * @{ @@ -35,41 +38,89 @@ extern "C" { #define ARDUINO_PIN_2 GPIO12 /**< Arduino pin 2 */ #define ARDUINO_PIN_3 GPIO27 /**< Arduino pin 3 (PWM) */ -#define ARDUINO_PIN_4 GPIO2 /**< Arduino pin 4 */ +#define ARDUINO_PIN_4 GPIO2 /**< Arduino pin 4 (PWM) */ #define ARDUINO_PIN_5 GPIO32 /**< Arduino pin 5 (PWM) */ #define ARDUINO_PIN_6 GPIO33 /**< Arduino pin 6 (PWM) */ #define ARDUINO_PIN_7 GPIO13 /**< Arduino pin 7 */ #define ARDUINO_PIN_8 GPIO14 /**< Arduino pin 8 */ -#define ARDUINO_PIN_9 GPIO0 /**< Arduino pin 9 (PWM) */ +#define ARDUINO_PIN_9 GPIO0 /**< Arduino pin 9 (PWM / BTN0) */ -#define ARDUINO_PIN_10 GPIO5 /**< Arduino pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO23 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_10 GPIO5 /**< Arduino pin 10 (CS0) */ +#define ARDUINO_PIN_11 GPIO23 /**< Arduino pin 11 (MOSI) */ #define ARDUINO_PIN_12 GPIO19 /**< Arduino pin 12 (MISO) */ #define ARDUINO_PIN_13 GPIO18 /**< Arduino pin 13 (SCK) */ /* analog pins as digital pin: */ -#define ARDUINO_PIN_14 GPIO25 /**< Arduino pin A0 */ -#define ARDUINO_PIN_15 GPIO26 /**< Arduino pin A1 */ -#define ARDUINO_PIN_16 GPIO4 /**< Arduino pin A2 */ -#define ARDUINO_PIN_17 GPIO15 /**< Arduino pin A3 */ +#define ARDUINO_PIN_14 GPIO25 /**< Arduino pin 14 (A0) */ +#define ARDUINO_PIN_15 GPIO26 /**< Arduino pin 15 (A1) */ +#define ARDUINO_PIN_16 GPIO4 /**< Arduino pin 16 (A2 / PWM) */ +#define ARDUINO_PIN_17 GPIO15 /**< Arduino pin 17 (A3) */ +#define ARDUINO_PIN_18 GPIO36 /**< Arduino pin 18 (A4) */ +#define ARDUINO_PIN_19 GPIO39 /**< Arduino pin 19 (A5) */ -#define ARDUINO_PIN_18 GPIO21 /**< Arduino pin A4 (SDA) */ -#define ARDUINO_PIN_19 GPIO22 /**< Arduino pin A5 (SCL) */ +#define ARDUINO_PIN_20 GPIO21 /**< Arduino pin 20 (SDA) */ +#define ARDUINO_PIN_21 GPIO22 /**< Arduino pin 21 (SCL) */ -#define ARDUINO_PIN_LAST 19 +#define ARDUINO_PIN_LAST 21 /**< Last Arduino pin index */ /** @} */ /** * @name Aliases for analog pins * @{ */ -#define ARDUINO_PIN_A0 ARDUINO_PIN_14 -#define ARDUINO_PIN_A1 ARDUINO_PIN_15 -#define ARDUINO_PIN_A2 ARDUINO_PIN_16 -#define ARDUINO_PIN_A3 ARDUINO_PIN_17 +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino pin A3 */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino pin A5 */ + +#define ARDUINO_PIN_DAC0 ARDUINO_PIN_14 /**< Arduino pin DAC0 */ +#define ARDUINO_PIN_DAC1 ARDUINO_PIN_15 /**< Arduino pin DAC1 */ +/** @} */ + +/** + * @name Mapping of Arduino analog pins to RIOT ADC lines + * @{ + */ +#define ARDUINO_A0 ADC_LINE(7) /**< ADC line for Arduino pin A0 */ +#define ARDUINO_A1 ADC_LINE(8) /**< ADC line for Arduino pin A1 */ +#define ARDUINO_A2 ADC_LINE(2) /**< ADC line for Arduino pin A2 */ +#define ARDUINO_A3 ADC_LINE(6) /**< ADC line for Arduino pin A3 */ +#define ARDUINO_A4 ADC_LINE(14) /**< ADC line for Arduino pin A4 */ +#define ARDUINO_A5 ADC_LINE(15) /**< ADC line for Arduino pin A5 */ + +#define ARDUINO_ANALOG_PIN_LAST 5 /**< Last Arduino analog pin index */ +/** @} */ + +/** + * @name Mapping of Arduino DAC pins to RIOT DAC lines + * @{ + */ +#define ARDUINO_DAC0 DAC_LINE(0) /**< DAC line for Arduino pin DAC0 */ +#define ARDUINO_DAC1 DAC_LINE(1) /**< DAC line for Arduino pin DAC1 */ + +#define ARDUINO_DAC_PIN_LAST 1 /**< Last Arduino DAC pin index */ +/** @} */ + +/** + * @name Mapping of Arduino pins to RIOT PWM dev and channel pairs + * @{ + */ +#define ARDUINO_PIN_3_PWM_DEV PWM_DEV(1) /**< PWM device for Arduino pin 3 */ +#define ARDUINO_PIN_3_PWM_CHAN 0 /**< PWM channel for Arduino pin 3 */ + +#define ARDUINO_PIN_4_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 4 */ +#define ARDUINO_PIN_4_PWM_CHAN 1 /**< PWM channel for Arduino pin 4 */ + +#define ARDUINO_PIN_5_PWM_DEV PWM_DEV(1) /**< PWM device for Arduino pin 5 */ +#define ARDUINO_PIN_5_PWM_CHAN 1 /**< PWM channel for Arduino pin 5 */ + +#define ARDUINO_PIN_6_PWM_DEV PWM_DEV(1) /**< PWM device for Arduino pin 6 */ +#define ARDUINO_PIN_6_PWM_CHAN 2 /**< PWM channel for Arduino pin 6 */ -#define ARDUINO_PIN_A4 ARDUINO_PIN_18 -#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +#define ARDUINO_PIN_9_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 9 */ +#define ARDUINO_PIN_9_PWM_CHAN 0 /**< PWM channel for Arduino pin 9 */ /** @} */ #ifdef __cplusplus diff --git a/boards/esp32-wrover-kit/Makefile.features b/boards/esp32-wrover-kit/Makefile.features index 2f8181395a28..e1dec252be27 100644 --- a/boards/esp32-wrover-kit/Makefile.features +++ b/boards/esp32-wrover-kit/Makefile.features @@ -15,4 +15,9 @@ FEATURES_PROVIDED += sdcard_spi FEATURES_PROVIDED += esp_rtc_timer_32k FEATURES_PROVIDED += esp_jtag +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_i2c FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_pwm +FEATURES_PROVIDED += arduino_spi +FEATURES_PROVIDED += arduino_uart diff --git a/boards/esp32-wrover-kit/include/arduino_iomap.h b/boards/esp32-wrover-kit/include/arduino_iomap.h index 09dec3729c85..a9ea53d41438 100644 --- a/boards/esp32-wrover-kit/include/arduino_iomap.h +++ b/boards/esp32-wrover-kit/include/arduino_iomap.h @@ -26,6 +26,13 @@ extern "C" { #endif +#define ARDUINO_UART_D0D1 UART_DEV(0) /**< Arduino UART interface */ +#define ARDUINO_SPI_D11D12D13 SPI_DEV(0) /**< Arduino SPI bus */ + +#if !MODULE_ESP32_WROVER_KIT_CAMERA && !MODULE_PERIPH_SDMMC +# define ARDUINO_LED (5) /**< LED is connected to Arduino pin 5 */ +#endif + /** * @name Mapping of MCU pins to Arduino pins * @{ @@ -34,40 +41,68 @@ extern "C" { #define ARDUINO_PIN_1 GPIO1 /**< Arduino pin 1 (TxD) */ #define ARDUINO_PIN_2 GPIO19 /**< Arduino pin 2 */ -#define ARDUINO_PIN_3 GPIO0 /**< Arduino pin 3 (PWM) */ +#define ARDUINO_PIN_3 GPIO0 /**< Arduino pin 3 (PWM / BTN0) */ #define ARDUINO_PIN_4 GPIO22 /**< Arduino pin 4 */ -#define ARDUINO_PIN_5 GPIO4 /**< Arduino pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO23 /**< Arduino pin 6 (PWM) */ +#define ARDUINO_PIN_5 GPIO4 /**< Arduino pin 5 (PWM / LED2) */ +#define ARDUINO_PIN_6 GPIO23 /**< Arduino pin 6 */ #define ARDUINO_PIN_7 GPIO25 /**< Arduino pin 7 */ #define ARDUINO_PIN_8 GPIO9 /**< Arduino pin 8 */ -#define ARDUINO_PIN_9 GPIO10 /**< Arduino pin 9 (PWM) */ +#define ARDUINO_PIN_9 GPIO10 /**< Arduino pin 9 */ -#define ARDUINO_PIN_10 GPIO13 /**< Arduino pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO15 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_10 GPIO13 /**< Arduino pin 10 (CS0) */ +#define ARDUINO_PIN_11 GPIO15 /**< Arduino pin 11 (MOSI) */ #define ARDUINO_PIN_12 GPIO2 /**< Arduino pin 12 (MISO) */ #define ARDUINO_PIN_13 GPIO14 /**< Arduino pin 13 (SCK) */ -#define ARDUINO_PIN_14 GPIO34 /**< Arduino pin A0 */ -#define ARDUINO_PIN_15 GPIO35 /**< Arduino pin A1 */ -#define ARDUINO_PIN_16 GPIO36 /**< Arduino pin A2 */ -#define ARDUINO_PIN_17 GPIO39 /**< Arduino pin A3 */ +#define ARDUINO_PIN_14 GPIO34 /**< Arduino pin 14 (A0) */ +#define ARDUINO_PIN_15 GPIO35 /**< Arduino pin 15 (A1) */ +#define ARDUINO_PIN_16 GPIO36 /**< Arduino pin 16 (A2) */ +#define ARDUINO_PIN_17 GPIO39 /**< Arduino pin 17 (A3) */ -#define ARDUINO_PIN_18 GPIO26 /**< Arduino pin A4 (SDA) */ -#define ARDUINO_PIN_19 GPIO27 /**< Arduino pin A5 (SCL) */ +#define ARDUINO_PIN_18 GPIO26 /**< Arduino pin 18 (SDA) */ +#define ARDUINO_PIN_19 GPIO27 /**< Arduino pin 19 (SCL) */ -#define ARDUINO_PIN_LAST 19 +#define ARDUINO_PIN_LAST 19 /**< Last Arduino pin index */ /** @} */ +#if !MODULE_ESP32_WROVER_KIT_CAMERA /** * @name Aliases for analog pins + * Analog pins are only available if the CAM module is not used. + * @{ + */ +# define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino pin A0 */ +# define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino pin A1 */ +# define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino pin A2 */ +# define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino pin A3 */ +/** @} */ + +/** + * @name Mapping of Arduino analog pins to RIOT ADC lines + * Analog pins are only available if the CAM module is not used. + * @{ + */ +# define ARDUINO_A0 ADC_LINE(0) /**< ADC line for Arduino pin A0 */ +# define ARDUINO_A1 ADC_LINE(1) /**< ADC line for Arduino pin A1 */ +# define ARDUINO_A2 ADC_LINE(2) /**< ADC line for Arduino pin A2 */ +# define ARDUINO_A3 ADC_LINE(3) /**< ADC line for Arduino pin A3 */ + +# define ARDUINO_ANALOG_PIN_LAST 3 /**< Last Arduino analog pin index */ +/** @} */ +#endif + +/** + * @name Mapping of Arduino pins to RIOT PWM dev and channel pairs * @{ */ -#define ARDUINO_PIN_A0 ARDUINO_PIN_14 -#define ARDUINO_PIN_A1 ARDUINO_PIN_15 -#define ARDUINO_PIN_A2 ARDUINO_PIN_16 -#define ARDUINO_PIN_A3 ARDUINO_PIN_17 -#define ARDUINO_PIN_A4 ARDUINO_PIN_18 -#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +#if !MODULE_ESP32_WROVER_KIT_CAMERA +# define ARDUINO_PIN_3_PWM_DEV PWM_DEV(1) /**< PWM device for Arduino pin 3 */ +# define ARDUINO_PIN_3_PWM_CHAN 0 /**< PWM channel for Arduino pin 3 */ +# if !MODULE_PERIPH_SDMMC +# define ARDUINO_PIN_5_PWM_DEV PWM_DEV(1) /**< PWM device for Arduino pin 5 */ +# define ARDUINO_PIN_5_PWM_CHAN 1 /**< PWM channel for Arduino pin 5 */ +# endif /* !MODULE_PERIPH_SDMMC */ +#endif /* !MODULE_ESP32_WROVER_KIT_CAMERA */ /** @} */ #ifdef __cplusplus diff --git a/boards/esp32-wrover-kit/include/board.h b/boards/esp32-wrover-kit/include/board.h index f41e76e1a736..2bce29092208 100644 --- a/boards/esp32-wrover-kit/include/board.h +++ b/boards/esp32-wrover-kit/include/board.h @@ -57,13 +57,14 @@ #define LED0_ACTIVE (1) /**< LED0 is high active */ #endif -#if !MODULE_SDCARD_SPI || DOXYGEN -#define LED1_PIN GPIO2 /**< LED1 is available when the SD-Card is not used */ +#if !MODULE_PERIPH_SPI || DOXYGEN +#define LED1_PIN GPIO2 /**< LED1 is available when the SPI bus is not used */ #define LED1_ACTIVE (1) /**< LED1 is high active */ #endif -#if !MODULE_ESP32_WROVER_KIT_CAMERA || DOXYGEN -#define LED2_PIN GPIO4 /**< LED2 is available when the camera is not plugged in */ +#if (!MODULE_ESP32_WROVER_KIT_CAMERA && !MODULE_PERIPH_SDMMC) || DOXYGEN +#define LED2_PIN GPIO4 /**< LED2 is available when the camera is not plugged in + and SDMMD is not used */ #define LED2_ACTIVE (1) /**< LED2 is high active */ #endif diff --git a/boards/esp32c3-devkit/Makefile.features b/boards/esp32c3-devkit/Makefile.features index b705976d6833..24c8359fc8de 100644 --- a/boards/esp32c3-devkit/Makefile.features +++ b/boards/esp32c3-devkit/Makefile.features @@ -12,4 +12,9 @@ FEATURES_PROVIDED += periph_spi # unique features provided by the board FEATURES_PROVIDED += esp_jtag +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_i2c FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_pwm +FEATURES_PROVIDED += arduino_spi +FEATURES_PROVIDED += arduino_uart diff --git a/boards/esp32c3-devkit/doc.txt b/boards/esp32c3-devkit/doc.txt index 7f468320d523..c87aa20f9473 100644 --- a/boards/esp32c3-devkit/doc.txt +++ b/boards/esp32c3-devkit/doc.txt @@ -70,7 +70,8 @@ configuration is the most flexible one which provides: - 6 x ADC channels at maximum - 1 x SPI - 1 x I2C -- 2 x UART +- 1 x UART +- 2 x PWM with 2 channels each - 1 RGB-LED Since all GPIOs have broken out, GPIOs can be used for different purposes @@ -102,22 +103,25 @@ overridden by \ref esp32_application_specific_configurations
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" -RGB-LED | GPIO8 | supported by driver module `ws281x` | | -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" +BUTTON0 | GPIO9 | | | +ADC | GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5 | | \ref esp32_adc_channels "ADC Channels" +PWM_DEV(0) | GPIO3, GPIO4 | | \ref esp32_pwm_channels "PWM Channels" +PWM_DEV(1) | GPIO10, GPIO7 | conflicts with SPI_DEV(0) | \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" +RGB-LED | GPIO8 | supported by driver module `ws281x` | | +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"
\n -@note The configuration of ADC channels contains all ESP32-C3 GPIOs that could - be used as ADC channels. +@note +- The configuration of ADC channels contains all ESP32-C3 GPIOs that could + be used as ADC channels. +- PWM_DEV(1) is only available if SPI_DEV(0) is not used. For detailed information about the peripheral configurations of ESP32-C3 boards, see section \ref esp32_peripherals "Common Peripherals". @@ -129,8 +133,8 @@ boards, see section \ref esp32_peripherals "Common Peripherals". 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" +@image html https://gitlab.com/gschorcht/RIOT.wiki-Images/-/raw/master/esp32/ESP32-C3-DevKitM-1_pinout_v2.png "EPS32-C3-DevKitM-1x Pinout" +@image html https://gitlab.com/gschorcht/RIOT.wiki-Images/-/raw/master/esp32/ESP32-C3-DevKitC-02_pinout_v2.png "EPS32-C3-DevKitC-02x Pinout" The corresponding board schematics can be found: diff --git a/boards/esp32c3-devkit/include/arduino_iomap.h b/boards/esp32c3-devkit/include/arduino_iomap.h index 70601e8bda5a..c744fdfd2c65 100644 --- a/boards/esp32c3-devkit/include/arduino_iomap.h +++ b/boards/esp32c3-devkit/include/arduino_iomap.h @@ -26,19 +26,22 @@ extern "C" { #endif +#define ARDUINO_UART_D0D1 UART_DEV(0) /**< Arduino UART interface */ +#define ARDUINO_SPI_D11D12D13 SPI_DEV(0) /**< Arduino SPI bus */ + /** * @name Mapping of MCU pins to Arduino pins * @{ */ #define ARDUINO_PIN_0 GPIO20 /**< Arduino pin 0 (RxD) */ #define ARDUINO_PIN_1 GPIO21 /**< Arduino pin 1 (TxD) */ -#if !defined(MODULE_ESP_RTC_TIMER_32K) #define ARDUINO_PIN_2 GPIO0 /**< Arduino pin 2 */ #define ARDUINO_PIN_3 GPIO1 /**< Arduino pin 3 (PWM) */ -#endif +#define ARDUINO_PIN_4 GPIO9 /**< Arduino pin 4 (BOOT / BTN0) */ #define ARDUINO_PIN_5 GPIO3 /**< Arduino pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO4 /**< Arduino pin 6 (PWM) */ -#define ARDUINO_PIN_7 GPIO8 /**< Arduino pin 7 */ +#define ARDUINO_PIN_6 GPIO8 /**< Arduino pin 6 (RGB-LED) */ + +/* Arduino pins D7 ... D9 are not available */ #define ARDUINO_PIN_10 GPIO10 /**< Arduino pin 10 (CS0 / PWM) */ #define ARDUINO_PIN_11 GPIO7 /**< Arduino pin 11 (MOSI / PWM) */ @@ -46,30 +49,60 @@ extern "C" { #define ARDUINO_PIN_13 GPIO6 /**< Arduino pin 13 (SCK) */ /* analog pins as digital pins: */ -#define ARDUINO_PIN_14 GPIO0 /**< Arduino pin A0 */ -#if !defined(MODULE_ESP_RTC_TIMER_32K) -#define ARDUINO_PIN_15 GPIO1 /**< Arduino pin A1 */ -#endif -#define ARDUINO_PIN_16 GPIO2 /**< Arduino pin A2 */ -#define ARDUINO_PIN_17 GPIO3 /**< Arduino pin A3 */ +#define ARDUINO_PIN_14 GPIO0 /**< Arduino pin 14 (A0) */ +#define ARDUINO_PIN_15 GPIO1 /**< Arduino pin 15 (A1) */ +#define ARDUINO_PIN_16 GPIO2 /**< Arduino pin 16 (A2) */ +#define ARDUINO_PIN_17 GPIO3 /**< Arduino pin 17 (A3) */ -#define ARDUINO_PIN_18 GPIO5 /**< Arduino pin A4 (SDA) */ -#define ARDUINO_PIN_19 GPIO4 /**< Arduino pin A5 (SCL) */ +#define ARDUINO_PIN_18 GPIO5 /**< Arduino pin 18 (A4 / SDA) */ +#define ARDUINO_PIN_19 GPIO4 /**< Arduino pin 19 (A5 / SCL) */ -#define ARDUINO_PIN_LAST 19 +#define ARDUINO_PIN_LAST 19 /**< Last Arduino pin index */ /** @} */ /** * @name Aliases for analog pins * @{ */ -#define ARDUINO_PIN_A0 ARDUINO_PIN_14 -#define ARDUINO_PIN_A1 ARDUINO_PIN_15 -#define ARDUINO_PIN_A2 ARDUINO_PIN_16 -#define ARDUINO_PIN_A3 ARDUINO_PIN_17 +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino pin A3 */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino pin A5 */ +/** @} */ + +/** + * @name Mapping of Arduino analog pins to RIOT ADC lines + * @{ + */ +#define ARDUINO_A0 ADC_LINE(0) /**< ADC line for Arduino pin A0 */ +#define ARDUINO_A1 ADC_LINE(1) /**< ADC line for Arduino pin A1 */ +#define ARDUINO_A2 ADC_LINE(2) /**< ADC line for Arduino pin A2 */ +#define ARDUINO_A3 ADC_LINE(3) /**< ADC line for Arduino pin A3 */ +#define ARDUINO_A4 ADC_LINE(4) /**< ADC line for Arduino pin A4 */ +#define ARDUINO_A5 ADC_LINE(5) /**< ADC line for Arduino pin A5 */ -#define ARDUINO_PIN_A4 ARDUINO_PIN_18 -#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +#define ARDUINO_ANALOG_PIN_LAST 5 /**< Last Arduino analog pin index */ +/** @} */ + +/** + * @name Mapping of Arduino pins to RIOT PWM dev and channel pairs + * @{ + */ +#define ARDUINO_PIN_3_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 3 */ +#define ARDUINO_PIN_3_PWM_CHAN 0 /**< PWM channel for Arduino pin 3 */ + +#define ARDUINO_PIN_5_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 5 */ +#define ARDUINO_PIN_5_PWM_CHAN 1 /**< PWM channel for Arduino pin 5 */ + +#ifndef MODULE_PERIPH_SPI +#define ARDUINO_PIN_10_PWM_DEV PWM_DEV(1) /**< PWM device for Arduino pin 10 */ +#define ARDUINO_PIN_10_PWM_CHAN 0 /**< PWM channel for Arduino pin 10 */ + +#define ARDUINO_PIN_11_PWM_DEV PWM_DEV(1) /**< PWM device for Arduino pin 11 */ +#define ARDUINO_PIN_11_PWM_CHAN 1 /**< PWM channel for Arduino pin 11 */ +#endif /** @} */ #ifdef __cplusplus diff --git a/boards/esp32c3-devkit/include/periph_conf.h b/boards/esp32c3-devkit/include/periph_conf.h index 0d1969375f56..fc7384b00f8d 100644 --- a/boards/esp32c3-devkit/include/periph_conf.h +++ b/boards/esp32c3-devkit/include/periph_conf.h @@ -88,7 +88,7 @@ extern "C" { * @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. + * contain all GPIOs that are not defined as I2C 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 @@ -103,7 +103,17 @@ extern "C" { * at maximum PWM_CHANNEL_NUM_DEV_MAX. */ #ifndef PWM0_GPIOS -#define PWM0_GPIOS { GPIO3, GPIO4 } +# define PWM0_GPIOS { GPIO3, GPIO1 } +#endif + +/** + * @brief Declaration of the channels for device PWM_DEV(1), + * at maximum PWM_CHANNEL_NUM_DEV_MAX. + * + * PWM_DEV(1) is only used if SPI peripheral is not enabled. + */ +#if !defined(PWM1_GPIOS) && !defined(MODULE_PERIPH_SPI) +# define PWM1_GPIOS { GPIO10, GPIO7 } #endif /** @} */ diff --git a/boards/esp32c3-wemos-mini/Makefile.features b/boards/esp32c3-wemos-mini/Makefile.features index c857e9e2cdd6..a611f116a8d6 100644 --- a/boards/esp32c3-wemos-mini/Makefile.features +++ b/boards/esp32c3-wemos-mini/Makefile.features @@ -12,4 +12,9 @@ FEATURES_PROVIDED += periph_spi # unique features provided by the board FEATURES_PROVIDED += esp_jtag +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_i2c FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_pwm +FEATURES_PROVIDED += arduino_spi +FEATURES_PROVIDED += arduino_uart diff --git a/boards/esp32c3-wemos-mini/doc.txt b/boards/esp32c3-wemos-mini/doc.txt index ada24a86eeb9..33d7b8dd22b5 100644 --- a/boards/esp32c3-wemos-mini/doc.txt +++ b/boards/esp32c3-wemos-mini/doc.txt @@ -97,7 +97,7 @@ Almost all GPIOs are broken out and can be used for different peripherals: - 1 x SPI - 1 x I2C - 1 x UART -- 2 x PWM channels +- 1 x PWM with 3 channels However, since the number of GPIOs of the ESP32-C3 SoC is very limited, some GPIOs are used in multiple peripheral configurations but can only be used for @@ -122,18 +122,18 @@ This configuration can be overridden by \ref esp32_application_specific_configur
Function | v1.0.0 | v2.1.0 | Remarks | Configuration :---------------|:-------|:-------|:--------|:--------------------- -BUTTON0 | GPIO9 | GPIO9 | | | -ADC | GPIO0 ... GPIO5 | GPIO0 ... GPIO5 | | see \ref esp32_adc_channels "ADC Channels" -I2C_DEV(0):SCL | GPIO10 | GPIO10 | | \ref esp32_i2c_interfaces "I2C Interfaces" -I2C_DEV(0):SDA | GPIO8 | GPIO8 | | \ref esp32_i2c_interfaces "I2C Interfaces" -LED0 | GPIO7 | - | | | -PWM_DEV(0) | GPIO1, GPIO6, GPIO7 | GPIO2, GPIO6 | | \ref esp32_pwm_channels "PWM Channels" -RGB-LED | - | GPIO7 | supported by driver module `ws281x` | | -SPI_DEV(0):CLK | GPIO2 | GPIO1 | SPI2_HOST (FSPI) is used | \ref esp32_spi_interfaces "SPI Interfaces" -SPI_DEV(0):MISO | GPIO3 | GPIO0 | SPI2_HOST (FSPI) is used | \ref esp32_spi_interfaces "SPI Interfaces" -SPI_DEV(0):MOSI | GPIO4 | GPIO4 | SPI2_HOST (FSPI) is used | \ref esp32_spi_interfaces "SPI Interfaces" -SPI_DEV(0):CS0 | GPIO5 | GPIO5 | SPI2_HOST (FSPI) is used | \ref esp32_spi_interfaces "SPI Interfaces" -UART_DEV(0):TxD | GPIO21 | GPIO21 | Console (configuration is fixed) | \ref esp32_uart_interfaces "UART interfaces" +BUTTON0 | GPIO9 | GPIO9 | | | +ADC | GPIO0 ... GPIO5 | GPIO0 ... GPIO5 | | \ref esp32_adc_channels "ADC Channels" +I2C_DEV(0):SCL | GPIO10 | GPIO10 | | \ref esp32_i2c_interfaces "I2C Interfaces" +I2C_DEV(0):SDA | GPIO8 | GPIO8 | | \ref esp32_i2c_interfaces "I2C Interfaces" +LED0 | GPIO7 | - | | | +PWM_DEV(0) | GPIO1, GPIO6, GPIO7 | GPIO2, GPIO6, GPIO3 | | \ref esp32_pwm_channels "PWM Channels" +RGB-LED | - | GPIO7 | supported by driver module `ws281x` | | +SPI_DEV(0):CLK | GPIO2 | GPIO1 | SPI2_HOST (FSPI) is used | \ref esp32_spi_interfaces "SPI Interfaces" +SPI_DEV(0):MISO | GPIO3 | GPIO0 | SPI2_HOST (FSPI) is used | \ref esp32_spi_interfaces "SPI Interfaces" +SPI_DEV(0):MOSI | GPIO4 | GPIO4 | SPI2_HOST (FSPI) is used | \ref esp32_spi_interfaces "SPI Interfaces" +SPI_DEV(0):CS0 | GPIO5 | GPIO5 | SPI2_HOST (FSPI) is used | \ref esp32_spi_interfaces "SPI Interfaces" +UART_DEV(0):TxD | GPIO21 | GPIO21 | Console (configuration is fixed) | \ref esp32_uart_interfaces "UART interfaces" UART_DEV(0):RxD | GPIO20 | GPIO20 | Console (configuration is fixed) | \ref esp32_uart_interfaces "UART interfaces"
\n @@ -150,7 +150,7 @@ boards, see section \ref esp32_peripherals "Common Peripherals". The following figures show the pinouts as configured by default board definition. -@image html https://gitlab.com/gschorcht/RIOT.wiki-Images/-/raw/master/esp32/Wesos_ESP32-C3_mini_pinout.png "Wemos EPS32-C3 mini Pinout" +@image html https://gitlab.com/gschorcht/RIOT.wiki-Images/-/raw/master/esp32/Wemos_ESP32-C3_mini_pinout_v2.png "Wemos EPS32-C3 mini Pinout" The corresponding board schematics can be found: diff --git a/boards/esp32c3-wemos-mini/include/arduino_iomap.h b/boards/esp32c3-wemos-mini/include/arduino_iomap.h index aea991ebc232..4aee76c2c143 100644 --- a/boards/esp32c3-wemos-mini/include/arduino_iomap.h +++ b/boards/esp32c3-wemos-mini/include/arduino_iomap.h @@ -26,43 +26,55 @@ extern "C" { #endif +#define ARDUINO_UART_D0D1 UART_DEV(0) /**< Arduino UART interface */ +#define ARDUINO_SPI_D11D12D13 SPI_DEV(0) /**< Arduino SPI bus */ + +#ifdef MODULE_ESP32C3_WEMOS_MINI_V1_0_0 +# define ARDUINO_LED (5) /**< LED is connected to Arduino pin 5 */ +#endif + /** * @name Mapping of MCU pins to Arduino pins * @{ */ #define ARDUINO_PIN_0 GPIO20 /**< Arduino pin 0 (RxD) */ #define ARDUINO_PIN_1 GPIO21 /**< Arduino pin 1 (TxD) */ -#define ARDUINO_PIN_2 GPIO9 /**< Arduino pin 2 */ +#define ARDUINO_PIN_2 GPIO9 /**< Arduino pin 2 (BTN0) */ #define ARDUINO_PIN_3 GPIO6 /**< Arduino pin 3 (PWM) */ #ifdef MODULE_ESP32C3_WEMOS_MINI_V1_0_0 -# define ARDUINO_PIN_5 GPIO7 /**< Arduino pin 5 (PWM) */ -# define ARDUINO_PIN_6 GPIO1 /**< Arduino pin 6 (PWM) */ -# define ARDUINO_PIN_7 GPIO0 /**< Arduino pin 7 */ -#else /* MODULE_ESP32C3_WEMOS_MINI_V2_1_0 */ -# define ARDUINO_PIN_6 GPIO2 /**< Arduino pin 6 (PWM) */ -# define ARDUINO_PIN_7 GPIO3 /**< Arduino pin 7 */ -#endif -#ifdef MODULE_ESP32C3_WEMOS_MINI_V1_0_0 -# define ARDUINO_PIN_10 GPIO5 /**< Arduino pin 10 (CS0 / PWM) */ -# define ARDUINO_PIN_11 GPIO4 /**< Arduino pin 11 (MOSI / PWM) */ +# define ARDUINO_PIN_4 GPIO0 /**< Arduino pin 4 */ +# define ARDUINO_PIN_5 GPIO1 /**< Arduino pin 5 (PWM/LED) */ +# define ARDUINO_PIN_6 GPIO7 /**< Arduino pin 6 (PWM) */ + +# define ARDUINO_PIN_10 GPIO5 /**< Arduino pin 10 (CS0) */ +# define ARDUINO_PIN_11 GPIO4 /**< Arduino pin 11 (MOSI) */ # define ARDUINO_PIN_12 GPIO3 /**< Arduino pin 12 (MISO) */ # define ARDUINO_PIN_13 GPIO2 /**< Arduino pin 13 (SCK) */ + #else /* MODULE_ESP32C3_WEMOS_MINI_V2_1_0 */ -# define ARDUINO_PIN_10 GPIO5 /**< Arduino pin 10 (CS0 / PWM) */ -# define ARDUINO_PIN_11 GPIO4 /**< Arduino pin 11 (MOSI / PWM) */ + +# define ARDUINO_PIN_4 GPIO7 /**< Arduino pin 4 (RGB LED) */ +# define ARDUINO_PIN_6 GPIO2 /**< Arduino pin 5 (PWM) */ +# define ARDUINO_PIN_7 GPIO3 /**< Arduino pin 6 (PWM) */ + +# define ARDUINO_PIN_10 GPIO5 /**< Arduino pin 10 (CS0) */ +# define ARDUINO_PIN_11 GPIO4 /**< Arduino pin 11 (MOSI) */ # define ARDUINO_PIN_12 GPIO0 /**< Arduino pin 12 (MISO) */ # define ARDUINO_PIN_13 GPIO1 /**< Arduino pin 13 (SCK) */ + #endif +/* Arduino pins 7 ... 9 are not available */ + /* analog pins as digital pin: */ -#define ARDUINO_PIN_14 GPIO0 /**< Arduino pin A0 */ -#define ARDUINO_PIN_15 GPIO1 /**< Arduino pin A1 */ -#define ARDUINO_PIN_16 GPIO2 /**< Arduino pin A2 */ -#define ARDUINO_PIN_17 GPIO3 /**< Arduino pin A3 */ -#define ARDUINO_PIN_18 GPIO4 /**< Arduino pin A4 (SDA) */ -#define ARDUINO_PIN_19 GPIO5 /**< Arduino pin A5 (SCL) */ +#define ARDUINO_PIN_14 GPIO0 /**< Arduino pin 14 (A0) */ +#define ARDUINO_PIN_15 GPIO1 /**< Arduino pin 15 (A1) */ +#define ARDUINO_PIN_16 GPIO2 /**< Arduino pin 16 (A2) */ +#define ARDUINO_PIN_17 GPIO3 /**< Arduino pin 17 (A3) */ +#define ARDUINO_PIN_18 GPIO4 /**< Arduino pin 18 (A4) */ +#define ARDUINO_PIN_19 GPIO5 /**< Arduino pin 19 (A5) */ #define ARDUINO_PIN_LAST 19 /** @} */ @@ -71,12 +83,40 @@ extern "C" { * @name Aliases for analog pins * @{ */ -#define ARDUINO_PIN_A0 ARDUINO_PIN_14 -#define ARDUINO_PIN_A1 ARDUINO_PIN_15 -#define ARDUINO_PIN_A2 ARDUINO_PIN_16 -#define ARDUINO_PIN_A3 ARDUINO_PIN_17 -#define ARDUINO_PIN_A4 ARDUINO_PIN_18 -#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino pin A3 */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino pin A5 */ +/** @} */ + +/** + * @name Mapping of Arduino analog pins to RIOT ADC lines + * @{ + */ +#define ARDUINO_A0 ADC_LINE(0) /**< ADC line for Arduino pin A0 */ +#define ARDUINO_A1 ADC_LINE(1) /**< ADC line for Arduino pin A1 */ +#define ARDUINO_A2 ADC_LINE(2) /**< ADC line for Arduino pin A2 */ +#define ARDUINO_A3 ADC_LINE(3) /**< ADC line for Arduino pin A3 */ +#define ARDUINO_A4 ADC_LINE(4) /**< ADC line for Arduino pin A4 */ +#define ARDUINO_A5 ADC_LINE(5) /**< ADC line for Arduino pin A5 */ + +#define ARDUINO_ANALOG_PIN_LAST 5 +/** @} */ + +/** + * @name Mapping of Arduino pins to RIOT PWM dev and channel pairs + * @{ + */ +#define ARDUINO_PIN_3_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 3 */ +#define ARDUINO_PIN_3_PWM_CHAN 1 /**< PWM channel for Arduino pin 3 */ + +#define ARDUINO_PIN_5_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 5 */ +#define ARDUINO_PIN_5_PWM_CHAN 0 /**< PWM channel for Arduino pin 5 */ + +#define ARDUINO_PIN_6_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 6 */ +#define ARDUINO_PIN_6_PWM_CHAN 2 /**< PWM channel for Arduino pin 6 */ /** @} */ #ifdef __cplusplus diff --git a/boards/esp32c3-wemos-mini/include/periph_conf.h b/boards/esp32c3-wemos-mini/include/periph_conf.h index 931583dddfb3..b3288db168b5 100644 --- a/boards/esp32c3-wemos-mini/include/periph_conf.h +++ b/boards/esp32c3-wemos-mini/include/periph_conf.h @@ -89,9 +89,8 @@ extern "C" { /** * @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. + * One PWM device is configured. It uses all GPIOs that are not defined as + * I2C, SPI or UART for this board. * * @note As long as the according PWM device is not initialized with * the `pwm_init`, the GPIOs declared for this device can be used @@ -105,11 +104,11 @@ extern "C" { * at maximum PWM_CHANNEL_NUM_DEV_MAX. */ #ifndef PWM0_GPIOS -#ifdef MODULE_ESP32C3_WEMOS_MINI_V1_0_0 -#define PWM0_GPIOS { GPIO1, GPIO6, GPIO7 } -#else /* MODULE_ESP32C3_WEMOS_MINI_V2_1_0 */ -#define PWM0_GPIOS { GPIO2, GPIO6 } -#endif +# ifdef MODULE_ESP32C3_WEMOS_MINI_V1_0_0 +# define PWM0_GPIOS { GPIO1, GPIO6, GPIO7 } +# else /* MODULE_ESP32C3_WEMOS_MINI_V2_1_0 */ +# define PWM0_GPIOS { GPIO2, GPIO6, GPIO3 } +# endif #endif /** @} */ diff --git a/boards/esp32s2-devkit/Makefile.features b/boards/esp32s2-devkit/Makefile.features index d04a85b206df..7b0c3d4ab480 100644 --- a/boards/esp32s2-devkit/Makefile.features +++ b/boards/esp32s2-devkit/Makefile.features @@ -39,9 +39,15 @@ FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_spi +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_dac +FEATURES_PROVIDED += arduino_i2c FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_pwm +FEATURES_PROVIDED += arduino_spi +FEATURES_PROVIDED += arduino_uart ifneq (,$(filter esp32s2-devkitc-%,$(BOARD_VERSION))) FEATURES_PROVIDED += periph_usbdev FEATURES_PROVIDED += tinyusb_device -endif \ No newline at end of file +endif diff --git a/boards/esp32s2-devkit/include/arduino_iomap.h b/boards/esp32s2-devkit/include/arduino_iomap.h index 4085ca4dcc5f..083b2e797664 100644 --- a/boards/esp32s2-devkit/include/arduino_iomap.h +++ b/boards/esp32s2-devkit/include/arduino_iomap.h @@ -26,49 +26,98 @@ extern "C" { #endif +#define ARDUINO_UART_D0D1 UART_DEV(0) /**< Arduino UART interface */ +#define ARDUINO_SPI_D11D12D13 SPI_DEV(0) /**< Arduino SPI bus */ + /** * @name Mapping of MCU pins to Arduino pins * @{ */ #define ARDUINO_PIN_0 GPIO44 /**< Arduino pin 0 (RxD) */ #define ARDUINO_PIN_1 GPIO43 /**< Arduino pin 1 (TxD) */ -#define ARDUINO_PIN_2 GPIO0 /**< Arduino pin 2 */ -#define ARDUINO_PIN_3 GPIO10 /**< Arduino pin 3 (PWM) */ +#define ARDUINO_PIN_2 GPIO0 /**< Arduino pin 2 (BTN0) */ +#define ARDUINO_PIN_3 GPIO11 /**< Arduino pin 3 (PWM) */ #define ARDUINO_PIN_4 GPIO3 /**< Arduino pin 4 */ -#define ARDUINO_PIN_5 GPIO11 /**< Arduino pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO12 /**< Arduino pin 6 (PWM) */ +#define ARDUINO_PIN_5 GPIO12 /**< Arduino pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO13 /**< Arduino pin 6 (PWM) */ #define ARDUINO_PIN_7 GPIO6 /**< Arduino pin 7 */ #define ARDUINO_PIN_8 GPIO7 /**< Arduino pin 8 */ -#define ARDUINO_PIN_9 GPIO13 /**< Arduino pin 9 (PWM) */ +#define ARDUINO_PIN_9 GPIO14 /**< Arduino pin 9 (PWM) */ -#define ARDUINO_PIN_10 GPIO38 /**< Arduino pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO35 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_10 GPIO34 /**< Arduino pin 10 (CS0) */ +#define ARDUINO_PIN_11 GPIO35 /**< Arduino pin 11 (MOSI) */ #define ARDUINO_PIN_12 GPIO37 /**< Arduino pin 12 (MISO) */ -#define ARDUINO_PIN_13 GPIO36 /**< Arduino pin 13 (SCK) */ +#define ARDUINO_PIN_13 GPIO36 /**< Arduino pin 13 (SCK) */ /* analog pins as digital pin */ -#define ARDUINO_PIN_14 GPIO1 /**< Arduino pin A0 */ -#define ARDUINO_PIN_15 GPIO2 /**< Arduino pin A1 */ -#define ARDUINO_PIN_16 GPIO4 /**< Arduino pin A2 */ -#define ARDUINO_PIN_17 GPIO5 /**< Arduino pin A3 */ +#define ARDUINO_PIN_14 GPIO1 /**< Arduino pin 14 (A0) */ +#define ARDUINO_PIN_15 GPIO2 /**< Arduino pin 15 (A1) */ +#define ARDUINO_PIN_16 GPIO4 /**< Arduino pin 16 (A2) */ +#define ARDUINO_PIN_17 GPIO5 /**< Arduino pin 17 (A3) */ + +#define ARDUINO_PIN_18 GPIO8 /**< Arduino pin 18 (A4 / SDA) */ +#define ARDUINO_PIN_19 GPIO9 /**< Arduino pin 19 (A5 / SCL) */ -#define ARDUINO_PIN_18 GPIO8 /**< Arduino pin A4 (SDA) */ -#define ARDUINO_PIN_19 GPIO9 /**< Arduino pin A5 (SCL) */ +#define ARDUINO_PIN_20 GPIO17 /**< Arduino pin 20 (DAC0) */ +#define ARDUINO_PIN_21 GPIO18 /**< Arduino pin 21 (DAC1) */ -#define ARDUINO_PIN_LAST 19 +#define ARDUINO_PIN_LAST 21 /**< Last Arduino pin index */ /** @} */ /** * @name Aliases for analog pins * @{ */ -#define ARDUINO_PIN_A0 ARDUINO_PIN_14 -#define ARDUINO_PIN_A1 ARDUINO_PIN_15 -#define ARDUINO_PIN_A2 ARDUINO_PIN_16 -#define ARDUINO_PIN_A3 ARDUINO_PIN_17 +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino pin A3 */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino pin A5 */ + +#define ARDUINO_PIN_DAC0 ARDUINO_PIN_20 /**< Arduino pin DAC0 */ +#define ARDUINO_PIN_DAC1 ARDUINO_PIN_21 /**< Arduino pin DAC1 */ +/** @} */ + +/** + * @name Mapping of Arduino analog pins to RIOT ADC lines + * @{ + */ +#define ARDUINO_A0 ADC_LINE(0) /**< ADC line for Arduino pin A0 */ +#define ARDUINO_A1 ADC_LINE(1) /**< ADC line for Arduino pin A1 */ +#define ARDUINO_A2 ADC_LINE(3) /**< ADC line for Arduino pin A2 */ +#define ARDUINO_A3 ADC_LINE(4) /**< ADC line for Arduino pin A3 */ +#define ARDUINO_A4 ADC_LINE(7) /**< ADC line for Arduino pin A4 */ +#define ARDUINO_A5 ADC_LINE(8) /**< ADC line for Arduino pin A5 */ + +#define ARDUINO_ANALOG_PIN_LAST 5 +/** @} */ + +/** + * @name Mapping of Arduino DAC pins to RIOT DAC lines + * @{ + */ +#define ARDUINO_DAC0 DAC_LINE(0) /**< DAC line for Arduino pin DAC0 */ +#define ARDUINO_DAC1 DAC_LINE(1) /**< DAC line for Arduino pin DAC1 */ + +#define ARDUINO_DAC_PIN_LAST 1 /**< Last Arduino DAC pin index */ +/** @} */ + +/** + * @name Mapping of Arduino pins to RIOT PWM dev and channel pairs + * @{ + */ +#define ARDUINO_PIN_3_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 3 */ +#define ARDUINO_PIN_3_PWM_CHAN 0 /**< PWM channel for Arduino pin 3 */ + +#define ARDUINO_PIN_5_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 5 */ +#define ARDUINO_PIN_5_PWM_CHAN 1 /**< PWM channel for Arduino pin 5 */ + +#define ARDUINO_PIN_6_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 6 */ +#define ARDUINO_PIN_6_PWM_CHAN 2 /**< PWM channel for Arduino pin 6 */ -#define ARDUINO_PIN_A4 ARDUINO_PIN_18 -#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +#define ARDUINO_PIN_9_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 9 */ +#define ARDUINO_PIN_9_PWM_CHAN 3 /**< PWM channel for Arduino pin 9 */ /** @} */ #ifdef __cplusplus diff --git a/boards/esp32s2-lilygo-ttgo-t8/Makefile.features b/boards/esp32s2-lilygo-ttgo-t8/Makefile.features index 024e2119d7e2..42ca342112ff 100644 --- a/boards/esp32s2-lilygo-ttgo-t8/Makefile.features +++ b/boards/esp32s2-lilygo-ttgo-t8/Makefile.features @@ -14,7 +14,14 @@ FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_usbdev # other features provided by the board +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_dac +FEATURES_PROVIDED += arduino_i2c FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_pwm +FEATURES_PROVIDED += arduino_spi +FEATURES_PROVIDED += arduino_uart + FEATURES_PROVIDED += esp_rtc_timer_32k FEATURES_PROVIDED += sdcard_spi FEATURES_PROVIDED += tinyusb_device diff --git a/boards/esp32s2-lilygo-ttgo-t8/include/arduino_iomap.h b/boards/esp32s2-lilygo-ttgo-t8/include/arduino_iomap.h index 22adb1e91ba7..3d881063cf53 100644 --- a/boards/esp32s2-lilygo-ttgo-t8/include/arduino_iomap.h +++ b/boards/esp32s2-lilygo-ttgo-t8/include/arduino_iomap.h @@ -26,13 +26,16 @@ extern "C" { #endif +#define ARDUINO_UART_D0D1 UART_DEV(0) /**< Arduino UART interface */ +#define ARDUINO_SPI_D11D12D13 SPI_DEV(0) /**< Arduino SPI bus */ + /** * @name Mapping of MCU pins to Arduino pins * @{ */ #define ARDUINO_PIN_0 GPIO44 /**< Arduino pin 0 (RxD) */ #define ARDUINO_PIN_1 GPIO43 /**< Arduino pin 1 (TxD) */ -#define ARDUINO_PIN_2 GPIO21 /**< Arduino pin 2 */ +#define ARDUINO_PIN_2 GPIO0 /**< Arduino pin 2 (BTN0) */ #define ARDUINO_PIN_3 GPIO39 /**< Arduino pin 3 (PWM) */ #define ARDUINO_PIN_4 GPIO21 /**< Arduino pin 4 */ #define ARDUINO_PIN_5 GPIO40 /**< Arduino pin 5 (PWM) */ @@ -41,34 +44,80 @@ extern "C" { #define ARDUINO_PIN_8 GPIO18 /**< Arduino pin 8 */ #define ARDUINO_PIN_9 GPIO42 /**< Arduino pin 9 (PWM) */ -#define ARDUINO_PIN_10 GPIO38 /**< Arduino pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO35 /**< Arduino pin 11 (MOSI / PWM) */ -#define ARDUINO_PIN_12 GPIO37 /**< Arduino pin 12 (MISO) */ -#define ARDUINO_PIN_13 GPIO36 /**< Arduino pin 13 (SCK) */ +#define ARDUINO_PIN_10 GPIO10 /**< Arduino pin 10 (CS0 / SD Card) */ +#define ARDUINO_PIN_11 GPIO11 /**< Arduino pin 11 (MOSI) */ +#define ARDUINO_PIN_12 GPIO13 /**< Arduino pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO12 /**< Arduino pin 13 (SCK) */ /* analog pins as digital pin: */ -#define ARDUINO_PIN_14 GPIO1 /**< Arduino pin A0 */ -#define ARDUINO_PIN_15 GPIO2 /**< Arduino pin A1 */ -#define ARDUINO_PIN_16 GPIO4 /**< Arduino pin A2 */ -#define ARDUINO_PIN_17 GPIO5 /**< Arduino pin A3 */ +#define ARDUINO_PIN_14 GPIO1 /**< Arduino pin 14 (A0) */ +#define ARDUINO_PIN_15 GPIO2 /**< Arduino pin 15 (A1) */ +#define ARDUINO_PIN_16 GPIO4 /**< Arduino pin 16 (A2) */ +#define ARDUINO_PIN_17 GPIO5 /**< Arduino pin 17 (A3)*/ + +#define ARDUINO_PIN_18 GPIO7 /**< Arduino pin 18 (A4 / SDA) */ +#define ARDUINO_PIN_19 GPIO8 /**< Arduino pin 19 (A5 / SCL) */ -#define ARDUINO_PIN_18 GPIO7 /**< Arduino pin A4 (SDA) */ -#define ARDUINO_PIN_19 GPIO8 /**< Arduino pin A5 (SCL) */ +#define ARDUINO_PIN_20 GPIO17 /**< Arduino pin 20 (DAC0) */ +#define ARDUINO_PIN_21 GPIO18 /**< Arduino pin 21 (DAC1) */ -#define ARDUINO_PIN_LAST 19 +#define ARDUINO_PIN_LAST 21 /**< Last Arduino pin index */ /** @} */ /** * @name Aliases for analog pins * @{ */ -#define ARDUINO_PIN_A0 ARDUINO_PIN_14 -#define ARDUINO_PIN_A1 ARDUINO_PIN_15 -#define ARDUINO_PIN_A2 ARDUINO_PIN_16 -#define ARDUINO_PIN_A3 ARDUINO_PIN_17 +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino pin A3 */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino pin A5 */ + +#define ARDUINO_PIN_DAC0 ARDUINO_PIN_20 /**< Arduino pin DAC0 */ +#define ARDUINO_PIN_DAC1 ARDUINO_PIN_21 /**< Arduino pin DAC1 */ +/** @} */ + +/** + * @name Mapping of Arduino analog pins to RIOT ADC lines + * @{ + */ +#define ARDUINO_A0 ADC_LINE(0) /**< ADC line for Arduino pin A0 */ +#define ARDUINO_A1 ADC_LINE(1) /**< ADC line for Arduino pin A1 */ +#define ARDUINO_A2 ADC_LINE(2) /**< ADC line for Arduino pin A2 */ +#define ARDUINO_A3 ADC_LINE(3) /**< ADC line for Arduino pin A3 */ +#define ARDUINO_A4 ADC_LINE(5) /**< ADC line for Arduino pin A4 */ +#define ARDUINO_A5 ADC_LINE(6) /**< ADC line for Arduino pin A5 */ + +#define ARDUINO_ANALOG_PIN_LAST 5 +/** @} */ + +/** + * @name Mapping of Arduino DAC pins to RIOT DAC lines + * @{ + */ +#define ARDUINO_DAC0 DAC_LINE(0) /**< DAC line for Arduino pin DAC0 */ +#define ARDUINO_DAC1 DAC_LINE(1) /**< DAC line for Arduino pin DAC1 */ + +#define ARDUINO_DAC_PIN_LAST 1 /**< Last Arduino DAC pin index */ +/** @} */ + +/** + * @name Mapping of Arduino pins to RIOT PWM dev and channel pairs + * @{ + */ +#define ARDUINO_PIN_3_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 3 */ +#define ARDUINO_PIN_3_PWM_CHAN 0 /**< PWM channel for Arduino pin 3 */ + +#define ARDUINO_PIN_5_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 5 */ +#define ARDUINO_PIN_5_PWM_CHAN 1 /**< PWM channel for Arduino pin 5 */ + +#define ARDUINO_PIN_6_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 6 */ +#define ARDUINO_PIN_6_PWM_CHAN 2 /**< PWM channel for Arduino pin 6 */ -#define ARDUINO_PIN_A4 ARDUINO_PIN_18 -#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +#define ARDUINO_PIN_9_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 9 */ +#define ARDUINO_PIN_9_PWM_CHAN 3 /**< PWM channel for Arduino pin 9 */ /** @} */ #ifdef __cplusplus diff --git a/boards/esp32s2-lilygo-ttgo-t8/include/periph_conf.h b/boards/esp32s2-lilygo-ttgo-t8/include/periph_conf.h index 08049629663d..79c06b9cd336 100644 --- a/boards/esp32s2-lilygo-ttgo-t8/include/periph_conf.h +++ b/boards/esp32s2-lilygo-ttgo-t8/include/periph_conf.h @@ -169,7 +169,7 @@ extern "C" { #define SPI1_MOSI GPIO11 /**< SPI MOSI */ #endif #ifndef SPI1_CS0 -#define SPI1_CS0 GPIO10 /**< SPI CS0 used for Display */ +#define SPI1_CS0 GPIO10 /**< SPI CS0 used for SD Card */ #endif /** @} */ diff --git a/boards/esp32s3-devkit/Makefile.features b/boards/esp32s3-devkit/Makefile.features index ada35c5457fb..bbcaf0da3060 100644 --- a/boards/esp32s3-devkit/Makefile.features +++ b/boards/esp32s3-devkit/Makefile.features @@ -37,6 +37,12 @@ FEATURES_PROVIDED += periph_spi # unique features provided by the board FEATURES_PROVIDED += esp_jtag +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_i2c FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_pwm +FEATURES_PROVIDED += arduino_spi +FEATURES_PROVIDED += arduino_uart + FEATURES_PROVIDED += periph_usbdev FEATURES_PROVIDED += tinyusb_device diff --git a/boards/esp32s3-devkit/include/arduino_iomap.h b/boards/esp32s3-devkit/include/arduino_iomap.h index 5edfc444e374..5c9e1630872a 100644 --- a/boards/esp32s3-devkit/include/arduino_iomap.h +++ b/boards/esp32s3-devkit/include/arduino_iomap.h @@ -26,13 +26,16 @@ extern "C" { #endif +#define ARDUINO_UART_D0D1 UART_DEV(0) /**< Arduino UART interface */ +#define ARDUINO_SPI_D11D12D13 SPI_DEV(0) /**< Arduino SPI bus */ + /** * @name Mapping of MCU pins to Arduino pins * @{ */ #define ARDUINO_PIN_0 GPIO44 /**< Arduino pin 0 (RxD) */ #define ARDUINO_PIN_1 GPIO43 /**< Arduino pin 1 (TxD) */ -#define ARDUINO_PIN_2 GPIO0 /**< Arduino pin 2 */ +#define ARDUINO_PIN_2 GPIO0 /**< Arduino pin 2 (BTN0) */ #define ARDUINO_PIN_3 GPIO14 /**< Arduino pin 3 (PWM) */ #define ARDUINO_PIN_4 GPIO3 /**< Arduino pin 4 */ #define ARDUINO_PIN_5 GPIO17 /**< Arduino pin 5 (PWM) */ @@ -41,33 +44,63 @@ extern "C" { #define ARDUINO_PIN_8 GPIO7 /**< Arduino pin 8 */ #define ARDUINO_PIN_9 GPIO21 /**< Arduino pin 9 (PWM) */ -#define ARDUINO_PIN_10 GPIO10 /**< Arduino pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO11 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_10 GPIO10 /**< Arduino pin 10 (CS0) */ +#define ARDUINO_PIN_11 GPIO11 /**< Arduino pin 11 (MOSI) */ #define ARDUINO_PIN_12 GPIO13 /**< Arduino pin 12 (MISO) */ -#define ARDUINO_PIN_13 GPIO12 /**< Arduino pin 13 (SCK) */ +#define ARDUINO_PIN_13 GPIO12 /**< Arduino pin 13 (SCK) */ -#define ARDUINO_PIN_14 GPIO1 /**< Arduino pin A0 */ -#define ARDUINO_PIN_15 GPIO2 /**< Arduino pin A1 */ -#define ARDUINO_PIN_16 GPIO4 /**< Arduino pin A2 */ -#define ARDUINO_PIN_17 GPIO5 /**< Arduino pin A3 */ +#define ARDUINO_PIN_14 GPIO1 /**< Arduino pin 14 (A0) */ +#define ARDUINO_PIN_15 GPIO2 /**< Arduino pin 15 (A1) */ +#define ARDUINO_PIN_16 GPIO4 /**< Arduino pin 16 (A2) */ +#define ARDUINO_PIN_17 GPIO5 /**< Arduino pin 17 (A3) */ -#define ARDUINO_PIN_18 GPIO8 /**< Arduino pin A4 (SDA) */ -#define ARDUINO_PIN_19 GPIO9 /**< Arduino pin A5 (SCL) */ +#define ARDUINO_PIN_18 GPIO8 /**< Arduino pin 18 (A4 / SDA) */ +#define ARDUINO_PIN_19 GPIO9 /**< Arduino pin 19 (A5 / SCL) */ -#define ARDUINO_PIN_LAST 19 +#define ARDUINO_PIN_LAST 19 /**< Last Arduino pin index */ /** @} */ /** * @name Aliases for analog pins * @{ */ -#define ARDUINO_PIN_A0 ARDUINO_PIN_14 -#define ARDUINO_PIN_A1 ARDUINO_PIN_15 -#define ARDUINO_PIN_A2 ARDUINO_PIN_16 -#define ARDUINO_PIN_A3 ARDUINO_PIN_17 +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino pin A3 */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino pin A5 */ +/** @} */ + +/** + * @name Mapping of Arduino analog pins to RIOT ADC lines + * @{ + */ +#define ARDUINO_A0 ADC_LINE(7) /**< ADC line for Arduino pin A0 */ +#define ARDUINO_A1 ADC_LINE(8) /**< ADC line for Arduino pin A1 */ +#define ARDUINO_A2 ADC_LINE(2) /**< ADC line for Arduino pin A2 */ +#define ARDUINO_A3 ADC_LINE(6) /**< ADC line for Arduino pin A3 */ +#define ARDUINO_A4 ADC_LINE(14) /**< ADC line for Arduino pin A4 */ +#define ARDUINO_A5 ADC_LINE(15) /**< ADC line for Arduino pin A5 */ + +#define ARDUINO_ANALOG_PIN_LAST 5 /**< Last Arduino analog pin index */ +/** @} */ + +/** + * @name Mapping of Arduino pins to RIOT PWM dev and channel pairs + * @{ + */ +#define ARDUINO_PIN_3_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 3 */ +#define ARDUINO_PIN_3_PWM_CHAN 0 /**< PWM channel for Arduino pin 3 */ + +#define ARDUINO_PIN_5_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 5 */ +#define ARDUINO_PIN_5_PWM_CHAN 1 /**< PWM channel for Arduino pin 5 */ + +#define ARDUINO_PIN_6_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 6 */ +#define ARDUINO_PIN_6_PWM_CHAN 2 /**< PWM channel for Arduino pin 6 */ -#define ARDUINO_PIN_A4 ARDUINO_PIN_18 -#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +#define ARDUINO_PIN_9_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 9 */ +#define ARDUINO_PIN_9_PWM_CHAN 3 /**< PWM channel for Arduino pin 9 */ /** @} */ #ifdef __cplusplus diff --git a/boards/esp32s3-pros3/Makefile.features b/boards/esp32s3-pros3/Makefile.features index ec6ebe983037..4765a51b0d2f 100644 --- a/boards/esp32s3-pros3/Makefile.features +++ b/boards/esp32s3-pros3/Makefile.features @@ -13,7 +13,13 @@ FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_usbdev # other features provided by the board +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_i2c FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_pwm +FEATURES_PROVIDED += arduino_spi +FEATURES_PROVIDED += arduino_uart + FEATURES_PROVIDED += esp_jtag FEATURES_PROVIDED += highlevel_stdio FEATURES_PROVIDED += tinyusb_device diff --git a/boards/esp32s3-pros3/include/arduino_iomap.h b/boards/esp32s3-pros3/include/arduino_iomap.h index 03cda0502f64..accd168ee21f 100644 --- a/boards/esp32s3-pros3/include/arduino_iomap.h +++ b/boards/esp32s3-pros3/include/arduino_iomap.h @@ -26,33 +26,36 @@ extern "C" { #endif +#define ARDUINO_UART_D0D1 UART_DEV(0) /**< Arduino UART interface */ +#define ARDUINO_SPI_D11D12D13 SPI_DEV(0) /**< Arduino SPI bus */ + /** * @name Mapping of MCU pins to Arduino pins * @{ */ #define ARDUINO_PIN_0 GPIO44 /**< Arduino pin 0 (RxD) */ #define ARDUINO_PIN_1 GPIO43 /**< Arduino pin 1 (TxD) */ -#define ARDUINO_PIN_2 GPIO0 /**< Arduino pin 2 */ +#define ARDUINO_PIN_2 GPIO0 /**< Arduino pin 2 (BTN0) */ #define ARDUINO_PIN_3 GPIO12 /**< Arduino pin 3 (PWM) */ #define ARDUINO_PIN_4 GPIO6 /**< Arduino pin 4 */ #define ARDUINO_PIN_5 GPIO13 /**< Arduino pin 5 (PWM) */ #define ARDUINO_PIN_6 GPIO14 /**< Arduino pin 6 (PWM) */ #define ARDUINO_PIN_7 GPIO7 /**< Arduino pin 7 */ -#define ARDUINO_PIN_8 GPIO16 /**< Arduino pin 8 */ -#define ARDUINO_PIN_9 GPIO15 /**< Arduino pin 9 (PWM) */ +#define ARDUINO_PIN_8 GPIO15 /**< Arduino pin 8 */ +#define ARDUINO_PIN_9 GPIO16 /**< Arduino pin 9 (PWM) */ -#define ARDUINO_PIN_10 GPIO34 /**< Arduino pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO35 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_10 GPIO34 /**< Arduino pin 10 (CS0) */ +#define ARDUINO_PIN_11 GPIO35 /**< Arduino pin 11 (MOSI) */ #define ARDUINO_PIN_12 GPIO37 /**< Arduino pin 12 (MISO) */ #define ARDUINO_PIN_13 GPIO36 /**< Arduino pin 13 (SCK) */ -#define ARDUINO_PIN_14 GPIO1 /**< Arduino pin A0 */ -#define ARDUINO_PIN_15 GPIO2 /**< Arduino pin A1 */ -#define ARDUINO_PIN_16 GPIO4 /**< Arduino pin A2 */ -#define ARDUINO_PIN_17 GPIO5 /**< Arduino pin A3 */ +#define ARDUINO_PIN_14 GPIO1 /**< Arduino pin 14 (A0) */ +#define ARDUINO_PIN_15 GPIO2 /**< Arduino pin 15 (A1) */ +#define ARDUINO_PIN_16 GPIO4 /**< Arduino pin 16 (A2) */ +#define ARDUINO_PIN_17 GPIO5 /**< Arduino pin 17 (A3) */ -#define ARDUINO_PIN_18 GPIO8 /**< Arduino pin A4 (SDA) */ -#define ARDUINO_PIN_19 GPIO9 /**< Arduino pin A5 (SCL) */ +#define ARDUINO_PIN_18 GPIO8 /**< Arduino pin 18 (A4 / SDA) */ +#define ARDUINO_PIN_19 GPIO9 /**< Arduino pin 19 (A5 / SCL) */ #define ARDUINO_PIN_LAST 19 /** @} */ @@ -61,12 +64,43 @@ extern "C" { * @name Aliases for analog pins * @{ */ -#define ARDUINO_PIN_A0 ARDUINO_PIN_14 -#define ARDUINO_PIN_A1 ARDUINO_PIN_15 -#define ARDUINO_PIN_A2 ARDUINO_PIN_16 -#define ARDUINO_PIN_A3 ARDUINO_PIN_17 -#define ARDUINO_PIN_A4 ARDUINO_PIN_18 -#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino pin A3 */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino pin A5 */ +/** @} */ + +/** + * @name Mapping of Arduino analog pins to RIOT ADC lines + * @{ + */ +#define ARDUINO_A0 ADC_LINE(0) /**< ADC line for Arduino pin A0 */ +#define ARDUINO_A1 ADC_LINE(1) /**< ADC line for Arduino pin A1 */ +#define ARDUINO_A2 ADC_LINE(3) /**< ADC line for Arduino pin A2 */ +#define ARDUINO_A3 ADC_LINE(4) /**< ADC line for Arduino pin A3 */ +#define ARDUINO_A4 ADC_LINE(7) /**< ADC line for Arduino pin A4 */ +#define ARDUINO_A5 ADC_LINE(8) /**< ADC line for Arduino pin A5 */ + +#define ARDUINO_ANALOG_PIN_LAST 5 /**< Last Arduino analog pin index */ +/** @} */ + +/** + * @name Mapping of Arduino pins to RIOT PWM dev and channel pairs + * @{ + */ +#define ARDUINO_PIN_3_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 3 */ +#define ARDUINO_PIN_3_PWM_CHAN 0 /**< PWM channel for Arduino pin 3 */ + +#define ARDUINO_PIN_5_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 5 */ +#define ARDUINO_PIN_5_PWM_CHAN 1 /**< PWM channel for Arduino pin 5 */ + +#define ARDUINO_PIN_6_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 6 */ +#define ARDUINO_PIN_6_PWM_CHAN 2 /**< PWM channel for Arduino pin 6 */ + +#define ARDUINO_PIN_9_PWM_DEV PWM_DEV(0) /**< PWM device for Arduino pin 9 */ +#define ARDUINO_PIN_9_PWM_CHAN 4 /**< PWM channel for Arduino pin 9 */ /** @} */ #ifdef __cplusplus