diff --git a/boards/adafruit-grand-central-m4-express/Kconfig b/boards/adafruit-grand-central-m4-express/Kconfig index 03891a824148b..2d5ad9b22e0b4 100644 --- a/boards/adafruit-grand-central-m4-express/Kconfig +++ b/boards/adafruit-grand-central-m4-express/Kconfig @@ -11,7 +11,8 @@ config BOARD_ADAFRUIT_GRAND_CENTRAL_M4_EXPRESS bool default y select CPU_MODEL_SAMD51P20A - select HAS_ARDUINO + select HAS_ARDUINO_ANALOG + select HAS_ARDUINO_PINS select HAS_HIGHLEVEL_STDIO select HAS_PERIPH_ADC select HAS_PERIPH_DAC diff --git a/boards/adafruit-grand-central-m4-express/Makefile.features b/boards/adafruit-grand-central-m4-express/Makefile.features index d16dabe903ea2..e4cbb709d7f24 100644 --- a/boards/adafruit-grand-central-m4-express/Makefile.features +++ b/boards/adafruit-grand-central-m4-express/Makefile.features @@ -15,5 +15,6 @@ FEATURES_PROVIDED += periph_uart FEATURES_PROVIDED += periph_usbdev # other board features -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_pins FEATURES_PROVIDED += sdcard_spi diff --git a/boards/adafruit-grand-central-m4-express/include/arduino_board.h b/boards/adafruit-grand-central-m4-express/include/arduino_board.h deleted file mode 100644 index 71624a051afc3..0000000000000 --- a/boards/adafruit-grand-central-m4-express/include/arduino_board.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2017 Inria - * - * 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_nucleo144 - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Alexandre Abadie - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_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_14, - ARDUINO_PIN_15, - 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_A0, - ARDUINO_A1, - ARDUINO_A2, - ARDUINO_A3, - ARDUINO_A4, - ARDUINO_A5, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/adafruit-grand-central-m4-express/include/arduino_pinmap.h b/boards/adafruit-grand-central-m4-express/include/arduino_iomap.h similarity index 63% rename from boards/adafruit-grand-central-m4-express/include/arduino_pinmap.h rename to boards/adafruit-grand-central-m4-express/include/arduino_iomap.h index c5dfc54ff6cec..bf7883e22e98f 100644 --- a/boards/adafruit-grand-central-m4-express/include/arduino_pinmap.h +++ b/boards/adafruit-grand-central-m4-express/include/arduino_iomap.h @@ -16,8 +16,8 @@ * @author Gunar Schorcht */ -#ifndef ARDUINO_PINMAP_H -#define ARDUINO_PINMAP_H +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H #include "periph/gpio.h" #include "periph/adc.h" @@ -49,12 +49,25 @@ extern "C" { #define ARDUINO_PIN_14 GPIO_PIN(PB, 20) #define ARDUINO_PIN_15 GPIO_PIN(PB, 21) -#define ARDUINO_PIN_A0 GPIO_PIN(PA, 3) -#define ARDUINO_PIN_A1 GPIO_PIN(PC, 0) -#define ARDUINO_PIN_A2 GPIO_PIN(PC, 3) -#define ARDUINO_PIN_A3 GPIO_PIN(PC, 1) -#define ARDUINO_PIN_A4 GPIO_PIN(PC, 4) -#define ARDUINO_PIN_A5 GPIO_PIN(PC, 5) +#define ARDUINO_PIN_16 GPIO_PIN(PA, 3) +#define ARDUINO_PIN_17 GPIO_PIN(PC, 0) +#define ARDUINO_PIN_18 GPIO_PIN(PC, 3) +#define ARDUINO_PIN_19 GPIO_PIN(PC, 1) +#define ARDUINO_PIN_20 GPIO_PIN(PC, 4) +#define ARDUINO_PIN_21 GPIO_PIN(PC, 5) + +#define ARDUINO_PIN_LAST 21 /** D21 (A5) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_16 /**< Arduino pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_17 /**< Arduino pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_18 /**< Arduino pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_19 /**< Arduino pin A3 */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_20 /**< Arduino pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_21 /**< Arduino pin A5 */ /** @} */ /** @@ -67,11 +80,13 @@ extern "C" { #define ARDUINO_A3 ADC_LINE(3) #define ARDUINO_A4 ADC_LINE(4) #define ARDUINO_A5 ADC_LINE(5) + +#define ARDUINO_ANALOG_PIN_LAST 5 /**< A5 is the last analog pin */ /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/arduino-duemilanove/Kconfig b/boards/arduino-duemilanove/Kconfig index f44d119798992..f7bc97483b49b 100644 --- a/boards/arduino-duemilanove/Kconfig +++ b/boards/arduino-duemilanove/Kconfig @@ -10,6 +10,7 @@ config BOARD_ARDUINO_DUEMILANOVE select BOARD_COMMON_ARDUINO_ATMEGA select CPU_MODEL_ATMEGA328P select MODULE_BOARDS_COMMON_ARDUINO-ATMEGA if TEST_KCONFIG + select HAS_ARDUINO_SHIELD_UNO config BOARD default "arduino-duemilanove" if BOARD_ARDUINO_DUEMILANOVE diff --git a/boards/arduino-duemilanove/Makefile.features b/boards/arduino-duemilanove/Makefile.features index fdceb9913ce2d..95efe48e75060 100644 --- a/boards/arduino-duemilanove/Makefile.features +++ b/boards/arduino-duemilanove/Makefile.features @@ -1,3 +1,4 @@ CPU = atmega328p +FEATURES_PROVIDED += arduino_shield_uno include $(RIOTBOARD)/common/arduino-atmega/Makefile.features diff --git a/boards/arduino-leonardo/Kconfig b/boards/arduino-leonardo/Kconfig index abaedbbfab71b..a812521834478 100644 --- a/boards/arduino-leonardo/Kconfig +++ b/boards/arduino-leonardo/Kconfig @@ -13,5 +13,6 @@ config BOARD_ARDUINO_LEONARDO select BOARD_COMMON_ARDUINO_ATMEGA select CPU_MODEL_ATMEGA32U4 select MODULE_BOARDS_COMMON_ARDUINO-ATMEGA if TEST_KCONFIG + select HAS_ARDUINO_SHIELD_UNO source "$(RIOTBOARD)/common/arduino-atmega/Kconfig" diff --git a/boards/arduino-leonardo/Makefile.features b/boards/arduino-leonardo/Makefile.features index 20de13ea2991a..336eb979ece0e 100644 --- a/boards/arduino-leonardo/Makefile.features +++ b/boards/arduino-leonardo/Makefile.features @@ -1,3 +1,4 @@ CPU = atmega32u4 +FEATURES_PROVIDED += arduino_shield_uno include $(RIOTBOARD)/common/arduino-atmega/Makefile.features diff --git a/boards/arduino-mega2560/Kconfig b/boards/arduino-mega2560/Kconfig index aeac7061b6011..e5dcdf3758180 100644 --- a/boards/arduino-mega2560/Kconfig +++ b/boards/arduino-mega2560/Kconfig @@ -13,5 +13,7 @@ config BOARD_ARDUINO_MEGA2560 select CPU_MODEL_ATMEGA2560 select BOARD_COMMON_ARDUINO_ATMEGA select MODULE_BOARDS_COMMON_ARDUINO-ATMEGA if TEST_KCONFIG + select HAS_ARDUINO_SHIELD_MEGA + select HAS_ARDUINO_SHIELD_UNO source "$(RIOTBOARD)/common/arduino-atmega/Kconfig" diff --git a/boards/arduino-mega2560/Makefile.features b/boards/arduino-mega2560/Makefile.features index 5e96764eff53f..8a9664dd17dbf 100644 --- a/boards/arduino-mega2560/Makefile.features +++ b/boards/arduino-mega2560/Makefile.features @@ -1,3 +1,6 @@ CPU = atmega2560 +FEATURES_PROVIDED += arduino_shield_mega +FEATURES_PROVIDED += arduino_shield_uno + include $(RIOTBOARD)/common/arduino-atmega/Makefile.features diff --git a/boards/arduino-mkr1000/include/board.h b/boards/arduino-mkr1000/include/board.h index ae6021b3d1d98..2ea9afe1a3cad 100644 --- a/boards/arduino-mkr1000/include/board.h +++ b/boards/arduino-mkr1000/include/board.h @@ -29,11 +29,6 @@ extern "C" { #endif -/** - * @brief The on-board LED is connected to pin 6 on this board - */ -#define ARDUINO_LED (6U) - /** * @name LED pin definitions and handlers * @{ diff --git a/boards/arduino-mkrfox1200/include/board.h b/boards/arduino-mkrfox1200/include/board.h index 48fc32e6e94c0..bfa91efa4de3f 100644 --- a/boards/arduino-mkrfox1200/include/board.h +++ b/boards/arduino-mkrfox1200/include/board.h @@ -40,11 +40,6 @@ extern "C" { #define ATA8520E_PARAM_RESET_PIN GPIO_PIN(PA, 27) /** @} */ -/** - * @brief The on-board LED is connected to pin 6 on this board - */ -#define ARDUINO_LED (6U) - /** * @name LED pin definitions and handlers * @{ diff --git a/boards/arduino-mkrwan1300/include/board.h b/boards/arduino-mkrwan1300/include/board.h index c0fe4cac20dd5..0b14032872f96 100644 --- a/boards/arduino-mkrwan1300/include/board.h +++ b/boards/arduino-mkrwan1300/include/board.h @@ -30,11 +30,6 @@ extern "C" { #endif -/** - * @brief The on-board LED is connected to pin 6 on this board - */ -#define ARDUINO_LED (6U) - /** * @name LED pin definitions and handlers * @{ diff --git a/boards/arduino-nano/Kconfig b/boards/arduino-nano/Kconfig index d0831843dd4e8..2f2e9dbd62933 100644 --- a/boards/arduino-nano/Kconfig +++ b/boards/arduino-nano/Kconfig @@ -10,6 +10,7 @@ config BOARD_ARDUINO_NANO select BOARD_COMMON_ARDUINO_ATMEGA select CPU_MODEL_ATMEGA328P select MODULE_BOARDS_COMMON_ARDUINO-ATMEGA if TEST_KCONFIG + select HAS_ARDUINO_SHIELD_NANO config BOARD default "arduino-nano" if BOARD_ARDUINO_NANO diff --git a/boards/arduino-nano/Makefile.features b/boards/arduino-nano/Makefile.features index fdceb9913ce2d..f6d2d1be93ed3 100644 --- a/boards/arduino-nano/Makefile.features +++ b/boards/arduino-nano/Makefile.features @@ -1,3 +1,4 @@ CPU = atmega328p +FEATURES_PROVIDED += arduino_shield_nano include $(RIOTBOARD)/common/arduino-atmega/Makefile.features diff --git a/boards/arduino-uno/Kconfig b/boards/arduino-uno/Kconfig index addd49117b494..c41b31e49d311 100644 --- a/boards/arduino-uno/Kconfig +++ b/boards/arduino-uno/Kconfig @@ -10,6 +10,7 @@ config BOARD_ARDUINO_UNO select CPU_MODEL_ATMEGA328P select BOARD_COMMON_ARDUINO_ATMEGA select MODULE_BOARDS_COMMON_ARDUINO-ATMEGA if TEST_KCONFIG + select HAS_ARDUINO_SHIELD_UNO config BOARD default "arduino-uno" if BOARD_ARDUINO_UNO diff --git a/boards/arduino-uno/Makefile.features b/boards/arduino-uno/Makefile.features index fdceb9913ce2d..95efe48e75060 100644 --- a/boards/arduino-uno/Makefile.features +++ b/boards/arduino-uno/Makefile.features @@ -1,3 +1,4 @@ CPU = atmega328p +FEATURES_PROVIDED += arduino_shield_uno include $(RIOTBOARD)/common/arduino-atmega/Makefile.features diff --git a/boards/common/arduino-atmega/Kconfig b/boards/common/arduino-atmega/Kconfig index 35e643afb9c5b..a0fc47a27b256 100644 --- a/boards/common/arduino-atmega/Kconfig +++ b/boards/common/arduino-atmega/Kconfig @@ -14,8 +14,13 @@ config BOARD_COMMON_ARDUINO_ATMEGA select HAS_PERIPH_TIMER select HAS_PERIPH_UART # Various other features (if any) - select HAS_ARDUINO + select HAS_ARDUINO_ANALOG + select HAS_ARDUINO_I2C + select HAS_ARDUINO_PINS select HAS_ARDUINO_PWM + select HAS_ARDUINO_SHIELD_ISP + select HAS_ARDUINO_SPI + select HAS_ARDUINO_UART select HAVE_SAUL_GPIO diff --git a/boards/common/arduino-atmega/Makefile.features b/boards/common/arduino-atmega/Makefile.features index 3bc938d8f662d..a8416f14913e6 100644 --- a/boards/common/arduino-atmega/Makefile.features +++ b/boards/common/arduino-atmega/Makefile.features @@ -7,5 +7,10 @@ FEATURES_PROVIDED += periph_timer FEATURES_PROVIDED += periph_uart # Various other features (if any) -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_i2c +FEATURES_PROVIDED += arduino_pins FEATURES_PROVIDED += arduino_pwm +FEATURES_PROVIDED += arduino_shield_isp +FEATURES_PROVIDED += arduino_spi +FEATURES_PROVIDED += arduino_uart diff --git a/boards/common/arduino-atmega/include/arduino_board.h b/boards/common/arduino-atmega/include/arduino_board.h deleted file mode 100644 index 29ac70f6daf37..0000000000000 --- a/boards/common/arduino-atmega/include/arduino_board.h +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright (C) 2016 Freie Universität Berlin - * 2017 Thomas Perrot - * - * 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_arduino-atmega - * @{ - * - * @file - * @brief Configuration of the Arduino API for Arduino Atmega boards - * - * @author Hauke Petersen - * @author Laurent Navet - * @author Thomas Perrot - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_pinmap.h" -#include "periph/pwm.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The on-board LED is connected to pin 13 on this board - */ -#define ARDUINO_LED (13) - -/** - * @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_14, - ARDUINO_PIN_15, - ARDUINO_PIN_16, - ARDUINO_PIN_17, - ARDUINO_PIN_18, - ARDUINO_PIN_19, -#if defined(CPU_ATMEGA2560) || defined(CPU_ATMEGA32U4) - ARDUINO_PIN_20, - ARDUINO_PIN_21, - ARDUINO_PIN_22, - ARDUINO_PIN_23, -#endif -#ifdef CPU_ATMEGA2560 - ARDUINO_PIN_24, - ARDUINO_PIN_25, - ARDUINO_PIN_26, - ARDUINO_PIN_27, - ARDUINO_PIN_28, - ARDUINO_PIN_29, -#endif -#if defined(CPU_ATMEGA2560) || defined(CPU_ATMEGA32U4) - ARDUINO_PIN_30, -#endif -#ifdef CPU_ATMEGA2560 - ARDUINO_PIN_31, - ARDUINO_PIN_32, - ARDUINO_PIN_33, - ARDUINO_PIN_34, - ARDUINO_PIN_35, - ARDUINO_PIN_36, - ARDUINO_PIN_37, - ARDUINO_PIN_38, - ARDUINO_PIN_39, - ARDUINO_PIN_40, - ARDUINO_PIN_41, - ARDUINO_PIN_42, - ARDUINO_PIN_43, - ARDUINO_PIN_44, - ARDUINO_PIN_45, - ARDUINO_PIN_46, - ARDUINO_PIN_47, - ARDUINO_PIN_48, - ARDUINO_PIN_49, - ARDUINO_PIN_50, - ARDUINO_PIN_51, - ARDUINO_PIN_52, - ARDUINO_PIN_53, - ARDUINO_PIN_54, - ARDUINO_PIN_55, - ARDUINO_PIN_56, - ARDUINO_PIN_57, - ARDUINO_PIN_58, - ARDUINO_PIN_59, - ARDUINO_PIN_60, - ARDUINO_PIN_61, - ARDUINO_PIN_62, - ARDUINO_PIN_63, - ARDUINO_PIN_64, - ARDUINO_PIN_65, - ARDUINO_PIN_66, - ARDUINO_PIN_67, - ARDUINO_PIN_68, - ARDUINO_PIN_69 -#endif -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { - ARDUINO_A0, - ARDUINO_A1, - ARDUINO_A2, - ARDUINO_A3, - ARDUINO_A4, - ARDUINO_A5, - ARDUINO_A6, - ARDUINO_A7, -#ifdef CPU_ATMEGA2560 - ARDUINO_A8, - ARDUINO_A9, - ARDUINO_A10, - ARDUINO_A11, - ARDUINO_A12, - ARDUINO_A13, - ARDUINO_A14, - ARDUINO_A15, -#endif -}; - -/** - * @brief PWM frequency - */ -#define ARDUINO_PWM_FREQU (490U) - -/** - * @brief List of PWM GPIO mappings - */ -static const arduino_pwm_t arduino_pwm_list[] = { -#if defined(CPU_ATMEGA2560) - { .pin = 13, .dev = PWM_DEV(0), .chan = 0 }, - { .pin = 4, .dev = PWM_DEV(0), .chan = 1 }, -#elif defined(CPU_ATMEGA32U4) - { .pin = 11, .dev = PWM_DEV(0), .chan = 0 }, - { .pin = 3, .dev = PWM_DEV(0), .chan = 1 }, -#else /* CPU_ATMEGA328p */ - { .pin = 6, .dev = PWM_DEV(0), .chan = 0 }, - { .pin = 5, .dev = PWM_DEV(0), .chan = 1 }, -#endif -#if defined(CPU_ATMEGA2560) - { .pin = 10, .dev = PWM_DEV(1), .chan = 0 }, - { .pin = 9, .dev = PWM_DEV(1), .chan = 1 }, -#else /* CPU_ATMEGA328p */ - { .pin = 11, .dev = PWM_DEV(1), .chan = 0 }, - { .pin = 3, .dev = PWM_DEV(1), .chan = 1 }, -#endif -}; - -/** - * @brief F_CPU defines the CPU frequency in Hz. - * - * This is used in AVR's libc delay.h and setbaud.h - * - * In RIOT delay() has a different implementation using ztimer, and F_CPU is - * already defined when using setbaud.h (see cpu/atmega_common/periph/uart.c) - * - * However Arduino libraries and sketches may expect F_CPU to be defined and - * fail otherwise (for example the Arduino SDI-12 package expects this, for AVR - * cpus). For this reason we define F_CPU here, if not already defined. - */ -#ifndef F_CPU -#define F_CPU CLOCK_CORECLOCK -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/common/arduino-atmega/include/arduino_iomap.h b/boards/common/arduino-atmega/include/arduino_iomap.h new file mode 100644 index 0000000000000..74eec32453637 --- /dev/null +++ b/boards/common/arduino-atmega/include/arduino_iomap.h @@ -0,0 +1,332 @@ +/* + * Copyright (C) 2015 Freie Universität Berlin + * 2016 Laurent Navet + * 2017 Thomas Perrot + * + * 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_arduino-atmega + * @{ + * + * @file + * @brief Mapping from MCU pins to Arduino pins for Arduino Atmega boards + * + * You can use the defines in this file for simplified interaction with the + * Arduino specific pin numbers. + * + * @author Hauke Petersen + * @author Daniel Nordahl + * @author Laurent Navet + * @author Thomas Perrot + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H + +#include "periph/adc.h" +#include "periph/gpio.h" +#include "periph/i2c.h" +#include "periph/pwm.h" +#include "periph/spi.h" +#include "periph/uart.h" +#include "periph_conf.h" /* For ADC_NUMOF */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Arduino's UART devices + * @{ + */ +#define ARDUINO_UART_D0D1 UART_DEV(0) +/** @} */ + +/** + * @name Arduino's SPI buses + * @{ + */ +/** + * @brief The only hardware SPI is connected to the ISP header + */ +#define ARDUINO_SPI_ISP SPI_DEV(0) +/** @} */ + +/** + * @name Arduino's I2C buses + * @{ + */ +/** + * @brief The only hardware I2C on ATmegas + */ +#define ARDUINO_I2C0 I2C_DEV(0) +/** @} */ + +/** + * @name Mapping of MCU pins to Arduino pins + * + * @note ISCP pins are not mapped. + * @{ + */ + +/* Digital pins */ +#ifdef CPU_ATMEGA328P +# define ARDUINO_PIN_0 GPIO_PIN(PORT_D, 0) +# define ARDUINO_PIN_1 GPIO_PIN(PORT_D, 1) +# define ARDUINO_PIN_2 GPIO_PIN(PORT_D, 2) +# define ARDUINO_PIN_3 GPIO_PIN(PORT_D, 3) +# define ARDUINO_PIN_4 GPIO_PIN(PORT_D, 4) +# define ARDUINO_PIN_5 GPIO_PIN(PORT_D, 5) +# define ARDUINO_PIN_6 GPIO_PIN(PORT_D, 6) +# define ARDUINO_PIN_7 GPIO_PIN(PORT_D, 7) +# define ARDUINO_PIN_8 GPIO_PIN(PORT_B, 0) +# define ARDUINO_PIN_9 GPIO_PIN(PORT_B, 1) +# define ARDUINO_PIN_10 GPIO_PIN(PORT_B, 2) +# define ARDUINO_PIN_11 GPIO_PIN(PORT_B, 3) +# define ARDUINO_PIN_12 GPIO_PIN(PORT_B, 4) +# define ARDUINO_PIN_13 GPIO_PIN(PORT_B, 5) +/* Analog pins as digital pins: */ +# define ARDUINO_PIN_14 GPIO_PIN(PORT_C, 0) +# define ARDUINO_PIN_15 GPIO_PIN(PORT_C, 1) +# define ARDUINO_PIN_16 GPIO_PIN(PORT_C, 2) +# define ARDUINO_PIN_17 GPIO_PIN(PORT_C, 3) +# define ARDUINO_PIN_18 GPIO_PIN(PORT_C, 4) +# define ARDUINO_PIN_19 GPIO_PIN(PORT_C, 5) + +# define ARDUINO_PIN_LAST 19 + +/* Analog aliases */ +# 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 +#endif + +#ifdef CPU_ATMEGA32U4 +/* Digital pins */ +# define ARDUINO_PIN_0 GPIO_PIN(PORT_D, 2) +# define ARDUINO_PIN_1 GPIO_PIN(PORT_D, 3) +# define ARDUINO_PIN_2 GPIO_PIN(PORT_D, 1) +# define ARDUINO_PIN_3 GPIO_PIN(PORT_D, 0) +# define ARDUINO_PIN_5 GPIO_PIN(PORT_C, 6) +# define ARDUINO_PIN_7 GPIO_PIN(PORT_E, 6) +# define ARDUINO_PIN_11 GPIO_PIN(PORT_B, 7) +# define ARDUINO_PIN_13 GPIO_PIN(PORT_C, 7) +# define ARDUINO_PIN_14 GPIO_PIN(PORT_B, 3) +# define ARDUINO_PIN_15 GPIO_PIN(PORT_B, 1) +# define ARDUINO_PIN_16 GPIO_PIN(PORT_B, 2) +# define ARDUINO_PIN_17 GPIO_PIN(PORT_B, 0) +# define ARDUINO_PIN_30 GPIO_PIN(PORT_D, 5) + +/* Analog pins as digital pins: */ +# define ARDUINO_PIN_4 GPIO_PIN(PORT_D, 4) +# define ARDUINO_PIN_6 GPIO_PIN(PORT_D, 7) +# define ARDUINO_PIN_8 GPIO_PIN(PORT_B, 4) +# define ARDUINO_PIN_9 GPIO_PIN(PORT_B, 5) +# define ARDUINO_PIN_10 GPIO_PIN(PORT_B, 6) +# define ARDUINO_PIN_12 GPIO_PIN(PORT_D, 6) +# define ARDUINO_PIN_18 GPIO_PIN(PORT_F, 7) +# define ARDUINO_PIN_19 GPIO_PIN(PORT_F, 6) +# define ARDUINO_PIN_20 GPIO_PIN(PORT_F, 5) +# define ARDUINO_PIN_21 GPIO_PIN(PORT_F, 4) +# define ARDUINO_PIN_22 GPIO_PIN(PORT_F, 3) +# define ARDUINO_PIN_23 GPIO_PIN(PORT_F, 2) + +# define ARDUINO_PIN_LAST 23 + +/* Analog aliases */ +# define ARDUINO_PIN_A0 ARDUINO_PIN_18 +# define ARDUINO_PIN_A1 ARDUINO_PIN_19 +# define ARDUINO_PIN_A2 ARDUINO_PIN_20 +# define ARDUINO_PIN_A3 ARDUINO_PIN_21 +# define ARDUINO_PIN_A4 ARDUINO_PIN_22 +# define ARDUINO_PIN_A5 ARDUINO_PIN_23 +# define ARDUINO_PIN_A6 ARDUINO_PIN_4 +# define ARDUINO_PIN_A7 ARDUINO_PIN_6 +# define ARDUINO_PIN_A8 ARDUINO_PIN_8 +# define ARDUINO_PIN_A9 ARDUINO_PIN_9 +# define ARDUINO_PIN_A10 ARDUINO_PIN_10 +# define ARDUINO_PIN_A11 ARDUINO_PIN_12 +#endif + +#ifdef CPU_ATMEGA2560 +/* Digital pins */ +# define ARDUINO_PIN_0 GPIO_PIN(PORT_E, 0) +# define ARDUINO_PIN_1 GPIO_PIN(PORT_E, 1) +# define ARDUINO_PIN_2 GPIO_PIN(PORT_E, 4) +# define ARDUINO_PIN_3 GPIO_PIN(PORT_E, 5) +# define ARDUINO_PIN_4 GPIO_PIN(PORT_G, 5) +# define ARDUINO_PIN_5 GPIO_PIN(PORT_E, 3) +# define ARDUINO_PIN_6 GPIO_PIN(PORT_H, 3) +# define ARDUINO_PIN_7 GPIO_PIN(PORT_H, 4) +# define ARDUINO_PIN_8 GPIO_PIN(PORT_H, 5) +# define ARDUINO_PIN_9 GPIO_PIN(PORT_H, 6) +# define ARDUINO_PIN_10 GPIO_PIN(PORT_B, 4) +# define ARDUINO_PIN_11 GPIO_PIN(PORT_B, 5) +# define ARDUINO_PIN_12 GPIO_PIN(PORT_B, 6) +# define ARDUINO_PIN_13 GPIO_PIN(PORT_B, 7) +# define ARDUINO_PIN_14 GPIO_PIN(PORT_J, 1) +# define ARDUINO_PIN_15 GPIO_PIN(PORT_J, 0) +# define ARDUINO_PIN_16 GPIO_PIN(PORT_H, 1) +# define ARDUINO_PIN_17 GPIO_PIN(PORT_H, 0) +# define ARDUINO_PIN_18 GPIO_PIN(PORT_D, 3) +# define ARDUINO_PIN_19 GPIO_PIN(PORT_D, 2) +# define ARDUINO_PIN_20 GPIO_PIN(PORT_D, 1) +# define ARDUINO_PIN_21 GPIO_PIN(PORT_D, 0) +# define ARDUINO_PIN_22 GPIO_PIN(PORT_A, 0) +# define ARDUINO_PIN_23 GPIO_PIN(PORT_A, 1) +# define ARDUINO_PIN_24 GPIO_PIN(PORT_A, 2) +# define ARDUINO_PIN_25 GPIO_PIN(PORT_A, 3) +# define ARDUINO_PIN_26 GPIO_PIN(PORT_A, 4) +# define ARDUINO_PIN_27 GPIO_PIN(PORT_A, 5) +# define ARDUINO_PIN_28 GPIO_PIN(PORT_A, 6) +# define ARDUINO_PIN_29 GPIO_PIN(PORT_A, 7) +# define ARDUINO_PIN_30 GPIO_PIN(PORT_C, 7) +# define ARDUINO_PIN_31 GPIO_PIN(PORT_C, 6) +# define ARDUINO_PIN_32 GPIO_PIN(PORT_C, 5) +# define ARDUINO_PIN_33 GPIO_PIN(PORT_C, 4) +# define ARDUINO_PIN_34 GPIO_PIN(PORT_C, 3) +# define ARDUINO_PIN_35 GPIO_PIN(PORT_C, 2) +# define ARDUINO_PIN_36 GPIO_PIN(PORT_C, 1) +# define ARDUINO_PIN_37 GPIO_PIN(PORT_E, 0) +# define ARDUINO_PIN_38 GPIO_PIN(PORT_D, 7) +# define ARDUINO_PIN_39 GPIO_PIN(PORT_G, 2) +# define ARDUINO_PIN_40 GPIO_PIN(PORT_G, 1) +# define ARDUINO_PIN_41 GPIO_PIN(PORT_G, 0) +# define ARDUINO_PIN_42 GPIO_PIN(PORT_L, 7) +# define ARDUINO_PIN_43 GPIO_PIN(PORT_L, 6) +# define ARDUINO_PIN_44 GPIO_PIN(PORT_L, 5) +# define ARDUINO_PIN_45 GPIO_PIN(PORT_L, 4) +# define ARDUINO_PIN_46 GPIO_PIN(PORT_L, 3) +# define ARDUINO_PIN_47 GPIO_PIN(PORT_L, 2) +# define ARDUINO_PIN_48 GPIO_PIN(PORT_L, 1) +# define ARDUINO_PIN_49 GPIO_PIN(PORT_L, 0) +# define ARDUINO_PIN_50 GPIO_PIN(PORT_B, 3) +# define ARDUINO_PIN_51 GPIO_PIN(PORT_B, 2) +# define ARDUINO_PIN_52 GPIO_PIN(PORT_B, 1) +# define ARDUINO_PIN_53 GPIO_PIN(PORT_B, 0) + +/* Analog pins as digital pins: */ +# define ARDUINO_PIN_54 GPIO_PIN(PORT_F, 0) +# define ARDUINO_PIN_55 GPIO_PIN(PORT_F, 1) +# define ARDUINO_PIN_56 GPIO_PIN(PORT_F, 2) +# define ARDUINO_PIN_57 GPIO_PIN(PORT_F, 3) +# define ARDUINO_PIN_58 GPIO_PIN(PORT_F, 4) +# define ARDUINO_PIN_59 GPIO_PIN(PORT_F, 5) +# define ARDUINO_PIN_60 GPIO_PIN(PORT_F, 6) +# define ARDUINO_PIN_61 GPIO_PIN(PORT_F, 7) +# define ARDUINO_PIN_62 GPIO_PIN(PORT_K, 0) +# define ARDUINO_PIN_63 GPIO_PIN(PORT_K, 1) +# define ARDUINO_PIN_64 GPIO_PIN(PORT_K, 2) +# define ARDUINO_PIN_65 GPIO_PIN(PORT_K, 3) +# define ARDUINO_PIN_66 GPIO_PIN(PORT_K, 4) +# define ARDUINO_PIN_67 GPIO_PIN(PORT_K, 5) +# define ARDUINO_PIN_68 GPIO_PIN(PORT_K, 6) +# define ARDUINO_PIN_69 GPIO_PIN(PORT_K, 7) + +# define ARDUINO_PIN_LAST 69 + +/* Analog aliases */ +# define ARDUINO_PIN_A0 ARDUINO_PIN_54 +# define ARDUINO_PIN_A1 ARDUINO_PIN_55 +# define ARDUINO_PIN_A2 ARDUINO_PIN_56 +# define ARDUINO_PIN_A3 ARDUINO_PIN_57 +# define ARDUINO_PIN_A4 ARDUINO_PIN_58 +# define ARDUINO_PIN_A5 ARDUINO_PIN_59 +# define ARDUINO_PIN_A6 ARDUINO_PIN_60 +# define ARDUINO_PIN_A7 ARDUINO_PIN_61 +# define ARDUINO_PIN_A8 ARDUINO_PIN_62 +# define ARDUINO_PIN_A9 ARDUINO_PIN_63 +# define ARDUINO_PIN_A10 ARDUINO_PIN_64 +# define ARDUINO_PIN_A11 ARDUINO_PIN_65 +# define ARDUINO_PIN_A12 ARDUINO_PIN_66 +# define ARDUINO_PIN_A13 ARDUINO_PIN_67 +# define ARDUINO_PIN_A14 ARDUINO_PIN_68 +# define ARDUINO_PIN_A15 ARDUINO_PIN_69 +#endif + +#if ADC_NUMOF >= 8 +# define ARDUINO_A0 ADC_LINE(0) +# define ARDUINO_A1 ADC_LINE(1) +# define ARDUINO_A2 ADC_LINE(2) +# define ARDUINO_A3 ADC_LINE(3) +# define ARDUINO_A4 ADC_LINE(4) +# define ARDUINO_A5 ADC_LINE(5) +# define ARDUINO_A6 ADC_LINE(6) +# define ARDUINO_A7 ADC_LINE(7) +#endif +#if ADC_NUMOF >= 16 +# define ARDUINO_A8 ADC_LINE(8) +# define ARDUINO_A9 ADC_LINE(9) +# define ARDUINO_A10 ADC_LINE(10) +# define ARDUINO_A11 ADC_LINE(11) +# define ARDUINO_A12 ADC_LINE(12) +# define ARDUINO_A13 ADC_LINE(13) +# define ARDUINO_A14 ADC_LINE(14) +# define ARDUINO_A15 ADC_LINE(15) +#endif + +/* Either 8, 16 or 0 ADC lines are configured by all ATmega boards */ +#if ADC_NUMOF == 8 +# define ARDUINO_ANALOG_PIN_LAST 7 +#elif ADC_NUMOF == 16 +# define ARDUINO_ANALOG_PIN_LAST 15 +#endif +/** @} */ + +/** + * @name Mapping of Arduino pins to RIOT PWM dev and channel pairs + * @{ + */ +/** + * @brief PWM frequency + */ +#define ARDUINO_PWM_FREQU (490U) + +/* keep in sync with PWM config in boards/common/atmega/include/periph_conf_atmega_common.h */ +#if defined(CPU_ATMEGA328P) +# define ARDUINO_PIN_6_PWM_DEV PWM_DEV(0) +# define ARDUINO_PIN_6_PWM_CHAN 0 + +# define ARDUINO_PIN_5_PWM_DEV PWM_DEV(0) +# define ARDUINO_PIN_5_PWM_CHAN 1 + +# define ARDUINO_PIN_11_PWM_DEV PWM_DEV(1) +# define ARDUINO_PIN_11_PWM_CHAN 0 + +# define ARDUINO_PIN_3_PWM_DEV PWM_DEV(1) +# define ARDUINO_PIN_3_PWM_CHAN 1 +#elif defined(CPU_ATMEGA2560) +# define ARDUINO_PIN_13_PWM_DEV PWM_DEV(0) +# define ARDUINO_PIN_13_PWM_CHAN 0 + +# define ARDUINO_PIN_4_PWM_DEV PWM_DEV(0) +# define ARDUINO_PIN_4_PWM_CHAN 1 + +# define ARDUINO_PIN_10_PWM_DEV PWM_DEV(1) +# define ARDUINO_PIN_10_PWM_CHAN 0 + +# define ARDUINO_PIN_9_PWM_DEV PWM_DEV(1) +# define ARDUINO_PIN_9_PWM_CHAN 1 +#elif defined(CPU_ATMEGA32U4) +# define ARDUINO_PIN_11_PWM_DEV PWM_DEV(0) +# define ARDUINO_PIN_11_PWM_CHAN 0 + +# define ARDUINO_PIN_3_PWM_DEV PWM_DEV(0) +# define ARDUINO_PIN_3_PWM_CHAN 1 +#endif + +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/common/arduino-atmega/include/arduino_pinmap.h b/boards/common/arduino-atmega/include/arduino_pinmap.h deleted file mode 100644 index b68ac6c5cb18a..0000000000000 --- a/boards/common/arduino-atmega/include/arduino_pinmap.h +++ /dev/null @@ -1,235 +0,0 @@ -/* - * Copyright (C) 2015 Freie Universität Berlin - * 2016 Laurent Navet - * 2017 Thomas Perrot - * - * 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_arduino-atmega - * @{ - * - * @file - * @brief Mapping from MCU pins to Arduino pins for Arduino Atmega boards - * - * You can use the defines in this file for simplified interaction with the - * Arduino specific pin numbers. - * - * @author Hauke Petersen - * @author Daniel Nordahl - * @author Laurent Navet - * @author Thomas Perrot - */ - -#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 - * - * @note ISCP pins are not mapped. - * @{ - */ - -/* Digital pins */ -#ifdef CPU_ATMEGA328P -#define ARDUINO_PIN_0 GPIO_PIN(PORT_D, 0) -#define ARDUINO_PIN_1 GPIO_PIN(PORT_D, 1) -#define ARDUINO_PIN_2 GPIO_PIN(PORT_D, 2) -#define ARDUINO_PIN_3 GPIO_PIN(PORT_D, 3) -#define ARDUINO_PIN_4 GPIO_PIN(PORT_D, 4) -#define ARDUINO_PIN_5 GPIO_PIN(PORT_D, 5) -#define ARDUINO_PIN_6 GPIO_PIN(PORT_D, 6) -#define ARDUINO_PIN_7 GPIO_PIN(PORT_D, 7) -#define ARDUINO_PIN_8 GPIO_PIN(PORT_B, 0) -#define ARDUINO_PIN_9 GPIO_PIN(PORT_B, 1) -#define ARDUINO_PIN_10 GPIO_PIN(PORT_B, 2) -#define ARDUINO_PIN_11 GPIO_PIN(PORT_B, 3) -#define ARDUINO_PIN_12 GPIO_PIN(PORT_B, 4) -#define ARDUINO_PIN_13 GPIO_PIN(PORT_B, 5) -/* Analog pins */ -#define ARDUINO_PIN_14 GPIO_PIN(PORT_C, 0) -#define ARDUINO_PIN_15 GPIO_PIN(PORT_C, 1) -#define ARDUINO_PIN_16 GPIO_PIN(PORT_C, 2) -#define ARDUINO_PIN_17 GPIO_PIN(PORT_C, 3) -#define ARDUINO_PIN_18 GPIO_PIN(PORT_C, 4) -#define ARDUINO_PIN_19 GPIO_PIN(PORT_C, 5) -/* Analog input */ -#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 -#endif - -#ifdef CPU_ATMEGA32U4 -/* Digital pins */ -#define ARDUINO_PIN_0 GPIO_PIN(PORT_D, 2) -#define ARDUINO_PIN_1 GPIO_PIN(PORT_D, 3) -#define ARDUINO_PIN_2 GPIO_PIN(PORT_D, 1) -#define ARDUINO_PIN_3 GPIO_PIN(PORT_D, 0) -#define ARDUINO_PIN_5 GPIO_PIN(PORT_C, 6) -#define ARDUINO_PIN_7 GPIO_PIN(PORT_E, 6) -#define ARDUINO_PIN_11 GPIO_PIN(PORT_B, 7) -#define ARDUINO_PIN_13 GPIO_PIN(PORT_C, 7) -#define ARDUINO_PIN_14 GPIO_PIN(PORT_B, 3) -#define ARDUINO_PIN_15 GPIO_PIN(PORT_B, 1) -#define ARDUINO_PIN_16 GPIO_PIN(PORT_B, 2) -#define ARDUINO_PIN_17 GPIO_PIN(PORT_B, 0) -#define ARDUINO_PIN_30 GPIO_PIN(PORT_D, 5) - -/* Analog pins */ -#define ARDUINO_PIN_4 GPIO_PIN(PORT_D, 4) -#define ARDUINO_PIN_6 GPIO_PIN(PORT_D, 7) -#define ARDUINO_PIN_8 GPIO_PIN(PORT_B, 4) -#define ARDUINO_PIN_9 GPIO_PIN(PORT_B, 5) -#define ARDUINO_PIN_10 GPIO_PIN(PORT_B, 6) -#define ARDUINO_PIN_12 GPIO_PIN(PORT_D, 6) -#define ARDUINO_PIN_18 GPIO_PIN(PORT_F, 7) -#define ARDUINO_PIN_19 GPIO_PIN(PORT_F, 6) -#define ARDUINO_PIN_20 GPIO_PIN(PORT_F, 5) -#define ARDUINO_PIN_21 GPIO_PIN(PORT_F, 4) -#define ARDUINO_PIN_22 GPIO_PIN(PORT_F, 3) -#define ARDUINO_PIN_23 GPIO_PIN(PORT_F, 2) - -/* Analog input */ -#define ARDUINO_PIN_A0 ARDUINO_PIN_18 -#define ARDUINO_PIN_A1 ARDUINO_PIN_19 -#define ARDUINO_PIN_A2 ARDUINO_PIN_20 -#define ARDUINO_PIN_A3 ARDUINO_PIN_21 -#define ARDUINO_PIN_A4 ARDUINO_PIN_22 -#define ARDUINO_PIN_A5 ARDUINO_PIN_23 -#define ARDUINO_PIN_A6 ARDUINO_PIN_4 -#define ARDUINO_PIN_A7 ARDUINO_PIN_6 -#define ARDUINO_PIN_A8 ARDUINO_PIN_8 -#define ARDUINO_PIN_A9 ARDUINO_PIN_9 -#define ARDUINO_PIN_A10 ARDUINO_PIN_10 -#define ARDUINO_PIN_A11 ARDUINO_PIN_12 -#endif - -#ifdef CPU_ATMEGA2560 -#define ARDUINO_PIN_0 GPIO_PIN(PORT_E, 0) -#define ARDUINO_PIN_1 GPIO_PIN(PORT_E, 1) -#define ARDUINO_PIN_2 GPIO_PIN(PORT_E, 4) -#define ARDUINO_PIN_3 GPIO_PIN(PORT_E, 5) -#define ARDUINO_PIN_4 GPIO_PIN(PORT_G, 5) -#define ARDUINO_PIN_5 GPIO_PIN(PORT_E, 3) -#define ARDUINO_PIN_6 GPIO_PIN(PORT_H, 3) -#define ARDUINO_PIN_7 GPIO_PIN(PORT_H, 4) -#define ARDUINO_PIN_8 GPIO_PIN(PORT_H, 5) -#define ARDUINO_PIN_9 GPIO_PIN(PORT_H, 6) -#define ARDUINO_PIN_10 GPIO_PIN(PORT_B, 4) -#define ARDUINO_PIN_11 GPIO_PIN(PORT_B, 5) -#define ARDUINO_PIN_12 GPIO_PIN(PORT_B, 6) -#define ARDUINO_PIN_13 GPIO_PIN(PORT_B, 7) -#define ARDUINO_PIN_14 GPIO_PIN(PORT_J, 1) -#define ARDUINO_PIN_15 GPIO_PIN(PORT_J, 0) -#define ARDUINO_PIN_16 GPIO_PIN(PORT_H, 1) -#define ARDUINO_PIN_17 GPIO_PIN(PORT_H, 0) -#define ARDUINO_PIN_18 GPIO_PIN(PORT_D, 3) -#define ARDUINO_PIN_19 GPIO_PIN(PORT_D, 2) -#define ARDUINO_PIN_20 GPIO_PIN(PORT_D, 1) -#define ARDUINO_PIN_21 GPIO_PIN(PORT_D, 0) -#define ARDUINO_PIN_22 GPIO_PIN(PORT_A, 0) -#define ARDUINO_PIN_23 GPIO_PIN(PORT_A, 1) -#define ARDUINO_PIN_24 GPIO_PIN(PORT_A, 2) -#define ARDUINO_PIN_25 GPIO_PIN(PORT_A, 3) -#define ARDUINO_PIN_26 GPIO_PIN(PORT_A, 4) -#define ARDUINO_PIN_27 GPIO_PIN(PORT_A, 5) -#define ARDUINO_PIN_28 GPIO_PIN(PORT_A, 6) -#define ARDUINO_PIN_29 GPIO_PIN(PORT_A, 7) -#define ARDUINO_PIN_30 GPIO_PIN(PORT_C, 7) -#define ARDUINO_PIN_31 GPIO_PIN(PORT_C, 6) -#define ARDUINO_PIN_32 GPIO_PIN(PORT_C, 5) -#define ARDUINO_PIN_33 GPIO_PIN(PORT_C, 4) -#define ARDUINO_PIN_34 GPIO_PIN(PORT_C, 3) -#define ARDUINO_PIN_35 GPIO_PIN(PORT_C, 2) -#define ARDUINO_PIN_36 GPIO_PIN(PORT_C, 1) -#define ARDUINO_PIN_37 GPIO_PIN(PORT_E, 0) -#define ARDUINO_PIN_38 GPIO_PIN(PORT_D, 7) -#define ARDUINO_PIN_39 GPIO_PIN(PORT_G, 2) -#define ARDUINO_PIN_40 GPIO_PIN(PORT_G, 1) -#define ARDUINO_PIN_41 GPIO_PIN(PORT_G, 0) -#define ARDUINO_PIN_42 GPIO_PIN(PORT_L, 7) -#define ARDUINO_PIN_43 GPIO_PIN(PORT_L, 6) -#define ARDUINO_PIN_44 GPIO_PIN(PORT_L, 5) -#define ARDUINO_PIN_45 GPIO_PIN(PORT_L, 4) -#define ARDUINO_PIN_46 GPIO_PIN(PORT_L, 3) -#define ARDUINO_PIN_47 GPIO_PIN(PORT_L, 2) -#define ARDUINO_PIN_48 GPIO_PIN(PORT_L, 1) -#define ARDUINO_PIN_49 GPIO_PIN(PORT_L, 0) -#define ARDUINO_PIN_50 GPIO_PIN(PORT_B, 3) -#define ARDUINO_PIN_51 GPIO_PIN(PORT_B, 2) -#define ARDUINO_PIN_52 GPIO_PIN(PORT_B, 1) -#define ARDUINO_PIN_53 GPIO_PIN(PORT_B, 0) -#define ARDUINO_PIN_54 GPIO_PIN(PORT_F, 0) -#define ARDUINO_PIN_55 GPIO_PIN(PORT_F, 1) -#define ARDUINO_PIN_56 GPIO_PIN(PORT_F, 2) -#define ARDUINO_PIN_57 GPIO_PIN(PORT_F, 3) -#define ARDUINO_PIN_58 GPIO_PIN(PORT_F, 4) -#define ARDUINO_PIN_59 GPIO_PIN(PORT_F, 5) -#define ARDUINO_PIN_60 GPIO_PIN(PORT_F, 6) -#define ARDUINO_PIN_61 GPIO_PIN(PORT_F, 7) -#define ARDUINO_PIN_62 GPIO_PIN(PORT_K, 0) -#define ARDUINO_PIN_63 GPIO_PIN(PORT_K, 1) -#define ARDUINO_PIN_64 GPIO_PIN(PORT_K, 2) -#define ARDUINO_PIN_65 GPIO_PIN(PORT_K, 3) -#define ARDUINO_PIN_66 GPIO_PIN(PORT_K, 4) -#define ARDUINO_PIN_67 GPIO_PIN(PORT_K, 5) -#define ARDUINO_PIN_68 GPIO_PIN(PORT_K, 6) -#define ARDUINO_PIN_69 GPIO_PIN(PORT_K, 7) -#define ARDUINO_PIN_A0 ARDUINO_PIN_54 -#define ARDUINO_PIN_A1 ARDUINO_PIN_55 -#define ARDUINO_PIN_A2 ARDUINO_PIN_56 -#define ARDUINO_PIN_A3 ARDUINO_PIN_57 -#define ARDUINO_PIN_A4 ARDUINO_PIN_58 -#define ARDUINO_PIN_A5 ARDUINO_PIN_59 -#define ARDUINO_PIN_A6 ARDUINO_PIN_60 -#define ARDUINO_PIN_A7 ARDUINO_PIN_61 -#define ARDUINO_PIN_A8 ARDUINO_PIN_62 -#define ARDUINO_PIN_A9 ARDUINO_PIN_63 -#define ARDUINO_PIN_A10 ARDUINO_PIN_64 -#define ARDUINO_PIN_A11 ARDUINO_PIN_65 -#define ARDUINO_PIN_A12 ARDUINO_PIN_66 -#define ARDUINO_PIN_A13 ARDUINO_PIN_67 -#define ARDUINO_PIN_A14 ARDUINO_PIN_68 -#define ARDUINO_PIN_A15 ARDUINO_PIN_69 -#endif - -#define ARDUINO_A0 ADC_LINE(0) -#define ARDUINO_A1 ADC_LINE(1) -#define ARDUINO_A2 ADC_LINE(2) -#define ARDUINO_A3 ADC_LINE(3) -#define ARDUINO_A4 ADC_LINE(4) -#define ARDUINO_A5 ADC_LINE(5) -#define ARDUINO_A6 ADC_LINE(6) -#define ARDUINO_A7 ADC_LINE(7) -#ifdef CPU_ATMEGA2560 -#define ARDUINO_A8 ADC_LINE(8) -#define ARDUINO_A9 ADC_LINE(9) -#define ARDUINO_A10 ADC_LINE(10) -#define ARDUINO_A11 ADC_LINE(11) -#define ARDUINO_A12 ADC_LINE(12) -#define ARDUINO_A13 ADC_LINE(13) -#define ARDUINO_A14 ADC_LINE(14) -#define ARDUINO_A15 ADC_LINE(15) -#endif -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_PINMAP_H */ -/** @} */ diff --git a/boards/common/arduino-due/Kconfig b/boards/common/arduino-due/Kconfig index d596a657249ea..f80cc88b3d2f9 100644 --- a/boards/common/arduino-due/Kconfig +++ b/boards/common/arduino-due/Kconfig @@ -7,7 +7,15 @@ config BOARD_COMMON_ARDUINO_DUE bool select CPU_MODEL_SAM3X8E - select HAS_ARDUINO + select HAS_ARDUINO_ANALOG + select HAS_ARDUINO_DAC + select HAS_ARDUINO_I2C + select HAS_ARDUINO_PINS + select HAS_ARDUINO_SHIELD_ISP + select HAS_ARDUINO_SHIELD_MEGA + select HAS_ARDUINO_SHIELD_UNO + select HAS_ARDUINO_SPI + select HAS_ARDUINO_UART select HAS_PERIPH_ADC select HAS_PERIPH_DAC select HAS_PERIPH_GPIO diff --git a/boards/common/arduino-due/Makefile.features b/boards/common/arduino-due/Makefile.features index 45c14863448d8..2aa562cf8cd77 100644 --- a/boards/common/arduino-due/Makefile.features +++ b/boards/common/arduino-due/Makefile.features @@ -12,4 +12,12 @@ FEATURES_PROVIDED += periph_timer FEATURES_PROVIDED += periph_uart # Various other features (if any) -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_dac +FEATURES_PROVIDED += arduino_i2c +FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_shield_isp +FEATURES_PROVIDED += arduino_shield_mega +FEATURES_PROVIDED += arduino_shield_uno +FEATURES_PROVIDED += arduino_spi +FEATURES_PROVIDED += arduino_uart diff --git a/boards/common/arduino-due/include/arduino_board.h b/boards/common/arduino-due/include/arduino_board.h deleted file mode 100644 index c0e434b123b97..0000000000000 --- a/boards/common/arduino-due/include/arduino_board.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (C) 2016,2017 Freie Universität Berlin - * - * 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_arduino_due - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Hauke Petersen - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_pinmap.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The on-board LED is connected to pin 13 on this board - */ -#define ARDUINO_LED (13) - -/** - * @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_14, - ARDUINO_PIN_15, - ARDUINO_PIN_16, - ARDUINO_PIN_17, - ARDUINO_PIN_18, - ARDUINO_PIN_19, - ARDUINO_PIN_20, - ARDUINO_PIN_21, - ARDUINO_PIN_22, - ARDUINO_PIN_23, - ARDUINO_PIN_24, - ARDUINO_PIN_25, - ARDUINO_PIN_26, - ARDUINO_PIN_27, - ARDUINO_PIN_28, - ARDUINO_PIN_29, - ARDUINO_PIN_30, - ARDUINO_PIN_31, - ARDUINO_PIN_32, - ARDUINO_PIN_33, - ARDUINO_PIN_34, - ARDUINO_PIN_35, - ARDUINO_PIN_36, - ARDUINO_PIN_37, - ARDUINO_PIN_38, - ARDUINO_PIN_39, - ARDUINO_PIN_40, - ARDUINO_PIN_41, - ARDUINO_PIN_42, - ARDUINO_PIN_43, - ARDUINO_PIN_44, - ARDUINO_PIN_45, - ARDUINO_PIN_46, - ARDUINO_PIN_47, - ARDUINO_PIN_48, - ARDUINO_PIN_49, - ARDUINO_PIN_50, - ARDUINO_PIN_51, - ARDUINO_PIN_52, - ARDUINO_PIN_53, - ARDUINO_PIN_54, - ARDUINO_PIN_55, - ARDUINO_PIN_56, - ARDUINO_PIN_57, - ARDUINO_PIN_58, - ARDUINO_PIN_59, - ARDUINO_PIN_60, - ARDUINO_PIN_61, - ARDUINO_PIN_62, - ARDUINO_PIN_63, - ARDUINO_PIN_64, - ARDUINO_PIN_65, - ARDUINO_PIN_66, - ARDUINO_PIN_67, - ARDUINO_PIN_68, - ARDUINO_PIN_69, - ARDUINO_PIN_70, - ARDUINO_PIN_71, - ARDUINO_PIN_72, - ARDUINO_PIN_73, - ARDUINO_PIN_74, - ARDUINO_PIN_75, - ARDUINO_PIN_76, - ARDUINO_PIN_77, - ARDUINO_PIN_78, -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { - ARDUINO_A0, - ARDUINO_A1, - ARDUINO_A2, - ARDUINO_A3, - ARDUINO_A4, - ARDUINO_A5, - ARDUINO_A6, - ARDUINO_A7, - ARDUINO_A8, - ARDUINO_A9, - ARDUINO_A10, - ARDUINO_A11, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/common/arduino-due/include/arduino_pinmap.h b/boards/common/arduino-due/include/arduino_iomap.h similarity index 73% rename from boards/common/arduino-due/include/arduino_pinmap.h rename to boards/common/arduino-due/include/arduino_iomap.h index 266f985efd04c..cfbb8883fba47 100644 --- a/boards/common/arduino-due/include/arduino_pinmap.h +++ b/boards/common/arduino-due/include/arduino_iomap.h @@ -19,16 +19,46 @@ * @author Hauke Petersen */ -#ifndef ARDUINO_PINMAP_H -#define ARDUINO_PINMAP_H +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H -#include "periph/gpio.h" #include "periph/adc.h" +#include "periph/gpio.h" +#include "periph/i2c.h" +#include "periph/spi.h" +#include "periph/uart.h" #ifdef __cplusplus extern "C" { #endif +/** + * @name Arduino's default UART device + * @{ + */ +#define ARDUINO_UART_D0D1 UART_DEV(0) +/** @} */ + +/** + * @name Arduino's default SPI device + * @{ + */ +/** + * @brief SPI_DEV(0) is connected to the ISP header + */ +#define ARDUINO_SPI_ISP SPI_DEV(0) +/** @} */ + +/** + * @name Arduino's I2C buses + * @{ + */ +/** + * @brief The only configured I2C + */ +#define ARDUINO_I2C0 I2C_DEV(0) +/** @} */ + /** * @name Mapping of MCU pins to Arduino pins * @{ @@ -112,6 +142,27 @@ extern "C" { #define ARDUINO_PIN_76 GPIO_PIN(PA, 27) #define ARDUINO_PIN_77 GPIO_PIN(PA, 28) #define ARDUINO_PIN_78 GPIO_PIN(PB, 23) + +#define ARDUINO_PIN_LAST 78 /**< D78 is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_54 /**< Arduino pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_55 /**< Arduino pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_56 /**< Arduino pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_57 /**< Arduino pin A3 */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_58 /**< Arduino pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_59 /**< Arduino pin A5 */ +#define ARDUINO_PIN_A6 ARDUINO_PIN_60 /**< Arduino pin A6 */ +#define ARDUINO_PIN_A7 ARDUINO_PIN_61 /**< Arduino pin A7 */ +#define ARDUINO_PIN_A8 ARDUINO_PIN_62 /**< Arduino pin A8 */ +#define ARDUINO_PIN_A9 ARDUINO_PIN_63 /**< Arduino pin A9 */ +#define ARDUINO_PIN_A10 ARDUINO_PIN_64 /**< Arduino pin A10 */ +#define ARDUINO_PIN_A11 ARDUINO_PIN_65 /**< Arduino pin A11 */ +#define ARDUINO_PIN_DAC0 ARDUINO_PIN_66 /**< Arduino pin DAC0 */ +#define ARDUINO_PIN_DAC1 ARDUINO_PIN_67 /**< Arduino pin DAC1 */ /** @} */ /** @@ -130,6 +181,8 @@ extern "C" { #define ARDUINO_A9 ADC_LINE(11) #define ARDUINO_A10 ADC_LINE(12) #define ARDUINO_A11 ADC_LINE(13) + +#define ARDUINO_ANALOG_PIN_LAST 11 /**< A11 is the last analog pin */ /** @} */ /** @@ -138,11 +191,13 @@ extern "C" { */ #define ARDUINO_DAC0 DAC_LINE(0) #define ARDUINO_DAC1 DAC_LINE(1) + +#define ARDUINO_DAC_PIN_LAST 1 /**< DAC1 is the last DAC pin */ /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/common/arduino-mkr/Kconfig b/boards/common/arduino-mkr/Kconfig index 5a4d2df3cbf11..d7547283a0197 100644 --- a/boards/common/arduino-mkr/Kconfig +++ b/boards/common/arduino-mkr/Kconfig @@ -16,7 +16,8 @@ config BOARD_COMMON_ARDUINO_MKR select HAS_PERIPH_TIMER select HAS_PERIPH_UART select HAS_PERIPH_USBDEV - select HAS_ARDUINO + select HAS_ARDUINO_ANALOG + select HAS_ARDUINO_PINS select HAS_ARDUINO_PWM select HAS_HIGHLEVEL_STDIO diff --git a/boards/common/arduino-mkr/Makefile.features b/boards/common/arduino-mkr/Makefile.features index 9888bd0a69f08..bf73961860bfe 100644 --- a/boards/common/arduino-mkr/Makefile.features +++ b/boards/common/arduino-mkr/Makefile.features @@ -14,6 +14,7 @@ FEATURES_PROVIDED += periph_uart FEATURES_PROVIDED += periph_usbdev # Various other features (if any) -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_pins FEATURES_PROVIDED += arduino_pwm FEATURES_PROVIDED += highlevel_stdio diff --git a/boards/common/arduino-mkr/include/arduino_board.h b/boards/common/arduino-mkr/include/arduino_board.h deleted file mode 100644 index 2704aa4cfeef0..0000000000000 --- a/boards/common/arduino-mkr/include/arduino_board.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2016 Freie Universität Berlin - * 2016-2017 Inria - * - * 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_arduino-mkr - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Hauke Petersen - * @author Alexandre Abadie - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_pinmap.h" -#include "periph/pwm.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief On-board serial port mapping, stdio is used for Serial - */ -#ifndef ARDUINO_UART_DEV -#define ARDUINO_UART_DEV UART_UNDEF -#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_14, - ARDUINO_PIN_A0, - ARDUINO_PIN_A1, - ARDUINO_PIN_A2, - ARDUINO_PIN_A3, - ARDUINO_PIN_A4, - ARDUINO_PIN_A5, - ARDUINO_PIN_A6, -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { - ARDUINO_A0, - ARDUINO_A1, - ARDUINO_A2, - ARDUINO_A3, - ARDUINO_A4, - ARDUINO_A5, - ARDUINO_A6, -}; - -/** - * @brief PWM frequency - */ -#define ARDUINO_PWM_FREQU (732U) - -/** - * @brief List of PWM GPIO mappings - */ -static const arduino_pwm_t arduino_pwm_list[] = { - { .pin = 2, .dev = PWM_DEV(0), .chan = 0 }, - { .pin = 3, .dev = PWM_DEV(0), .chan = 1 }, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/common/arduino-mkr/include/arduino_iomap.h b/boards/common/arduino-mkr/include/arduino_iomap.h new file mode 100644 index 0000000000000..b7a84a9fb1370 --- /dev/null +++ b/boards/common/arduino-mkr/include/arduino_iomap.h @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2016-2017 Inria + * + * 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_arduino-mkr + * @{ + * + * @file + * @brief Mapping from MCU pins to Arduino pins + * + * You can use the defines in this file for simplified interaction with the + * Arduino specific pin numbers. + * + * @author Alexandre Abadie + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H + +#include "periph/gpio.h" +#include "periph/adc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief The on-board LED is connected to pin D6 on Arduino MKR derivatives + */ +#define ARDUINO_LED (6U) + +/** + * @name Mapping of MCU pins to Arduino pins + * @{ + */ +#define ARDUINO_PIN_0 GPIO_PIN(PA, 22) /**< TC4-W0 */ +#define ARDUINO_PIN_1 GPIO_PIN(PA, 23) /**< TC4-W1 */ +#define ARDUINO_PIN_2 GPIO_PIN(PA, 10) /**< TCC0-W2 */ +#define ARDUINO_PIN_3 GPIO_PIN(PA, 11) /**< TCC0-W3 */ +#define ARDUINO_PIN_4 GPIO_PIN(PB, 10) /**< TCC0-W4 */ +#define ARDUINO_PIN_5 GPIO_PIN(PB, 11) /**< TCC0-W5 */ +#define ARDUINO_PIN_6 GPIO_PIN(PA, 20) /**< TCC0-W6, on-board LED */ +#define ARDUINO_PIN_7 GPIO_PIN(PA, 21) /**< TCC0-W7 */ + +#define ARDUINO_PIN_8 GPIO_PIN(PA, 16) /**< SERCOM1-MOSI */ +#define ARDUINO_PIN_9 GPIO_PIN(PA, 17) /**< SERCOM1-SCK */ +#define ARDUINO_PIN_10 GPIO_PIN(PA, 19) /**< SERCOM1-MISO */ +#define ARDUINO_PIN_11 GPIO_PIN(PA, 8) /**< SERCOM0-SDA, on-board pull-up */ +#define ARDUINO_PIN_12 GPIO_PIN(PA, 9) /**< SERCOM0-SCL, on-board pull-up */ +#define ARDUINO_PIN_13 GPIO_PIN(PB, 23) /**< SERCOM5-RX from MCU */ +#define ARDUINO_PIN_14 GPIO_PIN(PB, 22) /**< SERCOM5-TX from MCU */ + +/* analog pins as digital pin: */ +#define ARDUINO_PIN_15 GPIO_PIN(PA, 2) /**< AIN0, DAC0 */ +#define ARDUINO_PIN_16 GPIO_PIN(PB, 2) /**< AIN10 */ +#define ARDUINO_PIN_17 GPIO_PIN(PB, 3) /**< AIN11 */ +#define ARDUINO_PIN_18 GPIO_PIN(PA, 4) /**< AIN4 */ +#define ARDUINO_PIN_19 GPIO_PIN(PA, 5) /**< AIN5 */ +#define ARDUINO_PIN_20 GPIO_PIN(PA, 6) /**< AIN6 */ +#define ARDUINO_PIN_21 GPIO_PIN(PA, 7) /**< AIN7 */ + +#define ARDUINO_PIN_LAST 21 /**< D21 (A6) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_15 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_16 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_17 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_18 /**< Arduino Uno pin A3 */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_19 /**< Arduino Uno pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_20 /**< Arduino Uno pin A5 */ +#define ARDUINO_PIN_A6 ARDUINO_PIN_21 /**< Arduino Uno pin A6 */ +/** @} */ + +/** + * @name Mapping of Arduino analog pins to RIOT ADC lines + * @{ + */ +#define ARDUINO_A0 ADC_LINE(0) +#define ARDUINO_A1 ADC_LINE(1) +#define ARDUINO_A2 ADC_LINE(2) +#define ARDUINO_A3 ADC_LINE(3) +#define ARDUINO_A4 ADC_LINE(4) +#define ARDUINO_A5 ADC_LINE(5) +#define ARDUINO_A6 ADC_LINE(6) + +#define ARDUINO_ANALOG_PIN_LAST 6 /**< A6 is the last analog pin */ +/** @} */ + +/** + * @name Mapping of Arduino pins to RIOT PWM dev and channel pairs + * @{ + */ +/** + * @brief PWM frequency + */ +#define ARDUINO_PWM_FREQU (732U) + +#define ARDUINO_PIN_2_PWM_DEV PWM_DEV(0) +#define ARDUINO_PIN_2_PWM_CHAN 0 + +#define ARDUINO_PIN_3_PWM_DEV PWM_DEV(0) +#define ARDUINO_PIN_3_PWM_CHAN 1 +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/common/arduino-mkr/include/arduino_pinmap.h b/boards/common/arduino-mkr/include/arduino_pinmap.h deleted file mode 100644 index 5924aaf6d476b..0000000000000 --- a/boards/common/arduino-mkr/include/arduino_pinmap.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2016-2017 Inria - * - * 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_arduino-mkr - * @{ - * - * @file - * @brief Mapping from MCU pins to Arduino pins - * - * You can use the defines in this file for simplified interaction with the - * Arduino specific pin numbers. - * - * @author Alexandre Abadie - */ - -#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 GPIO_PIN(PA, 22) /* TC4-W0 */ -#define ARDUINO_PIN_1 GPIO_PIN(PA, 23) /* TC4-W1 */ -#define ARDUINO_PIN_2 GPIO_PIN(PA, 10) /* TCC0-W2 */ -#define ARDUINO_PIN_3 GPIO_PIN(PA, 11) /* TCC0-W3 */ -#define ARDUINO_PIN_4 GPIO_PIN(PB, 10) /* TCC0-W4 */ -#define ARDUINO_PIN_5 GPIO_PIN(PB, 11) /* TCC0-W5 */ -#define ARDUINO_PIN_6 GPIO_PIN(PA, 20) /* TCC0-W6, on-board LED */ -#define ARDUINO_PIN_7 GPIO_PIN(PA, 21) /* TCC0-W7 */ - -#define ARDUINO_PIN_8 GPIO_PIN(PA, 16) /* SERCOM1-MOSI */ -#define ARDUINO_PIN_9 GPIO_PIN(PA, 17) /* SERCOM1-SCK */ -#define ARDUINO_PIN_10 GPIO_PIN(PA, 19) /* SERCOM1-MISO */ -#define ARDUINO_PIN_11 GPIO_PIN(PA, 8) /* SERCOM0-SDA, on-board pull-up */ -#define ARDUINO_PIN_12 GPIO_PIN(PA, 9) /* SERCOM0-SCL, on-board pull-up */ -#define ARDUINO_PIN_13 GPIO_PIN(PB, 23) /* SERCOM5-RX from MCU */ -#define ARDUINO_PIN_14 GPIO_PIN(PB, 22) /* SERCOM5-TX from MCU */ - -#define ARDUINO_PIN_A0 GPIO_PIN(PA, 2) /* AIN0, DAC0 */ -#define ARDUINO_PIN_A1 GPIO_PIN(PB, 2) /* AIN10 */ -#define ARDUINO_PIN_A2 GPIO_PIN(PB, 3) /* AIN11 */ -#define ARDUINO_PIN_A3 GPIO_PIN(PA, 4) /* AIN4 */ -#define ARDUINO_PIN_A4 GPIO_PIN(PA, 5) /* AIN5 */ -#define ARDUINO_PIN_A5 GPIO_PIN(PA, 6) /* AIN6 */ -#define ARDUINO_PIN_A6 GPIO_PIN(PA, 7) /* AIN7 */ -/** @} */ - -/** - * @name Mapping of Arduino analog pins to RIOT ADC lines - * @{ - */ -#define ARDUINO_A0 ADC_LINE(0) -#define ARDUINO_A1 ADC_LINE(1) -#define ARDUINO_A2 ADC_LINE(2) -#define ARDUINO_A3 ADC_LINE(3) -#define ARDUINO_A4 ADC_LINE(4) -#define ARDUINO_A5 ADC_LINE(5) -#define ARDUINO_A6 ADC_LINE(6) -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_PINMAP_H */ -/** @} */ diff --git a/boards/common/arduino-zero/Kconfig b/boards/common/arduino-zero/Kconfig index 6392e0373c96c..82b9a8378cd7a 100644 --- a/boards/common/arduino-zero/Kconfig +++ b/boards/common/arduino-zero/Kconfig @@ -16,8 +16,14 @@ config BOARD_COMMON_ARDUINO_ZERO select HAS_PERIPH_TIMER select HAS_PERIPH_UART select HAS_PERIPH_USBDEV - select HAS_ARDUINO + select HAS_ARDUINO_ANALOG + select HAS_ARDUINO_I2C + select HAS_ARDUINO_PINS select HAS_ARDUINO_PWM + select HAS_ARDUINO_SHIELD_ISP + select HAS_ARDUINO_SHIELD_UNO + select HAS_ARDUINO_SPI + select HAS_ARDUINO_UART select HAVE_SAUL_GPIO diff --git a/boards/common/arduino-zero/Makefile.features b/boards/common/arduino-zero/Makefile.features index 03ea2c00bbedb..ca9f191dda4d4 100644 --- a/boards/common/arduino-zero/Makefile.features +++ b/boards/common/arduino-zero/Makefile.features @@ -13,5 +13,11 @@ FEATURES_PROVIDED += periph_uart FEATURES_PROVIDED += periph_usbdev # Various other features (if any) -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_i2c +FEATURES_PROVIDED += arduino_pins FEATURES_PROVIDED += arduino_pwm +FEATURES_PROVIDED += arduino_shield_isp +FEATURES_PROVIDED += arduino_shield_uno +FEATURES_PROVIDED += arduino_spi +FEATURES_PROVIDED += arduino_uart diff --git a/boards/common/arduino-zero/include/arduino_board.h b/boards/common/arduino-zero/include/arduino_board.h deleted file mode 100644 index 4ac4b35cb24d0..0000000000000 --- a/boards/common/arduino-zero/include/arduino_board.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2016 Freie Universität Berlin - * 2016 Inria - * - * 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_arduino_zero - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Hauke Petersen - * @author Alexandre Abadie - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_pinmap.h" -#include "periph/pwm.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The on-board LED is connected to pin 13 on this board - */ -#define ARDUINO_LED (13) - -/** - * @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_A0, - ARDUINO_A1, - ARDUINO_A2, - ARDUINO_A3, - ARDUINO_A4, - ARDUINO_A5, -}; - -/** - * @brief PWM frequency - */ -#define ARDUINO_PWM_FREQU (732U) - -/** - * @brief List of PWM GPIO mappings - */ -static const arduino_pwm_t arduino_pwm_list[] = { - { .pin = 3, .dev = PWM_DEV(0), .chan = 1 }, - { .pin = 4, .dev = PWM_DEV(0), .chan = 0 }, - { .pin = 8, .dev = PWM_DEV(1), .chan = 0 }, - { .pin = 9, .dev = PWM_DEV(1), .chan = 1 }, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/common/arduino-zero/include/arduino_iomap.h b/boards/common/arduino-zero/include/arduino_iomap.h new file mode 100644 index 0000000000000..5bb4adb6f9901 --- /dev/null +++ b/boards/common/arduino-zero/include/arduino_iomap.h @@ -0,0 +1,146 @@ +/* + * Copyright (C) 2016 Inria + * + * 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_arduino_zero + * @{ + * + * @file + * @brief Mapping from MCU pins to Arduino pins + * + * You can use the defines in this file for simplified interaction with the + * Arduino specific pin numbers. + * + * @author Alexandre Abadie + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H + +#include "periph/adc.h" +#include "periph/gpio.h" +#include "periph/i2c.h" +#include "periph/pwm.h" +#include "periph/spi.h" +#include "periph/uart.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Arduino's UART devices + * @{ + */ +#define ARDUINO_UART_D0D1 UART_DEV(1) +/** @} */ + +/** + * @name Arduino's SPI buses + * @{ + */ +/** + * @brief SPI_DEV(0) is connected to the ISP header + */ +#define ARDUINO_SPI_ISP SPI_DEV(0) +/** @} */ + +/** + * @name Arduino's I2C buses + * @{ + */ +/** + * @brief The first I2C bus is next to the AREF pin + */ +#define ARDUINO_I2C_UNO I2C_DEV(0) +/** @} */ + +/** + * @name Mapping of MCU pins to Arduino pins + * @{ + */ +#define ARDUINO_PIN_0 GPIO_PIN(PA, 11) +#define ARDUINO_PIN_1 GPIO_PIN(PA, 10) +#define ARDUINO_PIN_2 GPIO_PIN(PA, 14) +#define ARDUINO_PIN_3 GPIO_PIN(PA, 9) +#define ARDUINO_PIN_4 GPIO_PIN(PA, 8) +#define ARDUINO_PIN_5 GPIO_PIN(PA, 15) +#define ARDUINO_PIN_6 GPIO_PIN(PA, 20) +#define ARDUINO_PIN_7 GPIO_PIN(PA, 21) + +#define ARDUINO_PIN_8 GPIO_PIN(PA, 6) +#define ARDUINO_PIN_9 GPIO_PIN(PA, 7) +#define ARDUINO_PIN_10 GPIO_PIN(PA, 18) +#define ARDUINO_PIN_11 GPIO_PIN(PA, 16) +#define ARDUINO_PIN_12 GPIO_PIN(PA, 19) +#define ARDUINO_PIN_13 GPIO_PIN(PA, 17) /* on-board LED */ + +/* analog pins as digital pin: */ +#define ARDUINO_PIN_14 GPIO_PIN(PA, 2) +#define ARDUINO_PIN_15 GPIO_PIN(PB, 8) +#define ARDUINO_PIN_16 GPIO_PIN(PB, 9) +#define ARDUINO_PIN_17 GPIO_PIN(PA, 4) +#define ARDUINO_PIN_18 GPIO_PIN(PA, 5) +#define ARDUINO_PIN_19 GPIO_PIN(PB, 2) + +#define ARDUINO_PIN_LAST 19 /**< D19 (A5) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#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) +#define ARDUINO_A1 ADC_LINE(1) +#define ARDUINO_A2 ADC_LINE(2) +#define ARDUINO_A3 ADC_LINE(3) +#define ARDUINO_A4 ADC_LINE(4) +#define ARDUINO_A5 ADC_LINE(5) + +#define ARDUINO_ANALOG_PIN_LAST 5 /**< A5 is the last analog pin */ +/** @} */ + +/** + * @name Mapping of Arduino pins to RIOT PWM dev and channel pairs + * @{ + */ +/** + * @brief PWM frequency + */ +#define ARDUINO_PWM_FREQU (732U) + +#define ARDUINO_PIN_3_PWM_DEV PWM_DEV(0) +#define ARDUINO_PIN_3_PWM_CHAN 1 + +#define ARDUINO_PIN_4_PWM_DEV PWM_DEV(0) +#define ARDUINO_PIN_4_PWM_CHAN 0 + +#define ARDUINO_PIN_8_PWM_DEV PWM_DEV(1) +#define ARDUINO_PIN_8_PWM_CHAN 0 + +#define ARDUINO_PIN_9_PWM_DEV PWM_DEV(1) +#define ARDUINO_PIN_9_PWM_CHAN 1 +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/common/arduino-zero/include/arduino_pinmap.h b/boards/common/arduino-zero/include/arduino_pinmap.h deleted file mode 100644 index 3e03ee20c2ad7..0000000000000 --- a/boards/common/arduino-zero/include/arduino_pinmap.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (C) 2016 Inria - * - * 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_arduino_zero - * @{ - * - * @file - * @brief Mapping from MCU pins to Arduino pins - * - * You can use the defines in this file for simplified interaction with the - * Arduino specific pin numbers. - * - * @author Alexandre Abadie - */ - -#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 GPIO_PIN(PA, 11) -#define ARDUINO_PIN_1 GPIO_PIN(PA, 10) -#define ARDUINO_PIN_2 GPIO_PIN(PA, 14) -#define ARDUINO_PIN_3 GPIO_PIN(PA, 9) -#define ARDUINO_PIN_4 GPIO_PIN(PA, 8) -#define ARDUINO_PIN_5 GPIO_PIN(PA, 15) -#define ARDUINO_PIN_6 GPIO_PIN(PA, 20) -#define ARDUINO_PIN_7 GPIO_PIN(PA, 21) - -#define ARDUINO_PIN_8 GPIO_PIN(PA, 6) -#define ARDUINO_PIN_9 GPIO_PIN(PA, 7) -#define ARDUINO_PIN_10 GPIO_PIN(PA, 18) -#define ARDUINO_PIN_11 GPIO_PIN(PA, 16) -#define ARDUINO_PIN_12 GPIO_PIN(PA, 19) -#define ARDUINO_PIN_13 GPIO_PIN(PA, 17) /* on-board LED */ - -#define ARDUINO_PIN_A0 GPIO_PIN(PA, 2) -#define ARDUINO_PIN_A1 GPIO_PIN(PB, 8) -#define ARDUINO_PIN_A2 GPIO_PIN(PB, 9) -#define ARDUINO_PIN_A3 GPIO_PIN(PA, 4) -#define ARDUINO_PIN_A4 GPIO_PIN(PA, 5) -#define ARDUINO_PIN_A5 GPIO_PIN(PB, 2) -/** @} */ - -/** - * @name Mapping of Arduino analog pins to RIOT ADC lines - * @{ - */ -#define ARDUINO_A0 ADC_LINE(0) -#define ARDUINO_A1 ADC_LINE(1) -#define ARDUINO_A2 ADC_LINE(2) -#define ARDUINO_A3 ADC_LINE(3) -#define ARDUINO_A4 ADC_LINE(4) -#define ARDUINO_A5 ADC_LINE(5) -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_PINMAP_H */ -/** @} */ diff --git a/boards/common/esp8266/Kconfig b/boards/common/esp8266/Kconfig index 996efda23bdea..1a9c276dbf49a 100644 --- a/boards/common/esp8266/Kconfig +++ b/boards/common/esp8266/Kconfig @@ -6,7 +6,7 @@ config BOARD_COMMON_ESP8266 bool - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_PERIPH_ADC select HAS_PERIPH_I2C select HAS_PERIPH_PWM diff --git a/boards/common/esp8266/Makefile.features b/boards/common/esp8266/Makefile.features index 3f0ede6249ceb..e266c1503372b 100644 --- a/boards/common/esp8266/Makefile.features +++ b/boards/common/esp8266/Makefile.features @@ -8,4 +8,4 @@ FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_uart -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_pins diff --git a/boards/common/nucleo144/Kconfig b/boards/common/nucleo144/Kconfig index ead4e3fe184fe..c309ce3c37205 100644 --- a/boards/common/nucleo144/Kconfig +++ b/boards/common/nucleo144/Kconfig @@ -7,7 +7,10 @@ config BOARD_COMMON_NUCLEO144 bool - select HAS_ARDUINO + select HAS_ARDUINO_ANALOG + select HAS_ARDUINO_PINS + select HAS_ARDUINO_SHIELD_MEGA + select HAS_ARDUINO_SHIELD_UNO # Clock configuration select BOARD_HAS_HSE if !CPU_FAM_L4 && !CPU_FAM_L5 diff --git a/boards/common/nucleo144/Makefile.features b/boards/common/nucleo144/Makefile.features index c71c96c1a0cfa..4b1205d621dc6 100644 --- a/boards/common/nucleo144/Makefile.features +++ b/boards/common/nucleo144/Makefile.features @@ -1,2 +1,5 @@ # Various common features of Nucleo-144 boards -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_shield_mega +FEATURES_PROVIDED += arduino_shield_uno diff --git a/boards/common/nucleo144/include/arduino_board.h b/boards/common/nucleo144/include/arduino_board.h deleted file mode 100644 index 71624a051afc3..0000000000000 --- a/boards/common/nucleo144/include/arduino_board.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2017 Inria - * - * 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_nucleo144 - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Alexandre Abadie - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_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_14, - ARDUINO_PIN_15, - 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_A0, - ARDUINO_A1, - ARDUINO_A2, - ARDUINO_A3, - ARDUINO_A4, - ARDUINO_A5, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/common/nucleo144/include/arduino_pinmap.h b/boards/common/nucleo144/include/arduino_iomap.h similarity index 62% rename from boards/common/nucleo144/include/arduino_pinmap.h rename to boards/common/nucleo144/include/arduino_iomap.h index a90ddad53b113..2b678397c8bf6 100644 --- a/boards/common/nucleo144/include/arduino_pinmap.h +++ b/boards/common/nucleo144/include/arduino_iomap.h @@ -19,8 +19,8 @@ * @author Alexandre Abadie */ -#ifndef ARDUINO_PINMAP_H -#define ARDUINO_PINMAP_H +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H #include "periph/gpio.h" #include "periph/adc.h" @@ -57,23 +57,36 @@ extern "C" { #define ARDUINO_PIN_14 GPIO_PIN(PORT_B, 8) #define ARDUINO_PIN_15 GPIO_PIN(PORT_B, 9) -#define ARDUINO_PIN_A0 GPIO_PIN(PORT_A, 3) -#define ARDUINO_PIN_A1 GPIO_PIN(PORT_C, 0) -#define ARDUINO_PIN_A2 GPIO_PIN(PORT_C, 3) +#define ARDUINO_PIN_16 GPIO_PIN(PORT_A, 3) +#define ARDUINO_PIN_17 GPIO_PIN(PORT_C, 0) +#define ARDUINO_PIN_18 GPIO_PIN(PORT_C, 3) #if defined(CPU_MODEL_STM32F413ZH) || defined(CPU_MODEL_STM32F412ZG) || \ defined(CPU_MODEL_STM32L496ZG) -#define ARDUINO_PIN_A3 GPIO_PIN(PORT_C, 1) -#define ARDUINO_PIN_A4 GPIO_PIN(PORT_C, 4) -#define ARDUINO_PIN_A5 GPIO_PIN(PORT_C, 5) +# define ARDUINO_PIN_19 GPIO_PIN(PORT_C, 1) +# define ARDUINO_PIN_20 GPIO_PIN(PORT_C, 4) +# define ARDUINO_PIN_21 GPIO_PIN(PORT_C, 5) #elif defined(CPU_MODEL_STM32F303ZE) -#define ARDUINO_PIN_A3 GPIO_PIN(PORT_D, 11) -#define ARDUINO_PIN_A4 GPIO_PIN(PORT_D, 12) -#define ARDUINO_PIN_A5 GPIO_PIN(PORT_D, 13) +# define ARDUINO_PIN_19 GPIO_PIN(PORT_D, 11) +# define ARDUINO_PIN_20 GPIO_PIN(PORT_D, 12) +# define ARDUINO_PIN_21 GPIO_PIN(PORT_D, 13) #else -#define ARDUINO_PIN_A3 GPIO_PIN(PORT_F, 3) -#define ARDUINO_PIN_A4 GPIO_PIN(PORT_F, 5) -#define ARDUINO_PIN_A5 GPIO_PIN(PORT_F, 10) +# define ARDUINO_PIN_19 GPIO_PIN(PORT_F, 3) +# define ARDUINO_PIN_20 GPIO_PIN(PORT_F, 5) +# define ARDUINO_PIN_21 GPIO_PIN(PORT_F, 10) #endif + +#define ARDUINO_PIN_LAST 21 /**< D21 is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_16 /**< Arduino pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_17 /**< Arduino pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_18 /**< Arduino pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_19 /**< Arduino pin A3 */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_20 /**< Arduino pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_21 /**< Arduino pin A5 */ /** @} */ /** @@ -86,11 +99,13 @@ extern "C" { #define ARDUINO_A3 ADC_LINE(3) #define ARDUINO_A4 ADC_LINE(4) #define ARDUINO_A5 ADC_LINE(5) + +#define ARDUINO_ANALOG_PIN_LAST 5 /**< A5 is the last analog pin */ /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/common/nucleo32/Kconfig b/boards/common/nucleo32/Kconfig index 552ff66158814..a5ac1d7dfb9a0 100644 --- a/boards/common/nucleo32/Kconfig +++ b/boards/common/nucleo32/Kconfig @@ -7,7 +7,9 @@ config BOARD_COMMON_NUCLEO32 bool - select HAS_ARDUINO + select HAS_ARDUINO_ANALOG + select HAS_ARDUINO_PINS + select HAS_ARDUINO_SHIELD_NANO # Clock configuration select BOARD_HAS_LSE if (CPU_FAM_L0 || CPU_FAM_L4) && !BOARD_NUCLEO_L011K4 diff --git a/boards/common/nucleo32/Makefile.features b/boards/common/nucleo32/Makefile.features index 824e8a21f8a1c..5f13dca921e0c 100644 --- a/boards/common/nucleo32/Makefile.features +++ b/boards/common/nucleo32/Makefile.features @@ -1,2 +1,4 @@ # Various common features of Nucleo boards -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_shield_nano diff --git a/boards/common/nucleo32/include/arduino_board.h b/boards/common/nucleo32/include/arduino_board.h deleted file mode 100644 index 818d751de5a96..0000000000000 --- a/boards/common/nucleo32/include/arduino_board.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2017 Inria - * - * 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_nucleo32 - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Alexandre Abadie - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_pinmap.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The on-board LED is connected to pin 13 on this board - */ -#define ARDUINO_LED (13) - -/** - * @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, - ARDUINO_PIN_A6, - ARDUINO_PIN_A7 -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { - ARDUINO_A0, - ARDUINO_A1, - ARDUINO_A2, - ARDUINO_A3, - ARDUINO_A4, - ARDUINO_A5, - ARDUINO_A6, - ARDUINO_A7, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/common/nucleo32/include/arduino_pinmap.h b/boards/common/nucleo32/include/arduino_iomap.h similarity index 62% rename from boards/common/nucleo32/include/arduino_pinmap.h rename to boards/common/nucleo32/include/arduino_iomap.h index 54e4836e5c333..099f4f56f5690 100644 --- a/boards/common/nucleo32/include/arduino_pinmap.h +++ b/boards/common/nucleo32/include/arduino_iomap.h @@ -19,8 +19,8 @@ * @author Alexandre Abadie */ -#ifndef ARDUINO_PINMAP_H -#define ARDUINO_PINMAP_H +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H #include "periph/gpio.h" #include "periph/adc.h" @@ -54,14 +54,30 @@ extern "C" { #define ARDUINO_PIN_12 GPIO_PIN(PORT_B, 4) #define ARDUINO_PIN_13 GPIO_PIN(PORT_B, 3) /* on-board LED */ -#define ARDUINO_PIN_A0 GPIO_PIN(PORT_A, 0) -#define ARDUINO_PIN_A1 GPIO_PIN(PORT_A, 1) -#define ARDUINO_PIN_A2 GPIO_PIN(PORT_A, 3) -#define ARDUINO_PIN_A3 GPIO_PIN(PORT_A, 4) -#define ARDUINO_PIN_A4 GPIO_PIN(PORT_A, 5) -#define ARDUINO_PIN_A5 GPIO_PIN(PORT_A, 6) -#define ARDUINO_PIN_A6 GPIO_PIN(PORT_A, 7) -#define ARDUINO_PIN_A7 GPIO_PIN(PORT_A, 2) +/* analog pins as digital pin: */ +#define ARDUINO_PIN_14 GPIO_PIN(PORT_A, 0) +#define ARDUINO_PIN_15 GPIO_PIN(PORT_A, 1) +#define ARDUINO_PIN_16 GPIO_PIN(PORT_A, 3) +#define ARDUINO_PIN_17 GPIO_PIN(PORT_A, 4) +#define ARDUINO_PIN_18 GPIO_PIN(PORT_A, 5) +#define ARDUINO_PIN_19 GPIO_PIN(PORT_A, 6) +#define ARDUINO_PIN_20 GPIO_PIN(PORT_A, 7) +#define ARDUINO_PIN_21 GPIO_PIN(PORT_A, 2) + +#define ARDUINO_PIN_LAST 21 /**< D21 (A7) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#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_A6 ARDUINO_PIN_20 /**< Arduino pin A6 */ +#define ARDUINO_PIN_A7 ARDUINO_PIN_21 /**< Arduino pin A7 */ /** @} */ /** @@ -76,11 +92,13 @@ extern "C" { #define ARDUINO_A5 ADC_LINE(5) #define ARDUINO_A6 ADC_LINE(6) #define ARDUINO_A7 ADC_LINE(7) + +#define ARDUINO_ANALOG_PIN_LAST 7 /**< A7 is the last analog pin */ /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/common/nucleo64/Kconfig b/boards/common/nucleo64/Kconfig index 3b410fb4bd608..577e0e91cfddf 100644 --- a/boards/common/nucleo64/Kconfig +++ b/boards/common/nucleo64/Kconfig @@ -7,7 +7,12 @@ config BOARD_COMMON_NUCLEO64 bool - select HAS_ARDUINO + select HAS_ARDUINO_ANALOG + select HAS_ARDUINO_I2C + select HAS_ARDUINO_PINS + select HAS_ARDUINO_SHIELD_UNO + select HAS_ARDUINO_SPI + select HAS_ARDUINO_UART # Clock configuration select BOARD_HAS_HSE if !CPU_FAM_G0 && !CPU_FAM_L0 && !CPU_FAM_L1 && !CPU_FAM_L4 diff --git a/boards/common/nucleo64/Makefile.features b/boards/common/nucleo64/Makefile.features index 824e8a21f8a1c..75ae094f286ef 100644 --- a/boards/common/nucleo64/Makefile.features +++ b/boards/common/nucleo64/Makefile.features @@ -1,2 +1,7 @@ # Various common features of Nucleo boards -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_i2c +FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_shield_uno +FEATURES_PROVIDED += arduino_spi +FEATURES_PROVIDED += arduino_uart diff --git a/boards/common/nucleo64/include/arduino_board.h b/boards/common/nucleo64/include/arduino_board.h deleted file mode 100644 index 0164ce7bfb24d..0000000000000 --- a/boards/common/nucleo64/include/arduino_board.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2016 Freie Universität Berlin - * 2016 Inria - * - * 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_nucleo64 - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Hauke Petersen - * @author Alexandre Abadie - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_pinmap.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The on-board LED is connected to pin 13 on this board - */ -#define ARDUINO_LED (13) - -/** - * @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_A0, - ARDUINO_A1, - ARDUINO_A2, - ARDUINO_A3, - ARDUINO_A4, - ARDUINO_A5, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/common/nucleo64/include/arduino_pinmap.h b/boards/common/nucleo64/include/arduino_iomap.h similarity index 58% rename from boards/common/nucleo64/include/arduino_pinmap.h rename to boards/common/nucleo64/include/arduino_iomap.h index 5983bee5c988a..5501ba6ce13e1 100644 --- a/boards/common/nucleo64/include/arduino_pinmap.h +++ b/boards/common/nucleo64/include/arduino_iomap.h @@ -19,8 +19,8 @@ * @author Alexandre Abadie */ -#ifndef ARDUINO_PINMAP_H -#define ARDUINO_PINMAP_H +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H #include "periph/gpio.h" #include "periph/adc.h" @@ -29,6 +29,33 @@ extern "C" { #endif +/** + * @name Arduino's UART devices + * @{ + */ +#define ARDUINO_UART_D0D1 UART_DEV(0) +/** @} */ + +/** + * @name Arduino's SPI buses + * @{ + */ +/** + * @brief SPI_DEV(1) is connected to D11/D12/D13 + */ +#define ARDUINO_SPI_D11D12D13 SPI_DEV(1) +/** @} */ + +/** + * @name Arduino's I2C buses + * @{ + */ +/** + * @brief The first I2C bus is where shields for the Arduino UNO expect it + */ +#define ARDUINO_I2C_UNO I2C_DEV(0) +/** @} */ + /** * @brief Mapping of MCU pins to Arduino pins * @{ @@ -57,12 +84,26 @@ extern "C" { #define ARDUINO_PIN_14 GPIO_PIN(PORT_B, 9) #define ARDUINO_PIN_15 GPIO_PIN(PORT_B, 8) -#define ARDUINO_PIN_A0 GPIO_PIN(PORT_A, 0) -#define ARDUINO_PIN_A1 GPIO_PIN(PORT_A, 1) -#define ARDUINO_PIN_A2 GPIO_PIN(PORT_A, 4) -#define ARDUINO_PIN_A3 GPIO_PIN(PORT_B, 0) -#define ARDUINO_PIN_A4 GPIO_PIN(PORT_C, 1) -#define ARDUINO_PIN_A5 GPIO_PIN(PORT_C, 0) +/* analog pins as digital pins: */ +#define ARDUINO_PIN_16 GPIO_PIN(PORT_A, 0) +#define ARDUINO_PIN_17 GPIO_PIN(PORT_A, 1) +#define ARDUINO_PIN_18 GPIO_PIN(PORT_A, 4) +#define ARDUINO_PIN_19 GPIO_PIN(PORT_B, 0) +#define ARDUINO_PIN_20 GPIO_PIN(PORT_C, 1) +#define ARDUINO_PIN_21 GPIO_PIN(PORT_C, 0) + +#define ARDUINO_PIN_LAST 21 /**< D21 (A5) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_16 /**< Arduino pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_17 /**< Arduino pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_18 /**< Arduino pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_19 /**< Arduino pin A3 */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_20 /**< Arduino pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_21 /**< Arduino pin A5 */ /** @} */ /** @@ -75,11 +116,13 @@ extern "C" { #define ARDUINO_A3 ADC_LINE(3) #define ARDUINO_A4 ADC_LINE(4) #define ARDUINO_A5 ADC_LINE(5) + +#define ARDUINO_ANALOG_PIN_LAST 5 /**< A5 is the last analog pin */ /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/common/silabs/Kconfig b/boards/common/silabs/Kconfig index c425c2b2c5651..a37ec01c4f5a4 100644 --- a/boards/common/silabs/Kconfig +++ b/boards/common/silabs/Kconfig @@ -6,7 +6,8 @@ config BOARD_COMMON_SILABS bool - select HAS_ARDUINO + select HAS_ARDUINO_ANALOG + select HAS_ARDUINO_PINS select HAS_EFM32_CORETEMP select HAS_RIOTBOOT diff --git a/boards/common/silabs/Makefile.features b/boards/common/silabs/Makefile.features index bd382ec652d17..4463a2e0274bb 100644 --- a/boards/common/silabs/Makefile.features +++ b/boards/common/silabs/Makefile.features @@ -1,6 +1,7 @@ CPU = efm32 # Various other features (if any) -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_pins FEATURES_PROVIDED += efm32_coretemp FEATURES_PROVIDED += riotboot diff --git a/boards/common/silabs/include/arduino_board.h b/boards/common/silabs/include/arduino_board.h deleted file mode 100644 index ef02a9e874f65..0000000000000 --- a/boards/common/silabs/include/arduino_board.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2018 Federico Pellegrin - * - * 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_silabs - * @brief SiLabs Boards configuration for the Arduino API - * @file - * @author Federico Pellegrin - * @{ - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_pinmap.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Arduino's digital pins mappings - */ -static const gpio_t arduino_pinmap[] = { - ARDUINO_PIN_0, - ARDUINO_PIN_1, - ARDUINO_PIN_2, - ARDUINO_PIN_3 -}; - -/** - * @brief Arduino's analog pins mappings - */ -static const adc_t arduino_analog_map[] = { - ARDUINO_A0 -}; - -/** - * @brief On-board LED mapping - */ -#define ARDUINO_LED (0) - -/** - * @brief On-board serial port mapping - */ -#define ARDUINO_UART_DEV UART_DEV(0) - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/common/silabs/include/arduino_pinmap.h b/boards/common/silabs/include/arduino_iomap.h similarity index 51% rename from boards/common/silabs/include/arduino_pinmap.h rename to boards/common/silabs/include/arduino_iomap.h index aaf1592d279d2..5b6d6ed451532 100644 --- a/boards/common/silabs/include/arduino_pinmap.h +++ b/boards/common/silabs/include/arduino_iomap.h @@ -14,8 +14,8 @@ * @{ */ -#ifndef ARDUINO_PINMAP_H -#define ARDUINO_PINMAP_H +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H #include "board.h" #include "periph_cpu.h" @@ -26,21 +26,29 @@ extern "C" { #endif /** - * @brief Arduino's digital pins mappings + * @name Arduino's digital pins mappings + * @{ */ -#define ARDUINO_PIN_0 LED0_PIN -#define ARDUINO_PIN_1 LED1_PIN -#define ARDUINO_PIN_2 PB0_PIN -#define ARDUINO_PIN_3 PB1_PIN +#define ARDUINO_PIN_0 LED0_PIN +#define ARDUINO_PIN_1 LED1_PIN +#define ARDUINO_PIN_2 PB0_PIN +#define ARDUINO_PIN_3 PB1_PIN + +#define ARDUINO_PIN_LAST 3 /**< D3 is the last digital pin */ +/** @} */ /** - * @brief Arduino's analog pins mappings + * @name Arduino's analog pins mappings + * @{ */ -#define ARDUINO_A0 ADC_LINE(0) +#define ARDUINO_A0 ADC_LINE(0) + +#define ARDUINO_ANALOG_PIN_LAST 0 /**< A0 is the last analog pin */ +/** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/common/sodaq/Kconfig b/boards/common/sodaq/Kconfig index bab0e89688814..ff32879a0b58a 100644 --- a/boards/common/sodaq/Kconfig +++ b/boards/common/sodaq/Kconfig @@ -14,7 +14,7 @@ config BOARD_COMMON_SODAQ select HAS_PERIPH_TIMER select HAS_PERIPH_UART select HAS_PERIPH_USBDEV - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_HIGHLEVEL_STDIO select HAVE_SAUL_GPIO diff --git a/boards/common/sodaq/Makefile.features b/boards/common/sodaq/Makefile.features index 4f6613e8d75c6..6b81dc6d03b24 100644 --- a/boards/common/sodaq/Makefile.features +++ b/boards/common/sodaq/Makefile.features @@ -11,5 +11,5 @@ FEATURES_PROVIDED += periph_uart FEATURES_PROVIDED += periph_usbdev # Various other features (if any) -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_pins FEATURES_PROVIDED += highlevel_stdio diff --git a/boards/esp32-heltec-lora32-v2/Kconfig b/boards/esp32-heltec-lora32-v2/Kconfig index 65007058a284a..2abb4fbd693a8 100644 --- a/boards/esp32-heltec-lora32-v2/Kconfig +++ b/boards/esp32-heltec-lora32-v2/Kconfig @@ -12,7 +12,7 @@ config BOARD_ESP32_HELTEC_LORA32_V2 default y select BOARD_COMMON_ESP32 select CPU_MODEL_ESP32_D0WD - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_ESP_RTC_TIMER_32K select HAS_PERIPH_ADC select HAS_PERIPH_I2C diff --git a/boards/esp32-heltec-lora32-v2/Makefile.features b/boards/esp32-heltec-lora32-v2/Makefile.features index 044b63dfe8f1d..b16004dc0da83 100644 --- a/boards/esp32-heltec-lora32-v2/Makefile.features +++ b/boards/esp32-heltec-lora32-v2/Makefile.features @@ -10,4 +10,4 @@ FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += esp_rtc_timer_32k -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_pins diff --git a/boards/esp32-heltec-lora32-v2/include/arduino_board.h b/boards/esp32-heltec-lora32-v2/include/arduino_board.h deleted file mode 100644 index 1a282efad0842..0000000000000 --- a/boards/esp32-heltec-lora32-v2/include/arduino_board.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (C) 2019 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_esp32_heltec-lora32-v2 - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Gunar Schorcht - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_board_common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The on-board LED is connected to Arduino pin 3 on this board - */ -#define ARDUINO_LED (3) - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/esp32-heltec-lora32-v2/include/arduino_iomap.h b/boards/esp32-heltec-lora32-v2/include/arduino_iomap.h new file mode 100644 index 0000000000000..45fc3cfd2c697 --- /dev/null +++ b/boards/esp32-heltec-lora32-v2/include/arduino_iomap.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2019 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_esp32_heltec-lora32-v2 + * @{ + * + * @file + * @brief Mapping from MCU pins to Arduino pins + * + * @author Gunar Schorcht + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_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 GPIO3 /**< Arduino Uno pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO1 /**< Arduino Uno pin 1 (TxD) */ + +#define ARDUINO_PIN_2 GPIO12 /**< Arduino Uno pin 2 */ +#define ARDUINO_PIN_3 GPIO25 /**< Arduino Uno pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO13 /**< Arduino Uno pin 4 */ +#define ARDUINO_PIN_5 GPIO0 /**< Arduino Uno pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO2 /**< Arduino Uno pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO22 /**< Arduino Uno pin 7 */ +#define ARDUINO_PIN_8 GPIO23 /**< Arduino Uno pin 8 */ +#define ARDUINO_PIN_9 GPIO17 /**< Arduino Uno pin 9 (PWM) */ + +#define ARDUINO_PIN_10 GPIO18 /**< Arduino Uno pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO27 /**< Arduino Uno pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO19 /**< Arduino Uno pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO5 /**< Arduino Uno pin 13 (SCK) */ + +/* analog pins as digital pin: */ +#define ARDUINO_PIN_14 GPIO36 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_15 GPIO39 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_16 GPIO37 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_17 GPIO38 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_18 GPIO4 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO15 /**< Arduino Uno pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 /**< D19 is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino Uno pin A5 (SCL) */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/esp32-heltec-lora32-v2/include/arduino_pinmap.h b/boards/esp32-heltec-lora32-v2/include/arduino_pinmap.h deleted file mode 100644 index 90a16db74a8af..0000000000000 --- a/boards/esp32-heltec-lora32-v2/include/arduino_pinmap.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2019 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_esp32_heltec-lora32-v2 - * @{ - * - * @file - * @brief Mapping from MCU pins to Arduino pins - * - * @author Gunar Schorcht - */ - -#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 GPIO3 /**< Arduino Uno pin 0 (RxD) */ -#define ARDUINO_PIN_1 GPIO1 /**< Arduino Uno pin 1 (TxD) */ - -#define ARDUINO_PIN_2 GPIO12 /**< Arduino Uno pin 2 */ -#define ARDUINO_PIN_3 GPIO25 /**< Arduino Uno pin 3 (PWM) */ -#define ARDUINO_PIN_4 GPIO13 /**< Arduino Uno pin 4 */ -#define ARDUINO_PIN_5 GPIO0 /**< Arduino Uno pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO2 /**< Arduino Uno pin 6 (PWM) */ -#define ARDUINO_PIN_7 GPIO22 /**< Arduino Uno pin 7 */ -#define ARDUINO_PIN_8 GPIO23 /**< Arduino Uno pin 8 */ -#define ARDUINO_PIN_9 GPIO17 /**< Arduino Uno pin 9 (PWM) */ - -#define ARDUINO_PIN_10 GPIO18 /**< Arduino Uno pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO27 /**< Arduino Uno pin 11 (MOSI / PWM) */ -#define ARDUINO_PIN_12 GPIO19 /**< Arduino Uno pin 12 (MISO) */ -#define ARDUINO_PIN_13 GPIO5 /**< Arduino Uno pin 13 (SCK) */ - -#define ARDUINO_PIN_A0 GPIO36 /**< Arduino Uno pin A0 */ -#define ARDUINO_PIN_A1 GPIO39 /**< Arduino Uno pin A1 */ -#define ARDUINO_PIN_A2 GPIO37 /**< Arduino Uno pin A2 */ -#define ARDUINO_PIN_A3 GPIO38 /**< Arduino Uno pin A3 */ - -#define ARDUINO_PIN_A4 GPIO4 /**< Arduino Uno pin A4 (SDA) */ -#define ARDUINO_PIN_A5 GPIO15 /**< Arduino Uno pin A5 (SCL) */ -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_PINMAP_H */ -/** @} */ diff --git a/boards/esp32-mh-et-live-minikit/Kconfig b/boards/esp32-mh-et-live-minikit/Kconfig index 9228d1acd30de..027f0365b1288 100644 --- a/boards/esp32-mh-et-live-minikit/Kconfig +++ b/boards/esp32-mh-et-live-minikit/Kconfig @@ -12,7 +12,7 @@ config BOARD_ESP32_MH_ET_LIVE_MINIKIT default y select BOARD_COMMON_ESP32 select CPU_MODEL_ESP32_WROOM_32 - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_PERIPH_ADC select HAS_PERIPH_DAC select HAS_PERIPH_I2C diff --git a/boards/esp32-mh-et-live-minikit/Makefile.features b/boards/esp32-mh-et-live-minikit/Makefile.features index e5812c733ac26..b5c030fcfb012 100644 --- a/boards/esp32-mh-et-live-minikit/Makefile.features +++ b/boards/esp32-mh-et-live-minikit/Makefile.features @@ -10,4 +10,4 @@ FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_spi -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_pins diff --git a/boards/esp32-mh-et-live-minikit/include/arduino_board.h b/boards/esp32-mh-et-live-minikit/include/arduino_board.h deleted file mode 100644 index 685c48f9f496e..0000000000000 --- a/boards/esp32-mh-et-live-minikit/include/arduino_board.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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. - */ - -/** - * @ingroup boards_esp32_mh-et-live-minikit - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Gunar Schorcht - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_board_common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The on-board LED is connected to Arduino pin 3 on this board - */ -#define ARDUINO_LED (3) - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/esp32-mh-et-live-minikit/include/arduino_iomap.h b/boards/esp32-mh-et-live-minikit/include/arduino_iomap.h new file mode 100644 index 0000000000000..9073bff18d055 --- /dev/null +++ b/boards/esp32-mh-et-live-minikit/include/arduino_iomap.h @@ -0,0 +1,79 @@ +/* + * 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. + */ + +/** + * @ingroup boards_esp32_mh-et-live-minikit + * @{ + * + * @file + * @brief Mapping from MCU pins to Arduino pins + * + * @author Gunar Schorcht + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_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 GPIO3 /**< Arduino Uno pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO1 /**< Arduino Uno pin 1 (TxD) */ + +#define ARDUINO_PIN_2 GPIO32 /**< Arduino Uno pin 2 */ +#define ARDUINO_PIN_3 GPIO2 /**< Arduino Uno pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO27 /**< Arduino Uno pin 4 */ +#define ARDUINO_PIN_5 GPIO0 /**< Arduino Uno pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO4 /**< Arduino Uno pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO33 /**< Arduino Uno pin 7 */ +#define ARDUINO_PIN_8 GPIO25 /**< Arduino Uno pin 8 */ +#define ARDUINO_PIN_9 GPIO15 /**< Arduino Uno pin 9 (PWM) */ + +#define ARDUINO_PIN_10 GPIO5 /**< Arduino Uno pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO23 /**< Arduino Uno pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO19 /**< Arduino Uno pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO18 /**< Arduino Uno pin 13 (SCK) */ + +/* analog pins as digital pin: */ +#define ARDUINO_PIN_14 GPIO34 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_15 GPIO35 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_16 GPIO36 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_17 GPIO39 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_18 GPIO21 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO22 /**< Arduino Uno pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 /**< D19/A5 is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino Uno pin A5 (SCL) */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/esp32-mh-et-live-minikit/include/arduino_pinmap.h b/boards/esp32-mh-et-live-minikit/include/arduino_pinmap.h deleted file mode 100644 index 0473a2d846eae..0000000000000 --- a/boards/esp32-mh-et-live-minikit/include/arduino_pinmap.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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. - */ - -/** - * @ingroup boards_esp32_mh-et-live-minikit - * @{ - * - * @file - * @brief Mapping from MCU pins to Arduino pins - * - * @author Gunar Schorcht - */ - -#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 GPIO3 /**< Arduino Uno pin 0 (RxD) */ -#define ARDUINO_PIN_1 GPIO1 /**< Arduino Uno pin 1 (TxD) */ - -#define ARDUINO_PIN_2 GPIO32 /**< Arduino Uno pin 2 */ -#define ARDUINO_PIN_3 GPIO2 /**< Arduino Uno pin 3 (PWM) */ -#define ARDUINO_PIN_4 GPIO27 /**< Arduino Uno pin 4 */ -#define ARDUINO_PIN_5 GPIO0 /**< Arduino Uno pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO4 /**< Arduino Uno pin 6 (PWM) */ -#define ARDUINO_PIN_7 GPIO33 /**< Arduino Uno pin 7 */ -#define ARDUINO_PIN_8 GPIO25 /**< Arduino Uno pin 8 */ -#define ARDUINO_PIN_9 GPIO15 /**< Arduino Uno pin 9 (PWM) */ - -#define ARDUINO_PIN_10 GPIO5 /**< Arduino Uno pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO23 /**< Arduino Uno pin 11 (MOSI / PWM) */ -#define ARDUINO_PIN_12 GPIO19 /**< Arduino Uno pin 12 (MISO) */ -#define ARDUINO_PIN_13 GPIO18 /**< Arduino Uno pin 13 (SCK) */ - -#define ARDUINO_PIN_A0 GPIO34 /**< Arduino Uno pin A0 */ -#define ARDUINO_PIN_A1 GPIO35 /**< Arduino Uno pin A1 */ -#define ARDUINO_PIN_A2 GPIO36 /**< Arduino Uno pin A2 */ -#define ARDUINO_PIN_A3 GPIO39 /**< Arduino Uno pin A3 */ - -#define ARDUINO_PIN_A4 GPIO21 /**< Arduino Uno pin A4 (SDA) */ -#define ARDUINO_PIN_A5 GPIO22 /**< Arduino Uno pin A5 (SCL) */ -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_PINMAP_H */ -/** @} */ diff --git a/boards/esp32-olimex-evb/Kconfig b/boards/esp32-olimex-evb/Kconfig index 32232e3a7db7e..7b52efabd3f76 100644 --- a/boards/esp32-olimex-evb/Kconfig +++ b/boards/esp32-olimex-evb/Kconfig @@ -12,7 +12,7 @@ config BOARD_ESP32_OLIMEX_EVB default y select BOARD_COMMON_ESP32 select CPU_MODEL_ESP32_WROOM_32 - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_ESP_ETH select HAS_PERIPH_ADC if USEMODULE_OLIMEX_ESP32_GATEWAY select HAS_PERIPH_I2C diff --git a/boards/esp32-olimex-evb/Makefile.features b/boards/esp32-olimex-evb/Makefile.features index 8f565d45d4836..7db04be96b698 100644 --- a/boards/esp32-olimex-evb/Makefile.features +++ b/boards/esp32-olimex-evb/Makefile.features @@ -16,4 +16,4 @@ FEATURES_PROVIDED += esp_eth # Ethernet MAC (EMAC) FEATURES_PROVIDED += periph_can # CAN peripheral interface FEATURES_PROVIDED += periph_ir # IR peripheral interface -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_pins diff --git a/boards/esp32-olimex-evb/include/arduino_board.h b/boards/esp32-olimex-evb/include/arduino_board.h deleted file mode 100644 index 7c7a119ec351a..0000000000000 --- a/boards/esp32-olimex-evb/include/arduino_board.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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. - */ - -/** - * @ingroup boards_esp32_olimex-esp32-evb - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Gunar Schorcht - */ - -#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 */ -/** @} */ diff --git a/boards/esp32-olimex-evb/include/arduino_iomap.h b/boards/esp32-olimex-evb/include/arduino_iomap.h new file mode 100644 index 0000000000000..7a5ccc2cc72fb --- /dev/null +++ b/boards/esp32-olimex-evb/include/arduino_iomap.h @@ -0,0 +1,76 @@ +/* + * 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. + */ + +/** + * @ingroup boards_esp32_olimex-esp32-evb + * @{ + * + * @file + * @brief Mapping from MCU pins to Arduino pins + * + * @author Gunar Schorcht + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_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 GPIO3 /**< Arduino Uno pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO1 /**< Arduino Uno pin 1 (TxD) */ + +#define ARDUINO_PIN_2 GPIO32 /**< Arduino Uno pin 2 */ +#define ARDUINO_PIN_3 GPIO33 /**< Arduino Uno pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO4 /**< Arduino Uno pin 4 */ +#define ARDUINO_PIN_5 GPIO9 /**< Arduino Uno pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO10 /**< Arduino Uno pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO7 /**< Arduino Uno pin 7 */ +#define ARDUINO_PIN_8 GPIO8 /**< Arduino Uno pin 8 */ + +#define ARDUINO_PIN_10 GPIO17 /**< Arduino Uno pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO15 /**< Arduino Uno pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO2 /**< Arduino Uno pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO14 /**< Arduino Uno pin 13 (SCK) */ + +#define ARDUINO_PIN_14 GPIO34 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_15 GPIO35 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_16 GPIO36 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_17 GPIO39 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_18 GPIO13 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO16 /**< Arduino Uno pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 /**< D19 (A5) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#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 */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/esp32-olimex-evb/include/arduino_pinmap.h b/boards/esp32-olimex-evb/include/arduino_pinmap.h deleted file mode 100644 index 1a041304a9587..0000000000000 --- a/boards/esp32-olimex-evb/include/arduino_pinmap.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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. - */ - -/** - * @ingroup boards_esp32_olimex-esp32-evb - * @{ - * - * @file - * @brief Mapping from MCU pins to Arduino pins - * - * @author Gunar Schorcht - */ - -#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 GPIO3 /**< Arduino Uno pin 0 (RxD) */ -#define ARDUINO_PIN_1 GPIO1 /**< Arduino Uno pin 1 (TxD) */ - -#define ARDUINO_PIN_2 GPIO32 /**< Arduino Uno pin 2 */ -#define ARDUINO_PIN_3 GPIO33 /**< Arduino Uno pin 3 (PWM) */ -#define ARDUINO_PIN_4 GPIO4 /**< Arduino Uno pin 4 */ -#define ARDUINO_PIN_5 GPIO9 /**< Arduino Uno pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO10 /**< Arduino Uno pin 6 (PWM) */ -#define ARDUINO_PIN_7 GPIO7 /**< Arduino Uno pin 7 */ -#define ARDUINO_PIN_8 GPIO8 /**< Arduino Uno pin 8 */ -#define ARDUINO_PIN_9 GPIO_UNDEF /**< Arduino Uno pin 9 (PWM) */ - -#define ARDUINO_PIN_10 GPIO17 /**< Arduino Uno pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO15 /**< Arduino Uno pin 11 (MOSI / PWM) */ -#define ARDUINO_PIN_12 GPIO2 /**< Arduino Uno pin 12 (MISO) */ -#define ARDUINO_PIN_13 GPIO14 /**< Arduino Uno pin 13 (SCK) */ - -#define ARDUINO_PIN_A0 GPIO34 /**< Arduino Uno pin A0 */ -#define ARDUINO_PIN_A1 GPIO35 /**< Arduino Uno pin A1 */ -#define ARDUINO_PIN_A2 GPIO36 /**< Arduino Uno pin A2 */ -#define ARDUINO_PIN_A3 GPIO39 /**< Arduino Uno pin A3 */ - -#define ARDUINO_PIN_A4 GPIO13 /**< Arduino Uno pin A4 (SDA) */ -#define ARDUINO_PIN_A5 GPIO16 /**< Arduino Uno pin A5 (SCL) */ -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_PINMAP_H */ -/** @} */ diff --git a/boards/esp32-ttgo-t-beam/Kconfig b/boards/esp32-ttgo-t-beam/Kconfig index c79c109d8e924..c82b8d9a3446a 100644 --- a/boards/esp32-ttgo-t-beam/Kconfig +++ b/boards/esp32-ttgo-t-beam/Kconfig @@ -12,7 +12,7 @@ config BOARD_ESP32_TTGO_T_BEAM default y select BOARD_COMMON_ESP32 select CPU_MODEL_ESP32_D0WD - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_ESP_SPI_RAM select HAS_PERIPH_ADC select HAS_PERIPH_DAC diff --git a/boards/esp32-ttgo-t-beam/Makefile.features b/boards/esp32-ttgo-t-beam/Makefile.features index 6dd1d4b7e7abe..af35e4bf5db52 100644 --- a/boards/esp32-ttgo-t-beam/Makefile.features +++ b/boards/esp32-ttgo-t-beam/Makefile.features @@ -11,7 +11,7 @@ FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_uart -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_pins # unique features provided by the board FEATURES_PROVIDED += esp_spi_ram diff --git a/boards/esp32-ttgo-t-beam/include/arduino_board.h b/boards/esp32-ttgo-t-beam/include/arduino_board.h deleted file mode 100644 index 1d2173d3a5f9a..0000000000000 --- a/boards/esp32-ttgo-t-beam/include/arduino_board.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (C) 2019 Yegor Yefremov - * - * 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_esp32_ttgo-t-beam - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Yegor Yefremov - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_board_common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The on-board LED is connected to Arduino pin 3 on this board - */ -#ifndef MODULE_ESP32_TTGO_T_BEAM_V1_0 -#define ARDUINO_LED (3) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/esp32-ttgo-t-beam/include/arduino_iomap.h b/boards/esp32-ttgo-t-beam/include/arduino_iomap.h new file mode 100644 index 0000000000000..f3d051693c3ea --- /dev/null +++ b/boards/esp32-ttgo-t-beam/include/arduino_iomap.h @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2019 Yegor Yefremov + * + * 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_esp32_ttgo-t-beam + * @{ + * + * @file + * @brief Mapping from MCU pins to Arduino pins + * + * @author Yegor Yefremov + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_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 GPIO3 /**< Arduino Uno pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO1 /**< Arduino Uno pin 1 (TxD) */ +#define ARDUINO_PIN_2 GPIO0 /**< Arduino Uno pin 2 */ +#define ARDUINO_PIN_3 GPIO2 /**< Arduino Uno pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO4 /**< Arduino Uno pin 4 */ +#define ARDUINO_PIN_5 GPIO13 /**< Arduino Uno pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO15 /**< Arduino Uno pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO21 /**< Arduino Uno pin 7 */ +#define ARDUINO_PIN_8 GPIO22 /**< Arduino Uno pin 8 */ +#define ARDUINO_PIN_9 GPIO23 /**< Arduino Uno pin 9 (PWM) */ +#define ARDUINO_PIN_13 GPIO14 /**< Arduino Uno pin 13 (LED) */ +#define ARDUINO_PIN_14 GPIO25 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_15 GPIO32 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_16 GPIO33 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_17 GPIO35 /**< Arduino Uno pin A3 */ +#define ARDUINO_PIN_18 GPIO36 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO39 /**< Arduino Uno pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 /**< D19 (A5) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#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 */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/esp32-ttgo-t-beam/include/arduino_pinmap.h b/boards/esp32-ttgo-t-beam/include/arduino_pinmap.h deleted file mode 100644 index 53e5a1c0d327d..0000000000000 --- a/boards/esp32-ttgo-t-beam/include/arduino_pinmap.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) 2019 Yegor Yefremov - * - * 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_esp32_ttgo-t-beam - * @{ - * - * @file - * @brief Mapping from MCU pins to Arduino pins - * - * @author Yegor Yefremov - */ - -#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 GPIO3 /**< Arduino Uno pin 0 (RxD) */ -#define ARDUINO_PIN_1 GPIO1 /**< Arduino Uno pin 1 (TxD) */ -#define ARDUINO_PIN_2 GPIO0 /**< Arduino Uno pin 2 */ -#define ARDUINO_PIN_3 GPIO2 /**< Arduino Uno pin 3 (PWM) */ -#define ARDUINO_PIN_4 GPIO4 /**< Arduino Uno pin 4 */ -#define ARDUINO_PIN_5 GPIO13 /**< Arduino Uno pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO15 /**< Arduino Uno pin 6 (PWM) */ -#define ARDUINO_PIN_7 GPIO21 /**< Arduino Uno pin 7 */ -#define ARDUINO_PIN_8 GPIO22 /**< Arduino Uno pin 8 */ -#define ARDUINO_PIN_9 GPIO23 /**< Arduino Uno pin 9 (PWM) */ -#define ARDUINO_PIN_10 GPIO_UNDEF /**< Arduino Uno pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO_UNDEF /**< Arduino Uno pin 11 (MOSI / PWM) */ -#define ARDUINO_PIN_12 GPIO_UNDEF /**< Arduino Uno pin 12 (MISO) */ -#define ARDUINO_PIN_13 GPIO14 /**< Arduino Uno pin 13 (LED) */ -#define ARDUINO_PIN_A0 GPIO25 /**< Arduino Uno pin A0 */ -#define ARDUINO_PIN_A1 GPIO32 /**< Arduino Uno pin A1 */ -#define ARDUINO_PIN_A2 GPIO33 /**< Arduino Uno pin A2 */ -#define ARDUINO_PIN_A3 GPIO35 /**< Arduino Uno pin A3 */ -#define ARDUINO_PIN_A4 GPIO36 /**< Arduino Uno pin A4 (SDA) */ -#define ARDUINO_PIN_A5 GPIO39 /**< Arduino Uno pin A5 (SCL) */ -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_PINMAP_H */ -/** @} */ diff --git a/boards/esp32-wemos-lolin-d32-pro/Kconfig b/boards/esp32-wemos-lolin-d32-pro/Kconfig index cb3aca4f15ed3..e6196f6da4e85 100644 --- a/boards/esp32-wemos-lolin-d32-pro/Kconfig +++ b/boards/esp32-wemos-lolin-d32-pro/Kconfig @@ -12,7 +12,7 @@ config BOARD_ESP32_WEMOS_LOLIN_D32_PRO default y select BOARD_COMMON_ESP32 select CPU_MODEL_ESP32_WROVER - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_PERIPH_ADC select HAS_PERIPH_DAC select HAS_PERIPH_I2C diff --git a/boards/esp32-wemos-lolin-d32-pro/Makefile.features b/boards/esp32-wemos-lolin-d32-pro/Makefile.features index 650bddbd9a04f..e0d61206d8057 100644 --- a/boards/esp32-wemos-lolin-d32-pro/Makefile.features +++ b/boards/esp32-wemos-lolin-d32-pro/Makefile.features @@ -11,4 +11,4 @@ FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += sdcard_spi -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_pins diff --git a/boards/esp32-wemos-lolin-d32-pro/include/arduino_board.h b/boards/esp32-wemos-lolin-d32-pro/include/arduino_board.h deleted file mode 100644 index a1d9e0d5c8f35..0000000000000 --- a/boards/esp32-wemos-lolin-d32-pro/include/arduino_board.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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. - */ - -/** - * @ingroup boards_esp32_wemos-lolin-d32-pro - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Gunar Schorcht - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_board_common.h" - -#include "periph/gpio.h" -#include "periph/adc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The on-board LED is connected to Arduino pin 10 on this board - */ -#define ARDUINO_LED (10) - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/esp32-wemos-lolin-d32-pro/include/arduino_iomap.h b/boards/esp32-wemos-lolin-d32-pro/include/arduino_iomap.h new file mode 100644 index 0000000000000..caaf6a34029b9 --- /dev/null +++ b/boards/esp32-wemos-lolin-d32-pro/include/arduino_iomap.h @@ -0,0 +1,79 @@ +/* + * 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. + */ + +/** + * @ingroup boards_esp32_wemos-lolin-d32-pro + * @{ + * + * @file + * @brief Mapping from MCU pins to Arduino pins + * + * @author Gunar Schorcht + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_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 GPIO3 /**< Arduino Uno pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO1 /**< Arduino Uno pin 1 (TxD) */ + +#define ARDUINO_PIN_2 GPIO4 /**< Arduino Uno pin 2 */ +#define ARDUINO_PIN_3 GPIO0 /**< Arduino Uno pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO13 /**< Arduino Uno pin 4 */ +#define ARDUINO_PIN_5 GPIO2 /**< Arduino Uno pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO15 /**< Arduino Uno pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO25 /**< Arduino Uno pin 7 */ +#define ARDUINO_PIN_8 GPIO26 /**< Arduino Uno pin 8 */ +#define ARDUINO_PIN_9 GPIO32 /**< Arduino Uno pin 9 (PWM) */ + +#define ARDUINO_PIN_10 GPIO5 /**< Arduino Uno pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO23 /**< Arduino Uno pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO19 /**< Arduino Uno pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO18 /**< Arduino Uno pin 13 (SCK) */ + +/* analog pins as digital pin: */ +#define ARDUINO_PIN_14 GPIO36 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_15 GPIO39 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_16 GPIO34 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_17 GPIO35 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_18 GPIO21 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO22 /**< Arduino Uno pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 /**< D19 (A5) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino Uno pin A5 (SCL) */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/esp32-wemos-lolin-d32-pro/include/arduino_pinmap.h b/boards/esp32-wemos-lolin-d32-pro/include/arduino_pinmap.h deleted file mode 100644 index 1ad2e7d6d7257..0000000000000 --- a/boards/esp32-wemos-lolin-d32-pro/include/arduino_pinmap.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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. - */ - -/** - * @ingroup boards_esp32_wemos-lolin-d32-pro - * @{ - * - * @file - * @brief Mapping from MCU pins to Arduino pins - * - * @author Gunar Schorcht - */ - -#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 GPIO3 /**< Arduino Uno pin 0 (RxD) */ -#define ARDUINO_PIN_1 GPIO1 /**< Arduino Uno pin 1 (TxD) */ - -#define ARDUINO_PIN_2 GPIO4 /**< Arduino Uno pin 2 */ -#define ARDUINO_PIN_3 GPIO0 /**< Arduino Uno pin 3 (PWM) */ -#define ARDUINO_PIN_4 GPIO13 /**< Arduino Uno pin 4 */ -#define ARDUINO_PIN_5 GPIO2 /**< Arduino Uno pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO15 /**< Arduino Uno pin 6 (PWM) */ -#define ARDUINO_PIN_7 GPIO25 /**< Arduino Uno pin 7 */ -#define ARDUINO_PIN_8 GPIO26 /**< Arduino Uno pin 8 */ -#define ARDUINO_PIN_9 GPIO32 /**< Arduino Uno pin 9 (PWM) */ - -#define ARDUINO_PIN_10 GPIO5 /**< Arduino Uno pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO23 /**< Arduino Uno pin 11 (MOSI / PWM) */ -#define ARDUINO_PIN_12 GPIO19 /**< Arduino Uno pin 12 (MISO) */ -#define ARDUINO_PIN_13 GPIO18 /**< Arduino Uno pin 13 (SCK) */ - -#define ARDUINO_PIN_A0 GPIO36 /**< Arduino Uno pin A0 */ -#define ARDUINO_PIN_A1 GPIO39 /**< Arduino Uno pin A1 */ -#define ARDUINO_PIN_A2 GPIO34 /**< Arduino Uno pin A2 */ -#define ARDUINO_PIN_A3 GPIO35 /**< Arduino Uno pin A3 */ - -#define ARDUINO_PIN_A4 GPIO21 /**< Arduino Uno pin A4 (SDA) */ -#define ARDUINO_PIN_A5 GPIO22 /**< Arduino Uno pin A5 (SCL) */ -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_PINMAP_H */ -/** @} */ diff --git a/boards/esp32-wroom-32/Kconfig b/boards/esp32-wroom-32/Kconfig index c1f52a2b666bc..dbf682aceb235 100644 --- a/boards/esp32-wroom-32/Kconfig +++ b/boards/esp32-wroom-32/Kconfig @@ -12,7 +12,7 @@ config BOARD_ESP32_WROOM_32 default y select BOARD_COMMON_ESP32 select CPU_MODEL_ESP32_WROOM_32 - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_PERIPH_ADC select HAS_PERIPH_DAC select HAS_PERIPH_I2C diff --git a/boards/esp32-wroom-32/Makefile.features b/boards/esp32-wroom-32/Makefile.features index e5812c733ac26..b5c030fcfb012 100644 --- a/boards/esp32-wroom-32/Makefile.features +++ b/boards/esp32-wroom-32/Makefile.features @@ -10,4 +10,4 @@ FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_spi -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_pins diff --git a/boards/esp32-wroom-32/include/arduino_board.h b/boards/esp32-wroom-32/include/arduino_board.h deleted file mode 100644 index 8c0518e393c22..0000000000000 --- a/boards/esp32-wroom-32/include/arduino_board.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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. - */ - -/** - * @ingroup boards_esp32_wroom-32 - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Gunar Schorcht - */ - -#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 */ -/** @} */ diff --git a/boards/esp32-wroom-32/include/arduino_pinmap.h b/boards/esp32-wroom-32/include/arduino_iomap.h similarity index 59% rename from boards/esp32-wroom-32/include/arduino_pinmap.h rename to boards/esp32-wroom-32/include/arduino_iomap.h index 88f04e40dffb4..8c8253b2e6d72 100644 --- a/boards/esp32-wroom-32/include/arduino_pinmap.h +++ b/boards/esp32-wroom-32/include/arduino_iomap.h @@ -16,8 +16,8 @@ * @author Gunar Schorcht */ -#ifndef ARDUINO_PINMAP_H -#define ARDUINO_PINMAP_H +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H #include "periph/gpio.h" #include "periph/adc.h" @@ -47,18 +47,33 @@ extern "C" { #define ARDUINO_PIN_12 GPIO19 /**< Arduino Uno pin 12 (MISO) */ #define ARDUINO_PIN_13 GPIO18 /**< Arduino Uno pin 13 (SCK) */ -#define ARDUINO_PIN_A0 GPIO25 /**< Arduino Uno pin A0 */ -#define ARDUINO_PIN_A1 GPIO26 /**< Arduino Uno pin A1 */ -#define ARDUINO_PIN_A2 GPIO4 /**< Arduino Uno pin A2 */ -#define ARDUINO_PIN_A3 GPIO15 /**< Arduino Uno pin A3 */ +/* analog pins as digital pin: */ +#define ARDUINO_PIN_14 GPIO25 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_15 GPIO26 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_16 GPIO4 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_17 GPIO15 /**< Arduino Uno pin A3 */ -#define ARDUINO_PIN_A4 GPIO21 /**< Arduino Uno pin A4 (SDA) */ -#define ARDUINO_PIN_A5 GPIO22 /**< Arduino Uno pin A5 (SCL) */ +#define ARDUINO_PIN_18 GPIO21 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO22 /**< Arduino Uno pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 /**< D19 (A5) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino Uno pin A5 (SCL) */ /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/esp32-wrover-kit/Kconfig b/boards/esp32-wrover-kit/Kconfig index de160dff49147..e19495d7efe03 100644 --- a/boards/esp32-wrover-kit/Kconfig +++ b/boards/esp32-wrover-kit/Kconfig @@ -12,7 +12,7 @@ config BOARD_ESP32_WROVER_KIT default y select BOARD_COMMON_ESP32 select CPU_MODEL_ESP32_WROVER - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_ESP_RTC_TIMER_32K select HAS_ESP_JTAG select HAS_PERIPH_ADC diff --git a/boards/esp32-wrover-kit/Makefile.features b/boards/esp32-wrover-kit/Makefile.features index 2a0f9909d0219..c93ac66276b4b 100644 --- a/boards/esp32-wrover-kit/Makefile.features +++ b/boards/esp32-wrover-kit/Makefile.features @@ -14,4 +14,4 @@ FEATURES_PROVIDED += sdcard_spi FEATURES_PROVIDED += esp_rtc_timer_32k FEATURES_PROVIDED += esp_jtag -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_pins diff --git a/boards/esp32-wrover-kit/include/arduino_board.h b/boards/esp32-wrover-kit/include/arduino_board.h deleted file mode 100644 index bbca81e897149..0000000000000 --- a/boards/esp32-wrover-kit/include/arduino_board.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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. - */ - -/** - * @ingroup boards_esp32_esp-wrover-kit - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Gunar Schorcht - */ - -#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 */ -/** @} */ diff --git a/boards/esp32-wrover-kit/include/arduino_iomap.h b/boards/esp32-wrover-kit/include/arduino_iomap.h new file mode 100644 index 0000000000000..230c1ea077e4c --- /dev/null +++ b/boards/esp32-wrover-kit/include/arduino_iomap.h @@ -0,0 +1,77 @@ +/* + * 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. + */ + +/** + * @ingroup boards_esp32_esp-wrover-kit + * @{ + * + * @file + * @brief Mapping from MCU pins to Arduino pins + * + * @author Gunar Schorcht + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_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 GPIO3 /**< Arduino Uno pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO1 /**< Arduino Uno pin 1 (TxD) */ + +#define ARDUINO_PIN_2 GPIO19 /**< Arduino Uno pin 2 */ +#define ARDUINO_PIN_3 GPIO0 /**< Arduino Uno pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO22 /**< Arduino Uno pin 4 */ +#define ARDUINO_PIN_5 GPIO4 /**< Arduino Uno pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO23 /**< Arduino Uno pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO25 /**< Arduino Uno pin 7 */ +#define ARDUINO_PIN_8 GPIO9 /**< Arduino Uno pin 8 */ +#define ARDUINO_PIN_9 GPIO10 /**< Arduino Uno pin 9 (PWM) */ + +#define ARDUINO_PIN_10 GPIO13 /**< Arduino Uno pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO15 /**< Arduino Uno pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO2 /**< Arduino Uno pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO14 /**< Arduino Uno pin 13 (SCK) */ + +#define ARDUINO_PIN_14 GPIO34 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_15 GPIO35 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_16 GPIO36 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_17 GPIO39 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_18 GPIO26 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO27 /**< Arduino Uno pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 /**< D19 (A5) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#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 */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/esp32-wrover-kit/include/arduino_pinmap.h b/boards/esp32-wrover-kit/include/arduino_pinmap.h deleted file mode 100644 index 5d00d007f2b56..0000000000000 --- a/boards/esp32-wrover-kit/include/arduino_pinmap.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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. - */ - -/** - * @ingroup boards_esp32_esp-wrover-kit - * @{ - * - * @file - * @brief Mapping from MCU pins to Arduino pins - * - * @author Gunar Schorcht - */ - -#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 GPIO3 /**< Arduino Uno pin 0 (RxD) */ -#define ARDUINO_PIN_1 GPIO1 /**< Arduino Uno pin 1 (TxD) */ - -#define ARDUINO_PIN_2 GPIO19 /**< Arduino Uno pin 2 */ -#define ARDUINO_PIN_3 GPIO0 /**< Arduino Uno pin 3 (PWM) */ -#define ARDUINO_PIN_4 GPIO22 /**< Arduino Uno pin 4 */ -#define ARDUINO_PIN_5 GPIO4 /**< Arduino Uno pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO23 /**< Arduino Uno pin 6 (PWM) */ -#define ARDUINO_PIN_7 GPIO25 /**< Arduino Uno pin 7 */ -#define ARDUINO_PIN_8 GPIO9 /**< Arduino Uno pin 8 */ -#define ARDUINO_PIN_9 GPIO10 /**< Arduino Uno pin 9 (PWM) */ - -#define ARDUINO_PIN_10 GPIO13 /**< Arduino Uno pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO15 /**< Arduino Uno pin 11 (MOSI / PWM) */ -#define ARDUINO_PIN_12 GPIO2 /**< Arduino Uno pin 12 (MISO) */ -#define ARDUINO_PIN_13 GPIO14 /**< Arduino Uno pin 13 (SCK) */ - -#define ARDUINO_PIN_A0 GPIO34 /**< Arduino Uno pin A0 */ -#define ARDUINO_PIN_A1 GPIO35 /**< Arduino Uno pin A1 */ -#define ARDUINO_PIN_A2 GPIO36 /**< Arduino Uno pin A2 */ -#define ARDUINO_PIN_A3 GPIO39 /**< Arduino Uno pin A3 */ - -#define ARDUINO_PIN_A4 GPIO26 /**< Arduino Uno pin A4 (SDA) */ -#define ARDUINO_PIN_A5 GPIO27 /**< Arduino Uno pin A5 (SCL) */ -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_PINMAP_H */ -/** @} */ diff --git a/boards/esp32c3-devkit/Kconfig b/boards/esp32c3-devkit/Kconfig index 514d3b6703dc3..33eb7002a8257 100644 --- a/boards/esp32c3-devkit/Kconfig +++ b/boards/esp32c3-devkit/Kconfig @@ -13,7 +13,7 @@ config BOARD_ESP32C3_DEVKIT default y select BOARD_COMMON_ESP32C3 select CPU_MODEL_ESP32C3_MINI_1X - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_ESP_JTAG select HAS_PERIPH_ADC select HAS_PERIPH_I2C diff --git a/boards/esp32c3-devkit/Makefile.features b/boards/esp32c3-devkit/Makefile.features index fcd5860031daa..b705976d68333 100644 --- a/boards/esp32c3-devkit/Makefile.features +++ b/boards/esp32c3-devkit/Makefile.features @@ -12,4 +12,4 @@ FEATURES_PROVIDED += periph_spi # unique features provided by the board FEATURES_PROVIDED += esp_jtag -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_pins diff --git a/boards/esp32c3-devkit/include/arduino_board.h b/boards/esp32c3-devkit/include/arduino_board.h deleted file mode 100644 index 389c486db3906..0000000000000 --- a/boards/esp32c3-devkit/include/arduino_board.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 - */ - -#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 */ -/** @} */ diff --git a/boards/esp32c3-devkit/include/arduino_iomap.h b/boards/esp32c3-devkit/include/arduino_iomap.h new file mode 100644 index 0000000000000..12145adb019d5 --- /dev/null +++ b/boards/esp32c3-devkit/include/arduino_iomap.h @@ -0,0 +1,79 @@ +/* + * 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 + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_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) */ +#endif +#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_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) */ + +/* analog pins as digital pins: */ +#define ARDUINO_PIN_14 GPIO0 /**< Arduino Uno pin A0 */ +#if !defined(MODULE_ESP_RTC_TIMER_32K) +#define ARDUINO_PIN_15 GPIO1 /**< Arduino Uno pin A1 */ +#endif +#define ARDUINO_PIN_16 GPIO2 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_17 GPIO3 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_18 GPIO5 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO4 /**< Arduino Uno pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 /**< D19 (A5) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino Uno pin A5 (SCL) */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/esp32c3-devkit/include/arduino_pinmap.h b/boards/esp32c3-devkit/include/arduino_pinmap.h deleted file mode 100644 index 45277cddfabe0..0000000000000 --- a/boards/esp32c3-devkit/include/arduino_pinmap.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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 - */ - -#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 */ -/** @} */ diff --git a/boards/esp32c3-wemos-mini/Kconfig b/boards/esp32c3-wemos-mini/Kconfig index aedd829f561f6..4ae400788653a 100644 --- a/boards/esp32c3-wemos-mini/Kconfig +++ b/boards/esp32c3-wemos-mini/Kconfig @@ -13,7 +13,7 @@ config BOARD_ESP32C3_WEMOS_MINI default y select BOARD_COMMON_ESP32C3 select CPU_MODEL_ESP32C3_FH4 - # select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_ESP_JTAG select HAS_PERIPH_ADC select HAS_PERIPH_I2C diff --git a/boards/esp32c3-wemos-mini/Makefile.features b/boards/esp32c3-wemos-mini/Makefile.features index 69bfcf330bf3d..c857e9e2cdd60 100644 --- a/boards/esp32c3-wemos-mini/Makefile.features +++ b/boards/esp32c3-wemos-mini/Makefile.features @@ -12,4 +12,4 @@ FEATURES_PROVIDED += periph_spi # unique features provided by the board FEATURES_PROVIDED += esp_jtag -#FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_pins diff --git a/boards/esp32c3-wemos-mini/include/arduino_board.h b/boards/esp32c3-wemos-mini/include/arduino_board.h deleted file mode 100644 index 5e5e5f6fe03fa..0000000000000 --- a/boards/esp32c3-wemos-mini/include/arduino_board.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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_wemos_mini - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Gunar Schorcht - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_board_common.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The on-board LED (not available on board version 2.1.0) - */ -#ifdef MODULE_ESP32C3_WEMOS_MINI_V1_0_0 -#define ARDUINO_LED (5) -#else /* MODULE_ESP32C3_WEMOS_MINI_V2_1_0 */ -#define ARDUINO_LED (0) -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/esp32c3-wemos-mini/include/arduino_iomap.h b/boards/esp32c3-wemos-mini/include/arduino_iomap.h new file mode 100644 index 0000000000000..ab30b971be049 --- /dev/null +++ b/boards/esp32c3-wemos-mini/include/arduino_iomap.h @@ -0,0 +1,86 @@ +/* + * 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_wemos_mini + * @{ + * + * @file + * @brief Mapping from MCU pins to Arduino pins + * + * @author Gunar Schorcht + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_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) */ +#define ARDUINO_PIN_2 GPIO9 /**< Arduino Uno pin 2 */ +#define ARDUINO_PIN_3 GPIO6 /**< Arduino Uno pin 3 (PWM) */ + +#ifdef MODULE_ESP32C3_WEMOS_MINI_V1_0_0 +# define ARDUINO_PIN_5 GPIO7 /**< Arduino Uno pin 5 (PWM) */ +# define ARDUINO_PIN_6 GPIO1 /**< Arduino Uno pin 6 (PWM) */ +# define ARDUINO_PIN_7 GPIO0 /**< Arduino Uno pin 7 */ +#else /* MODULE_ESP32C3_WEMOS_MINI_V2_1_0 */ +# define ARDUINO_PIN_6 GPIO2 /**< Arduino Uno pin 6 (PWM) */ +# define ARDUINO_PIN_7 GPIO3 /**< Arduino Uno pin 7 */ +#endif + +#ifdef MODULE_ESP32C3_WEMOS_MINI_V1_0_0 +# define ARDUINO_PIN_10 GPIO5 /**< Arduino Uno pin 10 (CS0 / PWM) */ +# define ARDUINO_PIN_11 GPIO4 /**< Arduino Uno pin 11 (MOSI / PWM) */ +# define ARDUINO_PIN_12 GPIO3 /**< Arduino Uno pin 12 (MISO) */ +# define ARDUINO_PIN_13 GPIO2 /**< Arduino Uno pin 13 (SCK) */ +#else /* MODULE_ESP32C3_WEMOS_MINI_V2_1_0 */ +# define ARDUINO_PIN_10 GPIO5 /**< Arduino Uno pin 10 (CS0 / PWM) */ +# define ARDUINO_PIN_11 GPIO4 /**< Arduino Uno pin 11 (MOSI / PWM) */ +# define ARDUINO_PIN_12 GPIO0 /**< Arduino Uno pin 12 (MISO) */ +# define ARDUINO_PIN_13 GPIO1 /**< Arduino Uno pin 13 (SCK) */ +#endif + +/* analog pins as digital pin: */ +#define ARDUINO_PIN_14 GPIO0 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_15 GPIO1 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_16 GPIO2 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_17 GPIO3 /**< Arduino Uno pin A3 */ +#define ARDUINO_PIN_18 GPIO4 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO5 /**< Arduino Uno pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 /**< D19 (A5) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#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 */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/esp32c3-wemos-mini/include/arduino_pinmap.h b/boards/esp32c3-wemos-mini/include/arduino_pinmap.h deleted file mode 100644 index ff3fc69967f62..0000000000000 --- a/boards/esp32c3-wemos-mini/include/arduino_pinmap.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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_wemos_mini - * @{ - * - * @file - * @brief Mapping from MCU pins to Arduino pins - * - * @author Gunar Schorcht - */ - -#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) */ -#define ARDUINO_PIN_2 GPIO9 /**< Arduino Uno pin 2 */ -#define ARDUINO_PIN_3 GPIO6 /**< Arduino Uno pin 3 (PWM) */ -#define ARDUINO_PIN_4 GPIO_UNDEF /**< Arduino Uno pin 4 */ - -#ifdef MODULE_ESP32C3_WEMOS_MINI_V1_0_0 -#define ARDUINO_PIN_5 GPIO7 /**< Arduino Uno pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO1 /**< Arduino Uno pin 6 (PWM) */ -#define ARDUINO_PIN_7 GPIO0 /**< Arduino Uno pin 7 */ -#else /* MODULE_ESP32C3_WEMOS_MINI_V2_1_0 */ -#define ARDUINO_PIN_5 GPIO_UNDEF /**< Arduino Uno pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO2 /**< Arduino Uno pin 6 (PWM) */ -#define ARDUINO_PIN_7 GPIO3 /**< Arduino Uno pin 7 */ -#endif - -#define ARDUINO_PIN_8 GPIO_UNDEF /**< Arduino Uno pin 8 */ -#define ARDUINO_PIN_9 GPIO_UNDEF /**< Arduino Uno pin 9 (PWM) */ - -#ifdef MODULE_ESP32C3_WEMOS_MINI_V1_0_0 -#define ARDUINO_PIN_10 GPIO5 /**< Arduino Uno pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO4 /**< Arduino Uno pin 11 (MOSI / PWM) */ -#define ARDUINO_PIN_12 GPIO3 /**< Arduino Uno pin 12 (MISO) */ -#define ARDUINO_PIN_13 GPIO2 /**< Arduino Uno pin 13 (SCK) */ -#else /* MODULE_ESP32C3_WEMOS_MINI_V2_1_0 */ -#define ARDUINO_PIN_10 GPIO5 /**< Arduino Uno pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO4 /**< Arduino Uno pin 11 (MOSI / PWM) */ -#define ARDUINO_PIN_12 GPIO0 /**< Arduino Uno pin 12 (MISO) */ -#define ARDUINO_PIN_13 GPIO1 /**< Arduino Uno pin 13 (SCK) */ -#endif - -#define ARDUINO_PIN_A0 GPIO0 /**< Arduino Uno pin A0 */ -#define ARDUINO_PIN_A1 GPIO1 /**< Arduino Uno pin A1 */ -#define ARDUINO_PIN_A2 GPIO2 /**< Arduino Uno pin A2 */ -#define ARDUINO_PIN_A3 GPIO3 /**< Arduino Uno pin A3 */ -#define ARDUINO_PIN_A4 GPIO4 /**< Arduino Uno pin A4 (SDA) */ -#define ARDUINO_PIN_A5 GPIO5 /**< Arduino Uno pin A5 (SCL) */ -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_PINMAP_H */ -/** @} */ diff --git a/boards/esp32s2-devkit/Kconfig b/boards/esp32s2-devkit/Kconfig index c51b29253b081..f8d28211e7048 100644 --- a/boards/esp32s2-devkit/Kconfig +++ b/boards/esp32s2-devkit/Kconfig @@ -24,7 +24,7 @@ config BOARD_ESP32S2_DEVKIT select CPU_MODEL_ESP32S2_WROOM if BOARD_VERSION_ESP32S2_SAOLA_1MI select CPU_MODEL_ESP32S2_WROVER_N4R2 if BOARD_VERSION_ESP32S2_SAOLA_1R select CPU_MODEL_ESP32S2_WROVER_N4R2 if BOARD_VERSION_ESP32S2_SAOLA_1RI - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_PERIPH_ADC select HAS_PERIPH_DAC select HAS_PERIPH_I2C diff --git a/boards/esp32s2-devkit/Makefile.features b/boards/esp32s2-devkit/Makefile.features index cb42fd74eed1f..d04a85b206df8 100644 --- a/boards/esp32s2-devkit/Makefile.features +++ b/boards/esp32s2-devkit/Makefile.features @@ -39,7 +39,7 @@ FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_spi -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_pins ifneq (,$(filter esp32s2-devkitc-%,$(BOARD_VERSION))) FEATURES_PROVIDED += periph_usbdev diff --git a/boards/esp32s2-devkit/include/arduino_board.h b/boards/esp32s2-devkit/include/arduino_board.h deleted file mode 100644 index 13bd88688a3ea..0000000000000 --- a/boards/esp32s2-devkit/include/arduino_board.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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_esp32s2_devkit - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Gunar Schorcht - */ - -#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 */ -/** @} */ diff --git a/boards/esp32s2-devkit/include/arduino_iomap.h b/boards/esp32s2-devkit/include/arduino_iomap.h new file mode 100644 index 0000000000000..82ec94c7261e2 --- /dev/null +++ b/boards/esp32s2-devkit/include/arduino_iomap.h @@ -0,0 +1,78 @@ +/* + * 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_esp32s2_devkit + * @{ + * + * @file + * @brief Mapping from MCU pins to Arduino pins + * + * @author Gunar Schorcht + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_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 GPIO44 /**< Arduino Uno pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO43 /**< Arduino Uno pin 1 (TxD) */ +#define ARDUINO_PIN_2 GPIO0 /**< Arduino Uno pin 2 */ +#define ARDUINO_PIN_3 GPIO10 /**< Arduino Uno pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO3 /**< Arduino Uno pin 4 */ +#define ARDUINO_PIN_5 GPIO11 /**< Arduino Uno pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO12 /**< Arduino Uno pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO6 /**< Arduino Uno pin 7 */ +#define ARDUINO_PIN_8 GPIO7 /**< Arduino Uno pin 8 */ +#define ARDUINO_PIN_9 GPIO13 /**< Arduino Uno pin 9 (PWM) */ + +#define ARDUINO_PIN_10 GPIO38 /**< Arduino Uno pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO35 /**< Arduino Uno pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO37 /**< Arduino Uno pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO36 /**< Arduino Uno pin 13 (SCK) */ + +/* analog pins as digital pin */ +#define ARDUINO_PIN_14 GPIO1 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_15 GPIO2 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_16 GPIO4 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_17 GPIO5 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_18 GPIO8 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO9 /**< Arduino Uno pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 /**< D19 (A5) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino Uno pin A5 (SCL) */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/esp32s2-devkit/include/arduino_pinmap.h b/boards/esp32s2-devkit/include/arduino_pinmap.h deleted file mode 100644 index f39513e016429..0000000000000 --- a/boards/esp32s2-devkit/include/arduino_pinmap.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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_esp32s2_devkit - * @{ - * - * @file - * @brief Mapping from MCU pins to Arduino pins - * - * @author Gunar Schorcht - */ - -#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 GPIO44 /**< Arduino Uno pin 0 (RxD) */ -#define ARDUINO_PIN_1 GPIO43 /**< Arduino Uno pin 1 (TxD) */ -#define ARDUINO_PIN_2 GPIO0 /**< Arduino Uno pin 2 */ -#define ARDUINO_PIN_3 GPIO10 /**< Arduino Uno pin 3 (PWM) */ -#define ARDUINO_PIN_4 GPIO3 /**< Arduino Uno pin 4 */ -#define ARDUINO_PIN_5 GPIO11 /**< Arduino Uno pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO12 /**< Arduino Uno pin 6 (PWM) */ -#define ARDUINO_PIN_7 GPIO6 /**< Arduino Uno pin 7 */ -#define ARDUINO_PIN_8 GPIO7 /**< Arduino Uno pin 8 */ -#define ARDUINO_PIN_9 GPIO13 /**< Arduino Uno pin 9 (PWM) */ - -#define ARDUINO_PIN_10 GPIO38 /**< Arduino Uno pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO35 /**< Arduino Uno pin 11 (MOSI / PWM) */ -#define ARDUINO_PIN_12 GPIO37 /**< Arduino Uno pin 12 (MISO) */ -#define ARDUINO_PIN_13 GPIO36 /**< Arduino Uno pin 13 (SCK) */ - -#define ARDUINO_PIN_A0 GPIO1 /**< Arduino Uno pin A0 */ -#define ARDUINO_PIN_A1 GPIO2 /**< Arduino Uno pin A1 */ -#define ARDUINO_PIN_A2 GPIO4 /**< Arduino Uno pin A2 */ -#define ARDUINO_PIN_A3 GPIO5 /**< Arduino Uno pin A3 */ - -#define ARDUINO_PIN_A4 GPIO8 /**< Arduino Uno pin A4 (SDA) */ -#define ARDUINO_PIN_A5 GPIO9 /**< Arduino Uno pin A5 (SCL) */ -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_PINMAP_H */ -/** @} */ diff --git a/boards/esp32s2-lilygo-ttgo-t8/Kconfig b/boards/esp32s2-lilygo-ttgo-t8/Kconfig index e4c820fa4998f..f62d0d80a942e 100644 --- a/boards/esp32s2-lilygo-ttgo-t8/Kconfig +++ b/boards/esp32s2-lilygo-ttgo-t8/Kconfig @@ -13,7 +13,7 @@ config BOARD_ESP32S2_LILYGO_TTGO_T8 default y select BOARD_COMMON_ESP32S2 select CPU_MODEL_ESP32S2 - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_ESP_RTC_TIMER_32K if ESP32S2_LILYGO_TTGO_T8_32K_XTAL select HAS_ESP_SPI_RAM select HAS_HIGHLEVEL_STDIO if ESP32S2_LILYGO_TTGO_T8_USB diff --git a/boards/esp32s2-lilygo-ttgo-t8/Makefile.features b/boards/esp32s2-lilygo-ttgo-t8/Makefile.features index 2a9342802bbbf..024e2119d7e26 100644 --- a/boards/esp32s2-lilygo-ttgo-t8/Makefile.features +++ b/boards/esp32s2-lilygo-ttgo-t8/Makefile.features @@ -14,7 +14,7 @@ FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_usbdev # other features provided by the board -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_pins FEATURES_PROVIDED += esp_rtc_timer_32k FEATURES_PROVIDED += sdcard_spi FEATURES_PROVIDED += tinyusb_device diff --git a/boards/esp32s2-lilygo-ttgo-t8/include/arduino_board.h b/boards/esp32s2-lilygo-ttgo-t8/include/arduino_board.h deleted file mode 100644 index 0fcca86b5f79a..0000000000000 --- a/boards/esp32s2-lilygo-ttgo-t8/include/arduino_board.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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_esp32s2_lilygo_ttgo_t8 - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Gunar Schorcht - */ - -#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 */ -/** @} */ diff --git a/boards/esp32s2-lilygo-ttgo-t8/include/arduino_iomap.h b/boards/esp32s2-lilygo-ttgo-t8/include/arduino_iomap.h new file mode 100644 index 0000000000000..419067c2b999d --- /dev/null +++ b/boards/esp32s2-lilygo-ttgo-t8/include/arduino_iomap.h @@ -0,0 +1,78 @@ +/* + * 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_esp32s2_lilygo_ttgo_t8 + * @{ + * + * @file + * @brief Mapping from MCU pins to Arduino pins + * + * @author Gunar Schorcht + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_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 GPIO44 /**< Arduino Uno pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO43 /**< Arduino Uno pin 1 (TxD) */ +#define ARDUINO_PIN_2 GPIO21 /**< Arduino Uno pin 2 */ +#define ARDUINO_PIN_3 GPIO39 /**< Arduino Uno pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO21 /**< Arduino Uno pin 4 */ +#define ARDUINO_PIN_5 GPIO40 /**< Arduino Uno pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO41 /**< Arduino Uno pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO17 /**< Arduino Uno pin 7 */ +#define ARDUINO_PIN_8 GPIO18 /**< Arduino Uno pin 8 */ +#define ARDUINO_PIN_9 GPIO42 /**< Arduino Uno pin 9 (PWM) */ + +#define ARDUINO_PIN_10 GPIO38 /**< Arduino Uno pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO35 /**< Arduino Uno pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO37 /**< Arduino Uno pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO36 /**< Arduino Uno pin 13 (SCK) */ + +/* analog pins as digital pin: */ +#define ARDUINO_PIN_14 GPIO1 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_15 GPIO2 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_16 GPIO4 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_17 GPIO5 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_18 GPIO7 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO8 /**< Arduino Uno pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 /**< D19/A5 is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino Uno pin A5 (SCL) */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/esp32s2-lilygo-ttgo-t8/include/arduino_pinmap.h b/boards/esp32s2-lilygo-ttgo-t8/include/arduino_pinmap.h deleted file mode 100644 index f1624c5689b92..0000000000000 --- a/boards/esp32s2-lilygo-ttgo-t8/include/arduino_pinmap.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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_esp32s2_lilygo_ttgo_t8 - * @{ - * - * @file - * @brief Mapping from MCU pins to Arduino pins - * - * @author Gunar Schorcht - */ - -#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 GPIO44 /**< Arduino Uno pin 0 (RxD) */ -#define ARDUINO_PIN_1 GPIO43 /**< Arduino Uno pin 1 (TxD) */ -#define ARDUINO_PIN_2 GPIO21 /**< Arduino Uno pin 2 */ -#define ARDUINO_PIN_3 GPIO39 /**< Arduino Uno pin 3 (PWM) */ -#define ARDUINO_PIN_4 GPIO21 /**< Arduino Uno pin 4 */ -#define ARDUINO_PIN_5 GPIO40 /**< Arduino Uno pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO41 /**< Arduino Uno pin 6 (PWM) */ -#define ARDUINO_PIN_7 GPIO17 /**< Arduino Uno pin 7 */ -#define ARDUINO_PIN_8 GPIO18 /**< Arduino Uno pin 8 */ -#define ARDUINO_PIN_9 GPIO42 /**< Arduino Uno pin 9 (PWM) */ - -#define ARDUINO_PIN_10 GPIO38 /**< Arduino Uno pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO35 /**< Arduino Uno pin 11 (MOSI / PWM) */ -#define ARDUINO_PIN_12 GPIO37 /**< Arduino Uno pin 12 (MISO) */ -#define ARDUINO_PIN_13 GPIO36 /**< Arduino Uno pin 13 (SCK) */ - -#define ARDUINO_PIN_A0 GPIO1 /**< Arduino Uno pin A0 */ -#define ARDUINO_PIN_A1 GPIO2 /**< Arduino Uno pin A1 */ -#define ARDUINO_PIN_A2 GPIO4 /**< Arduino Uno pin A2 */ -#define ARDUINO_PIN_A3 GPIO5 /**< Arduino Uno pin A3 */ - -#define ARDUINO_PIN_A4 GPIO7 /**< Arduino Uno pin A4 (SDA) */ -#define ARDUINO_PIN_A5 GPIO8 /**< Arduino Uno pin A5 (SCL) */ -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_PINMAP_H */ -/** @} */ diff --git a/boards/esp32s3-devkit/Kconfig b/boards/esp32s3-devkit/Kconfig index 5f1f8f2787691..f13f62c98045c 100644 --- a/boards/esp32s3-devkit/Kconfig +++ b/boards/esp32s3-devkit/Kconfig @@ -37,7 +37,7 @@ config BOARD_ESP32S3_DEVKIT select CPU_MODEL_ESP32S3_WROOM_1X_N8R8 if BOARD_VERSION_ESP32S3_DEVKITC_1U_N8R8 select CPU_MODEL_ESP32S3_MINI_1X_N8 if BOARD_VERSION_ESP32S3_DEVKITM_1_N8 select CPU_MODEL_ESP32S3_MINI_1X_N8 if BOARD_VERSION_ESP32S3_DEVKITM_1U_N8 - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_ESP_JTAG select HAS_PERIPH_ADC select HAS_PERIPH_I2C diff --git a/boards/esp32s3-devkit/Makefile.features b/boards/esp32s3-devkit/Makefile.features index e009433f58bd5..ada35c5457fb0 100644 --- a/boards/esp32s3-devkit/Makefile.features +++ b/boards/esp32s3-devkit/Makefile.features @@ -37,6 +37,6 @@ FEATURES_PROVIDED += periph_spi # unique features provided by the board FEATURES_PROVIDED += esp_jtag -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_pins FEATURES_PROVIDED += periph_usbdev FEATURES_PROVIDED += tinyusb_device diff --git a/boards/esp32s3-devkit/include/arduino_board.h b/boards/esp32s3-devkit/include/arduino_board.h deleted file mode 100644 index c666ee85d278e..0000000000000 --- a/boards/esp32s3-devkit/include/arduino_board.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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_esp32s3_devkit - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Gunar Schorcht - */ - -#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 */ -/** @} */ diff --git a/boards/esp32s3-devkit/include/arduino_iomap.h b/boards/esp32s3-devkit/include/arduino_iomap.h new file mode 100644 index 0000000000000..5934f4ace1aa9 --- /dev/null +++ b/boards/esp32s3-devkit/include/arduino_iomap.h @@ -0,0 +1,77 @@ +/* + * 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_esp32s3_devkit + * @{ + * + * @file + * @brief Mapping from MCU pins to Arduino pins + * + * @author Gunar Schorcht + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_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 GPIO44 /**< Arduino Uno pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO43 /**< Arduino Uno pin 1 (TxD) */ +#define ARDUINO_PIN_2 GPIO0 /**< Arduino Uno pin 2 */ +#define ARDUINO_PIN_3 GPIO14 /**< Arduino Uno pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO3 /**< Arduino Uno pin 4 */ +#define ARDUINO_PIN_5 GPIO17 /**< Arduino Uno pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO18 /**< Arduino Uno pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO6 /**< Arduino Uno pin 7 */ +#define ARDUINO_PIN_8 GPIO7 /**< Arduino Uno pin 8 */ +#define ARDUINO_PIN_9 GPIO21 /**< Arduino Uno pin 9 (PWM) */ + +#define ARDUINO_PIN_10 GPIO10 /**< Arduino Uno pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO11 /**< Arduino Uno pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO13 /**< Arduino Uno pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO12 /**< Arduino Uno pin 13 (SCK) */ + +#define ARDUINO_PIN_14 GPIO1 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_15 GPIO2 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_16 GPIO4 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_17 GPIO5 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_18 GPIO8 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO9 /**< Arduino Uno pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 /**< D19 is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino Uno pin A5 (SCL) */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/esp32s3-devkit/include/arduino_pinmap.h b/boards/esp32s3-devkit/include/arduino_pinmap.h deleted file mode 100644 index 45fdd9f28f507..0000000000000 --- a/boards/esp32s3-devkit/include/arduino_pinmap.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * 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_esp32s3_devkit - * @{ - * - * @file - * @brief Mapping from MCU pins to Arduino pins - * - * @author Gunar Schorcht - */ - -#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 GPIO44 /**< Arduino Uno pin 0 (RxD) */ -#define ARDUINO_PIN_1 GPIO43 /**< Arduino Uno pin 1 (TxD) */ -#define ARDUINO_PIN_2 GPIO0 /**< Arduino Uno pin 2 */ -#define ARDUINO_PIN_3 GPIO14 /**< Arduino Uno pin 3 (PWM) */ -#define ARDUINO_PIN_4 GPIO3 /**< Arduino Uno pin 4 */ -#define ARDUINO_PIN_5 GPIO17 /**< Arduino Uno pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO18 /**< Arduino Uno pin 6 (PWM) */ -#define ARDUINO_PIN_7 GPIO6 /**< Arduino Uno pin 7 */ -#define ARDUINO_PIN_8 GPIO7 /**< Arduino Uno pin 8 */ -#define ARDUINO_PIN_9 GPIO21 /**< Arduino Uno pin 9 (PWM) */ - -#define ARDUINO_PIN_10 GPIO10 /**< Arduino Uno pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO11 /**< Arduino Uno pin 11 (MOSI / PWM) */ -#define ARDUINO_PIN_12 GPIO13 /**< Arduino Uno pin 12 (MISO) */ -#define ARDUINO_PIN_13 GPIO12 /**< Arduino Uno pin 13 (SCK) */ - -#define ARDUINO_PIN_A0 GPIO1 /**< Arduino Uno pin A0 */ -#define ARDUINO_PIN_A1 GPIO2 /**< Arduino Uno pin A1 */ -#define ARDUINO_PIN_A2 GPIO4 /**< Arduino Uno pin A2 */ -#define ARDUINO_PIN_A3 GPIO5 /**< Arduino Uno pin A3 */ - -#define ARDUINO_PIN_A4 GPIO8 /**< Arduino Uno pin A4 (SDA) */ -#define ARDUINO_PIN_A5 GPIO9 /**< Arduino Uno pin A5 (SCL) */ -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_PINMAP_H */ -/** @} */ diff --git a/boards/esp32s3-pros3/Kconfig b/boards/esp32s3-pros3/Kconfig index 85021934cfa3c..e779ab0e6a082 100644 --- a/boards/esp32s3-pros3/Kconfig +++ b/boards/esp32s3-pros3/Kconfig @@ -13,7 +13,7 @@ config BOARD_ESP32S3_PROS3 default y select BOARD_COMMON_ESP32S3 select CPU_MODEL_ESP32S3 - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_ESP_JTAG select HAS_ESP_SPI_RAM select HAS_HIGHLEVEL_STDIO diff --git a/boards/esp32s3-pros3/Makefile.features b/boards/esp32s3-pros3/Makefile.features index b3764b1939331..ec6ebe9830378 100644 --- a/boards/esp32s3-pros3/Makefile.features +++ b/boards/esp32s3-pros3/Makefile.features @@ -13,7 +13,7 @@ FEATURES_PROVIDED += periph_spi FEATURES_PROVIDED += periph_usbdev # other features provided by the board -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_pins FEATURES_PROVIDED += esp_jtag FEATURES_PROVIDED += highlevel_stdio FEATURES_PROVIDED += tinyusb_device diff --git a/boards/esp32s3-pros3/include/arduino_board.h b/boards/esp32s3-pros3/include/arduino_board.h deleted file mode 100644 index 9731fb4440fcd..0000000000000 --- a/boards/esp32s3-pros3/include/arduino_board.h +++ /dev/null @@ -1,38 +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_esp32s3_pros3 - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Gunar Schorcht - */ - -#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 */ -/** @} */ diff --git a/boards/esp32s3-pros3/include/arduino_iomap.h b/boards/esp32s3-pros3/include/arduino_iomap.h new file mode 100644 index 0000000000000..5ef5475fc1221 --- /dev/null +++ b/boards/esp32s3-pros3/include/arduino_iomap.h @@ -0,0 +1,76 @@ +/* + * 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_esp32s3_pros3 + * @{ + * + * @file + * @brief Mapping from MCU pins to Arduino pins + * + * @author Gunar Schorcht + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_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 GPIO44 /**< Arduino Uno pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO43 /**< Arduino Uno pin 1 (TxD) */ +#define ARDUINO_PIN_2 GPIO0 /**< Arduino Uno pin 2 */ +#define ARDUINO_PIN_3 GPIO12 /**< Arduino Uno pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO6 /**< Arduino Uno pin 4 */ +#define ARDUINO_PIN_5 GPIO13 /**< Arduino Uno pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO14 /**< Arduino Uno pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO7 /**< Arduino Uno pin 7 */ +#define ARDUINO_PIN_8 GPIO16 /**< Arduino Uno pin 8 */ +#define ARDUINO_PIN_9 GPIO15 /**< Arduino Uno pin 9 (PWM) */ + +#define ARDUINO_PIN_10 GPIO34 /**< Arduino Uno pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO35 /**< Arduino Uno pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO37 /**< Arduino Uno pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO36 /**< Arduino Uno pin 13 (SCK) */ + +#define ARDUINO_PIN_14 GPIO1 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_15 GPIO2 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_16 GPIO4 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_17 GPIO5 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_18 GPIO8 /**< Arduino Uno pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO9 /**< Arduino Uno pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 /**< D19 (A5) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#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 */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/esp32s3-pros3/include/arduino_pinmap.h b/boards/esp32s3-pros3/include/arduino_pinmap.h deleted file mode 100644 index 5cfc44ea6227b..0000000000000 --- a/boards/esp32s3-pros3/include/arduino_pinmap.h +++ /dev/null @@ -1,63 +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_esp32s3_pros3 - * @{ - * - * @file - * @brief Mapping from MCU pins to Arduino pins - * - * @author Gunar Schorcht - */ - -#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 GPIO44 /**< Arduino Uno pin 0 (RxD) */ -#define ARDUINO_PIN_1 GPIO43 /**< Arduino Uno pin 1 (TxD) */ -#define ARDUINO_PIN_2 GPIO0 /**< Arduino Uno pin 2 */ -#define ARDUINO_PIN_3 GPIO12 /**< Arduino Uno pin 3 (PWM) */ -#define ARDUINO_PIN_4 GPIO6 /**< Arduino Uno pin 4 */ -#define ARDUINO_PIN_5 GPIO13 /**< Arduino Uno pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO14 /**< Arduino Uno pin 6 (PWM) */ -#define ARDUINO_PIN_7 GPIO7 /**< Arduino Uno pin 7 */ -#define ARDUINO_PIN_8 GPIO16 /**< Arduino Uno pin 8 */ -#define ARDUINO_PIN_9 GPIO15 /**< Arduino Uno pin 9 (PWM) */ - -#define ARDUINO_PIN_10 GPIO34 /**< Arduino Uno pin 10 (CS0 / PWM) */ -#define ARDUINO_PIN_11 GPIO35 /**< Arduino Uno pin 11 (MOSI / PWM) */ -#define ARDUINO_PIN_12 GPIO37 /**< Arduino Uno pin 12 (MISO) */ -#define ARDUINO_PIN_13 GPIO36 /**< Arduino Uno pin 13 (SCK) */ - -#define ARDUINO_PIN_A0 GPIO1 /**< Arduino Uno pin A0 */ -#define ARDUINO_PIN_A1 GPIO2 /**< Arduino Uno pin A1 */ -#define ARDUINO_PIN_A2 GPIO4 /**< Arduino Uno pin A2 */ -#define ARDUINO_PIN_A3 GPIO5 /**< Arduino Uno pin A3 */ - -#define ARDUINO_PIN_A4 GPIO8 /**< Arduino Uno pin A4 (SDA) */ -#define ARDUINO_PIN_A5 GPIO9 /**< Arduino Uno pin A5 (SCL) */ -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_PINMAP_H */ -/** @} */ diff --git a/boards/esp8266-esp-12x/include/arduino_board.h b/boards/esp8266-esp-12x/include/arduino_board.h deleted file mode 100644 index c8e2e62dfb835..0000000000000 --- a/boards/esp8266-esp-12x/include/arduino_board.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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. - */ - -/** - * @ingroup boards_esp8266_esp-12x - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Gunar Schorcht - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "periph/gpio.h" -#include "periph/adc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The on-board LED is connected to GPIO2 (Arduino pin 3) on this board - */ -#define ARDUINO_LED (3) - -/** - * @brief Look-up table for the Arduino's digital pins - */ -static const gpio_t arduino_pinmap[] = { - GPIO1, /* ARDUINO_PIN_0 (RxD) */ - GPIO3, /* ARDUINO_PIN_1 (TxD) */ - GPIO0, /* ARDUINO_PIN_2 */ - GPIO2, /* ARDUINO_PIN_3 */ - #if defined(CONFIG_FLASHMODE_QIO) || defined(CONFIG_FLASHMODE_QOUT) - GPIO9, /* ARDUINO_PIN_4 */ - GPIO10, /* ARDUINO_PIN_5 */ - #else - GPIO_UNDEF, /* ARDUINO_PIN_4 */ - GPIO_UNDEF, /* ARDUINO_PIN_5 */ - #endif - GPIO_UNDEF, /* ARDUINO_PIN_6 */ - GPIO_UNDEF, /* ARDUINO_PIN_7 */ - GPIO_UNDEF, /* ARDUINO_PIN_8 */ - GPIO_UNDEF, /* ARDUINO_PIN_9 */ - GPIO15, /* ARDUINO_PIN_10 (CS0) */ - GPIO13, /* ARDUINO_PIN_11 (MOSI) */ - GPIO12, /* ARDUINO_PIN_12 (MISO) */ - GPIO14, /* ARDUINO_PIN_13 (SCK) */ - GPIO_UNDEF, /* ARDUINO_PIN_A0 */ - GPIO_UNDEF, /* ARDUINO_PIN_A1 */ - GPIO_UNDEF, /* ARDUINO_PIN_A2 */ - GPIO_UNDEF, /* ARDUINO_PIN_A3 */ - GPIO4, /* ARDUINO_PIN_A4 (SDA) */ - GPIO5, /* ARDUINO_PIN_A5 (SCL) */ -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/esp8266-esp-12x/include/arduino_iomap.h b/boards/esp8266-esp-12x/include/arduino_iomap.h new file mode 100644 index 0000000000000..5eb5d79a6f47c --- /dev/null +++ b/boards/esp8266-esp-12x/include/arduino_iomap.h @@ -0,0 +1,69 @@ +/* + * 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. + */ + +/** + * @ingroup boards_esp8266_esp-12x + * @{ + * + * @file + * @brief Board specific configuration for the Arduino API + * + * @author Gunar Schorcht + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H + +#include "periph/gpio.h" +#include "periph/adc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief The on-board LED is connected to GPIO2 (Arduino pin 3) on this board + */ +#define ARDUINO_LED (3) + +/** + * @brief Mapping of MCU pins to Arduino pins + * @{ + */ +#define ARDUINO_PIN_0 GPIO1 /* D0 (RxD) */ +#define ARDUINO_PIN_1 GPIO3 /* D1 (TxD) */ +#define ARDUINO_PIN_2 GPIO0 /* D2 */ +#define ARDUINO_PIN_3 GPIO2 /* D3 */ +#if defined(CONFIG_FLASHMODE_QIO) || defined(CONFIG_FLASHMODE_QOUT) +# define ARDUINO_PIN_4 GPIO9 /* D4 */ +# define ARDUINO_PIN_5 GPIO10 /* D5 */ +#endif +#define ARDUINO_PIN_10 GPIO15 /* D10 (CS0) */ +#define ARDUINO_PIN_11 GPIO13 /* D11 (MOSI) */ +#define ARDUINO_PIN_12 GPIO12 /* D12 (MISO) */ +#define ARDUINO_PIN_13 GPIO14 /* D13 (SCK) */ + +#define ARDUINO_PIN_18 GPIO4 /* D18 (A4 / SDA) */ +#define ARDUINO_PIN_19 GPIO5 /* D19 (A5 / SCL) */ + +#define ARDUINO_PIN_LAST 19 /**< D19 (A5) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino pin A5 */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/esp8266-olimex-mod/include/arduino_board.h b/boards/esp8266-olimex-mod/include/arduino_board.h deleted file mode 100644 index 188618a3f356c..0000000000000 --- a/boards/esp8266-olimex-mod/include/arduino_board.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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. - */ - -/** - * @ingroup boards_esp8266_olimex-mod - * @brief Board specific configuration for the Arduino API - * @file - * @author Gunar Schorcht - * @{ - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "periph/gpio.h" -#include "periph/adc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The on-board LED is connected to GPIO1 (Arduino pin 0) on this board - */ -#define ARDUINO_LED (0) - -/** - * @brief Look-up table for the Arduino's digital pins - */ -static const gpio_t arduino_pinmap[] = { - GPIO1, /* ARDUINO_PIN_0 (RxD) */ - GPIO3, /* ARDUINO_PIN_1 (TxD) */ - GPIO0, /* ARDUINO_PIN_2 */ - GPIO4, /* ARDUINO_PIN_3 */ - #if defined(CONFIG_FLASHMODE_QIO) || defined(CONFIG_FLASHMODE_QOUT) - GPIO9, /* ARDUINO_PIN_4 */ - GPIO10, /* ARDUINO_PIN_5 */ - #else - GPIO_UNDEF, /* ARDUINO_PIN_4 */ - GPIO_UNDEF, /* ARDUINO_PIN_5 */ - #endif - GPIO5, /* ARDUINO_PIN_6 */ - GPIO_UNDEF, /* ARDUINO_PIN_7 */ - GPIO_UNDEF, /* ARDUINO_PIN_8 */ - GPIO_UNDEF, /* ARDUINO_PIN_9 */ - GPIO15, /* ARDUINO_PIN_10 (CS0) */ - GPIO13, /* ARDUINO_PIN_11 (MOSI) */ - GPIO12, /* ARDUINO_PIN_12 (MISO) */ - GPIO14, /* ARDUINO_PIN_13 (SCK) */ - GPIO_UNDEF, /* ARDUINO_PIN_A0 */ - GPIO_UNDEF, /* ARDUINO_PIN_A1 */ - GPIO_UNDEF, /* ARDUINO_PIN_A2 */ - GPIO_UNDEF, /* ARDUINO_PIN_A3 */ - GPIO2, /* ARDUINO_PIN_A4 (SDA) */ - GPIO14, /* ARDUINO_PIN_A5 (SCL) */ -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/esp8266-olimex-mod/include/arduino_iomap.h b/boards/esp8266-olimex-mod/include/arduino_iomap.h new file mode 100644 index 0000000000000..8b2cc18389f4c --- /dev/null +++ b/boards/esp8266-olimex-mod/include/arduino_iomap.h @@ -0,0 +1,68 @@ +/* + * 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. + */ + +/** + * @ingroup boards_esp8266_olimex-mod + * @brief Board specific configuration for the Arduino API + * @file + * @author Gunar Schorcht + * @{ + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H + +#include "periph/adc.h" +#include "periph/gpio.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief The on-board LED is connected to GPIO1 (Arduino pin 0) on this board + */ +#define ARDUINO_LED (0) + +/** + * @brief Mapping of MCU pins to Arduino pins + * @{ + */ +#define ARDUINO_PIN_0 GPIO1 /* D0 (RxD) */ +#define ARDUINO_PIN_1 GPIO3 /* D1 (TxD) */ +#define ARDUINO_PIN_2 GPIO0 /* D2 */ +#define ARDUINO_PIN_3 GPIO4 /* D3 */ +#if defined(CONFIG_FLASHMODE_QIO) || defined(CONFIG_FLASHMODE_QOUT) +# define ARDUINO_PIN_4 GPIO9 /* D4 */ +# define ARDUINO_PIN_5 GPIO10 /* D5 */ +#endif +#define ARDUINO_PIN_6 GPIO5 /* D6 */ +#define ARDUINO_PIN_10 GPIO15 /* D10 (CS0) */ +#define ARDUINO_PIN_11 GPIO13 /* D11 (MOSI) */ +#define ARDUINO_PIN_12 GPIO12 /* D12 (MISO) */ +#define ARDUINO_PIN_13 GPIO14 /* D13 (SCK) */ + +#define ARDUINO_PIN_18 GPIO2 /* D18 (A4 / SDA) */ +#define ARDUINO_PIN_19 GPIO14 /* D19 (A5 / SCL) */ + +#define ARDUINO_PIN_LAST 19 /**< D19 (A5) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino pin A5 */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/esp8266-sparkfun-thing/include/arduino_board.h b/boards/esp8266-sparkfun-thing/include/arduino_board.h deleted file mode 100644 index 7a65bf89d6e58..0000000000000 --- a/boards/esp8266-sparkfun-thing/include/arduino_board.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * 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. - */ - -/** - * @ingroup boards_esp8266_sparkfun-thing - * @brief Board specific configuration for the Arduino API - * @file - * @author Gunar Schorcht - * @{ - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "periph/gpio.h" -#include "periph/adc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The on-board LED is connected to GPIO5 (Arduino pin 6) on this board - */ -#define ARDUINO_LED (6) - -/** - * @brief Look-up table for the Arduino's digital pins - */ -static const gpio_t arduino_pinmap[] = { - GPIO1, /* ARDUINO_PIN_0 (RxD) */ - GPIO3, /* ARDUINO_PIN_1 (TxD) */ - GPIO0, /* ARDUINO_PIN_2 */ - GPIO4, /* ARDUINO_PIN_3 */ - #if defined(CONFIG_FLASHMODE_QIO) || defined(CONFIG_FLASHMODE_QOUT) - GPIO9, /* ARDUINO_PIN_4 */ - GPIO10, /* ARDUINO_PIN_5 */ - #else - GPIO_UNDEF, /* ARDUINO_PIN_4 */ - GPIO_UNDEF, /* ARDUINO_PIN_5 */ - #endif - GPIO5, /* ARDUINO_PIN_6 */ - GPIO_UNDEF, /* ARDUINO_PIN_7 */ - GPIO_UNDEF, /* ARDUINO_PIN_8 */ - GPIO_UNDEF, /* ARDUINO_PIN_9 */ - GPIO15, /* ARDUINO_PIN_10 (CS0) */ - GPIO13, /* ARDUINO_PIN_11 (MOSI) */ - GPIO12, /* ARDUINO_PIN_12 (MISO) */ - GPIO14, /* ARDUINO_PIN_13 (SCK) */ - GPIO_UNDEF, /* ARDUINO_PIN_A0 */ - GPIO_UNDEF, /* ARDUINO_PIN_A1 */ - GPIO_UNDEF, /* ARDUINO_PIN_A2 */ - GPIO_UNDEF, /* ARDUINO_PIN_A3 */ - GPIO2, /* ARDUINO_PIN_A4 (SDA) */ - GPIO14, /* ARDUINO_PIN_A5 (SCL) */ -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/esp8266-sparkfun-thing/include/arduino_iomap.h b/boards/esp8266-sparkfun-thing/include/arduino_iomap.h new file mode 100644 index 0000000000000..080bd2a8348cf --- /dev/null +++ b/boards/esp8266-sparkfun-thing/include/arduino_iomap.h @@ -0,0 +1,68 @@ +/* + * 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. + */ + +/** + * @ingroup boards_esp8266_sparkfun-thing + * @brief Board specific configuration for the Arduino API + * @file + * @author Gunar Schorcht + * @{ + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H + +#include "periph/adc.h" +#include "periph/gpio.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief The on-board LED is connected to GPIO5 (Arduino pin 6) on this board + */ +#define ARDUINO_LED (6) + +/** + * @brief Mapping of MCU pins to Arduino pins + * @{ + */ +#define ARDUINO_PIN_0 GPIO1 /* D0 (RxD) */ +#define ARDUINO_PIN_1 GPIO3 /* D1 (TxD) */ +#define ARDUINO_PIN_2 GPIO0 /* D2 */ +#define ARDUINO_PIN_3 GPIO4 /* D3 */ +#if defined(CONFIG_FLASHMODE_QIO) || defined(CONFIG_FLASHMODE_QOUT) +# define ARDUINO_PIN_4 GPIO9 /* D4 */ +# define ARDUINO_PIN_5 GPIO10 /* D5 */ +#endif +#define ARDUINO_PIN_6 GPIO5 /* D6 */ +#define ARDUINO_PIN_10 GPIO15 /* D10 (CS0) */ +#define ARDUINO_PIN_11 GPIO13 /* D11 (MOSI) */ +#define ARDUINO_PIN_12 GPIO12 /* D12 (MISO) */ +#define ARDUINO_PIN_13 GPIO14 /* D13 (SCK) */ + +#define ARDUINO_PIN_18 GPIO2 /* D18 (A4 / SDA) */ +#define ARDUINO_PIN_19 GPIO14 /* D19 (A5 / SCL) */ + +#define ARDUINO_PIN_LAST 19 /**< D19 (A5) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< Arduino pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< Arduino pin A5 */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/feather-m0/Kconfig.feather-m0-base b/boards/feather-m0/Kconfig.feather-m0-base index cd58db7a7f0cb..b539599977cc6 100644 --- a/boards/feather-m0/Kconfig.feather-m0-base +++ b/boards/feather-m0/Kconfig.feather-m0-base @@ -17,7 +17,8 @@ config BOARD_FEATHER_M0_BASE select HAS_PERIPH_TIMER select HAS_PERIPH_UART select HAS_PERIPH_USBDEV - select HAS_ARDUINO + select HAS_ARDUINO_ANALOG + select HAS_ARDUINO_PINS select HAS_HIGHLEVEL_STDIO select HAVE_SAUL_GPIO diff --git a/boards/feather-m0/Makefile.features b/boards/feather-m0/Makefile.features index dcfbbf7224ed2..3829f6c7e596d 100644 --- a/boards/feather-m0/Makefile.features +++ b/boards/feather-m0/Makefile.features @@ -13,5 +13,6 @@ FEATURES_PROVIDED += periph_uart FEATURES_PROVIDED += periph_usbdev # Put other features for this board (in alphabetical order) -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_pins FEATURES_PROVIDED += highlevel_stdio diff --git a/boards/feather-m0/include/arduino_board.h b/boards/feather-m0/include/arduino_board.h deleted file mode 100644 index 4e97255ff8cf2..0000000000000 --- a/boards/feather-m0/include/arduino_board.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (C) 2021 J. David Ibáñez - * - * 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_feather-m0 - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author J. David Ibáñez - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_pinmap.h" -#include "periph/pwm.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The on-board LED is connected to pin 13 on this board - */ -#define ARDUINO_LED (13) - -/** - * @brief On-board serial port mapping, stdio is used for Serial - */ -#ifndef ARDUINO_UART_DEV -#define ARDUINO_UART_DEV UART_UNDEF -#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_14, - ARDUINO_PIN_15, - ARDUINO_PIN_16, - ARDUINO_PIN_17, - ARDUINO_PIN_18, - ARDUINO_PIN_19, - ARDUINO_PIN_20, - ARDUINO_PIN_21, - ARDUINO_PIN_22, - ARDUINO_PIN_23, - ARDUINO_PIN_24, -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { - ARDUINO_A0, - ARDUINO_A1, - ARDUINO_A2, - ARDUINO_A3, - ARDUINO_A4, - ARDUINO_A5, - ADC_UNDEF, - ARDUINO_A7, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/feather-m0/include/arduino_pinmap.h b/boards/feather-m0/include/arduino_iomap.h similarity index 65% rename from boards/feather-m0/include/arduino_pinmap.h rename to boards/feather-m0/include/arduino_iomap.h index f28fcf0fcd73e..c4a878ab45e10 100644 --- a/boards/feather-m0/include/arduino_pinmap.h +++ b/boards/feather-m0/include/arduino_iomap.h @@ -19,8 +19,8 @@ * @author J. David Ibáñez */ -#ifndef ARDUINO_PINMAP_H -#define ARDUINO_PINMAP_H +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H #include "periph/gpio.h" #include "periph/adc.h" @@ -56,26 +56,24 @@ extern "C" { #define ARDUINO_PIN_23 GPIO_PIN(PB, 10) /**< D23 (SPI MOSI) */ #define ARDUINO_PIN_24 GPIO_PIN(PB, 11) /**< D24 (SPI SCK) */ +#define ARDUINO_PIN_LAST 24 /**< D24 is the last digital pin */ + #if defined(BOARD_FEATHER_M0_WIFI) -#define ARDUINO_PIN_2 GPIO_PIN(PA, 14) /**< D2 (WINC_CHIP_EN) */ -#define ARDUINO_PIN_3 GPIO_UNDEF /**< D3 */ -#define ARDUINO_PIN_4 GPIO_PIN(PA, 8) /**< D4 (WINC_RST) */ -#define ARDUINO_PIN_7 GPIO_PIN(PA, 21) /**< D7 (WINC_IRQ) */ -#define ARDUINO_PIN_8 GPIO_PIN(PA, 6) /**< D8 (WINC_CS) */ +# define ARDUINO_PIN_2 GPIO_PIN(PA, 14) /**< D2 (WINC_CHIP_EN) */ +# define ARDUINO_PIN_4 GPIO_PIN(PA, 8) /**< D4 (WINC_RST) */ +# define ARDUINO_PIN_7 GPIO_PIN(PA, 21) /**< D7 (WINC_IRQ) */ +# define ARDUINO_PIN_8 GPIO_PIN(PA, 6) /**< D8 (WINC_CS) */ #elif defined(BOARD_FEATHER_M0_LORA) -#define ARDUINO_PIN_2 GPIO_UNDEF /**< D2 */ -#define ARDUINO_PIN_3 GPIO_PIN(PA, 9) /**< D3 (LORA_IRQ) */ -#define ARDUINO_PIN_4 GPIO_PIN(PA, 8) /**< D4 (LORA_RST) */ -#define ARDUINO_PIN_7 GPIO_UNDEF /**< D7 */ -#define ARDUINO_PIN_8 GPIO_PIN(PA, 6) /**< D8 (LORA_CS) */ -#else -#define ARDUINO_PIN_2 GPIO_UNDEF /**< D2 */ -#define ARDUINO_PIN_3 GPIO_UNDEF /**< D3 */ -#define ARDUINO_PIN_4 GPIO_UNDEF /**< D4 */ -#define ARDUINO_PIN_7 GPIO_UNDEF /**< D7 */ -#define ARDUINO_PIN_8 GPIO_UNDEF /**< D8 */ +# define ARDUINO_PIN_3 GPIO_PIN(PA, 9) /**< D3 (LORA_IRQ) */ +# define ARDUINO_PIN_4 GPIO_PIN(PA, 8) /**< D4 (LORA_RST) */ +# define ARDUINO_PIN_7 GPIO_UNDEF /**< D7 */ +# define ARDUINO_PIN_8 GPIO_PIN(PA, 6) /**< D8 (LORA_CS) */ #endif +/** @} */ +/** + * @name Aliases for analog pins + */ #define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< A0 */ #define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< A1 */ #define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< A2 */ @@ -89,18 +87,20 @@ extern "C" { * @name Mapping of Arduino analog pins to RIOT ADC lines * @{ */ -#define ARDUINO_A0 ADC_LINE(0) /**< ADC 0 */ -#define ARDUINO_A1 ADC_LINE(2) /**< ADC 1 */ -#define ARDUINO_A2 ADC_LINE(3) /**< ADC 2 */ -#define ARDUINO_A3 ADC_LINE(4) /**< ADC 3 */ -#define ARDUINO_A4 ADC_LINE(5) /**< ADC 4 */ -#define ARDUINO_A5 ADC_LINE(10) /**< ADC 5 */ -#define ARDUINO_A7 ADC_LINE(7) /**< ADC 7 */ +#define ARDUINO_A0 ADC_LINE(0) /**< ADC 0 */ +#define ARDUINO_A1 ADC_LINE(2) /**< ADC 1 */ +#define ARDUINO_A2 ADC_LINE(3) /**< ADC 2 */ +#define ARDUINO_A3 ADC_LINE(4) /**< ADC 3 */ +#define ARDUINO_A4 ADC_LINE(5) /**< ADC 4 */ +#define ARDUINO_A5 ADC_LINE(10) /**< ADC 5 */ +#define ARDUINO_A7 ADC_LINE(7) /**< ADC 7 */ + +#define ARDUINO_ANALOG_PIN_LAST 7 /**< A7 is the last analog pin */ /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/hifive1b/Kconfig b/boards/hifive1b/Kconfig index 7c2f44c818ce9..4f45f05176c6f 100644 --- a/boards/hifive1b/Kconfig +++ b/boards/hifive1b/Kconfig @@ -18,4 +18,4 @@ config BOARD_HIFIVE1B select HAS_PERIPH_SPI select HAS_PERIPH_TIMER select HAS_PERIPH_UART - select HAS_ARDUINO + select HAS_ARDUINO_PINS diff --git a/boards/hifive1b/Makefile.features b/boards/hifive1b/Makefile.features index 6d183b3805aac..dbf41816ede9e 100644 --- a/boards/hifive1b/Makefile.features +++ b/boards/hifive1b/Makefile.features @@ -11,4 +11,4 @@ FEATURES_PROVIDED += periph_timer FEATURES_PROVIDED += periph_uart # Put other features for this board (in alphabetical order) -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_pins diff --git a/boards/hifive1b/include/arduino_board.h b/boards/hifive1b/include/arduino_board.h deleted file mode 100644 index 46a14a6e64aac..0000000000000 --- a/boards/hifive1b/include/arduino_board.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2019 Inria - * - * 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_hifive1b - * @{ - * - * @file - * @brief Configuration of the Arduino API for the SiFive HiFive1b board - * - * @author Alexandre Abadie - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_pinmap.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief One on-board red LED is connected to pin 6 on this board - */ -#define ARDUINO_LED (6) - -/** - * @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_14, - ARDUINO_PIN_15, - ARDUINO_PIN_16, - ARDUINO_PIN_17, - ARDUINO_PIN_18, - ARDUINO_PIN_19, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/hifive1b/include/arduino_pinmap.h b/boards/hifive1b/include/arduino_iomap.h similarity index 91% rename from boards/hifive1b/include/arduino_pinmap.h rename to boards/hifive1b/include/arduino_iomap.h index d2ee77400e9ae..41e670707335c 100644 --- a/boards/hifive1b/include/arduino_pinmap.h +++ b/boards/hifive1b/include/arduino_iomap.h @@ -19,8 +19,8 @@ * @author Alexandre Abadie */ -#ifndef ARDUINO_PINMAP_H -#define ARDUINO_PINMAP_H +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H #include "periph/gpio.h" @@ -48,17 +48,18 @@ extern "C" { #define ARDUINO_PIN_11 GPIO_PIN(0, 3) /* SPI MOSI/PWM0 */ #define ARDUINO_PIN_12 GPIO_PIN(0, 4) /* SPI MISO */ #define ARDUINO_PIN_13 GPIO_PIN(0, 5) /* SPI SCK */ -#define ARDUINO_PIN_14 GPIO_UNDEF #define ARDUINO_PIN_15 GPIO_PIN(0, 9) #define ARDUINO_PIN_16 GPIO_PIN(0, 10) /* PWM2 */ #define ARDUINO_PIN_17 GPIO_PIN(0, 11) /* PWM2 */ #define ARDUINO_PIN_18 GPIO_PIN(0, 12) /* SDA/PWM2 */ #define ARDUINO_PIN_19 GPIO_PIN(0, 13) /* SCL/PWM2 */ + +#define ARDUINO_PIN_LAST 19 /**< D19 is the last digital pin */ /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/lora-e5-dev/Kconfig b/boards/lora-e5-dev/Kconfig index ae10e390c372d..ee0228f6e5966 100644 --- a/boards/lora-e5-dev/Kconfig +++ b/boards/lora-e5-dev/Kconfig @@ -23,7 +23,7 @@ config BOARD_LORA_E5_DEV select HAS_PERIPH_UART # Put other features for this board (in alphabetical order) - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_RIOTBOOT # Clock configuration diff --git a/boards/lora-e5-dev/Makefile.features b/boards/lora-e5-dev/Makefile.features index b0f90c175e315..df60c40d433b0 100644 --- a/boards/lora-e5-dev/Makefile.features +++ b/boards/lora-e5-dev/Makefile.features @@ -11,5 +11,5 @@ FEATURES_PROVIDED += periph_timer FEATURES_PROVIDED += periph_uart # Put other features for this board (in alphabetical order) -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_pins FEATURES_PROVIDED += riotboot diff --git a/boards/lora-e5-dev/include/arduino_board.h b/boards/lora-e5-dev/include/arduino_board.h deleted file mode 100644 index 4a6f34b0e6b3f..0000000000000 --- a/boards/lora-e5-dev/include/arduino_board.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (C) 2022 J. David Ibáñez - * - * 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_lora-e5-dev - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author J. David Ibáñez - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_pinmap.h" -#include "periph/adc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The on-board LED is connected to pin 11 on this board - */ -#define ARDUINO_LED (11) - -/** - * @brief Look-up table for the Arduino's digital pins - */ -static const gpio_t arduino_pinmap[] = { - GPIO_UNDEF, - 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_14, - ARDUINO_PIN_15, - ARDUINO_PIN_16, - ARDUINO_PIN_17, - ARDUINO_PIN_18, - ARDUINO_PIN_19, - ARDUINO_PIN_20, - ARDUINO_PIN_21, - ARDUINO_PIN_22, - ARDUINO_PIN_23, - ARDUINO_PIN_24, - ARDUINO_PIN_25, - ARDUINO_PIN_26, - ARDUINO_PIN_27, - ARDUINO_PIN_28, -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/lora-e5-dev/include/arduino_pinmap.h b/boards/lora-e5-dev/include/arduino_iomap.h similarity index 79% rename from boards/lora-e5-dev/include/arduino_pinmap.h rename to boards/lora-e5-dev/include/arduino_iomap.h index d08616b3a5d62..2962a13929b57 100644 --- a/boards/lora-e5-dev/include/arduino_pinmap.h +++ b/boards/lora-e5-dev/include/arduino_iomap.h @@ -19,8 +19,8 @@ * @author J. David Ibáñez */ -#ifndef ARDUINO_PINMAP_H -#define ARDUINO_PINMAP_H +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H #include "periph/gpio.h" @@ -33,14 +33,12 @@ extern "C" { * * @warning Beware: Despite an Arduino pin mapping being available, Arduino shields * are mechanically not compatible with the board. Check header file - * https://github.com/RIOT-OS/RIOT/blob/master/boards/lora-e5-dev/include/arduino_pinmap.h#L42 + * https://github.com/RIOT-OS/RIOT/blob/master/boards/lora-e5-dev/include/arduino_iomap.h#L42 * for the exact mapping. * * @{ */ -#define ARDUINO_PIN_1 GPIO_UNDEF /**< VCC: Supply voltage for the module */ -#define ARDUINO_PIN_2 GPIO_UNDEF /**< GND: Ground */ #define ARDUINO_PIN_3 GPIO_PIN(PORT_A, 13) /**< SWDIO of SWIM for program download */ #define ARDUINO_PIN_4 GPIO_PIN(PORT_A, 14) /**< SWCLK of SWIM for program download */ #define ARDUINO_PIN_5 GPIO_PIN(PORT_B, 15) /**< SCL of I2C2 from MCU */ @@ -52,21 +50,18 @@ extern "C" { #define ARDUINO_PIN_11 GPIO_PIN(PORT_B, 5) /**< MCU GPIO */ #define ARDUINO_PIN_12 GPIO_PIN(PORT_C, 1) /**< MCU GPIO; LPUART1_TX from MCU */ #define ARDUINO_PIN_13 GPIO_PIN(PORT_C, 0) /**< MCU GPIO; LPUART1_RX from MCU */ -#define ARDUINO_PIN_14 GPIO_UNDEF /**< GND: Ground */ -#define ARDUINO_PIN_15 GPIO_UNDEF /**< RFIO: RF input/output */ -#define ARDUINO_PIN_16 GPIO_UNDEF /**< GND: Ground */ -#define ARDUINO_PIN_17 GPIO_UNDEF /**< RST: Reset trigger input for MCU */ #define ARDUINO_PIN_18 GPIO_PIN(PORT_A, 3) /**< MCU GPIO; USART2_RX from MCU */ #define ARDUINO_PIN_19 GPIO_PIN(PORT_A, 2) /**< MCU GPIO; USART2_TX from MCU */ #define ARDUINO_PIN_20 GPIO_PIN(PORT_B, 10) /**< MCU GPIO */ #define ARDUINO_PIN_21 GPIO_PIN(PORT_A, 9) /**< MCU GPIO */ -#define ARDUINO_PIN_22 GPIO_UNDEF /**< GND: Ground */ #define ARDUINO_PIN_23 GPIO_PIN(PORT_A, 0) /**< MCU GPIO */ #define ARDUINO_PIN_24 GPIO_PIN(PORT_B, 13) /**< SPI2_SCK from MCU; Boot pin(Active low) */ #define ARDUINO_PIN_25 GPIO_PIN(PORT_B, 9) /**< SPI2_NSS from MCU */ #define ARDUINO_PIN_26 GPIO_PIN(PORT_B, 14) /**< SPI2_MISO from MCU */ #define ARDUINO_PIN_27 GPIO_PIN(PORT_A, 10) /**< SPI2_MOSI from MCU */ #define ARDUINO_PIN_28 GPIO_PIN(PORT_B, 0) /**< Unavailable;Suspended treatment */ + +#define ARDUINO_PIN_LAST 28 /**< D28 is the last digital pin */ /** @} */ @@ -74,5 +69,5 @@ extern "C" { } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/nucleo-wl55jc/Kconfig b/boards/nucleo-wl55jc/Kconfig index 2c66431f4c15b..03845b2094512 100644 --- a/boards/nucleo-wl55jc/Kconfig +++ b/boards/nucleo-wl55jc/Kconfig @@ -23,7 +23,7 @@ config BOARD_NUCLEO_WL55JC select HAS_PERIPH_UART # Put other features for this board (in alphabetical order) - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_PERIPH_GPIO_IRQ select HAS_RIOTBOOT select HAVE_SX126X_STM32WL diff --git a/boards/nucleo-wl55jc/include/arduino_board.h b/boards/nucleo-wl55jc/include/arduino_board.h deleted file mode 100644 index 15879fcc2651f..0000000000000 --- a/boards/nucleo-wl55jc/include/arduino_board.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2021 Freie Universität Berlin - * - * 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_nucleo-wl55jc - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Akshai M - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_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_A0, - ARDUINO_A1, - ARDUINO_A2, - ARDUINO_A3, - ARDUINO_A4, - ARDUINO_A5, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/nucleo-wl55jc/include/arduino_pinmap.h b/boards/nucleo-wl55jc/include/arduino_iomap.h similarity index 69% rename from boards/nucleo-wl55jc/include/arduino_pinmap.h rename to boards/nucleo-wl55jc/include/arduino_iomap.h index faaeac9233749..b743d846c5b5b 100644 --- a/boards/nucleo-wl55jc/include/arduino_pinmap.h +++ b/boards/nucleo-wl55jc/include/arduino_iomap.h @@ -20,8 +20,8 @@ * */ -#ifndef ARDUINO_PINMAP_H -#define ARDUINO_PINMAP_H +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H #include "periph/gpio.h" #include "periph/adc.h" @@ -51,12 +51,27 @@ extern "C" { #define ARDUINO_PIN_14 GPIO_PIN(PORT_A, 11) #define ARDUINO_PIN_15 GPIO_PIN(PORT_A, 12) -#define ARDUINO_PIN_A0 GPIO_PIN(PORT_B, 1) -#define ARDUINO_PIN_A1 GPIO_PIN(PORT_B, 2) -#define ARDUINO_PIN_A2 GPIO_PIN(PORT_A, 10) -#define ARDUINO_PIN_A3 GPIO_PIN(PORT_B, 4) -#define ARDUINO_PIN_A4 GPIO_PIN(PORT_B, 14) -#define ARDUINO_PIN_A5 GPIO_PIN(PORT_B, 13) +/* analog pins in digital mode: */ +#define ARDUINO_PIN_16 GPIO_PIN(PORT_B, 1) +#define ARDUINO_PIN_17 GPIO_PIN(PORT_B, 2) +#define ARDUINO_PIN_18 GPIO_PIN(PORT_A, 10) +#define ARDUINO_PIN_19 GPIO_PIN(PORT_B, 4) +#define ARDUINO_PIN_20 GPIO_PIN(PORT_B, 14) +#define ARDUINO_PIN_21 GPIO_PIN(PORT_B, 13) + +#define ARDUINO_PIN_LAST 21 +/** @} */ + +/** + * @brief Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_16 +#define ARDUINO_PIN_A1 ARDUINO_PIN_17 +#define ARDUINO_PIN_A2 ARDUINO_PIN_18 +#define ARDUINO_PIN_A3 ARDUINO_PIN_19 +#define ARDUINO_PIN_A4 ARDUINO_PIN_20 +#define ARDUINO_PIN_A5 ARDUINO_PIN_21 /** @} */ /** @@ -69,11 +84,13 @@ extern "C" { #define ARDUINO_A3 ADC_LINE(3) #define ARDUINO_A4 ADC_LINE(4) #define ARDUINO_A5 ADC_LINE(5) + +#define ARDUINO_ANALOG_PIN_LAST 5 /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/p-nucleo-wb55/Kconfig b/boards/p-nucleo-wb55/Kconfig index 1351bf5d2ca30..46a32593a4feb 100644 --- a/boards/p-nucleo-wb55/Kconfig +++ b/boards/p-nucleo-wb55/Kconfig @@ -25,7 +25,9 @@ config BOARD_P_NUCLEO_WB55 select MODULE_PERIPH_LPUART if MODULE_STDIO_UART && HAS_PERIPH_LPUART # Put other features for this board (in alphabetical order) - select HAS_ARDUINO + select HAS_ARDUINO_ANALOG + select HAS_ARDUINO_PINS + select HAS_ARDUINO_SHIELD_UNO select HAS_RIOTBOOT select HAS_TINYUSB_DEVICE diff --git a/boards/p-nucleo-wb55/Makefile.features b/boards/p-nucleo-wb55/Makefile.features index 9d17d84c535c6..a59e19133edfe 100644 --- a/boards/p-nucleo-wb55/Makefile.features +++ b/boards/p-nucleo-wb55/Makefile.features @@ -13,6 +13,8 @@ FEATURES_PROVIDED += periph_uart FEATURES_PROVIDED += periph_usbdev # Put other features for this board (in alphabetical order) -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_shield_uno FEATURES_PROVIDED += riotboot FEATURES_PROVIDED += tinyusb_device diff --git a/boards/p-nucleo-wb55/include/arduino_board.h b/boards/p-nucleo-wb55/include/arduino_board.h deleted file mode 100644 index 5695fe82dccdf..0000000000000 --- a/boards/p-nucleo-wb55/include/arduino_board.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2016 Freie Universität Berlin - * 2019 Inria - * - * 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_p-nucleo-wb55 - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Hauke Petersen - * @author Alexandre Abadie - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_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_A0, - ARDUINO_A1, - ARDUINO_A2, - ARDUINO_A3, - ARDUINO_A4, - ARDUINO_A5, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/p-nucleo-wb55/include/arduino_pinmap.h b/boards/p-nucleo-wb55/include/arduino_iomap.h similarity index 65% rename from boards/p-nucleo-wb55/include/arduino_pinmap.h rename to boards/p-nucleo-wb55/include/arduino_iomap.h index ead5821ca3eea..5739e4fb70f93 100644 --- a/boards/p-nucleo-wb55/include/arduino_pinmap.h +++ b/boards/p-nucleo-wb55/include/arduino_iomap.h @@ -21,8 +21,8 @@ * */ -#ifndef ARDUINO_PINMAP_H -#define ARDUINO_PINMAP_H +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H #include "periph/gpio.h" #include "periph/adc.h" @@ -52,12 +52,25 @@ extern "C" { #define ARDUINO_PIN_14 GPIO_PIN(PORT_B, 9) #define ARDUINO_PIN_15 GPIO_PIN(PORT_B, 8) -#define ARDUINO_PIN_A0 GPIO_PIN(PORT_C, 0) -#define ARDUINO_PIN_A1 GPIO_PIN(PORT_C, 1) -#define ARDUINO_PIN_A2 GPIO_PIN(PORT_A, 1) -#define ARDUINO_PIN_A3 GPIO_PIN(PORT_A, 0) -#define ARDUINO_PIN_A4 GPIO_PIN(PORT_C, 3) -#define ARDUINO_PIN_A5 GPIO_PIN(PORT_C, 2) +#define ARDUINO_PIN_16 GPIO_PIN(PORT_C, 0) +#define ARDUINO_PIN_17 GPIO_PIN(PORT_C, 1) +#define ARDUINO_PIN_18 GPIO_PIN(PORT_A, 1) +#define ARDUINO_PIN_19 GPIO_PIN(PORT_A, 0) +#define ARDUINO_PIN_20 GPIO_PIN(PORT_C, 3) +#define ARDUINO_PIN_21 GPIO_PIN(PORT_C, 2) + +#define ARDUINO_PIN_LAST 21 /**< D21 (A5) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_16 /**< Arduino pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_17 /**< Arduino pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_18 /**< Arduino pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_19 /**< Arduino pin A3 */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_20 /**< Arduino pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_21 /**< Arduino pin A5 */ /** @} */ /** @@ -70,11 +83,13 @@ extern "C" { #define ARDUINO_A3 ADC_LINE(3) #define ARDUINO_A4 ADC_LINE(4) #define ARDUINO_A5 ADC_LINE(5) + +#define ARDUINO_ANALOG_PIN_LAST 5 /**< A5 is the last analog pin */ /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/remote-revb/Kconfig b/boards/remote-revb/Kconfig index e1cafa4b8c49f..dfba9af3f7c42 100644 --- a/boards/remote-revb/Kconfig +++ b/boards/remote-revb/Kconfig @@ -11,7 +11,8 @@ config BOARD_REMOTE_REVB bool default y select BOARD_COMMON_REMOTE - select HAS_ARDUINO + select HAS_ARDUINO_ANALOG + select HAS_ARDUINO_PINS select HAVE_SAUL_ADC select HAVE_SAUL_GPIO diff --git a/boards/remote-revb/Makefile.features b/boards/remote-revb/Makefile.features index 85a55f8ecfcc1..2942e38d7d628 100644 --- a/boards/remote-revb/Makefile.features +++ b/boards/remote-revb/Makefile.features @@ -1,4 +1,5 @@ include $(RIOTBOARD)/common/remote/Makefile.features -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_pins FEATURES_PROVIDED += sdcard_spi diff --git a/boards/remote-revb/include/arduino_board.h b/boards/remote-revb/include/arduino_board.h deleted file mode 100644 index ee26399393811..0000000000000 --- a/boards/remote-revb/include/arduino_board.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2020 J. David Ibáñez - * - * 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_remote-revb - * @{ - * - * @file - * @brief Configuration of the Arduino API for Remote revision B board - * - * You can use the defines in this file for simplified interaction with the - * Arduino specific pin numbers. - * - * @author J. David Ibáñez - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_pinmap.h" -#include "periph/pwm.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The on-board LED is connected to pin 13 on this board - */ -#define ARDUINO_LED (1) - -/** - * @brief Look-up table for the Arduino's digital pins - */ -static const gpio_t arduino_pinmap[] = { - GPIO_UNDEF, - ARDUINO_PIN_1, - ARDUINO_PIN_2, - ARDUINO_PIN_3, - ARDUINO_PIN_4, - ARDUINO_PIN_5, - ARDUINO_PIN_6, - ARDUINO_PIN_7, - ARDUINO_PIN_8, - GPIO_UNDEF, - GPIO_UNDEF, - ARDUINO_PIN_11, - ARDUINO_PIN_12, - ARDUINO_PIN_13, - ARDUINO_PIN_14, - GPIO_UNDEF, - GPIO_UNDEF, - ARDUINO_PIN_17, - GPIO_UNDEF, - GPIO_UNDEF, - GPIO_UNDEF, - ARDUINO_PIN_21, - ARDUINO_PIN_22, - ARDUINO_PIN_23, - ARDUINO_PIN_24, - ARDUINO_PIN_25, - GPIO_UNDEF, - GPIO_UNDEF, - ARDUINO_PIN_28, - ARDUINO_PIN_29, - GPIO_UNDEF, - GPIO_UNDEF, - ARDUINO_PIN_32, - ARDUINO_PIN_33, - ARDUINO_PIN_34, - ARDUINO_PIN_35, - ARDUINO_PIN_36, -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { - ADC_UNDEF, - ARDUINO_A1, - ARDUINO_A2, - ARDUINO_A3, - ARDUINO_A4, - ARDUINO_A5, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/remote-revb/include/arduino_iomap.h b/boards/remote-revb/include/arduino_iomap.h new file mode 100644 index 0000000000000..6265fcccd8783 --- /dev/null +++ b/boards/remote-revb/include/arduino_iomap.h @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2020 J. David Ibáñez + * + * 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_remote-revb + * @{ + * + * @file + * @brief Mapping from MCU pins to Arduino pins for Remote revision B board + * + * You can use the defines in this file for simplified interaction with the + * Arduino specific pin numbers. + * + * @author J. David Ibáñez + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H + +#include "periph/gpio.h" +#include "periph/adc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Mapping of MCU pins to Arduino pins + * + * @warning Beware: Despite an Arudino pin mapping being available, Arduino shields + * are mechanically not compatible with the board. Check header file + * https://github.com/RIOT-OS/RIOT/blob/master/boards/remote-revb/include/arduino_iomap.h#L43 + * for the exact mapping. + * + * @{ + */ + +#define ARDUINO_PIN_1 GPIO_PIN(PORT_D, 4) // LED1.R +#define ARDUINO_PIN_2 GPIO_PIN(PORT_B, 7) // LED2.G/JTAG.TDO +#define ARDUINO_PIN_3 GPIO_PIN(PORT_B, 6) // LED3.B/JTAG.TDI +#define ARDUINO_PIN_4 GPIO_PIN(PORT_A, 0) // UART0.RX +#define ARDUINO_PIN_5 GPIO_PIN(PORT_A, 1) // UART0.TX +#define ARDUINO_PIN_6 GPIO_PIN(PORT_D, 0) // I2C.INT +#define ARDUINO_PIN_7 GPIO_PIN(PORT_C, 2) // I2C.SDA +#define ARDUINO_PIN_8 GPIO_PIN(PORT_C, 3) // I2C.SCL +#define ARDUINO_PIN_11 GPIO_PIN(PORT_B, 4) // CC1200.GPIO0 +#define ARDUINO_PIN_12 GPIO_PIN(PORT_B, 0) // CC1200.GPIO2 +#define ARDUINO_PIN_13 GPIO_PIN(PORT_C, 1) // UART1.RX +#define ARDUINO_PIN_14 GPIO_PIN(PORT_C, 0) // UART1.TX +#define ARDUINO_PIN_17 GPIO_PIN(PORT_B, 5) // CC1200.CSN +#define ARDUINO_PIN_21 GPIO_PIN(PORT_A, 3) // USER.BUTTON +#define ARDUINO_PIN_22 GPIO_PIN(PORT_B, 2) // CC1200.CLK +#define ARDUINO_PIN_23 GPIO_PIN(PORT_B, 1) // CC1200.MOSI +#define ARDUINO_PIN_24 GPIO_PIN(PORT_B, 3) // CC1200.MISO +#define ARDUINO_PIN_25 GPIO_PIN(PORT_A, 7) // ADC5/AIN7 +#define ARDUINO_PIN_28 GPIO_PIN(PORT_A, 5) // ADC1/AIN5 +#define ARDUINO_PIN_29 GPIO_PIN(PORT_A, 4) // ADC2/AIN4 +#define ARDUINO_PIN_32 GPIO_PIN(PORT_A, 2) // ADC3/AIN2 +#define ARDUINO_PIN_33 GPIO_PIN(PORT_A, 6) // USD.SEL/ADC4 +#define ARDUINO_PIN_34 GPIO_PIN(PORT_C, 6) // USD.MISO +#define ARDUINO_PIN_35 GPIO_PIN(PORT_C, 5) // USD.MOSI +#define ARDUINO_PIN_36 GPIO_PIN(PORT_C, 4) // USD.SCLK +#define ARDUINO_PIN_LAST 36 /**< D36 is the highest digital pin */ + +/* Aliases for analog pins */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_28 +#define ARDUINO_PIN_A2 ARDUINO_PIN_29 +#define ARDUINO_PIN_A3 ARDUINO_PIN_32 +#define ARDUINO_PIN_A4 ARDUINO_PIN_33 +#define ARDUINO_PIN_A5 ARDUINO_PIN_25 + +#define ARDUINO_A1 ADC_LINE(1) +#define ARDUINO_A2 ADC_LINE(2) +#define ARDUINO_A3 ADC_LINE(3) +#define ARDUINO_A4 ADC_LINE(4) +#define ARDUINO_A5 ADC_LINE(5) +#define ARDUINO_ANALOG_PIN_LAST 5 /**< A5 is the highest analog pin */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/remote-revb/include/arduino_pinmap.h b/boards/remote-revb/include/arduino_pinmap.h deleted file mode 100644 index ed50a62ca7dbc..0000000000000 --- a/boards/remote-revb/include/arduino_pinmap.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2020 J. David Ibáñez - * - * 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_remote-revb - * @{ - * - * @file - * @brief Mapping from MCU pins to Arduino pins for Remote revision B board - * - * You can use the defines in this file for simplified interaction with the - * Arduino specific pin numbers. - * - * @author J. David Ibáñez - */ - -#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 - * - * @warning Beware: Despite an Arudino pin mapping being available, Arduino shields - * are mechanically not compatible with the board. Check header file - * https://github.com/RIOT-OS/RIOT/blob/master/boards/remote-revb/include/arduino_pinmap.h#L43 - * for the exact mapping. - * - * @{ - */ - -#define ARDUINO_PIN_1 GPIO_PIN(PORT_D, 4) // LED1.R -#define ARDUINO_PIN_2 GPIO_PIN(PORT_B, 7) // LED2.G/JTAG.TDO -#define ARDUINO_PIN_3 GPIO_PIN(PORT_B, 6) // LED3.B/JTAG.TDI -#define ARDUINO_PIN_4 GPIO_PIN(PORT_A, 0) // UART0.RX -#define ARDUINO_PIN_5 GPIO_PIN(PORT_A, 1) // UART0.TX -#define ARDUINO_PIN_6 GPIO_PIN(PORT_D, 0) // I2C.INT -#define ARDUINO_PIN_7 GPIO_PIN(PORT_C, 2) // I2C.SDA -#define ARDUINO_PIN_8 GPIO_PIN(PORT_C, 3) // I2C.SCL -#define ARDUINO_PIN_11 GPIO_PIN(PORT_B, 4) // CC1200.GPIO0 -#define ARDUINO_PIN_12 GPIO_PIN(PORT_B, 0) // CC1200.GPIO2 -#define ARDUINO_PIN_13 GPIO_PIN(PORT_C, 1) // UART1.RX -#define ARDUINO_PIN_14 GPIO_PIN(PORT_C, 0) // UART1.TX -#define ARDUINO_PIN_17 GPIO_PIN(PORT_B, 5) // CC1200.CSN -#define ARDUINO_PIN_21 GPIO_PIN(PORT_A, 3) // USER.BUTTON -#define ARDUINO_PIN_22 GPIO_PIN(PORT_B, 2) // CC1200.CLK -#define ARDUINO_PIN_23 GPIO_PIN(PORT_B, 1) // CC1200.MOSI -#define ARDUINO_PIN_24 GPIO_PIN(PORT_B, 3) // CC1200.MISO -#define ARDUINO_PIN_25 GPIO_PIN(PORT_A, 7) // ADC5/AIN7 -#define ARDUINO_PIN_28 GPIO_PIN(PORT_A, 5) // ADC1/AIN5 -#define ARDUINO_PIN_29 GPIO_PIN(PORT_A, 4) // ADC2/AIN4 -#define ARDUINO_PIN_32 GPIO_PIN(PORT_A, 2) // ADC3/AIN2 -#define ARDUINO_PIN_33 GPIO_PIN(PORT_A, 6) // USD.SEL/ADC4 -#define ARDUINO_PIN_34 GPIO_PIN(PORT_C, 6) // USD.MISO -#define ARDUINO_PIN_35 GPIO_PIN(PORT_C, 5) // USD.MOSI -#define ARDUINO_PIN_36 GPIO_PIN(PORT_C, 4) // USD.SCLK -#define ARDUINO_PIN_A1 ARDUINO_PIN_28 -#define ARDUINO_PIN_A2 ARDUINO_PIN_29 -#define ARDUINO_PIN_A3 ARDUINO_PIN_32 -#define ARDUINO_PIN_A4 ARDUINO_PIN_33 -#define ARDUINO_PIN_A5 ARDUINO_PIN_25 - -#define ARDUINO_A1 ADC_LINE(1) -#define ARDUINO_A2 ADC_LINE(2) -#define ARDUINO_A3 ADC_LINE(3) -#define ARDUINO_A4 ADC_LINE(4) -#define ARDUINO_A5 ADC_LINE(5) -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_PINMAP_H */ -/** @} */ diff --git a/boards/saml21-xpro/include/arduino_board.h b/boards/saml21-xpro/include/arduino_board.h deleted file mode 100644 index fb9f3f7735923..0000000000000 --- a/boards/saml21-xpro/include/arduino_board.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (C) 2018 Federico Pellegrin - * - * 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_saml21-xpro - * @brief Board configuration for the Arduino API - * @file - * @author Federico Pellegrin - * @{ - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_pinmap.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Arduino's digital pins mappings - */ -static const gpio_t arduino_pinmap[] = { - ARDUINO_PIN_0, - ARDUINO_PIN_1 -}; - -/** - * @brief Arduino's analog pins mappings - */ -static const adc_t arduino_analog_map[] = { - ARDUINO_A0, - ARDUINO_A1, - ARDUINO_A2 -}; - -/** - * @brief On-board LED mapping - */ -#define ARDUINO_LED (0) - -/** - * @brief On-board serial port mapping - */ -#define ARDUINO_UART_DEV UART_DEV(0) - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/saml21-xpro/include/arduino_iomap.h b/boards/saml21-xpro/include/arduino_iomap.h new file mode 100644 index 0000000000000..b3edfa47c63c4 --- /dev/null +++ b/boards/saml21-xpro/include/arduino_iomap.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2018 Federico Pellegrin + * + * 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_saml21-xpro + * @brief Mapping from board pins to Arduino pins + * @file + * @author Federico Pellegrin + * @{ + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H + +#include "board.h" +#include "periph/adc.h" +#include "periph/uart.h" +#include "periph_cpu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Arduino's default UART device + * @{ + */ +#define ARDUINO_UART_DEV UART_DEV(0) +/** @} */ + +/** + * @name Arduino's digital pins mappings + * @{ + */ +#define ARDUINO_PIN_0 LED0_PIN +#define ARDUINO_PIN_1 BTN0_PIN + +#define ARDUINO_PIN_LAST 1 /**< D1 is the last digital pin */ +/** @} */ + +/** + * @name Arduino's analog pins mappings + * @{ + */ +#define ARDUINO_A0 ADC_LINE(0) +#define ARDUINO_A1 ADC_LINE(1) +#define ARDUINO_A2 ADC_LINE(2) + +#define ARDUINO_ANALOG_PIN_LAST 2 /**< A2 is the last analog pin */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/saml21-xpro/include/arduino_pinmap.h b/boards/saml21-xpro/include/arduino_pinmap.h deleted file mode 100644 index 0c3f3bc6153e1..0000000000000 --- a/boards/saml21-xpro/include/arduino_pinmap.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2018 Federico Pellegrin - * - * 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_saml21-xpro - * @brief Mapping from board pins to Arduino pins - * @file - * @author Federico Pellegrin - * @{ - */ - -#ifndef ARDUINO_PINMAP_H -#define ARDUINO_PINMAP_H - -#include "board.h" -#include "periph_cpu.h" -#include "periph/adc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Arduino's digital pins mappings - */ -#define ARDUINO_PIN_0 LED0_PIN -#define ARDUINO_PIN_1 BTN0_PIN - -/** - * @brief Arduino's analog pins mappings - */ -#define ARDUINO_A0 ADC_LINE(0) -#define ARDUINO_A1 ADC_LINE(1) -#define ARDUINO_A2 ADC_LINE(2) - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_PINMAP_H */ -/** @} */ diff --git a/boards/sodaq-autonomo/include/arduino_board.h b/boards/sodaq-autonomo/include/arduino_board.h deleted file mode 100644 index aacb468936e60..0000000000000 --- a/boards/sodaq-autonomo/include/arduino_board.h +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (C) 2019 Kees Bakker - * - * 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_sodaq-autonomo - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Kees Bakker - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "periph/gpio.h" -#include "periph/adc.h" -#include "periph/pwm.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The builtin LED - */ -#define ARDUINO_LED (13) - -/** - * @brief On-board serial port mapping - */ -#ifndef ARDUINO_UART_DEV -#define ARDUINO_UART_DEV UART_UNDEF -#endif - -/** - * @brief Look-up table for the Arduino's digital pins - */ -static const gpio_t arduino_pinmap[] = { - /* 0..1 - SERCOM/UART (Serial) */ - GPIO_PIN(PA, 9), - GPIO_PIN(PA, 10), - - /* 2..15 Digital */ - GPIO_PIN(PA, 11), - GPIO_PIN(PB, 10), - GPIO_PIN(PB, 11), - GPIO_PIN(PB, 12), - GPIO_PIN(PB, 13), - GPIO_PIN(PB, 14), - GPIO_PIN(PB, 15), - GPIO_PIN(PA, 14), - GPIO_PIN(PA, 15), - GPIO_PIN(PA, 16), - GPIO_PIN(PA, 17), - GPIO_PIN(PA, 18), - GPIO_PIN(PA, 19), - GPIO_PIN(PB, 16), - - /* 16..18 Other Digital */ - GPIO_PIN(PA, 8), - GPIO_PIN(PA, 28), - GPIO_PIN(PB, 17), - - /* 19..32 A0..A13 */ - GPIO_PIN(PA, 2), - GPIO_PIN(PA, 6), - GPIO_PIN(PA, 5), - GPIO_PIN(PA, 4), - GPIO_PIN(PB, 9), - GPIO_PIN(PB, 8), - GPIO_PIN(PB, 7), - GPIO_PIN(PB, 6), - GPIO_PIN(PB, 5), - GPIO_PIN(PB, 4), - GPIO_PIN(PA, 7), - GPIO_PIN(PB, 3), - GPIO_PIN(PB, 2), - GPIO_PIN(PB, 1), - - /* 33-35 Other Analog + DAC */ - GPIO_PIN(PB, 0), - GPIO_PIN(PA, 3), - GPIO_PIN(PA, 2), - - /* 36..39 - SERCOM/UART (Serial1) */ - GPIO_PIN(PB, 30), - GPIO_PIN(PB, 31), - GPIO_PIN(PB, 22), - GPIO_PIN(PB, 23), - - /* 40..41 - I2C pins (SDA/SCL) */ - GPIO_PIN(PA, 12), - GPIO_PIN(PA, 13), - - /* 42..45 - SPI pins (ICSP: MISO, SS, MOSI, SCK) */ - GPIO_PIN(PA, 22), - GPIO_PIN(PA, 23), - GPIO_PIN(PA, 20), - GPIO_PIN(PA, 21), - - /* 46 - SD CARD CS */ - GPIO_PIN(PA, 27), - - /* 47..48 - USB */ - GPIO_PIN(PA, 24), - GPIO_PIN(PA, 25), - - /* 49..50 - Serial2 (alternative use for D6/D7) */ - GPIO_PIN(PB, 13), - GPIO_PIN(PB, 14), - - /* 51..52 - Serial3 (alternative use for D12/D13) */ - GPIO_PIN(PA, 17), - GPIO_PIN(PA, 18), - - /* 53..56 - SPI1 (alternative use for D5..D8) */ - GPIO_PIN(PB, 12), - GPIO_PIN(PB, 13), - GPIO_PIN(PB, 14), - GPIO_PIN(PB, 15), -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { - ADC_LINE(0), - ADC_LINE(1), - ADC_LINE(2), - ADC_LINE(3), - ADC_LINE(4), - ADC_LINE(5), - ADC_LINE(6), - ADC_LINE(7), - ADC_LINE(8), - ADC_LINE(9), - ADC_LINE(10), - ADC_LINE(11), - ADC_LINE(12), - ADC_LINE(13), - ADC_LINE(14), -}; - -/** - * @brief PWM frequency - */ -#define ARDUINO_PWM_FREQU (732U) - -/** - * @brief List of PWM GPIO mappings - */ -static const arduino_pwm_t arduino_pwm_list[] = { - { .pin = 20, .dev = PWM_DEV(0), .chan = 0 }, - { .pin = 29, .dev = PWM_DEV(0), .chan = 1 }, - { .pin = 11, .dev = PWM_DEV(1), .chan = 0 }, - { .pin = 13, .dev = PWM_DEV(1), .chan = 1 }, - { .pin = 14, .dev = PWM_DEV(1), .chan = 2 }, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/sodaq-autonomo/include/arduino_iomap.h b/boards/sodaq-autonomo/include/arduino_iomap.h new file mode 100644 index 0000000000000..b32b2b1804664 --- /dev/null +++ b/boards/sodaq-autonomo/include/arduino_iomap.h @@ -0,0 +1,197 @@ +/* + * Copyright (C) 2019 Kees Bakker + * + * 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_sodaq-autonomo + * @{ + * + * @file + * @brief Mapping from MCU pins to Arduino pins for the sodaq-autonomo + * + * @author Kees Bakker + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H + +#include "periph/adc.h" +#include "periph/gpio.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief The builtin LED + */ +#define ARDUINO_LED (13) + +/** + * @name Mapping of MCU pins to digital Arduino pins + * @{ + */ +/* D0..D1 - SERCOM/UART (Serial) */ +#define ARDUINO_PIN_0 GPIO_PIN(PA, 9) +#define ARDUINO_PIN_1 GPIO_PIN(PA, 10) + +/* D2..D15 - Digital */ +#define ARDUINO_PIN_2 GPIO_PIN(PA, 11) +#define ARDUINO_PIN_3 GPIO_PIN(PB, 10) +#define ARDUINO_PIN_4 GPIO_PIN(PB, 11) +#define ARDUINO_PIN_5 GPIO_PIN(PB, 12) +#define ARDUINO_PIN_6 GPIO_PIN(PB, 13) +#define ARDUINO_PIN_7 GPIO_PIN(PB, 14) +#define ARDUINO_PIN_8 GPIO_PIN(PB, 15) +#define ARDUINO_PIN_9 GPIO_PIN(PA, 14) +#define ARDUINO_PIN_10 GPIO_PIN(PA, 15) +#define ARDUINO_PIN_11 GPIO_PIN(PA, 16) +#define ARDUINO_PIN_12 GPIO_PIN(PA, 17) +#define ARDUINO_PIN_13 GPIO_PIN(PA, 18) +#define ARDUINO_PIN_14 GPIO_PIN(PA, 19) +#define ARDUINO_PIN_15 GPIO_PIN(PB, 16) + +/* D16..D18 - Other Digital */ +#define ARDUINO_PIN_16 GPIO_PIN(PA, 8) +#define ARDUINO_PIN_17 GPIO_PIN(PA, 28) +#define ARDUINO_PIN_18 GPIO_PIN(PB, 17) + +/* D19..D32 - A0..A13 */ +#define ARDUINO_PIN_19 GPIO_PIN(PA, 2) +#define ARDUINO_PIN_20 GPIO_PIN(PA, 6) +#define ARDUINO_PIN_21 GPIO_PIN(PA, 5) +#define ARDUINO_PIN_22 GPIO_PIN(PA, 4) +#define ARDUINO_PIN_23 GPIO_PIN(PB, 9) +#define ARDUINO_PIN_24 GPIO_PIN(PB, 8) +#define ARDUINO_PIN_25 GPIO_PIN(PB, 7) +#define ARDUINO_PIN_26 GPIO_PIN(PB, 6) +#define ARDUINO_PIN_27 GPIO_PIN(PB, 5) +#define ARDUINO_PIN_28 GPIO_PIN(PB, 4) +#define ARDUINO_PIN_29 GPIO_PIN(PA, 7) +#define ARDUINO_PIN_30 GPIO_PIN(PB, 3) +#define ARDUINO_PIN_31 GPIO_PIN(PB, 2) +#define ARDUINO_PIN_32 GPIO_PIN(PB, 1) + +/* D33..D35 - Other Analog + DAC */ +#define ARDUINO_PIN_33 GPIO_PIN(PB, 0) +#define ARDUINO_PIN_34 GPIO_PIN(PA, 3) +#define ARDUINO_PIN_35 GPIO_PIN(PA, 2) + +/* D36..D39 - SERCOM/UART (Serial1) */ +#define ARDUINO_PIN_36 GPIO_PIN(PB, 30) +#define ARDUINO_PIN_37 GPIO_PIN(PB, 31) +#define ARDUINO_PIN_38 GPIO_PIN(PB, 22) +#define ARDUINO_PIN_39 GPIO_PIN(PB, 23) + +/* D40..D41 - I2C pins (SDA/SCL) */ +#define ARDUINO_PIN_40 GPIO_PIN(PA, 12) +#define ARDUINO_PIN_41 GPIO_PIN(PA, 13) + +/* D42..D45 - SPI pins (ICSP: MISO, SS, MOSI, SCK) */ +#define ARDUINO_PIN_42 GPIO_PIN(PA, 22) +#define ARDUINO_PIN_43 GPIO_PIN(PA, 23) +#define ARDUINO_PIN_44 GPIO_PIN(PA, 20) +#define ARDUINO_PIN_45 GPIO_PIN(PA, 21) + +/* D46 - SD CARD CS */ +#define ARDUINO_PIN_46 GPIO_PIN(PA, 27) + +/* D47..D48 - USB */ +#define ARDUINO_PIN_47 GPIO_PIN(PA, 24) +#define ARDUINO_PIN_48 GPIO_PIN(PA, 25) + +/* D49..D50 - Serial2 (alternative use for D6/D7) */ +#define ARDUINO_PIN_49 GPIO_PIN(PB, 13) +#define ARDUINO_PIN_50 GPIO_PIN(PB, 14) + +/* D51..D52 - Serial3 (alternative use for D12/D13) */ +#define ARDUINO_PIN_51 GPIO_PIN(PA, 17) +#define ARDUINO_PIN_52 GPIO_PIN(PA, 18) + +/* D53..D56 - SPI1 (alternative use for D5..D8) */ +#define ARDUINO_PIN_53 GPIO_PIN(PB, 12) +#define ARDUINO_PIN_54 GPIO_PIN(PB, 13) +#define ARDUINO_PIN_55 GPIO_PIN(PB, 14) +#define ARDUINO_PIN_56 GPIO_PIN(PB, 15) + +#define ARDUINO_PIN_LAST 56 /**< D56 is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_19 +#define ARDUINO_PIN_A1 ARDUINO_PIN_20 +#define ARDUINO_PIN_A2 ARDUINO_PIN_21 +#define ARDUINO_PIN_A3 ARDUINO_PIN_22 +#define ARDUINO_PIN_A4 ARDUINO_PIN_23 +#define ARDUINO_PIN_A5 ARDUINO_PIN_24 +#define ARDUINO_PIN_A6 ARDUINO_PIN_25 +#define ARDUINO_PIN_A7 ARDUINO_PIN_26 +#define ARDUINO_PIN_A8 ARDUINO_PIN_27 +#define ARDUINO_PIN_A9 ARDUINO_PIN_28 +#define ARDUINO_PIN_A10 ARDUINO_PIN_29 +#define ARDUINO_PIN_A11 ARDUINO_PIN_30 +#define ARDUINO_PIN_A12 ARDUINO_PIN_31 +#define ARDUINO_PIN_A13 ARDUINO_PIN_32 +/** @} */ + +/** + * @name Analog pin to adc line mapping + * @{ + */ +#define ARDUINO_A0 ADC_LINE(0) +#define ARDUINO_A1 ADC_LINE(1) +#define ARDUINO_A2 ADC_LINE(2) +#define ARDUINO_A3 ADC_LINE(3) +#define ARDUINO_A4 ADC_LINE(4) +#define ARDUINO_A5 ADC_LINE(5) +#define ARDUINO_A6 ADC_LINE(6) +#define ARDUINO_A7 ADC_LINE(7) +#define ARDUINO_A8 ADC_LINE(8) +#define ARDUINO_A9 ADC_LINE(9) +#define ARDUINO_A10 ADC_LINE(10) +#define ARDUINO_A11 ADC_LINE(11) +#define ARDUINO_A12 ADC_LINE(12) +#define ARDUINO_A13 ADC_LINE(13) +#define ARDUINO_A14 ADC_LINE(14) + +#define ARDUINO_ANALOG_PIN_LAST 14 /**< A14 is the last analog pin */ +/** @} */ + +/** + * @name Mapping of Arduino pins to RIOT PWM dev and channel pairs + * @{ + */ +/** + * @brief PWM frequency + */ +#define ARDUINO_PWM_FREQU (732U) + +#define ARDUINO_PIN_20_PWM_DEV PWM_DEV(0) +#define ARDUINO_PIN_20_PWM_CHAN 0 + +#define ARDUINO_PIN_29_PWM_DEV PWM_DEV(0) +#define ARDUINO_PIN_29_PWM_CHAN 1 + +#define ARDUINO_PIN_11_PWM_DEV PWM_DEV(1) +#define ARDUINO_PIN_11_PWM_CHAN 0 + +#define ARDUINO_PIN_13_PWM_DEV PWM_DEV(1) +#define ARDUINO_PIN_13_PWM_CHAN 1 + +#define ARDUINO_PIN_14_PWM_DEV PWM_DEV(1) +#define ARDUINO_PIN_14_PWM_CHAN 2 +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/sodaq-explorer/include/arduino_board.h b/boards/sodaq-explorer/include/arduino_board.h deleted file mode 100644 index 8fe4a317cc0b8..0000000000000 --- a/boards/sodaq-explorer/include/arduino_board.h +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright (C) 2019 Kees Bakker - * - * 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_sodaq-explorer - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Kees Bakker - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "periph/gpio.h" -#include "periph/adc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The builtin LED - */ -#define ARDUINO_LED (13) - -/** - * @brief On-board serial port mapping - */ -#ifndef ARDUINO_UART_DEV -#define ARDUINO_UART_DEV UART_UNDEF -#endif - -/** - * @brief Look-up table for the Arduino's digital pins - */ -static const gpio_t arduino_pinmap[] = { - /* 0..1 - SERCOM/UART (Serial) */ - GPIO_PIN(PB, 31), - GPIO_PIN(PB, 30), - - /* 2..15 Digital */ - GPIO_PIN(PA, 2), - GPIO_PIN(PA, 3), - GPIO_PIN(PB, 4), - GPIO_PIN(PB, 6), - GPIO_PIN(PB, 7), - GPIO_PIN(PB, 8), - GPIO_PIN(PB, 10), - GPIO_PIN(PB, 11), - GPIO_PIN(PA, 23), - GPIO_PIN(PA, 20), - GPIO_PIN(PA, 22), - GPIO_PIN(PA, 21), - GPIO_PIN(PA, 10), - GPIO_PIN(PA, 11), - - /* 16..19 Other Digital */ - GPIO_PIN(PA, 12), - GPIO_PIN(PB, 15), - GPIO_PIN(PA, 13), - GPIO_PIN(PA, 15), - - /* 20..28 A0..A8 */ - GPIO_PIN(PB, 0), - GPIO_PIN(PB, 1), - GPIO_PIN(PB, 2), - GPIO_PIN(PB, 3), - GPIO_PIN(PA, 8), - GPIO_PIN(PA, 9), - GPIO_PIN(PA, 4), - GPIO_PIN(PA, 10), - GPIO_PIN(PA, 11), - - /* 29..30 - SERCOM/UART (Serial1) */ - GPIO_PIN(PB, 14), - GPIO_PIN(PB, 13), - - /* 31..32 - SERCOM/UART (Serial2) */ - GPIO_PIN(PA, 6), - GPIO_PIN(PA, 5), - - /* 33..34 - I2C pins (SDA/SCL) */ - GPIO_PIN(PA, 16), - GPIO_PIN(PA, 17), - - /* 35..36 - I2C1 pins (SDA/SCL) */ - GPIO_PIN(PA, 8), - GPIO_PIN(PA, 9), - - /* 37..40 - SPI pins (ICSP: MISO, SS, MOSI, SCK) */ - /* Notice that SCK is sharing the same PA21 with LED_BUILTIN */ - GPIO_PIN(PA, 22), - GPIO_PIN(PA, 23), - GPIO_PIN(PA, 20), - GPIO_PIN(PA, 21), - - /* 41..42 - USB */ - GPIO_PIN(PA, 24), - GPIO_PIN(PA, 25), - - /* 43 DAC */ - GPIO_PIN(PA, 2), - - /* 44 Flash CS */ - GPIO_PIN(PB, 16), - - /* 45..46 LoRa, BT Reset */ - GPIO_PIN(PA, 7), - GPIO_PIN(PB, 17), - - /* 47 Button */ - GPIO_PIN(PA, 14), - - /* 48 BAT_VOLT */ - GPIO_PIN(PB, 5), -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { - ADC_LINE(0), - ADC_LINE(1), - ADC_LINE(2), - ADC_LINE(3), - ADC_LINE(4), - ADC_LINE(5), - ADC_LINE(6), - ADC_LINE(7), - ADC_LINE(8), - ADC_LINE(9), -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/sodaq-explorer/include/arduino_iomap.h b/boards/sodaq-explorer/include/arduino_iomap.h new file mode 100644 index 0000000000000..682ea77a3dfa1 --- /dev/null +++ b/boards/sodaq-explorer/include/arduino_iomap.h @@ -0,0 +1,159 @@ +/* + * Copyright (C) 2019 Kees Bakker + * + * 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_sodaq-explorer + * @{ + * + * @file + * @brief Board specific configuration for the Arduino API + * + * @author Kees Bakker + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H + +#include "periph/adc.h" +#include "periph/gpio.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief The builtin LED + */ +#define ARDUINO_LED (13) + +/** + * @name Mapping of MCU pins to digital Arduino pins + * @{ + */ +/* D0..D1 - SERCOM/UART (Serial) */ +#define ARDUINO_PIN_0 GPIO_PIN(PB, 31) +#define ARDUINO_PIN_1 GPIO_PIN(PB, 30) + +/* D2..D15 - Digital */ +#define ARDUINO_PIN_2 GPIO_PIN(PA, 2) +#define ARDUINO_PIN_3 GPIO_PIN(PA, 3) +#define ARDUINO_PIN_4 GPIO_PIN(PB, 4) +#define ARDUINO_PIN_5 GPIO_PIN(PB, 6) +#define ARDUINO_PIN_6 GPIO_PIN(PB, 7) +#define ARDUINO_PIN_7 GPIO_PIN(PB, 8) +#define ARDUINO_PIN_8 GPIO_PIN(PB, 10) +#define ARDUINO_PIN_9 GPIO_PIN(PB, 11) +#define ARDUINO_PIN_10 GPIO_PIN(PA, 23) +#define ARDUINO_PIN_11 GPIO_PIN(PA, 20) +#define ARDUINO_PIN_12 GPIO_PIN(PA, 22) +#define ARDUINO_PIN_13 GPIO_PIN(PA, 21) +#define ARDUINO_PIN_14 GPIO_PIN(PA, 10) +#define ARDUINO_PIN_15 GPIO_PIN(PA, 11) + +/* D16..D19 - Other Digital */ +#define ARDUINO_PIN_16 GPIO_PIN(PA, 12) +#define ARDUINO_PIN_17 GPIO_PIN(PB, 15) +#define ARDUINO_PIN_18 GPIO_PIN(PA, 13) +#define ARDUINO_PIN_19 GPIO_PIN(PA, 15) + +/* D20..D28 - A0..A8 */ +#define ARDUINO_PIN_20 GPIO_PIN(PB, 0) +#define ARDUINO_PIN_21 GPIO_PIN(PB, 1) +#define ARDUINO_PIN_22 GPIO_PIN(PB, 2) +#define ARDUINO_PIN_23 GPIO_PIN(PB, 3) +#define ARDUINO_PIN_24 GPIO_PIN(PA, 8) +#define ARDUINO_PIN_25 GPIO_PIN(PA, 9) +#define ARDUINO_PIN_26 GPIO_PIN(PA, 4) +#define ARDUINO_PIN_27 GPIO_PIN(PA, 10) +#define ARDUINO_PIN_28 GPIO_PIN(PA, 11) + +/* D29..D30 - SERCOM/UART (Serial1) */ +#define ARDUINO_PIN_29 GPIO_PIN(PB, 14) +#define ARDUINO_PIN_30 GPIO_PIN(PB, 13) + +/* D31..D32 - SERCOM/UART (Serial2) */ +#define ARDUINO_PIN_31 GPIO_PIN(PA, 6) +#define ARDUINO_PIN_32 GPIO_PIN(PA, 5) + +/* D33..D34 - I2C pins (SDA/SCL) */ +#define ARDUINO_PIN_33 GPIO_PIN(PA, 16) +#define ARDUINO_PIN_34 GPIO_PIN(PA, 17) + +/* D35..D36 - I2C1 pins (SDA/SCL) */ +#define ARDUINO_PIN_35 GPIO_PIN(PA, 8) +#define ARDUINO_PIN_36 GPIO_PIN(PA, 9) + +/* D37..D40 - SPI pins (ICSP: MISO, SS, MOSI, SCK) */ +/* Notice that SCK is sharing the same PA21 with LED_BUILTIN */ +#define ARDUINO_PIN_37 GPIO_PIN(PA, 22) +#define ARDUINO_PIN_38 GPIO_PIN(PA, 23) +#define ARDUINO_PIN_39 GPIO_PIN(PA, 20) +#define ARDUINO_PIN_40 GPIO_PIN(PA, 21) + +/* D41..D42 - USB */ +#define ARDUINO_PIN_41 GPIO_PIN(PA, 24) +#define ARDUINO_PIN_42 GPIO_PIN(PA, 25) + +/* D43 - DAC */ +#define ARDUINO_PIN_43 GPIO_PIN(PA, 2) + +/* D44 - Flash CS */ +#define ARDUINO_PIN_44 GPIO_PIN(PB, 16) + +/* D45..D46 - LoRa, BT Reset */ +#define ARDUINO_PIN_45 GPIO_PIN(PA, 7) +#define ARDUINO_PIN_46 GPIO_PIN(PB, 17) + +/* D47 - Button */ +#define ARDUINO_PIN_47 GPIO_PIN(PA, 14) + +/* D48 - BAT_VOLT */ +#define ARDUINO_PIN_48 GPIO_PIN(PB, 5) + +#define ARDUINO_PIN_LAST 48 /**< D48 is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_20 +#define ARDUINO_PIN_A1 ARDUINO_PIN_21 +#define ARDUINO_PIN_A2 ARDUINO_PIN_22 +#define ARDUINO_PIN_A3 ARDUINO_PIN_23 +#define ARDUINO_PIN_A4 ARDUINO_PIN_24 +#define ARDUINO_PIN_A5 ARDUINO_PIN_25 +#define ARDUINO_PIN_A6 ARDUINO_PIN_26 +#define ARDUINO_PIN_A7 ARDUINO_PIN_27 +#define ARDUINO_PIN_A8 ARDUINO_PIN_28 +/** @} */ + +/** + * @name Analog pin to adc line mapping + * @{ + */ +#define ARDUINO_A0 ADC_LINE(0) +#define ARDUINO_A1 ADC_LINE(1) +#define ARDUINO_A2 ADC_LINE(2) +#define ARDUINO_A3 ADC_LINE(3) +#define ARDUINO_A4 ADC_LINE(4) +#define ARDUINO_A5 ADC_LINE(5) +#define ARDUINO_A6 ADC_LINE(6) +#define ARDUINO_A7 ADC_LINE(7) +#define ARDUINO_A8 ADC_LINE(8) +#define ARDUINO_A9 ADC_LINE(9) + +#define ARDUINO_ANALOG_PIN_LAST 9 /**< A9 is the last analog pin */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/sodaq-one/include/arduino_board.h b/boards/sodaq-one/include/arduino_board.h deleted file mode 100644 index 19f8597fbf5f6..0000000000000 --- a/boards/sodaq-one/include/arduino_board.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2019 Kees Bakker - * - * 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_sodaq-one - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Kees Bakker - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "periph/gpio.h" -#include "periph/adc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The green of the RGB led is used as "the builtin led" - */ -#define ARDUINO_LED (15) - -/** - * @brief On-board serial port mapping - */ -#ifndef ARDUINO_UART_DEV -#define ARDUINO_UART_DEV UART_UNDEF -#endif - -/** - * @brief Look-up table for the Arduino's digital pins - */ -static const gpio_t arduino_pinmap[] = { - /* 0..3 Main IO Pins (D0-D3) Digital Properties */ - GPIO_PIN(PA, 2), - GPIO_PIN(PA, 3), - GPIO_PIN(PB, 8), - GPIO_PIN(PB, 9), - - /* 4..5 Other Digital Pins */ - GPIO_PIN(PA, 21), - GPIO_PIN(PA, 20), - - /* 6..13 Main IO Pins (D6-D13) Digital Properties */ - GPIO_PIN(PA, 6), - GPIO_PIN(PA, 7), - GPIO_PIN(PA, 8), - GPIO_PIN(PA, 9), - GPIO_PIN(PA, 10), - GPIO_PIN(PA, 11), - GPIO_PIN(PB, 2), - GPIO_PIN(PB, 3), - - /* 14..21 Other Digital Pins */ - GPIO_PIN(PA, 15), - GPIO_PIN(PB, 10), - GPIO_PIN(PB, 11), - GPIO_PIN(PA, 14), - GPIO_PIN(PA, 18), - GPIO_PIN(PA, 16), - GPIO_PIN(PB, 22), - GPIO_PIN(PA, 17), - - /* 22..33 Main IO Pins Analog Properties */ - GPIO_PIN(PA, 2), - GPIO_PIN(PA, 3), - GPIO_PIN(PB, 8), - GPIO_PIN(PB, 9), - GPIO_PIN(PA, 6), - GPIO_PIN(PA, 7), - GPIO_PIN(PA, 8), - GPIO_PIN(PA, 9), - GPIO_PIN(PA, 10), - GPIO_PIN(PA, 11), - GPIO_PIN(PB, 2), - GPIO_PIN(PB, 3), - - /* 34..36 Other Analog Pins */ - GPIO_PIN(PA, 2), - GPIO_PIN(PA, 3), - GPIO_PIN(PA, 5), - - /* 37..38 USB Pins */ - GPIO_PIN(PA, 24), - GPIO_PIN(PA, 25), - - /* 39..40 Serial */ - GPIO_PIN(PB, 3), - GPIO_PIN(PB, 2), - - /* 41..42 Serial1 */ - GPIO_PIN(PA, 13), - GPIO_PIN(PA, 12), - - /* 43..46 SPI */ - GPIO_PIN(PA, 8), - GPIO_PIN(PA, 9), - GPIO_PIN(PA, 10), - GPIO_PIN(PA, 11), - - /* 47..48 I2C */ - GPIO_PIN(PA, 22), - GPIO_PIN(PA, 23), - - /* 49 LoRa RESET */ - GPIO_PIN(PA, 4), - - /* 50 MAG_INT */ - GPIO_PIN(PA, 19), -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { - ADC_LINE(0), - ADC_LINE(1), - ADC_LINE(2), - ADC_LINE(3), - ADC_LINE(4), - ADC_LINE(5), - ADC_LINE(6), - ADC_LINE(7), - ADC_LINE(8), - ADC_LINE(9), - ADC_LINE(10), -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/sodaq-one/include/arduino_iomap.h b/boards/sodaq-one/include/arduino_iomap.h new file mode 100644 index 0000000000000..5007d712ea5dc --- /dev/null +++ b/boards/sodaq-one/include/arduino_iomap.h @@ -0,0 +1,142 @@ +/* + * Copyright (C) 2019 Kees Bakker + * + * 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_sodaq-one + * @{ + * + * @file + * @brief Board specific configuration for the Arduino API + * + * @author Kees Bakker + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H + +#include "periph/adc.h" +#include "periph/gpio.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief The green of the RGB led is used as "the builtin led" + */ +#define ARDUINO_LED (15) + +/** + * @name Mapping of MCU pins to digital Arduino pins + * @{ + */ +/* D0..D3 - Main IO Pins Digital Properties */ +#define ARDUINO_PIN_0 GPIO_PIN(PA, 2) +#define ARDUINO_PIN_1 GPIO_PIN(PA, 3) +#define ARDUINO_PIN_2 GPIO_PIN(PB, 8) +#define ARDUINO_PIN_3 GPIO_PIN(PB, 9) + +/* D4..D5 - Other Digital Pins */ +#define ARDUINO_PIN_4 GPIO_PIN(PA, 21) +#define ARDUINO_PIN_5 GPIO_PIN(PA, 20) + +/* D6..D13 - Main IO Pins Digital Properties */ +#define ARDUINO_PIN_6 GPIO_PIN(PA, 6) +#define ARDUINO_PIN_7 GPIO_PIN(PA, 7) +#define ARDUINO_PIN_8 GPIO_PIN(PA, 8) +#define ARDUINO_PIN_9 GPIO_PIN(PA, 9) +#define ARDUINO_PIN_10 GPIO_PIN(PA, 10) +#define ARDUINO_PIN_11 GPIO_PIN(PA, 11) +#define ARDUINO_PIN_12 GPIO_PIN(PB, 2) +#define ARDUINO_PIN_13 GPIO_PIN(PB, 3) + +/* D14..D21 - Other Digital Pins */ +#define ARDUINO_PIN_14 GPIO_PIN(PA, 15) +#define ARDUINO_PIN_15 GPIO_PIN(PB, 10) +#define ARDUINO_PIN_16 GPIO_PIN(PB, 11) +#define ARDUINO_PIN_17 GPIO_PIN(PA, 14) +#define ARDUINO_PIN_18 GPIO_PIN(PA, 18) +#define ARDUINO_PIN_19 GPIO_PIN(PA, 16) +#define ARDUINO_PIN_20 GPIO_PIN(PB, 22) +#define ARDUINO_PIN_21 GPIO_PIN(PA, 17) + +/* D22..D33 - Main IO Pins Analog Properties */ +#define ARDUINO_PIN_22 GPIO_PIN(PA, 2) +#define ARDUINO_PIN_23 GPIO_PIN(PA, 3) +#define ARDUINO_PIN_24 GPIO_PIN(PB, 8) +#define ARDUINO_PIN_25 GPIO_PIN(PB, 9) +#define ARDUINO_PIN_26 GPIO_PIN(PA, 6) +#define ARDUINO_PIN_27 GPIO_PIN(PA, 7) +#define ARDUINO_PIN_28 GPIO_PIN(PA, 8) +#define ARDUINO_PIN_29 GPIO_PIN(PA, 9) +#define ARDUINO_PIN_30 GPIO_PIN(PA, 10) +#define ARDUINO_PIN_31 GPIO_PIN(PA, 11) +#define ARDUINO_PIN_32 GPIO_PIN(PB, 2) +#define ARDUINO_PIN_33 GPIO_PIN(PB, 3) + +/* D34..D36 - Other Analog Pins */ +#define ARDUINO_PIN_34 GPIO_PIN(PA, 2) +#define ARDUINO_PIN_35 GPIO_PIN(PA, 3) +#define ARDUINO_PIN_36 GPIO_PIN(PA, 5) + +/* D37..D38 - USB Pins */ +#define ARDUINO_PIN_37 GPIO_PIN(PA, 24) +#define ARDUINO_PIN_38 GPIO_PIN(PA, 25) + +/* D39..D40 - Serial */ +#define ARDUINO_PIN_39 GPIO_PIN(PB, 3) +#define ARDUINO_PIN_40 GPIO_PIN(PB, 2) + +/* D41..D42 - Serial1 */ +#define ARDUINO_PIN_41 GPIO_PIN(PA, 13) +#define ARDUINO_PIN_42 GPIO_PIN(PA, 12) + +/* D43..D46 - SPI */ +#define ARDUINO_PIN_43 GPIO_PIN(PA, 8) +#define ARDUINO_PIN_44 GPIO_PIN(PA, 9) +#define ARDUINO_PIN_45 GPIO_PIN(PA, 10) +#define ARDUINO_PIN_46 GPIO_PIN(PA, 11) + +/* D47..D48 - I2C */ +#define ARDUINO_PIN_47 GPIO_PIN(PA, 22) +#define ARDUINO_PIN_48 GPIO_PIN(PA, 23) + +/* D49 - LoRa RESET */ +#define ARDUINO_PIN_49 GPIO_PIN(PA, 4) + +/* D50 - MAG_INT */ +#define ARDUINO_PIN_50 GPIO_PIN(PA, 19) + +#define ARDUINO_PIN_LAST 50 /**< D50 is the last digital pin */ +/** @} */ + +/** + * @name Analog pin to adc line mapping + * @{ + */ +#define ARDUINO_A0 ADC_LINE(0) +#define ARDUINO_A1 ADC_LINE(1) +#define ARDUINO_A2 ADC_LINE(2) +#define ARDUINO_A3 ADC_LINE(3) +#define ARDUINO_A4 ADC_LINE(4) +#define ARDUINO_A5 ADC_LINE(5) +#define ARDUINO_A6 ADC_LINE(6) +#define ARDUINO_A7 ADC_LINE(7) +#define ARDUINO_A8 ADC_LINE(8) +#define ARDUINO_A9 ADC_LINE(9) +#define ARDUINO_A10 ADC_LINE(10) + +#define ARDUINO_ANALOG_PIN_LAST 10 /**< A10 is the last analog pin */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/sodaq-sara-aff/include/arduino_board.h b/boards/sodaq-sara-aff/include/arduino_board.h deleted file mode 100644 index b0a78981b18d4..0000000000000 --- a/boards/sodaq-sara-aff/include/arduino_board.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (C) 2019 Kees Bakker - * - * 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_sodaq-sara-aff - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Kees Bakker - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "periph/gpio.h" -#include "periph/adc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The green of the RGB led is used as "the builtin led" - */ -#define ARDUINO_LED (17) - -/** - * @brief On-board serial port mapping - */ -#ifndef ARDUINO_UART_DEV -#define ARDUINO_UART_DEV UART_UNDEF -#endif - -/** - * @brief Look-up table for the Arduino's digital pins - */ -static const gpio_t arduino_pinmap[] = { - /* 0..1 - SERCOM/UART (Serial) */ - GPIO_PIN(PB, 31), - GPIO_PIN(PB, 30), - - /* 2..15 Digital */ - GPIO_PIN(PA, 2), - GPIO_PIN(PA, 19), - GPIO_PIN(PB, 4), - GPIO_PIN(PB, 6), - GPIO_PIN(PB, 7), - GPIO_PIN(PB, 8), - GPIO_PIN(PB, 10), - GPIO_PIN(PB, 11), - GPIO_PIN(PA, 23), - GPIO_PIN(PA, 20), - GPIO_PIN(PA, 22), - GPIO_PIN(PA, 21), - GPIO_PIN(PA, 10), - GPIO_PIN(PA, 11), - - /* 16..18 RGB LED */ - GPIO_PIN(PA, 12), - GPIO_PIN(PB, 15), - GPIO_PIN(PA, 13), - - /* 19..25 On-board Peripheral Inputs */ - GPIO_PIN(PA, 14), - GPIO_PIN(PA, 15), - GPIO_PIN(PA, 18), - GPIO_PIN(PB, 16), - GPIO_PIN(PB, 22), - GPIO_PIN(PA, 4), - GPIO_PIN(PA, 7), - - /* 26..30 On-board Peripheral Outputs */ - GPIO_PIN(PA, 28), - GPIO_PIN(PA, 27), - GPIO_PIN(PB, 14), - GPIO_PIN(PB, 13), - GPIO_PIN(PB, 12), - - /* 31..36 A0..A5 */ - GPIO_PIN(PB, 0), - GPIO_PIN(PB, 1), - GPIO_PIN(PB, 2), - GPIO_PIN(PB, 3), - GPIO_PIN(PA, 8), - GPIO_PIN(PA, 9), - - /* 37..40 Other Analog Inputs */ - GPIO_PIN(PA, 10), - GPIO_PIN(PA, 11), - GPIO_PIN(PB, 5), - GPIO_PIN(PB, 9), - - /* 41..42 - SERCOM/UART (Serial1) */ - GPIO_PIN(PA, 6), - GPIO_PIN(PA, 5), - - /* 43..44 - I2C pins (SDA/SCL) */ - GPIO_PIN(PA, 16), - GPIO_PIN(PA, 17), - - /* 45..48 - SPI pins (ICSP: MISO, SS, MOSI, SCK) - * Notice that SCK is sharing the same PA21 with LED_BUILTIN - */ - GPIO_PIN(PA, 22), - GPIO_PIN(PA, 23), - GPIO_PIN(PA, 20), - GPIO_PIN(PA, 21), - - /* 49..50 - USB */ - GPIO_PIN(PA, 24), - GPIO_PIN(PA, 25), - - /* 51..52 - DAC, SARA_R4XX_TOGGLE */ - GPIO_PIN(PA, 2), - GPIO_PIN(PB, 17), - - /* 53..54 - I2C1 pins (SDA/SCL) */ - GPIO_PIN(PA, 8), - GPIO_PIN(PA, 9), -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { - ADC_LINE(0), - ADC_LINE(1), - ADC_LINE(2), - ADC_LINE(3), - ADC_LINE(4), - ADC_LINE(5), - ADC_LINE(6), - ADC_LINE(7), - ADC_LINE(8), -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/sodaq-sara-aff/include/arduino_iomap.h b/boards/sodaq-sara-aff/include/arduino_iomap.h new file mode 100644 index 0000000000000..3ea64b13ce82f --- /dev/null +++ b/boards/sodaq-sara-aff/include/arduino_iomap.h @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2019 Kees Bakker + * + * 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_sodaq-sara-aff + * @{ + * + * @file + * @brief Board specific configuration for the Arduino API + * + * @author Kees Bakker + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H + +#include "periph/adc.h" +#include "periph/gpio.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief The green of the RGB led is used as "the builtin led" + */ +#define ARDUINO_LED (17) + +/** + * @name Mapping of MCU pins to digital Arduino pins + * @{ + */ +/* D0..D1 - SERCOM/UART (Serial) */ +#define ARDUINO_PIN_0 GPIO_PIN(PB, 31) +#define ARDUINO_PIN_1 GPIO_PIN(PB, 30) + +/* D2..D15 - Digital */ +#define ARDUINO_PIN_2 GPIO_PIN(PA, 2) +#define ARDUINO_PIN_3 GPIO_PIN(PA, 19) +#define ARDUINO_PIN_4 GPIO_PIN(PB, 4) +#define ARDUINO_PIN_5 GPIO_PIN(PB, 6) +#define ARDUINO_PIN_6 GPIO_PIN(PB, 7) +#define ARDUINO_PIN_7 GPIO_PIN(PB, 8) +#define ARDUINO_PIN_8 GPIO_PIN(PB, 10) +#define ARDUINO_PIN_9 GPIO_PIN(PB, 11) +#define ARDUINO_PIN_10 GPIO_PIN(PA, 23) +#define ARDUINO_PIN_11 GPIO_PIN(PA, 20) +#define ARDUINO_PIN_12 GPIO_PIN(PA, 22) +#define ARDUINO_PIN_13 GPIO_PIN(PA, 21) +#define ARDUINO_PIN_14 GPIO_PIN(PA, 10) +#define ARDUINO_PIN_15 GPIO_PIN(PA, 11) + +/* D16..D18 - RGB LED */ +#define ARDUINO_PIN_16 GPIO_PIN(PA, 12) +#define ARDUINO_PIN_17 GPIO_PIN(PB, 15) +#define ARDUINO_PIN_18 GPIO_PIN(PA, 13) + +/* D19..D25 - On-board Peripheral Inputs */ +#define ARDUINO_PIN_19 GPIO_PIN(PA, 14) +#define ARDUINO_PIN_20 GPIO_PIN(PA, 15) +#define ARDUINO_PIN_21 GPIO_PIN(PA, 18) +#define ARDUINO_PIN_22 GPIO_PIN(PB, 16) +#define ARDUINO_PIN_23 GPIO_PIN(PB, 22) +#define ARDUINO_PIN_24 GPIO_PIN(PA, 4) +#define ARDUINO_PIN_25 GPIO_PIN(PA, 7) + +/* D26..D30 - On-board Peripheral Outputs */ +#define ARDUINO_PIN_26 GPIO_PIN(PA, 28) +#define ARDUINO_PIN_27 GPIO_PIN(PA, 27) +#define ARDUINO_PIN_28 GPIO_PIN(PB, 14) +#define ARDUINO_PIN_29 GPIO_PIN(PB, 13) +#define ARDUINO_PIN_30 GPIO_PIN(PB, 12) + +/* D31..D36 - A0..A5 */ +#define ARDUINO_PIN_31 GPIO_PIN(PB, 0) +#define ARDUINO_PIN_32 GPIO_PIN(PB, 1) +#define ARDUINO_PIN_33 GPIO_PIN(PB, 2) +#define ARDUINO_PIN_34 GPIO_PIN(PB, 3) +#define ARDUINO_PIN_35 GPIO_PIN(PA, 8) +#define ARDUINO_PIN_36 GPIO_PIN(PA, 9) + +/* D37..D40 - Other Analog Inputs */ +#define ARDUINO_PIN_37 GPIO_PIN(PA, 10) +#define ARDUINO_PIN_38 GPIO_PIN(PA, 11) +#define ARDUINO_PIN_39 GPIO_PIN(PB, 5) +#define ARDUINO_PIN_40 GPIO_PIN(PB, 9) + +/* D41..D42 - SERCOM/UART (Serial1) */ +#define ARDUINO_PIN_41 GPIO_PIN(PA, 6) +#define ARDUINO_PIN_42 GPIO_PIN(PA, 5) + +/* D43..D44 - I2C pins (SDA/SCL) */ +#define ARDUINO_PIN_43 GPIO_PIN(PA, 16) +#define ARDUINO_PIN_44 GPIO_PIN(PA, 17) + +/* D45..D48 - SPI pins (ICSP: MISO, SS, MOSI, SCK) + * Notice that SCK is sharing the same PA21 with LED_BUILTIN + */ +#define ARDUINO_PIN_45 GPIO_PIN(PA, 22) +#define ARDUINO_PIN_46 GPIO_PIN(PA, 23) +#define ARDUINO_PIN_47 GPIO_PIN(PA, 20) +#define ARDUINO_PIN_48 GPIO_PIN(PA, 21) + +/* D49..D50 - USB */ +#define ARDUINO_PIN_49 GPIO_PIN(PA, 24) +#define ARDUINO_PIN_50 GPIO_PIN(PA, 25) + +/* D51..D52 - DAC, SARA_R4XX_TOGGLE */ +#define ARDUINO_PIN_51 GPIO_PIN(PA, 2) +#define ARDUINO_PIN_52 GPIO_PIN(PB, 17) + +/* D53..D54 - I2C1 pins (SDA/SCL) */ +#define ARDUINO_PIN_53 GPIO_PIN(PA, 8) +#define ARDUINO_PIN_54 GPIO_PIN(PA, 9) + +#define ARDUINO_PIN_LAST 54 /**< D54 is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_31 +#define ARDUINO_PIN_A1 ARDUINO_PIN_32 +#define ARDUINO_PIN_A2 ARDUINO_PIN_33 +#define ARDUINO_PIN_A3 ARDUINO_PIN_34 +#define ARDUINO_PIN_A4 ARDUINO_PIN_35 +#define ARDUINO_PIN_A5 ARDUINO_PIN_36 +/** @} */ + +/** + * @name Analog pin to adc line mapping + * @{ + */ +#define ARDUINO_A0 ADC_LINE(0) +#define ARDUINO_A1 ADC_LINE(1) +#define ARDUINO_A2 ADC_LINE(2) +#define ARDUINO_A3 ADC_LINE(3) +#define ARDUINO_A4 ADC_LINE(4) +#define ARDUINO_A5 ADC_LINE(5) +#define ARDUINO_A6 ADC_LINE(6) +#define ARDUINO_A7 ADC_LINE(7) +#define ARDUINO_A8 ADC_LINE(8) + +#define ARDUINO_ANALOG_PIN_LAST 8 /**< A8 is the last analog pin */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/sodaq-sara-sff/include/arduino_board.h b/boards/sodaq-sara-sff/include/arduino_board.h deleted file mode 100644 index 84fae71689be7..0000000000000 --- a/boards/sodaq-sara-sff/include/arduino_board.h +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (C) 2020 Kees Bakker - * - * 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_sodaq-sara-sff - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Kees Bakker - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "periph/gpio.h" -#include "periph/adc.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The green of the RGB led is used as "the builtin led" - */ -#define ARDUINO_LED (15) - -/** - * @brief On-board serial port mapping - */ -#ifndef ARDUINO_UART_DEV -#define ARDUINO_UART_DEV UART_UNDEF -#endif - -/** - * @brief Look-up table for the Arduino's digital pins - */ -static const gpio_t arduino_pinmap[] = { - /* 0..3 Main IO Pins (D0-D3) Digital Properties */ - GPIO_PIN(PA, 2), - GPIO_PIN(PA, 3), - GPIO_PIN(PB, 8), - GPIO_PIN(PB, 9), - - /* 4..5 Other Digital Pins */ - GPIO_PIN(PA, 21), - GPIO_PIN(PA, 20), - - /* 6..13 Main IO Pins (D6-D13) Digital Properties */ - GPIO_PIN(PA, 6), - GPIO_PIN(PA, 7), - GPIO_PIN(PA, 8), - GPIO_PIN(PA, 9), - GPIO_PIN(PA, 10), - GPIO_PIN(PA, 11), - GPIO_PIN(PB, 2), - GPIO_PIN(PB, 3), - - /* 14..21 Other Digital Pins */ - GPIO_PIN(PA, 15), - GPIO_PIN(PB, 10), - GPIO_PIN(PB, 11), - GPIO_PIN(PA, 14), - GPIO_PIN(PA, 18), - GPIO_PIN(PA, 16), - GPIO_PIN(PB, 22), - GPIO_PIN(PA, 17), - - /* 22..33 Main IO Pins Analog Properties */ - GPIO_PIN(PA, 2), - GPIO_PIN(PA, 3), - GPIO_PIN(PB, 8), - GPIO_PIN(PB, 9), - GPIO_PIN(PA, 6), - GPIO_PIN(PA, 7), - GPIO_PIN(PA, 8), - GPIO_PIN(PA, 9), - GPIO_PIN(PA, 10), - GPIO_PIN(PA, 11), - GPIO_PIN(PB, 2), - GPIO_PIN(PB, 3), - - /* 34..36 Other Analog Pins */ - GPIO_PIN(PA, 2), - GPIO_PIN(PA, 3), - GPIO_PIN(PA, 5), - - /* 37..38 USB Pins */ - GPIO_PIN(PA, 24), - GPIO_PIN(PA, 25), - - /* 39..40 Serial */ - GPIO_PIN(PB, 3), - GPIO_PIN(PB, 2), - - /* 41..42 Serial1 */ - GPIO_PIN(PA, 13), - GPIO_PIN(PA, 12), - - /* 43..46 SPI */ - GPIO_PIN(PA, 8), - GPIO_PIN(PA, 9), - GPIO_PIN(PA, 10), - GPIO_PIN(PA, 11), - - /* 47..48 I2C */ - GPIO_PIN(PA, 22), - GPIO_PIN(PA, 23), - - /* 49 */ - GPIO_PIN(PA, 4), - - /* 50 MAG_INT */ - GPIO_PIN(PA, 19), - - /* 51 SARA_TX_ENABLE */ - GPIO_PIN(PA, 27), -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { - ADC_LINE(0), - ADC_LINE(1), - ADC_LINE(2), - ADC_LINE(3), - ADC_LINE(4), - ADC_LINE(5), - ADC_LINE(6), - ADC_LINE(7), - ADC_LINE(8), - ADC_LINE(9), - ADC_LINE(10), -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/sodaq-sara-sff/include/arduino_iomap.h b/boards/sodaq-sara-sff/include/arduino_iomap.h new file mode 100644 index 0000000000000..20103d4a29b26 --- /dev/null +++ b/boards/sodaq-sara-sff/include/arduino_iomap.h @@ -0,0 +1,145 @@ +/* + * Copyright (C) 2020 Kees Bakker + * + * 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_sodaq-sara-sff + * @{ + * + * @file + * @brief Board specific configuration for the Arduino API + * + * @author Kees Bakker + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H + +#include "periph/adc.h" +#include "periph/gpio.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief The green of the RGB led is used as "the builtin led" + */ +#define ARDUINO_LED (15) + +/** + * @name Mapping of MCU pins to digital Arduino pins + * @{ + */ +/* D0..D3 - Main IO Pins Digital Properties */ +#define ARDUINO_PIN_0 GPIO_PIN(PA, 2) +#define ARDUINO_PIN_1 GPIO_PIN(PA, 3) +#define ARDUINO_PIN_2 GPIO_PIN(PB, 8) +#define ARDUINO_PIN_3 GPIO_PIN(PB, 9) + +/* D4..D5 - Other Digital Pins */ +#define ARDUINO_PIN_4 GPIO_PIN(PA, 21) +#define ARDUINO_PIN_5 GPIO_PIN(PA, 20) + +/* D6..D13 - Main IO Pins Digital Properties */ +#define ARDUINO_PIN_6 GPIO_PIN(PA, 6) +#define ARDUINO_PIN_7 GPIO_PIN(PA, 7) +#define ARDUINO_PIN_8 GPIO_PIN(PA, 8) +#define ARDUINO_PIN_9 GPIO_PIN(PA, 9) +#define ARDUINO_PIN_10 GPIO_PIN(PA, 10) +#define ARDUINO_PIN_11 GPIO_PIN(PA, 11) +#define ARDUINO_PIN_12 GPIO_PIN(PB, 2) +#define ARDUINO_PIN_13 GPIO_PIN(PB, 3) + +/* D14..D21 - Other Digital Pins */ +#define ARDUINO_PIN_14 GPIO_PIN(PA, 15) +#define ARDUINO_PIN_15 GPIO_PIN(PB, 10) +#define ARDUINO_PIN_16 GPIO_PIN(PB, 11) +#define ARDUINO_PIN_17 GPIO_PIN(PA, 14) +#define ARDUINO_PIN_18 GPIO_PIN(PA, 18) +#define ARDUINO_PIN_19 GPIO_PIN(PA, 16) +#define ARDUINO_PIN_20 GPIO_PIN(PB, 22) +#define ARDUINO_PIN_21 GPIO_PIN(PA, 17) + +/* D22..D33 - Main IO Pins Analog Properties */ +#define ARDUINO_PIN_22 GPIO_PIN(PA, 2) +#define ARDUINO_PIN_23 GPIO_PIN(PA, 3) +#define ARDUINO_PIN_24 GPIO_PIN(PB, 8) +#define ARDUINO_PIN_25 GPIO_PIN(PB, 9) +#define ARDUINO_PIN_26 GPIO_PIN(PA, 6) +#define ARDUINO_PIN_27 GPIO_PIN(PA, 7) +#define ARDUINO_PIN_28 GPIO_PIN(PA, 8) +#define ARDUINO_PIN_29 GPIO_PIN(PA, 9) +#define ARDUINO_PIN_30 GPIO_PIN(PA, 10) +#define ARDUINO_PIN_31 GPIO_PIN(PA, 11) +#define ARDUINO_PIN_32 GPIO_PIN(PB, 2) +#define ARDUINO_PIN_33 GPIO_PIN(PB, 3) + +/* D34..D36 - Other Analog Pins */ +#define ARDUINO_PIN_34 GPIO_PIN(PA, 2) +#define ARDUINO_PIN_35 GPIO_PIN(PA, 3) +#define ARDUINO_PIN_36 GPIO_PIN(PA, 5) + +/* D37..D38 - USB Pins */ +#define ARDUINO_PIN_37 GPIO_PIN(PA, 24) +#define ARDUINO_PIN_38 GPIO_PIN(PA, 25) + +/* D39..D40 - Serial */ +#define ARDUINO_PIN_39 GPIO_PIN(PB, 3) +#define ARDUINO_PIN_40 GPIO_PIN(PB, 2) + +/* D41..D42 - Serial1 */ +#define ARDUINO_PIN_41 GPIO_PIN(PA, 13) +#define ARDUINO_PIN_42 GPIO_PIN(PA, 12) + +/* D43..D46 - SPI */ +#define ARDUINO_PIN_43 GPIO_PIN(PA, 8) +#define ARDUINO_PIN_44 GPIO_PIN(PA, 9) +#define ARDUINO_PIN_45 GPIO_PIN(PA, 10) +#define ARDUINO_PIN_46 GPIO_PIN(PA, 11) + +/* D47..D48 - I2C */ +#define ARDUINO_PIN_47 GPIO_PIN(PA, 22) +#define ARDUINO_PIN_48 GPIO_PIN(PA, 23) + +/* D49 */ +#define ARDUINO_PIN_49 GPIO_PIN(PA, 4) + +/* D50 - MAG_INT */ +#define ARDUINO_PIN_50 GPIO_PIN(PA, 19) + +/* D51 - SARA_TX_ENABLE */ +#define ARDUINO_PIN_51 GPIO_PIN(PA, 27) + +#define ARDUINO_PIN_LAST 51 /**< D51 is the last digital pin */ +/** @} */ + +/** + * @name Analog pin to adc line mapping + * @{ + */ +#define ARDUINO_A0 ADC_LINE(0) +#define ARDUINO_A1 ADC_LINE(1) +#define ARDUINO_A2 ADC_LINE(2) +#define ARDUINO_A3 ADC_LINE(3) +#define ARDUINO_A4 ADC_LINE(4) +#define ARDUINO_A5 ADC_LINE(5) +#define ARDUINO_A6 ADC_LINE(6) +#define ARDUINO_A7 ADC_LINE(7) +#define ARDUINO_A8 ADC_LINE(8) +#define ARDUINO_A9 ADC_LINE(9) +#define ARDUINO_A10 ADC_LINE(10) + +#define ARDUINO_ANALOG_PIN_LAST 10 /**< A10 is the last analog pin */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/stm32f4discovery/Kconfig b/boards/stm32f4discovery/Kconfig index ad6d78d76d7bd..0f8f388f355c3 100644 --- a/boards/stm32f4discovery/Kconfig +++ b/boards/stm32f4discovery/Kconfig @@ -26,7 +26,8 @@ config BOARD_STM32F4DISCOVERY select HAS_PERIPH_USBDEV # Various other features (if any) - select HAS_ARDUINO + select HAS_ARDUINO_ANALOG + select HAS_ARDUINO_PINS select HAS_TINYUSB_DEVICE select HAS_HIGHLEVEL_STDIO diff --git a/boards/stm32f4discovery/Makefile.features b/boards/stm32f4discovery/Makefile.features index 24ec337fec72e..a7969b60733bb 100644 --- a/boards/stm32f4discovery/Makefile.features +++ b/boards/stm32f4discovery/Makefile.features @@ -14,7 +14,8 @@ FEATURES_PROVIDED += periph_uart FEATURES_PROVIDED += periph_usbdev # Various other features (if any) -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_pins FEATURES_PROVIDED += tinyusb_device FEATURES_PROVIDED += highlevel_stdio diff --git a/boards/stm32f4discovery/include/arduino_board.h b/boards/stm32f4discovery/include/arduino_board.h deleted file mode 100644 index 1376f9bd9abf7..0000000000000 --- a/boards/stm32f4discovery/include/arduino_board.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (C) 2015 Freie Universität Berlin - * - * 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_stm32f4discovery - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Hauke Petersen - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_pinmap.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ARDUINO_LED (2) - -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, -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { - ARDUINO_A0, - ARDUINO_A1, - ARDUINO_A2, - ARDUINO_A3, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/stm32f4discovery/include/arduino_pinmap.h b/boards/stm32f4discovery/include/arduino_iomap.h similarity index 85% rename from boards/stm32f4discovery/include/arduino_pinmap.h rename to boards/stm32f4discovery/include/arduino_iomap.h index 40d0efbfbb1c0..6c134847f739a 100644 --- a/boards/stm32f4discovery/include/arduino_pinmap.h +++ b/boards/stm32f4discovery/include/arduino_iomap.h @@ -19,8 +19,8 @@ * @author Sebastian Meiling */ -#ifndef ARDUINO_PINMAP_H -#define ARDUINO_PINMAP_H +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H #include "periph/gpio.h" #include "periph/adc.h" @@ -41,6 +41,8 @@ extern "C" { #define ARDUINO_PIN_5 GPIO_PIN(PORT_A, 15) #define ARDUINO_PIN_6 GPIO_PIN(PORT_B, 1) #define ARDUINO_PIN_7 GPIO_PIN(PORT_B, 2) + +#define ARDUINO_PIN_LAST 7 /**< D7 is the last digital pin */ /** @} */ /** @@ -51,11 +53,13 @@ extern "C" { #define ARDUINO_A1 ADC_LINE(1) #define ARDUINO_A2 ADC_LINE(2) #define ARDUINO_A3 ADC_LINE(3) + +#define ARDUINO_ANALOG_PIN_LAST 3 /**< A3 is the last analog pin */ /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/stm32l496g-disco/Kconfig b/boards/stm32l496g-disco/Kconfig index cc5a452ffeca9..44f34f387bb90 100644 --- a/boards/stm32l496g-disco/Kconfig +++ b/boards/stm32l496g-disco/Kconfig @@ -30,7 +30,8 @@ config BOARD_STM32L496G_DISCO select HAS_PERIPH_USBDEV # Put other features for this board (in alphabetical order) - select HAS_ARDUINO + select HAS_ARDUINO_ANALOG + select HAS_ARDUINO_PINS select HAS_RIOTBOOT select HAS_TINYUSB_DEVICE diff --git a/boards/stm32l496g-disco/Makefile.features b/boards/stm32l496g-disco/Makefile.features index eaf67e7a6f440..45a92f47d7073 100644 --- a/boards/stm32l496g-disco/Makefile.features +++ b/boards/stm32l496g-disco/Makefile.features @@ -18,6 +18,7 @@ FEATURES_PROVIDED += periph_uart_hw_fc FEATURES_PROVIDED += periph_usbdev # Put other features for this board (in alphabetical order) -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_pins FEATURES_PROVIDED += riotboot FEATURES_PROVIDED += tinyusb_device diff --git a/boards/stm32l496g-disco/include/arduino_board.h b/boards/stm32l496g-disco/include/arduino_board.h deleted file mode 100644 index 299855dd09e5f..0000000000000 --- a/boards/stm32l496g-disco/include/arduino_board.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2017 Inria - * - * 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_stm32l496g-disco - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Alexandre Abadie - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_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_14, - ARDUINO_PIN_15, - 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_A0, - ARDUINO_A1, - ARDUINO_A2, - ARDUINO_A3, - ARDUINO_A4, - ARDUINO_A5, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/stm32l496g-disco/include/arduino_pinmap.h b/boards/stm32l496g-disco/include/arduino_iomap.h similarity index 63% rename from boards/stm32l496g-disco/include/arduino_pinmap.h rename to boards/stm32l496g-disco/include/arduino_iomap.h index 73632548dfa03..cdd743f369dd4 100644 --- a/boards/stm32l496g-disco/include/arduino_pinmap.h +++ b/boards/stm32l496g-disco/include/arduino_iomap.h @@ -16,8 +16,8 @@ * @author Gunar Schorcht */ -#ifndef ARDUINO_PINMAP_H -#define ARDUINO_PINMAP_H +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H #include "periph/gpio.h" #include "periph/adc.h" @@ -47,12 +47,26 @@ extern "C" { #define ARDUINO_PIN_14 GPIO_PIN(PORT_B, 7) #define ARDUINO_PIN_15 GPIO_PIN(PORT_B, 8) -#define ARDUINO_PIN_A0 GPIO_PIN(PORT_C, 4) -#define ARDUINO_PIN_A1 GPIO_PIN(PORT_C, 1) -#define ARDUINO_PIN_A2 GPIO_PIN(PORT_C, 3) -#define ARDUINO_PIN_A3 GPIO_PIN(PORT_F, 10) -#define ARDUINO_PIN_A4 GPIO_PIN(PORT_A, 1) -#define ARDUINO_PIN_A5 GPIO_PIN(PORT_C, 0) +/* analog pins as digital pin */ +#define ARDUINO_PIN_16 GPIO_PIN(PORT_C, 4) +#define ARDUINO_PIN_17 GPIO_PIN(PORT_C, 1) +#define ARDUINO_PIN_18 GPIO_PIN(PORT_C, 3) +#define ARDUINO_PIN_19 GPIO_PIN(PORT_F, 10) +#define ARDUINO_PIN_20 GPIO_PIN(PORT_A, 1) +#define ARDUINO_PIN_21 GPIO_PIN(PORT_C, 0) + +#define ARDUINO_PIN_LAST 19 /**< D19 (A5) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_16 /**< Arduino pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_17 /**< Arduino pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_18 /**< Arduino pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_19 /**< Arduino pin A3 */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_20 /**< Arduino pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_21 /**< Arduino pin A5 */ /** @} */ /** @@ -65,11 +79,13 @@ extern "C" { #define ARDUINO_A3 ADC_LINE(3) #define ARDUINO_A4 ADC_LINE(4) #define ARDUINO_A5 ADC_LINE(5) + +#define ARDUINO_ANALOG_PIN_LAST 5 /**< A5 is the last analog pin */ /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/ublox-c030-u201/include/arduino_pinmap.h b/boards/ublox-c030-u201/include/arduino_iomap.h similarity index 64% rename from boards/ublox-c030-u201/include/arduino_pinmap.h rename to boards/ublox-c030-u201/include/arduino_iomap.h index a272a63798426..03252a3ca1a76 100644 --- a/boards/ublox-c030-u201/include/arduino_pinmap.h +++ b/boards/ublox-c030-u201/include/arduino_iomap.h @@ -19,8 +19,8 @@ * @author Vincent Dupont */ -#ifndef ARDUINO_PINMAP_H -#define ARDUINO_PINMAP_H +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H #include "periph/gpio.h" #include "periph/adc.h" @@ -52,12 +52,26 @@ extern "C" { #define ARDUINO_PIN_14 GPIO_PIN(PORT_B, 7) #define ARDUINO_PIN_15 GPIO_PIN(PORT_B, 6) -#define ARDUINO_PIN_A0 GPIO_PIN(PORT_A, 3) -#define ARDUINO_PIN_A1 GPIO_PIN(PORT_C, 0) -#define ARDUINO_PIN_A2 GPIO_PIN(PORT_C, 3) -#define ARDUINO_PIN_A3 GPIO_PIN(PORT_A, 4) -#define ARDUINO_PIN_A4 GPIO_PIN(PORT_B, 7) -#define ARDUINO_PIN_A5 GPIO_PIN(PORT_B, 6) +#define ARDUINO_PIN_16 GPIO_PIN(PORT_A, 3) +#define ARDUINO_PIN_17 GPIO_PIN(PORT_C, 0) +#define ARDUINO_PIN_18 GPIO_PIN(PORT_C, 3) +#define ARDUINO_PIN_19 GPIO_PIN(PORT_A, 4) +#define ARDUINO_PIN_20 GPIO_PIN(PORT_B, 7) +#define ARDUINO_PIN_21 GPIO_PIN(PORT_B, 6) + +#define ARDUINO_PIN_LAST 21 /**< D21 (A5) is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_16 /**< Arduino Uno pin A0 */ +#define ARDUINO_PIN_A1 ARDUINO_PIN_17 /**< Arduino Uno pin A1 */ +#define ARDUINO_PIN_A2 ARDUINO_PIN_18 /**< Arduino Uno pin A2 */ +#define ARDUINO_PIN_A3 ARDUINO_PIN_19 /**< Arduino Uno pin A3 */ + +#define ARDUINO_PIN_A4 ARDUINO_PIN_20 /**< Arduino Uno pin A4 */ +#define ARDUINO_PIN_A5 ARDUINO_PIN_21 /**< Arduino Uno pin A5 */ /** @} */ /** @@ -70,11 +84,13 @@ extern "C" { #define ARDUINO_A3 ADC_LINE(3) #define ARDUINO_A4 ADC_LINE(4) #define ARDUINO_A5 ADC_LINE(5) + +#define ARDUINO_ANALOG_PIN_LAST 5 /**< A5 is the last analog pin */ /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/waspmote-pro/Kconfig b/boards/waspmote-pro/Kconfig index 86b67817e15fe..29607765243df 100644 --- a/boards/waspmote-pro/Kconfig +++ b/boards/waspmote-pro/Kconfig @@ -11,7 +11,8 @@ config BOARD_WASPMOTE_PRO bool default y select CPU_MODEL_ATMEGA1281 - select HAS_ARDUINO + select HAS_ARDUINO_ANALOG + select HAS_ARDUINO_PINS select HAS_PERIPH_ADC select HAS_PERIPH_I2C select HAS_PERIPH_SPI diff --git a/boards/waspmote-pro/Makefile.features b/boards/waspmote-pro/Makefile.features index f36b5252083b3..20b497f9e46c9 100644 --- a/boards/waspmote-pro/Makefile.features +++ b/boards/waspmote-pro/Makefile.features @@ -9,4 +9,5 @@ FEATURES_PROVIDED += periph_uart FEATURES_PROVIDED += sdcard_spi # Various other features (if any) -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_pins diff --git a/boards/waspmote-pro/include/arduino_board.h b/boards/waspmote-pro/include/arduino_board.h deleted file mode 100644 index 24ad73b8052e2..0000000000000 --- a/boards/waspmote-pro/include/arduino_board.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) 2020 J. David Ibáñez - * - * 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_waspmote-pro - * @{ - * - * @file - * @brief Configuration of the Arduino API for Waspmote Pro board - * - * @author J. David Ibáñez - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_pinmap.h" -#include "periph/pwm.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The on-board LED is connected to pin 13 on this board - * - * The waspmote-pro board has 2 programmable LEDs: green connected to pin 13 - * (aka LED1), and red connected to pin 12 (aka LED0). - */ -#define ARDUINO_LED (13) - -/** - * @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_14, - ARDUINO_PIN_15, - ARDUINO_PIN_16, - ARDUINO_PIN_17, - ARDUINO_PIN_18, - ARDUINO_PIN_19, - ARDUINO_PIN_20, - ARDUINO_PIN_21, - ARDUINO_PIN_22, - ARDUINO_PIN_23, - ARDUINO_PIN_24, - ARDUINO_PIN_25, - ARDUINO_PIN_26, - ARDUINO_PIN_27, - ARDUINO_PIN_28, - ARDUINO_PIN_29, - ARDUINO_PIN_30, - ARDUINO_PIN_31, - ARDUINO_PIN_32, - ARDUINO_PIN_33, - ARDUINO_PIN_34, - ARDUINO_PIN_35, - ARDUINO_PIN_36, - ARDUINO_PIN_37, - ARDUINO_PIN_38, - ARDUINO_PIN_39, - ARDUINO_PIN_40, - ARDUINO_PIN_41, - ARDUINO_PIN_42, - ARDUINO_PIN_43, - ARDUINO_PIN_44, - ARDUINO_PIN_45, - ARDUINO_PIN_46, - ARDUINO_PIN_47, - ARDUINO_PIN_48, - ARDUINO_PIN_49, - ARDUINO_PIN_50, - ARDUINO_PIN_51, - ARDUINO_PIN_52, -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { - ARDUINO_A0, - ARDUINO_A1, - ARDUINO_A2, - ARDUINO_A3, - ARDUINO_A4, - ARDUINO_A5, - ARDUINO_A6, - ARDUINO_A7, -}; - -/** - * @brief PWM frequency - */ -#define ARDUINO_PWM_FREQU (490U) - -/** - * @brief List of PWM GPIO mappings - */ -static const arduino_pwm_t arduino_pwm_list[] = { -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/waspmote-pro/include/arduino_pinmap.h b/boards/waspmote-pro/include/arduino_iomap.h similarity index 91% rename from boards/waspmote-pro/include/arduino_pinmap.h rename to boards/waspmote-pro/include/arduino_iomap.h index dfc283f12d1d5..eae69243d8b68 100644 --- a/boards/waspmote-pro/include/arduino_pinmap.h +++ b/boards/waspmote-pro/include/arduino_iomap.h @@ -19,8 +19,8 @@ * @author J. David Ibáñez */ -#ifndef ARDUINO_PINMAP_H -#define ARDUINO_PINMAP_H +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H #include "periph/gpio.h" #include "periph/adc.h" @@ -30,12 +30,11 @@ extern "C" { #endif /** - * @name Mapping of MCU pins to Arduino pins + * @name Mapping of MCU pins to digital Arduino pins * * @note ISCP pins are not mapped. * @{ */ - #define ARDUINO_PIN_0 GPIO_PIN(PORT_E, 0) #define ARDUINO_PIN_1 GPIO_PIN(PORT_E, 1) #define ARDUINO_PIN_2 GPIO_PIN(PORT_E, 3) @@ -89,6 +88,14 @@ extern "C" { #define ARDUINO_PIN_50 GPIO_PIN(PORT_G, 0) #define ARDUINO_PIN_51 GPIO_PIN(PORT_G, 3) #define ARDUINO_PIN_52 GPIO_PIN(PORT_G, 4) + +#define ARDUINO_PIN_LAST 52 /**< D52 is the last digital pin */ +/** @} */ + +/** + * @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 @@ -97,7 +104,12 @@ extern "C" { #define ARDUINO_PIN_A5 ARDUINO_PIN_19 #define ARDUINO_PIN_A6 ARDUINO_PIN_20 #define ARDUINO_PIN_A7 ARDUINO_PIN_21 +/** @} */ +/** + * @name Analog pin to adc line mapping + * @{ + */ #define ARDUINO_A0 ADC_LINE(0) #define ARDUINO_A1 ADC_LINE(1) #define ARDUINO_A2 ADC_LINE(2) @@ -106,11 +118,12 @@ extern "C" { #define ARDUINO_A5 ADC_LINE(5) #define ARDUINO_A6 ADC_LINE(6) #define ARDUINO_A7 ADC_LINE(7) +#define ARDUINO_ANALOG_PIN_LAST 7 /**< A7 is the last analog pin */ /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/waveshare-nrf52840-eval-kit/Kconfig b/boards/waveshare-nrf52840-eval-kit/Kconfig index 840e41168845f..a238d61c83aeb 100644 --- a/boards/waveshare-nrf52840-eval-kit/Kconfig +++ b/boards/waveshare-nrf52840-eval-kit/Kconfig @@ -12,8 +12,10 @@ config BOARD_WAVESHARE_NRF52840_EVAL_KIT default y select BOARD_COMMON_NRF52 select CPU_MODEL_NRF52840XXAA - select HAS_ARDUINO + select HAS_ARDUINO_ANALOG + select HAS_ARDUINO_PINS select HAS_ARDUINO_PWM + select HAS_ARDUINO_SHIELD_UNO select HAS_PERIPH_I2C select HAS_PERIPH_PWM select HAS_PERIPH_SPI diff --git a/boards/waveshare-nrf52840-eval-kit/Makefile.features b/boards/waveshare-nrf52840-eval-kit/Makefile.features index 0b795a74b5a3d..81e7e7f8d4f65 100644 --- a/boards/waveshare-nrf52840-eval-kit/Makefile.features +++ b/boards/waveshare-nrf52840-eval-kit/Makefile.features @@ -10,7 +10,9 @@ FEATURES_PROVIDED += periph_uart FEATURES_PROVIDED += periph_usbdev # Other features -FEATURES_PROVIDED += arduino +FEATURES_PROVIDED += arduino_analog +FEATURES_PROVIDED += arduino_pins FEATURES_PROVIDED += arduino_pwm -FEATURES_PROVIDED += tinyusb_device +FEATURES_PROVIDED += arduino_shield_uno FEATURES_PROVIDED += sdcard_spi +FEATURES_PROVIDED += tinyusb_device diff --git a/boards/waveshare-nrf52840-eval-kit/include/arduino_board.h b/boards/waveshare-nrf52840-eval-kit/include/arduino_board.h deleted file mode 100644 index a5d404a8c259c..0000000000000 --- a/boards/waveshare-nrf52840-eval-kit/include/arduino_board.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (C) 2016 Freie Universität Berlin - * 2016 Inria - * 2020 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_waveshare_nrf52840_eval_kit - * @{ - * - * @file - * @brief Board specific configuration for the Arduino API - * - * @author Hauke Petersen - * @author Alexandre Abadie - * @author Gunar Schorcht - */ - -#ifndef ARDUINO_BOARD_H -#define ARDUINO_BOARD_H - -#include "arduino_pinmap.h" -#include "periph/pwm.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief The on-board LED is connected to Arduino pin 20 on this board - */ -#define ARDUINO_LED (20) - -/** - * @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, - ARDUINO_PIN_20, - ARDUINO_PIN_21, - ARDUINO_PIN_22, - ARDUINO_PIN_23 -}; - -/** - * @brief Look-up table for the Arduino's analog pins - */ -static const adc_t arduino_analog_map[] = { - ARDUINO_A0, - ARDUINO_A1, - ARDUINO_A2, - ARDUINO_A3, - ARDUINO_A4, - ARDUINO_A5, -}; - -/** - * @brief PWM frequency - */ -#define ARDUINO_PWM_FREQU (15625U) - -/** - * @brief List of PWM GPIO mappings - */ -static const arduino_pwm_t arduino_pwm_list[] = { - { .pin = 3, .dev = PWM_DEV(0), .chan = 0 }, - { .pin = 5, .dev = PWM_DEV(0), .chan = 1 }, - { .pin = 6, .dev = PWM_DEV(0), .chan = 2 }, - { .pin = 9, .dev = PWM_DEV(0), .chan = 3 }, - { .pin = 20, .dev = PWM_DEV(1), .chan = 0 }, - { .pin = 21, .dev = PWM_DEV(1), .chan = 1 }, - { .pin = 22, .dev = PWM_DEV(1), .chan = 2 }, - { .pin = 23, .dev = PWM_DEV(1), .chan = 3 }, -}; - -#ifdef __cplusplus -} -#endif - -#endif /* ARDUINO_BOARD_H */ -/** @} */ diff --git a/boards/waveshare-nrf52840-eval-kit/include/arduino_pinmap.h b/boards/waveshare-nrf52840-eval-kit/include/arduino_iomap.h similarity index 51% rename from boards/waveshare-nrf52840-eval-kit/include/arduino_pinmap.h rename to boards/waveshare-nrf52840-eval-kit/include/arduino_iomap.h index bfb0056861669..4df1797ffff51 100644 --- a/boards/waveshare-nrf52840-eval-kit/include/arduino_pinmap.h +++ b/boards/waveshare-nrf52840-eval-kit/include/arduino_iomap.h @@ -19,8 +19,8 @@ * @author Gunar Schorcht */ -#ifndef ARDUINO_PINMAP_H -#define ARDUINO_PINMAP_H +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H #include "periph/gpio.h" #include "periph/adc.h" @@ -47,16 +47,29 @@ extern "C" { #define ARDUINO_PIN_11 GPIO_PIN(1, 13) #define ARDUINO_PIN_12 GPIO_PIN(1, 14) #define ARDUINO_PIN_13 GPIO_PIN(1, 15) -#define ARDUINO_PIN_A0 GPIO_PIN(0, 3) -#define ARDUINO_PIN_A1 GPIO_PIN(0, 4) -#define ARDUINO_PIN_A2 GPIO_PIN(0, 28) -#define ARDUINO_PIN_A3 GPIO_PIN(0, 29) -#define ARDUINO_PIN_A4 GPIO_PIN(0, 30) -#define ARDUINO_PIN_A5 GPIO_PIN(0, 31) +#define ARDUINO_PIN_14 GPIO_PIN(0, 3) +#define ARDUINO_PIN_15 GPIO_PIN(0, 4) +#define ARDUINO_PIN_16 GPIO_PIN(0, 28) +#define ARDUINO_PIN_17 GPIO_PIN(0, 29) +#define ARDUINO_PIN_18 GPIO_PIN(0, 30) +#define ARDUINO_PIN_19 GPIO_PIN(0, 31) #define ARDUINO_PIN_20 GPIO_PIN(0, 13) #define ARDUINO_PIN_21 GPIO_PIN(0, 14) #define ARDUINO_PIN_22 GPIO_PIN(1, 9) #define ARDUINO_PIN_23 GPIO_PIN(0, 16) + +#define ARDUINO_PIN_LAST 23 /**< D23 is the last digital pin */ +/** @} */ + +/** + * @name Aliases for analog pins + */ +#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 */ /** @} */ /** @@ -69,11 +82,47 @@ extern "C" { #define ARDUINO_A3 ADC_LINE(5) #define ARDUINO_A4 ADC_LINE(6) #define ARDUINO_A5 ADC_LINE(7) + +#define ARDUINO_ANALOG_PIN_LAST 5 /**< A5 is the last analog pin */ +/** @} */ + +/** + * @name Mapping of Arduino pins to RIOT PWM dev and channel pairs + * @{ + */ +/** + * @brief PWM frequency + */ +#define ARDUINO_PWM_FREQU (15625U) + +#define ARDUINO_PIN_3_PWM_DEV PWM_DEV(0) +#define ARDUINO_PIN_3_PWM_CHAN 0 + +#define ARDUINO_PIN_5_PWM_DEV PWM_DEV(0) +#define ARDUINO_PIN_5_PWM_CHAN 1 + +#define ARDUINO_PIN_6_PWM_DEV PWM_DEV(0) +#define ARDUINO_PIN_6_PWM_CHAN 2 + +#define ARDUINO_PIN_9_PWM_DEV PWM_DEV(0) +#define ARDUINO_PIN_9_PWM_CHAN 3 + +#define ARDUINO_PIN_20_PWM_DEV PWM_DEV(1) +#define ARDUINO_PIN_20_PWM_CHAN 0 + +#define ARDUINO_PIN_21_PWM_DEV PWM_DEV(1) +#define ARDUINO_PIN_21_PWM_CHAN 1 + +#define ARDUINO_PIN_22_PWM_DEV PWM_DEV(1) +#define ARDUINO_PIN_22_PWM_CHAN 2 + +#define ARDUINO_PIN_23_PWM_DEV PWM_DEV(1) +#define ARDUINO_PIN_23_PWM_CHAN 3 /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/doc/doxygen/riot.doxyfile b/doc/doxygen/riot.doxyfile index 0a8821f41bbd9..f47934aa285a8 100644 --- a/doc/doxygen/riot.doxyfile +++ b/doc/doxygen/riot.doxyfile @@ -775,6 +775,7 @@ INPUT = ../../doc.txt \ src/debugging-aids.md \ src/emulators.md \ src/release-cycle.md \ + src/io-mapping-and-shields.md \ src/changelog.md \ ../../LOSTANDFOUND.md \ ../../makefiles/pseudomodules.inc.mk \ diff --git a/doc/doxygen/src/io-mapping-and-shields.md b/doc/doxygen/src/io-mapping-and-shields.md new file mode 100644 index 0000000000000..10f0b23b06563 --- /dev/null +++ b/doc/doxygen/src/io-mapping-and-shields.md @@ -0,0 +1,162 @@ +IO-Mapping and Shields {#iomaps} +====================== + +[TOC] + +Introduction {#iomaps-intro} +============ + +Arduino has popularized the concept of adding an abstraction layer over the +MCU GPIOs and ADC multiplexer as "Digital Pins" and "Analog Pins". For historic +reasons as well as to express appreciation for the introduction of concept, we +prefix features and macros that map board pins to MCU pins with `ARDUINO`. + +@note This means, we also explicitly use the Arduino feature for boards that + are neither official Arduino products nor compatible. + +I/O Mappings {#iomaps-mapping} +============ + +All I/O mappings are provided by the `arduino_iomap.h` header file. This is +provided either by the board directly (e.g. in +`/board//include/arduino_iomap.h`) or by the board +family (e.g. in `board/common//include/arduino_iomap.h`). + +To add support to new boards, start by copy-pasting the `arduino_iomap.h` from +an existing board and adapt/extend the macros as needed. Finally, add the +features to the `Makefile.features` and `KConfig` files of the board that +indicate the presence of the added mappings. + +Digital Pins {#iomaps-mapping-gpio} +------------ + +The feature `arduino_pins` is provided by boards that do have a mapping to +digital pins. The GPIO for e.g. `D3` is provided as `ARDUINO_PIN_3`. The +number of the highest digital pin is provided as `ARDUINO_PIN_LAST`. E.g. if +`ARDUINO_PIN_LAST` is 42, digital pins `D0` to `D42` are typically provided. + +@warning Some boards do have "gaps" in the pin mapping. It could be that + e.g. `ARDUINO_PIN_5` is defined, but `ARDUINO_PIN_4` is not. + +@note Often aliases are provided for analog pins in digital mode. E.g. + to use the pin `A3` as digital pin, `ARDUINO_PIN_A3` can be used + to avoid looking up what digital number that pin has. + +Analog Pins {#iomaps-mapping-adc} +----------- + +The feature `arduino_analog` is provided by boards that do have a mapping of +ADC lines to analog pins. E.g. the ADC line corresponding to pin `A5` would +be `ARDUINO_A5`. The number of the highest analog pin is provided as +`ARDUINO_ANALOG_PIN_LAST`. The macro `ARDUINO_ANALOG_PIN_LAST` is defined if +and only if a mapping is provided (so it can be used to test for this feature). + +@warning Some boards do have "gaps" in the analog pin mapping. It could be + that e.g. `ARDUINO_A3` is defined, but `ARDUINO_A2` is not. + +DAC Pins {#iomaps-mapping-dac} +-------- + +The feature `arduino_dac` is provided by boards that do have a mapping of +DAC pins to DAC lines. E.g. the DAC line for the pin DAC1 would be +`ARDUINO_DAC1`. The number of the highest DAC pin is provided as +`ARDUINO_DAC_PIN_LAST`. The macro `ARDUINO_DAC_PIN_LAST` is defined if +and only if a mapping is provided (so it can be used to test for this feature). + +@warning Some boards do have "gaps" in the analog pin mapping. It could be + that e.g. `ARDUINO_DAC4` is defined, but `ARDUINO_DAC3` is not. + +PWM Pins {#iomaps-mapping-pwm} +-------- + +The feature `arduino_pwm` is provided by boards that do have a mapping of +digital pins to PWM settings. E.g. the PWM device connected to the digital pin +`D11` would be `ARDUINO_PIN_11_PWM_DEV` and the channel would be +`ARDUINO_PIN_11_PWM_CHAN`. A PWM frequency for all PWM pins is defined as +`ARDUINO_PWM_FREQU`. + +@warning Typically only few digital pins support PWM. For pins without PWM + output no `ARDUINO_PIN__PWM_DEV` macro and no + `ARDUINO_PIN__PWM_DEV` is defined. + +UART Device {#iomaps-mapping-uart} +----------- + +The feature `arduino_uart` is provided by boards that do provide an UART device +mapping. For the official Arduino boards and compatible boards, the +`ARDUINO_UART_D0D1` macro refers to the UART device that uses the digital pins +`D0` and `D1`. + +Please extend the table below to keep naming among boards of the same form +factor consistent: + +| Form Factor | Macro Name | Description | +|:------------- |:--------------------- |:--------------------------------- | +| Arduino Nano | `ARDUINO_UART_D0D1` | UART on D0 (RXD) and D1 (TXD) | +| Arduino Uno | `ARDUINO_UART_D0D1` | UART on D0 (RXD) and D1 (TXD) | +| Arduino Mega | `ARDUINO_UART_D0D1` | UART on D0 (RXD) and D1 (TXD) | + +I²C Buses {#iomaps-mapping-i2c} +--------- + +The feature `arduino_i2c` is provided by boards that do provide an I²C bus +mapping. + +| Form Factor | Macro Name | Description | +|:------------- |:--------------------- |:--------------------------------- | +| Arduino Nano | `ARDUINO_I2C_NANO` | D18 (SDA) / D19 (SCL) | +| Arduino Uno | `ARDUINO_I2C_UNO` | D18 (SDA) / D19 (SCL) | +| Arduino Mega | `ARDUINO_I2C_UNO` | D20 (SDA) / D21 (SCL) | +| Arduino Zero | `ARDUINO_I2C_UNO` | D20 (SDA) / D21 (SCL) | +| Arduino Due | `ARDUINO_I2C_UNO` | D70 (SDA) / D71 (SCL) | + +The `ARDUINO_I2C_UNO` refers to the I²C bus next to the AREF pin (the topmost +pins on header on the top right) of an Arduino Uno compatible board, e.g. +such as the Arduino Mega2560. Even though the Arduino UNO, the Arduino MEGA2560, +the Arduino Zero and the Arduino Zero all having the I²C bus at the exact same +mechanical positions, the digital pin number of the I²C bus next to the AREF +differs between the versions. + +SPI Buses {#iomaps-mapping-spi} +--------- + +The feature `arduino_spi` is provided by boards that do provide an SPI bus +mapping. + +| Form Factor | Macro Name | Description | +|:------------- |:------------------------- |:------------------------------------- | +| Arduino Nano | `ARDUINO_SPI_ISP` | The SPI on the ISP header | +| Arduino Nano | `ARDUINO_SPI_D11D12D13` | D11 (MOSI) / D12 (MISO) / D13 (SCK) | +| Arduino Uno | `ARDUINO_SPI_ISP` | The SPI on the ISP header | +| Arduino Uno | `ARDUINO_SPI_D11D12D13` | D11 (MOSI) / D12 (MISO) / D13 (SCK) | +| Arduino Mega | `ARDUINO_SPI_ISP` | The SPI on the ISP header | +| Arduino Mega | `ARDUINO_SPI_D11D12D13` | D11 (MOSI) / D12 (MISO) / D13 (SCK) | + +@note The original AVR based Arduinos only have a single hard SPI bus which + is only provided via the ISP header. Many modern Arduino compatible + boards do not provide the ISP header and only have SPI on D11/D12/D13 + provided. + +Mechanical and Electrical Compatibility {#iomaps-shields} +======================================= + +Modules implementing drivers for extension boards, a.k.a. shields, can express +their mechanical and electrical requirements by depending on `arduino_shield_...` +features. The following list of features currently exists: + +| Feature Name | Compatibility Claim | +| +| `arduino_shield_nano` | Board has side headers compatible with the Arduino Nano | +| `arduino_shield_uno` | Board has side headers compatible with the Arduino UNO | +| `arduino_shield_mega` | Board has side headers compatible with the Arduino MEGA | +| `arduino_shield_isp` | Board has an ISP header | + +@note A board providing `arduino_shield_mega` **MUST** also provide + `arduino_shield_uno`, as Arduino MEGA boards are backward compatible to + shields for the Arduino UNO. + +E.g. a module that implements the W5100 based Ethernet shield would depend on +both `arduino_shield_uno` and `arduino_shield_isp` for electrical compatibility +as well as on `arduino_spi` for SPI bus mapping and `arduino_pins` for the CS +pin mapping. This module could reuse the existing `w5100` driver and just +supply the correct `w5100_params_t` using the I/O mappings. diff --git a/doc/doxygen/src/kconfig/kconfig.md b/doc/doxygen/src/kconfig/kconfig.md index 3e3286dce42f5..3665914399bf5 100644 --- a/doc/doxygen/src/kconfig/kconfig.md +++ b/doc/doxygen/src/kconfig/kconfig.md @@ -315,14 +315,14 @@ CPU family or vendor, it should be placed in the correspondent Kconfig file the Kconfig file of that module. #### Example -The feature `arduino` is placed in `/kconfigs/Kconfig.features` and modelled +The feature `arduino_pins` is placed in `/kconfigs/Kconfig.features` and modelled like: ```Kconfig config HAS_ARDUINO bool help - Indicates that Arduino pins compatibility is supported. + Indicates that Arduino digital pins mappings are provided. ``` ### CPUs diff --git a/drivers/include/arduino_pinmap.h b/drivers/include/arduino_pinmap.h new file mode 100644 index 0000000000000..fcd272e2f931a --- /dev/null +++ b/drivers/include/arduino_pinmap.h @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2023 Otto-von-Guericke-Universität Magdeburg + * + * 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 drivers + * @{ + * + * @file + * @brief Compatibility wrapper for `arduino_iomap.h`. + * + * Please update your code to include `arduino_iomap.h` instead. + * + * @author Marian Buschsieweke + */ + +#ifndef ARDUINO_PINMAP_H +#define ARDUINO_PINMAP_H + +#include "arduino_iomap.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* just a wrapper for arduino_iomap.h for backward compatibility, no code + * here ... */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_PINMAP_H */ +/** @} */ diff --git a/drivers/include/periph/pwm.h b/drivers/include/periph/pwm.h index d3cedb2b9f185..7f31aefebbd6b 100644 --- a/drivers/include/periph/pwm.h +++ b/drivers/include/periph/pwm.h @@ -105,12 +105,13 @@ typedef enum { #ifdef MODULE_ARDUINO /** - * @brief RIOT GPIO mapping between Arduino pin, PWM device and channel + * @brief Mapping of an Arduino digital pin to the corresponding PWM dev and + * channel pair */ typedef struct { - int pin; /**< Arduino pin number */ - int dev; /**< PWM device index of pin */ - int chan; /**< PWM channel index */ + pwm_t dev; /**< PWM device connected to the pin */ + uint8_t chan; /**< PWM channel index */ + uint8_t pin; /**< Arduino pin number */ } arduino_pwm_t; #endif diff --git a/kconfigs/Kconfig.features b/kconfigs/Kconfig.features index 557406b58c724..44c586f05999e 100644 --- a/kconfigs/Kconfig.features +++ b/kconfigs/Kconfig.features @@ -27,15 +27,71 @@ config HAS_ARCH_ARM help Indicates that the current architecture is ARM. -config HAS_ARDUINO +config HAS_ARDUINO_ANALOG bool help - Indicates that Arduino pins compatibility is supported. + Indicates that Arduino analog pins mappings are provided. + +config HAS_ARDUINO_DAC + bool + help + Indicates that Arduino DAC pins mappings are provided. + +config HAS_ARDUINO_I2C + bool + help + Indicates that Arduino I²C bus mappings are provided. + +config HAS_ARDUINO_PINS + bool + help + Indicates that Arduino digital pins mappings are provided. config HAS_ARDUINO_PWM bool help - Indicates that Arduino PWM compatibility is supported. + Indicates that Arduino digital pin to PWM mappings are provided. + +config HAS_ARDUINO_SHIELD_ISP + bool + help + Indicates that the board is electrically and mechanically compatible + with shields that mate with the ISP header for SPI connectivity. + +config HAS_ARDUINO_SHIELD_MEGA + bool + # The Arduino Mega 2560 is backward compatible with Arduino UNO shields. So + # any board compatible with Mega shields will automatically be compatible + # with UNO shields. + select HAS_ARDUINO_SHIELD_UNO + help + Indicates that the board is mechanically and electrically compatible + with shields developed for the Arduino Mega 2560. (Note: Not including + the ISP header, that requires HAS_ARDUINO_SHIELD_ISP in addition.) + +config HAS_ARDUINO_SHIELD_NANO + bool + help + Indicates that the board is mechanically and electrically compatible + with shields developed for the Arduino Nano. (Note: Not including + the ISP header, that requires HAS_ARDUINO_SHIELD_ISP in addition.) + +config HAS_ARDUINO_SHIELD_UNO + bool + help + Indicates that the board is mechanically and electrically compatible + with shields developed for the Arduino Nano. (Note: Not including + the ISP header, that requires HAS_ARDUINO_SHIELD_ISP in addition.) + +config HAS_ARDUINO_SPI + bool + help + Indicates that Arduino SPI bus mappings are provided. + +config HAS_ARDUINO_UART + bool + help + Indicates that Arduino UART device mappings are provided. config HAS_BACKUP_RAM bool diff --git a/sys/arduino/Kconfig b/sys/arduino/Kconfig index b1ffeff5f4a99..a6277517c301a 100644 --- a/sys/arduino/Kconfig +++ b/sys/arduino/Kconfig @@ -13,7 +13,7 @@ menuconfig MODULE_ARDUINO imply MODULE_PERIPH_ADC imply MODULE_PERIPH_I2C imply MODULE_PERIPH_SPI - depends on HAS_ARDUINO + depends on HAS_ARDUINO_PINS depends on HAS_PERIPH_GPIO depends on HAS_PERIPH_UART depends on HAS_CPP diff --git a/sys/arduino/Makefile.dep b/sys/arduino/Makefile.dep index 6dea0e1621939..d731373790d79 100644 --- a/sys/arduino/Makefile.dep +++ b/sys/arduino/Makefile.dep @@ -1,14 +1,19 @@ +FEATURES_OPTIONAL += arduino_analog +FEATURES_OPTIONAL += arduino_dac +FEATURES_OPTIONAL += arduino_i2c +FEATURES_OPTIONAL += arduino_spi +FEATURES_OPTIONAL += arduino_uart FEATURES_OPTIONAL += periph_adc FEATURES_OPTIONAL += periph_i2c FEATURES_OPTIONAL += periph_spi -FEATURES_REQUIRED += arduino +FEATURES_REQUIRED += arduino_pins FEATURES_REQUIRED += cpp FEATURES_REQUIRED += periph_gpio FEATURES_REQUIRED += periph_uart USEMODULE += arduino_sketches USEMODULE += fmt -USEMODULE += ztimer_usec USEMODULE += ztimer_msec +USEMODULE += ztimer_usec ifneq (,$(filter stdio_cdc_acm,$(USEMODULE))) USEMODULE += arduino_serial_stdio diff --git a/sys/arduino/base.cpp b/sys/arduino/base.cpp index 284d54d363aee..dc8ad8ff9a029 100644 --- a/sys/arduino/base.cpp +++ b/sys/arduino/base.cpp @@ -18,21 +18,22 @@ * @} */ -extern "C" { +#include "arduino_board.h" #include "assert.h" -#include "ztimer.h" -#include "periph/gpio.h" #include "periph/adc.h" +#include "periph/gpio.h" #include "periph/pwm.h" -} +#include "ztimer.h" #include "arduino.hpp" -#define ANALOG_PIN_NUMOF (ARRAY_SIZE(arduino_analog_map)) - void pinMode(int pin, int mode) { - assert(gpio_is_valid(arduino_pinmap[pin])); + if ((pin > ARDUINO_PIN_LAST) || (pin < 0) || + !gpio_is_valid(arduino_pinmap[pin])) { + assert(0); + return; + } gpio_mode_t m = GPIO_OUT; if (mode == INPUT) { @@ -82,7 +83,7 @@ unsigned long millis() return ztimer_now(ZTIMER_MSEC); } -#if MODULE_PERIPH_ADC +#if IS_USED(MODULE_PERIPH_ADC) && defined(ARDUINO_ANALOG_PIN_LAST) int analogRead(int arduino_pin) { /* @@ -91,13 +92,16 @@ int analogRead(int arduino_pin) * 1: Successfully initialized */ static uint16_t adc_line_state; +#if ARDUINO_ANALOG_PIN_LAST > 15 +# error "Implementation currently not compatible with more than 16 analog pins" +#endif int adc_value; /* Check if the ADC line is valid */ - assert((arduino_pin >= 0) && (arduino_pin < (int)ANALOG_PIN_NUMOF)); + assert((arduino_pin >= 0) && (arduino_pin <= (int)ARDUINO_ANALOG_PIN_LAST)); /* Initialization of given ADC channel */ - if (!(adc_line_state & (1 << arduino_pin))) { + if (!(adc_line_state & (1UL << arduino_pin))) { if (adc_init(arduino_analog_map[arduino_pin]) != 0) { return -1; } diff --git a/sys/arduino/doc.txt b/sys/arduino/doc.txt index 53118a3a9c44a..71ed93ef761fa 100644 --- a/sys/arduino/doc.txt +++ b/sys/arduino/doc.txt @@ -89,55 +89,19 @@ * * @section sec_boardsupport Add Arduino support to a board * - * @note As prerequisite, the board must have support for C++. - * - * To add Arduino support to a board, it has to provide the following: - * - * In `RIOT/board/BOARD/include/arduino_board.h`: - * - a mapping of GPIO pins to Arduino pin numbers named `arduino_pinmap`, e.g. - * @code{c} - * static const gpio_t arduino_pinmap[] = { - * GPIO_PIN(PORT_D, 12), - * GPIO_PIN(PORT_D, 13), - * GPIO_PIN(PORT_D, 14), - * GPIO_PIN(PORT_D, 15), - * GPIO_PIN(PORT_A, 12), - * GPIO_PIN(PORT_A, 15), - * GPIO_PIN(PORT_B, 1), - * GPIO_PIN(PORT_B, 2), - * ... - * }; - * @endcode - * - * - a mapping of ADC lines to Arduino analogs pins named `arduino_analog_map`, e.g. - * @code{c} - * static const adc_t arduino_analog_map[] = { - * ADC_LINE(3), - * ADC_LINE(2), - * ADC_LINE(1), - * ... - * }; - * @endcode - * - * - a define `ARDUINO_LED` that is mapped to an Arduino pin number connected to - * any on-board LED, or to pin 0 in case no LED is defined: - * @code{c} - * #define ARDUINO_LED (2) - * @endcode - * This links to the third entry in the `arduino_pinmap` array. - * - * - a define `ARDUINO_UART_DEV` that defines the UART to use as the Arduino - * primary serial port (default UART_DEV(0)): - * @code{c} - * #define ARDUINO_UART_DEV (UART_DEV(3)) - * @endcode + * @note As prerequisite, the board must have support for C++. Support for + * the standard C++ lib (feature `libstdcpp`) is not required. * - * In addition, you have to add the 'arduino' feature to the board. For this, - * just add `FEATURES_PROVIDED += arduino` to the 'other features' section in - * your board's `Makefile.features'. + * As a minimum requirement, the features `arduino_pins` is a hard dependency. + * See @ref iomaps-mapping-gpio what a board needs to provide this. * - * That's it, your board can now run Ardunio sketches. + * Additional mappings for analog pins (see @ref iomaps-mapping-adc) and PWM + * pins (see @ref iomaps-mapping-pwm) is required to be able to use + * `analogRead()` and `analogWrite()`. * + * See also @ref iomaps on how a board can provide more I/O mappings and even + * declare electrical and mechanical compatibility with common Arduino form + * factors. * * @section sec_todo Open issues * diff --git a/sys/arduino/include/arduino_board.h b/sys/arduino/include/arduino_board.h new file mode 100644 index 0000000000000..5ccff1a32368a --- /dev/null +++ b/sys/arduino/include/arduino_board.h @@ -0,0 +1,699 @@ +/* + * Copyright (C) 2016 Freie Universität Berlin + * 2017 Thomas Perrot + * + * 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 sys_arduino + * @{ + * + * @file + * @brief Configuration of the Arduino API for Arduino Atmega boards + * + * @author Hauke Petersen + * @author Laurent Navet + * @author Thomas Perrot + */ + +#ifndef ARDUINO_BOARD_H +#define ARDUINO_BOARD_H + +#include "arduino_iomap.h" +#include "periph/adc.h" +#include "periph/gpio.h" +#include "periph/pwm.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef DOXYGEN +/** + * @brief The digital pin connected to the LED + * + * E.g. 13 when LED is connected to D13. + */ +#define ARDUINO_LED /* board specific number */ + +/** + * @brief Number of the last digital pin + * + * E.g. 42 if D42 is the digital pin with the highest number. + */ +#define ARDUINO_PIN_LAST /* board specific number */ + +/** + * @brief Number of the last analog pin + * + * E.g. 5 if A5 is the analog pin with the highest number. + */ +#define ARDUINO_ANALOG_PIN_LAST /* board specific number */ +#endif /* DOXYGEN */ + +#if !defined(ARDUINO_LED) && !defined(DOXYGEN) +#define ARDUINO_LED (13) +#endif + +#ifndef ARDUINO_PIN_LAST +# error "ARDUINO_PIN_LAST undefined" +#endif + +/* A board may not have any analog pins. But if it has any, it MUST define + * ARDUINO_ANALOG_PIN_LAST. */ +#if !defined(ARDUINO_ANALOG_PIN_LAST) && (defined(ARDUINO_A0) || defined(ARDUINO_A1)) +# error "ARDUINO_PIN_LAST undefined despite analog pins available" +#endif + +/* A board not having A0 and A1, but having e.g. A3 would also trigger this. + * Extend as needed when porting new boards. */ +#if defined(ARDUINO_ANALOG_PIN_LAST) && !defined(ARDUINO_A0) && !defined(ARDUINO_A1) +# error "ARDUINO_PIN_LAST defined but no analog pins available" +#endif + +/** + * @brief Look-up table for the Arduino's digital pins: + * + * Generate using + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.py} + * format = """#ifdef ARDUINO_PIN_{0:} + * ARDUINO_PIN_{0:}, + * #elif ARDUINO_PIN_LAST > {0:} + * GPIO_UNDEF, + * #endif""" + * for i in range(70): + * print(format.format(i)) + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * The Arduino MEGA2560 has D0 to D69, so 70 digital pins is the largest + * Arduino form factor there is. + */ +static const gpio_t arduino_pinmap[] = { +#ifdef ARDUINO_PIN_0 + ARDUINO_PIN_0, +#elif ARDUINO_PIN_LAST > 0 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_1 + ARDUINO_PIN_1, +#elif ARDUINO_PIN_LAST > 1 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_2 + ARDUINO_PIN_2, +#elif ARDUINO_PIN_LAST > 2 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_3 + ARDUINO_PIN_3, +#elif ARDUINO_PIN_LAST > 3 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_4 + ARDUINO_PIN_4, +#elif ARDUINO_PIN_LAST > 4 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_5 + ARDUINO_PIN_5, +#elif ARDUINO_PIN_LAST > 5 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_6 + ARDUINO_PIN_6, +#elif ARDUINO_PIN_LAST > 6 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_7 + ARDUINO_PIN_7, +#elif ARDUINO_PIN_LAST > 7 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_8 + ARDUINO_PIN_8, +#elif ARDUINO_PIN_LAST > 8 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_9 + ARDUINO_PIN_9, +#elif ARDUINO_PIN_LAST > 9 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_10 + ARDUINO_PIN_10, +#elif ARDUINO_PIN_LAST > 10 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_11 + ARDUINO_PIN_11, +#elif ARDUINO_PIN_LAST > 11 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_12 + ARDUINO_PIN_12, +#elif ARDUINO_PIN_LAST > 12 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_13 + ARDUINO_PIN_13, +#elif ARDUINO_PIN_LAST > 13 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_14 + ARDUINO_PIN_14, +#elif ARDUINO_PIN_LAST > 14 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_15 + ARDUINO_PIN_15, +#elif ARDUINO_PIN_LAST > 15 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_16 + ARDUINO_PIN_16, +#elif ARDUINO_PIN_LAST > 16 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_17 + ARDUINO_PIN_17, +#elif ARDUINO_PIN_LAST > 17 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_18 + ARDUINO_PIN_18, +#elif ARDUINO_PIN_LAST > 18 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_19 + ARDUINO_PIN_19, +#elif ARDUINO_PIN_LAST > 19 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_20 + ARDUINO_PIN_20, +#elif ARDUINO_PIN_LAST > 20 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_21 + ARDUINO_PIN_21, +#elif ARDUINO_PIN_LAST > 21 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_22 + ARDUINO_PIN_22, +#elif ARDUINO_PIN_LAST > 22 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_23 + ARDUINO_PIN_23, +#elif ARDUINO_PIN_LAST > 23 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_24 + ARDUINO_PIN_24, +#elif ARDUINO_PIN_LAST > 24 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_25 + ARDUINO_PIN_25, +#elif ARDUINO_PIN_LAST > 25 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_26 + ARDUINO_PIN_26, +#elif ARDUINO_PIN_LAST > 26 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_27 + ARDUINO_PIN_27, +#elif ARDUINO_PIN_LAST > 27 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_28 + ARDUINO_PIN_28, +#elif ARDUINO_PIN_LAST > 28 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_29 + ARDUINO_PIN_29, +#elif ARDUINO_PIN_LAST > 29 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_30 + ARDUINO_PIN_30, +#elif ARDUINO_PIN_LAST > 30 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_31 + ARDUINO_PIN_31, +#elif ARDUINO_PIN_LAST > 31 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_32 + ARDUINO_PIN_32, +#elif ARDUINO_PIN_LAST > 32 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_33 + ARDUINO_PIN_33, +#elif ARDUINO_PIN_LAST > 33 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_34 + ARDUINO_PIN_34, +#elif ARDUINO_PIN_LAST > 34 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_35 + ARDUINO_PIN_35, +#elif ARDUINO_PIN_LAST > 35 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_36 + ARDUINO_PIN_36, +#elif ARDUINO_PIN_LAST > 36 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_37 + ARDUINO_PIN_37, +#elif ARDUINO_PIN_LAST > 37 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_38 + ARDUINO_PIN_38, +#elif ARDUINO_PIN_LAST > 38 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_39 + ARDUINO_PIN_39, +#elif ARDUINO_PIN_LAST > 39 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_40 + ARDUINO_PIN_40, +#elif ARDUINO_PIN_LAST > 40 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_41 + ARDUINO_PIN_41, +#elif ARDUINO_PIN_LAST > 41 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_42 + ARDUINO_PIN_42, +#elif ARDUINO_PIN_LAST > 42 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_43 + ARDUINO_PIN_43, +#elif ARDUINO_PIN_LAST > 43 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_44 + ARDUINO_PIN_44, +#elif ARDUINO_PIN_LAST > 44 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_45 + ARDUINO_PIN_45, +#elif ARDUINO_PIN_LAST > 45 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_46 + ARDUINO_PIN_46, +#elif ARDUINO_PIN_LAST > 46 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_47 + ARDUINO_PIN_47, +#elif ARDUINO_PIN_LAST > 47 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_48 + ARDUINO_PIN_48, +#elif ARDUINO_PIN_LAST > 48 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_49 + ARDUINO_PIN_49, +#elif ARDUINO_PIN_LAST > 49 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_50 + ARDUINO_PIN_50, +#elif ARDUINO_PIN_LAST > 50 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_51 + ARDUINO_PIN_51, +#elif ARDUINO_PIN_LAST > 51 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_52 + ARDUINO_PIN_52, +#elif ARDUINO_PIN_LAST > 52 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_53 + ARDUINO_PIN_53, +#elif ARDUINO_PIN_LAST > 53 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_54 + ARDUINO_PIN_54, +#elif ARDUINO_PIN_LAST > 54 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_55 + ARDUINO_PIN_55, +#elif ARDUINO_PIN_LAST > 55 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_56 + ARDUINO_PIN_56, +#elif ARDUINO_PIN_LAST > 56 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_57 + ARDUINO_PIN_57, +#elif ARDUINO_PIN_LAST > 57 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_58 + ARDUINO_PIN_58, +#elif ARDUINO_PIN_LAST > 58 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_59 + ARDUINO_PIN_59, +#elif ARDUINO_PIN_LAST > 59 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_60 + ARDUINO_PIN_60, +#elif ARDUINO_PIN_LAST > 60 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_61 + ARDUINO_PIN_61, +#elif ARDUINO_PIN_LAST > 61 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_62 + ARDUINO_PIN_62, +#elif ARDUINO_PIN_LAST > 62 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_63 + ARDUINO_PIN_63, +#elif ARDUINO_PIN_LAST > 63 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_64 + ARDUINO_PIN_64, +#elif ARDUINO_PIN_LAST > 64 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_65 + ARDUINO_PIN_65, +#elif ARDUINO_PIN_LAST > 65 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_66 + ARDUINO_PIN_66, +#elif ARDUINO_PIN_LAST > 66 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_67 + ARDUINO_PIN_67, +#elif ARDUINO_PIN_LAST > 67 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_68 + ARDUINO_PIN_68, +#elif ARDUINO_PIN_LAST > 68 + GPIO_UNDEF, +#endif +#ifdef ARDUINO_PIN_69 + ARDUINO_PIN_69, +#elif ARDUINO_PIN_LAST > 69 + GPIO_UNDEF, +#endif +}; + +#if defined(ARDUINO_ANALOG_PIN_LAST) || defined(DOXYGEN) +/** + * @brief Look-up table for the Arduino's analog pins + * + * Generate using + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.py} + * format = """#ifdef ARDUINO_A{0:} + * ARDUINO_A{0:}, + * #elif ARDUINO_ANALOG_PIN_LAST > {0:} + * ADC_UNDEF, + * #endif""" + * for i in range(16): + * print(format.format(i)) + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * The Arduino MEGA 2560 has A0 to A15, so 16 Analog inputs is the largest + * as of now. + */ +static const adc_t arduino_analog_map[] = { +#ifdef ARDUINO_A0 + ARDUINO_A0, +#elif ARDUINO_ANALOG_PIN_LAST > 0 + ADC_UNDEF, +#endif +#ifdef ARDUINO_A1 + ARDUINO_A1, +#elif ARDUINO_ANALOG_PIN_LAST > 1 + ADC_UNDEF, +#endif +#ifdef ARDUINO_A2 + ARDUINO_A2, +#elif ARDUINO_ANALOG_PIN_LAST > 2 + ADC_UNDEF, +#endif +#ifdef ARDUINO_A3 + ARDUINO_A3, +#elif ARDUINO_ANALOG_PIN_LAST > 3 + ADC_UNDEF, +#endif +#ifdef ARDUINO_A4 + ARDUINO_A4, +#elif ARDUINO_ANALOG_PIN_LAST > 4 + ADC_UNDEF, +#endif +#ifdef ARDUINO_A5 + ARDUINO_A5, +#elif ARDUINO_ANALOG_PIN_LAST > 5 + ADC_UNDEF, +#endif +#ifdef ARDUINO_A6 + ARDUINO_A6, +#elif ARDUINO_ANALOG_PIN_LAST > 6 + ADC_UNDEF, +#endif +#ifdef ARDUINO_A7 + ARDUINO_A7, +#elif ARDUINO_ANALOG_PIN_LAST > 7 + ADC_UNDEF, +#endif +#ifdef ARDUINO_A8 + ARDUINO_A8, +#elif ARDUINO_ANALOG_PIN_LAST > 8 + ADC_UNDEF, +#endif +#ifdef ARDUINO_A9 + ARDUINO_A9, +#elif ARDUINO_ANALOG_PIN_LAST > 9 + ADC_UNDEF, +#endif +#ifdef ARDUINO_A10 + ARDUINO_A10, +#elif ARDUINO_ANALOG_PIN_LAST > 10 + ADC_UNDEF, +#endif +#ifdef ARDUINO_A11 + ARDUINO_A11, +#elif ARDUINO_ANALOG_PIN_LAST > 11 + ADC_UNDEF, +#endif +#ifdef ARDUINO_A12 + ARDUINO_A12, +#elif ARDUINO_ANALOG_PIN_LAST > 12 + ADC_UNDEF, +#endif +#ifdef ARDUINO_A13 + ARDUINO_A13, +#elif ARDUINO_ANALOG_PIN_LAST > 13 + ADC_UNDEF, +#endif +#ifdef ARDUINO_A14 + ARDUINO_A14, +#elif ARDUINO_ANALOG_PIN_LAST > 14 + ADC_UNDEF, +#endif +#ifdef ARDUINO_A15 + ARDUINO_A15, +#elif ARDUINO_ANALOG_PIN_LAST > 15 + ADC_UNDEF, +#endif +}; +#endif /* defined(ARDUINO_ANALOG_PIN_LAST) */ + +#ifdef DOXYGEN +/** + * @brief PWM frequency + */ +#define ARDUINO_PWM_FREQU /* implementation defined */ +#else +# ifndef ARDUINO_PWM_FREQU +# define ARDUINO_PWM_FREQU (490U) +# endif +#endif + +/** + * @brief List of PWM GPIO mappings + * + * Generate using + * + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~{.py} + * format = """#ifdef ARDUINO_PIN_{0:}_PWM_DEV + * {{ .dev = ARDUINO_PIN_{0:}_PWM_DEV, .chan = ARDUINO_PIN_{0:}_PWM_CHAN, .pin = {0:} }}, + * #endif""" + * for i in range(32): + * print(format.format(i)) + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + * + * We assume D0..D31 are the only candidates for PWM pins as a wild guess. Once + * this no longer holds, the list needs to be extended. + */ +static const arduino_pwm_t arduino_pwm_list[] = { +#ifdef ARDUINO_PIN_0_PWM_DEV + { .dev = ARDUINO_PIN_0_PWM_DEV, .chan = ARDUINO_PIN_0_PWM_CHAN, .pin = 0 }, +#endif +#ifdef ARDUINO_PIN_1_PWM_DEV + { .dev = ARDUINO_PIN_1_PWM_DEV, .chan = ARDUINO_PIN_1_PWM_CHAN, .pin = 1 }, +#endif +#ifdef ARDUINO_PIN_2_PWM_DEV + { .dev = ARDUINO_PIN_2_PWM_DEV, .chan = ARDUINO_PIN_2_PWM_CHAN, .pin = 2 }, +#endif +#ifdef ARDUINO_PIN_3_PWM_DEV + { .dev = ARDUINO_PIN_3_PWM_DEV, .chan = ARDUINO_PIN_3_PWM_CHAN, .pin = 3 }, +#endif +#ifdef ARDUINO_PIN_4_PWM_DEV + { .dev = ARDUINO_PIN_4_PWM_DEV, .chan = ARDUINO_PIN_4_PWM_CHAN, .pin = 4 }, +#endif +#ifdef ARDUINO_PIN_5_PWM_DEV + { .dev = ARDUINO_PIN_5_PWM_DEV, .chan = ARDUINO_PIN_5_PWM_CHAN, .pin = 5 }, +#endif +#ifdef ARDUINO_PIN_6_PWM_DEV + { .dev = ARDUINO_PIN_6_PWM_DEV, .chan = ARDUINO_PIN_6_PWM_CHAN, .pin = 6 }, +#endif +#ifdef ARDUINO_PIN_7_PWM_DEV + { .dev = ARDUINO_PIN_7_PWM_DEV, .chan = ARDUINO_PIN_7_PWM_CHAN, .pin = 7 }, +#endif +#ifdef ARDUINO_PIN_8_PWM_DEV + { .dev = ARDUINO_PIN_8_PWM_DEV, .chan = ARDUINO_PIN_8_PWM_CHAN, .pin = 8 }, +#endif +#ifdef ARDUINO_PIN_9_PWM_DEV + { .dev = ARDUINO_PIN_9_PWM_DEV, .chan = ARDUINO_PIN_9_PWM_CHAN, .pin = 9 }, +#endif +#ifdef ARDUINO_PIN_10_PWM_DEV + { .dev = ARDUINO_PIN_10_PWM_DEV, .chan = ARDUINO_PIN_10_PWM_CHAN, .pin = 10 }, +#endif +#ifdef ARDUINO_PIN_11_PWM_DEV + { .dev = ARDUINO_PIN_11_PWM_DEV, .chan = ARDUINO_PIN_11_PWM_CHAN, .pin = 11 }, +#endif +#ifdef ARDUINO_PIN_12_PWM_DEV + { .dev = ARDUINO_PIN_12_PWM_DEV, .chan = ARDUINO_PIN_12_PWM_CHAN, .pin = 12 }, +#endif +#ifdef ARDUINO_PIN_13_PWM_DEV + { .dev = ARDUINO_PIN_13_PWM_DEV, .chan = ARDUINO_PIN_13_PWM_CHAN, .pin = 13 }, +#endif +#ifdef ARDUINO_PIN_14_PWM_DEV + { .dev = ARDUINO_PIN_14_PWM_DEV, .chan = ARDUINO_PIN_14_PWM_CHAN, .pin = 14 }, +#endif +#ifdef ARDUINO_PIN_15_PWM_DEV + { .dev = ARDUINO_PIN_15_PWM_DEV, .chan = ARDUINO_PIN_15_PWM_CHAN, .pin = 15 }, +#endif +#ifdef ARDUINO_PIN_16_PWM_DEV + { .dev = ARDUINO_PIN_16_PWM_DEV, .chan = ARDUINO_PIN_16_PWM_CHAN, .pin = 16 }, +#endif +#ifdef ARDUINO_PIN_17_PWM_DEV + { .dev = ARDUINO_PIN_17_PWM_DEV, .chan = ARDUINO_PIN_17_PWM_CHAN, .pin = 17 }, +#endif +#ifdef ARDUINO_PIN_18_PWM_DEV + { .dev = ARDUINO_PIN_18_PWM_DEV, .chan = ARDUINO_PIN_18_PWM_CHAN, .pin = 18 }, +#endif +#ifdef ARDUINO_PIN_19_PWM_DEV + { .dev = ARDUINO_PIN_19_PWM_DEV, .chan = ARDUINO_PIN_19_PWM_CHAN, .pin = 19 }, +#endif +#ifdef ARDUINO_PIN_20_PWM_DEV + { .dev = ARDUINO_PIN_20_PWM_DEV, .chan = ARDUINO_PIN_20_PWM_CHAN, .pin = 20 }, +#endif +#ifdef ARDUINO_PIN_21_PWM_DEV + { .dev = ARDUINO_PIN_21_PWM_DEV, .chan = ARDUINO_PIN_21_PWM_CHAN, .pin = 21 }, +#endif +#ifdef ARDUINO_PIN_22_PWM_DEV + { .dev = ARDUINO_PIN_22_PWM_DEV, .chan = ARDUINO_PIN_22_PWM_CHAN, .pin = 22 }, +#endif +#ifdef ARDUINO_PIN_23_PWM_DEV + { .dev = ARDUINO_PIN_23_PWM_DEV, .chan = ARDUINO_PIN_23_PWM_CHAN, .pin = 23 }, +#endif +#ifdef ARDUINO_PIN_24_PWM_DEV + { .dev = ARDUINO_PIN_24_PWM_DEV, .chan = ARDUINO_PIN_24_PWM_CHAN, .pin = 24 }, +#endif +#ifdef ARDUINO_PIN_25_PWM_DEV + { .dev = ARDUINO_PIN_25_PWM_DEV, .chan = ARDUINO_PIN_25_PWM_CHAN, .pin = 25 }, +#endif +#ifdef ARDUINO_PIN_26_PWM_DEV + { .dev = ARDUINO_PIN_26_PWM_DEV, .chan = ARDUINO_PIN_26_PWM_CHAN, .pin = 26 }, +#endif +#ifdef ARDUINO_PIN_27_PWM_DEV + { .dev = ARDUINO_PIN_27_PWM_DEV, .chan = ARDUINO_PIN_27_PWM_CHAN, .pin = 27 }, +#endif +#ifdef ARDUINO_PIN_28_PWM_DEV + { .dev = ARDUINO_PIN_28_PWM_DEV, .chan = ARDUINO_PIN_28_PWM_CHAN, .pin = 28 }, +#endif +#ifdef ARDUINO_PIN_29_PWM_DEV + { .dev = ARDUINO_PIN_29_PWM_DEV, .chan = ARDUINO_PIN_29_PWM_CHAN, .pin = 29 }, +#endif +#ifdef ARDUINO_PIN_30_PWM_DEV + { .dev = ARDUINO_PIN_30_PWM_DEV, .chan = ARDUINO_PIN_30_PWM_CHAN, .pin = 30 }, +#endif +#ifdef ARDUINO_PIN_31_PWM_DEV + { .dev = ARDUINO_PIN_31_PWM_DEV, .chan = ARDUINO_PIN_31_PWM_CHAN, .pin = 31 }, +#endif +}; + +/** + * @brief F_CPU defines the CPU frequency in Hz. + * + * This is used in AVR's libc delay.h and setbaud.h + * + * In RIOT delay() has a different implementation using ztimer, and F_CPU is + * already defined when using setbaud.h (see cpu/atmega_common/periph/uart.c) + * + * However Arduino libraries and sketches may expect F_CPU to be defined and + * fail otherwise (for example the Arduino SDI-12 package expects this, for AVR + * cpus). For this reason we define F_CPU here, if not already defined. + */ +#ifndef F_CPU +#define F_CPU CLOCK_CORECLOCK +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_BOARD_H */ +/** @} */ diff --git a/tests/build_system/external_board_dirs/esp-ci-boards/esp32-ci/Kconfig b/tests/build_system/external_board_dirs/esp-ci-boards/esp32-ci/Kconfig index a58f6fda0b3de..6c3df391158fa 100644 --- a/tests/build_system/external_board_dirs/esp-ci-boards/esp32-ci/Kconfig +++ b/tests/build_system/external_board_dirs/esp-ci-boards/esp32-ci/Kconfig @@ -12,7 +12,7 @@ config BOARD_ESP32_CI default y select BOARD_COMMON_ESP32 select CPU_MODEL_ESP32_WROVER - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_ESP_RTC_TIMER_32K select HAS_ESP_JTAG select HAS_PERIPH_ADC diff --git a/tests/build_system/external_board_dirs/esp-ci-boards/esp32c3-ci/Kconfig b/tests/build_system/external_board_dirs/esp-ci-boards/esp32c3-ci/Kconfig index d19e55bbe213f..98f55d83a8e26 100644 --- a/tests/build_system/external_board_dirs/esp-ci-boards/esp32c3-ci/Kconfig +++ b/tests/build_system/external_board_dirs/esp-ci-boards/esp32c3-ci/Kconfig @@ -13,7 +13,7 @@ config BOARD_ESP32C3_CI default y select BOARD_COMMON_ESP32C3 select CPU_MODEL_ESP32C3_MINI_1X - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_ESP_RTC_TIMER_32K select HAS_ESP_JTAG select HAS_PERIPH_ADC diff --git a/tests/build_system/external_board_dirs/esp-ci-boards/esp32s2-ci/Kconfig b/tests/build_system/external_board_dirs/esp-ci-boards/esp32s2-ci/Kconfig index e49903ffe90a0..a565e64d09545 100644 --- a/tests/build_system/external_board_dirs/esp-ci-boards/esp32s2-ci/Kconfig +++ b/tests/build_system/external_board_dirs/esp-ci-boards/esp32s2-ci/Kconfig @@ -13,7 +13,7 @@ config BOARD_ESP32S2_CI default y select BOARD_COMMON_ESP32S2 select CPU_MODEL_ESP32S2_MINI_1X_N4R2 - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_ESP_JTAG select HAS_ESP_RTC_TIMER_32K select HAS_PERIPH_ADC diff --git a/tests/build_system/external_board_dirs/esp-ci-boards/esp32s3-ci/Kconfig b/tests/build_system/external_board_dirs/esp-ci-boards/esp32s3-ci/Kconfig index 53eb62ad6d52a..cccfc875d7c69 100644 --- a/tests/build_system/external_board_dirs/esp-ci-boards/esp32s3-ci/Kconfig +++ b/tests/build_system/external_board_dirs/esp-ci-boards/esp32s3-ci/Kconfig @@ -13,7 +13,7 @@ config BOARD_ESP32S3_CI default y select BOARD_COMMON_ESP32S3 select CPU_MODEL_ESP32S3_WROOM_1X_N8R8 - select HAS_ARDUINO + select HAS_ARDUINO_PINS select HAS_ESP_JTAG select HAS_ESP_RTC_TIMER_32K select HAS_PERIPH_ADC