From 043e8cc88e849861c808010454e389398879a47e Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Fri, 23 Jun 2023 15:42:08 +0200 Subject: [PATCH] boards,sys/arduino: major clean up - Rename all `arduino_pinmap.h` to `arduino_iomap.h` - An empty `arduino_pinmap.h` that just includes `arduino_iomap.h` is provided for backward compatibility - Move all info from `arduino_board.h` into the new file as trivial macros, so that they can also be used outside of sketches - The new name reflects the fact not just pin mappings, but also other I/O features such as PWMs are mapped - Drop all `arduino_board.h` - `arduino_board.h` and `arduino_iomap.h` now provide the exact same information, just in a different format - a generic `arduino_board.h` is provided instead that just uses the info in `arduinio_iomap.h` and provides them in the format the code in `sys/arduino` expects it - Add fine grained features to indicate for mappings - availability of mappings for analog pins, DAC pins, PWM pins, UART devices, SPI/I2C buses to the corresponding RIOT identification can now be expressed: - `arduino_pins`: `ARDUINO_PIN_0` etc. are available - `arduino_analog`: `ARDUINO_A0` etc. are available - `arduino_pwm`: `ARDUINO_PIN_13_PWM_DEV` etc. are available - `arduino_dac`: `ARDUINO_DAC0` etc. are available - `arduino_uart`: `ARDUINO_UART_D0D1` or similar are available - `arduino_spi`: `ARDUINO_SPI_ISP` or similar are available - `arduino_i2c`: `ARDUINO_I2C_UNO` or similar are available - mechanical/electrical compatibility with specific form factors can now be expressed as features: - `aruino_shield_nano`: Arduino NANO compatible headers - `aruino_shield_uno`: Arduino UNO compatible headers - `aruino_shield_mega`: Arduino MEGA compatible headers - `aruino_shield_isp`: ISP header is available This provides the groundwork to implement shield support as modules that can rely on the I/O mappings, rather than having to provide a configuration per board. --- .../adafruit-grand-central-m4-express/Kconfig | 3 +- .../Makefile.features | 3 +- .../include/arduino_board.h | 73 --- .../{arduino_pinmap.h => arduino_iomap.h} | 34 +- boards/arduino-duemilanove/Kconfig | 1 + boards/arduino-duemilanove/Makefile.features | 1 + boards/arduino-leonardo/Kconfig | 1 + boards/arduino-leonardo/Makefile.features | 1 + boards/arduino-mega2560/Kconfig | 2 + boards/arduino-mega2560/Makefile.features | 3 + boards/arduino-mkr1000/include/board.h | 5 - boards/arduino-mkrfox1200/include/board.h | 5 - boards/arduino-mkrwan1300/include/board.h | 5 - boards/arduino-nano/Kconfig | 1 + boards/arduino-nano/Makefile.features | 1 + boards/arduino-uno/Kconfig | 1 + boards/arduino-uno/Makefile.features | 1 + boards/common/arduino-atmega/Kconfig | 7 +- .../common/arduino-atmega/Makefile.features | 7 +- .../arduino-atmega/include/arduino_board.h | 194 -------- .../arduino-atmega/include/arduino_iomap.h | 332 +++++++++++++ .../arduino-atmega/include/arduino_pinmap.h | 235 ---------- boards/common/arduino-due/Kconfig | 10 +- boards/common/arduino-due/Makefile.features | 10 +- .../arduino-due/include/arduino_board.h | 141 ------ .../{arduino_pinmap.h => arduino_iomap.h} | 64 ++- boards/common/arduino-mkr/Kconfig | 3 +- boards/common/arduino-mkr/Makefile.features | 3 +- .../arduino-mkr/include/arduino_board.h | 97 ---- .../arduino-mkr/include/arduino_iomap.h | 119 +++++ .../arduino-mkr/include/arduino_pinmap.h | 80 ---- boards/common/arduino-zero/Kconfig | 8 +- boards/common/arduino-zero/Makefile.features | 8 +- .../arduino-zero/include/arduino_board.h | 94 ---- .../arduino-zero/include/arduino_iomap.h | 147 ++++++ .../arduino-zero/include/arduino_pinmap.h | 77 ---- boards/common/esp8266/Kconfig | 2 +- boards/common/esp8266/Makefile.features | 2 +- boards/common/nucleo144/Kconfig | 5 +- boards/common/nucleo144/Makefile.features | 5 +- .../common/nucleo144/include/arduino_board.h | 73 --- .../{arduino_pinmap.h => arduino_iomap.h} | 46 +- boards/common/nucleo32/Kconfig | 4 +- boards/common/nucleo32/Makefile.features | 4 +- .../common/nucleo32/include/arduino_board.h | 80 ---- .../{arduino_pinmap.h => arduino_iomap.h} | 41 +- boards/common/nucleo64/Kconfig | 7 +- boards/common/nucleo64/Makefile.features | 7 +- .../common/nucleo64/include/arduino_board.h | 78 ---- .../{arduino_pinmap.h => arduino_iomap.h} | 62 ++- boards/common/silabs/Kconfig | 3 +- boards/common/silabs/Makefile.features | 3 +- boards/common/silabs/include/arduino_board.h | 58 --- .../{arduino_pinmap.h => arduino_iomap.h} | 28 +- boards/common/sodaq/Kconfig | 2 +- boards/common/sodaq/Makefile.features | 2 +- boards/esp32-heltec-lora32-v2/Kconfig | 2 +- .../esp32-heltec-lora32-v2/Makefile.features | 2 +- .../include/arduino_board.h | 38 -- .../include/arduino_iomap.h | 80 ++++ .../include/arduino_pinmap.h | 64 --- boards/esp32-mh-et-live-minikit/Kconfig | 2 +- .../Makefile.features | 2 +- .../include/arduino_board.h | 38 -- .../include/arduino_iomap.h | 80 ++++ .../include/arduino_pinmap.h | 64 --- boards/esp32-olimex-evb/Kconfig | 2 +- boards/esp32-olimex-evb/Makefile.features | 2 +- .../esp32-olimex-evb/include/arduino_board.h | 38 -- .../esp32-olimex-evb/include/arduino_iomap.h | 77 ++++ .../esp32-olimex-evb/include/arduino_pinmap.h | 64 --- boards/esp32-ttgo-t-beam/Kconfig | 2 +- boards/esp32-ttgo-t-beam/Makefile.features | 2 +- .../esp32-ttgo-t-beam/include/arduino_board.h | 40 -- .../esp32-ttgo-t-beam/include/arduino_iomap.h | 71 +++ .../include/arduino_pinmap.h | 60 --- boards/esp32-wemos-lolin-d32-pro/Kconfig | 2 +- .../Makefile.features | 2 +- .../include/arduino_board.h | 41 -- .../include/arduino_iomap.h | 80 ++++ .../include/arduino_pinmap.h | 64 --- boards/esp32-wroom-32/Kconfig | 2 +- boards/esp32-wroom-32/Makefile.features | 2 +- boards/esp32-wroom-32/include/arduino_board.h | 38 -- boards/esp32-wroom-32/include/arduino_iomap.h | 80 ++++ .../esp32-wroom-32/include/arduino_pinmap.h | 64 --- boards/esp32-wrover-kit/Kconfig | 2 +- boards/esp32-wrover-kit/Makefile.features | 2 +- .../esp32-wrover-kit/include/arduino_board.h | 38 -- .../esp32-wrover-kit/include/arduino_iomap.h | 78 ++++ .../esp32-wrover-kit/include/arduino_pinmap.h | 64 --- boards/esp32c3-devkit/Kconfig | 2 +- boards/esp32c3-devkit/Makefile.features | 2 +- boards/esp32c3-devkit/include/arduino_board.h | 38 -- boards/esp32c3-devkit/include/arduino_iomap.h | 80 ++++ .../esp32c3-devkit/include/arduino_pinmap.h | 71 --- boards/esp32c3-wemos-mini/Kconfig | 2 +- boards/esp32c3-wemos-mini/Makefile.features | 2 +- .../include/arduino_board.h | 42 -- .../include/arduino_iomap.h | 87 ++++ .../include/arduino_pinmap.h | 77 ---- boards/esp32s2-devkit/Kconfig | 2 +- boards/esp32s2-devkit/Makefile.features | 2 +- boards/esp32s2-devkit/include/arduino_board.h | 38 -- boards/esp32s2-devkit/include/arduino_iomap.h | 79 ++++ .../esp32s2-devkit/include/arduino_pinmap.h | 63 --- boards/esp32s2-lilygo-ttgo-t8/Kconfig | 2 +- .../esp32s2-lilygo-ttgo-t8/Makefile.features | 2 +- .../include/arduino_board.h | 38 -- .../include/arduino_iomap.h | 79 ++++ .../include/arduino_pinmap.h | 63 --- boards/esp32s3-devkit/Kconfig | 2 +- boards/esp32s3-devkit/Makefile.features | 2 +- boards/esp32s3-devkit/include/arduino_board.h | 38 -- boards/esp32s3-devkit/include/arduino_iomap.h | 78 ++++ .../esp32s3-devkit/include/arduino_pinmap.h | 63 --- boards/esp32s3-pros3/Kconfig | 2 +- boards/esp32s3-pros3/Makefile.features | 2 +- boards/esp32s3-pros3/include/arduino_board.h | 38 -- boards/esp32s3-pros3/include/arduino_iomap.h | 77 ++++ boards/esp32s3-pros3/include/arduino_pinmap.h | 63 --- .../esp8266-esp-12x/include/arduino_board.h | 76 --- .../esp8266-esp-12x/include/arduino_iomap.h | 70 +++ .../include/arduino_board.h | 74 --- .../include/arduino_iomap.h | 69 +++ .../include/arduino_board.h | 74 --- .../include/arduino_iomap.h | 69 +++ boards/feather-m0/Kconfig.feather-m0-base | 3 +- boards/feather-m0/Makefile.features | 3 +- boards/feather-m0/include/arduino_board.h | 91 ---- .../{arduino_pinmap.h => arduino_iomap.h} | 73 +-- boards/hifive1b/Kconfig | 2 +- boards/hifive1b/Makefile.features | 2 +- boards/hifive1b/include/arduino_board.h | 64 --- .../{arduino_pinmap.h => arduino_iomap.h} | 9 +- boards/lora-e5-dev/Kconfig | 2 +- boards/lora-e5-dev/Makefile.features | 2 +- boards/lora-e5-dev/include/arduino_board.h | 80 ---- .../{arduino_pinmap.h => arduino_iomap.h} | 17 +- boards/nucleo-wl55jc/Kconfig | 2 +- boards/nucleo-wl55jc/include/arduino_board.h | 71 --- .../{arduino_pinmap.h => arduino_iomap.h} | 35 +- boards/p-nucleo-wb55/Kconfig | 4 +- boards/p-nucleo-wb55/Makefile.features | 4 +- boards/p-nucleo-wb55/include/arduino_board.h | 73 --- .../{arduino_pinmap.h => arduino_iomap.h} | 34 +- boards/remote-revb/Kconfig | 3 +- boards/remote-revb/Makefile.features | 3 +- boards/remote-revb/include/arduino_board.h | 97 ---- boards/remote-revb/include/arduino_iomap.h | 90 ++++ boards/remote-revb/include/arduino_pinmap.h | 86 ---- boards/saml21-xpro/include/arduino_board.h | 58 --- boards/saml21-xpro/include/arduino_iomap.h | 62 +++ boards/saml21-xpro/include/arduino_pinmap.h | 46 -- boards/sodaq-autonomo/include/arduino_board.h | 172 ------- boards/sodaq-autonomo/include/arduino_iomap.h | 197 ++++++++ boards/sodaq-explorer/include/arduino_board.h | 147 ------ boards/sodaq-explorer/include/arduino_iomap.h | 159 +++++++ boards/sodaq-one/include/arduino_board.h | 145 ------ boards/sodaq-one/include/arduino_iomap.h | 142 ++++++ boards/sodaq-sara-aff/include/arduino_board.h | 149 ------ boards/sodaq-sara-aff/include/arduino_iomap.h | 158 +++++++ boards/sodaq-sara-sff/include/arduino_board.h | 148 ------ boards/sodaq-sara-sff/include/arduino_iomap.h | 145 ++++++ boards/stm32f4discovery/Kconfig | 3 +- boards/stm32f4discovery/Makefile.features | 3 +- .../stm32f4discovery/include/arduino_board.h | 56 --- .../{arduino_pinmap.h => arduino_iomap.h} | 10 +- boards/stm32l496g-disco/Kconfig | 3 +- boards/stm32l496g-disco/Makefile.features | 3 +- .../stm32l496g-disco/include/arduino_board.h | 73 --- .../{arduino_pinmap.h => arduino_iomap.h} | 35 +- .../{arduino_pinmap.h => arduino_iomap.h} | 35 +- boards/waspmote-pro/Kconfig | 3 +- boards/waspmote-pro/Makefile.features | 3 +- boards/waspmote-pro/include/arduino_board.h | 126 ----- .../{arduino_pinmap.h => arduino_iomap.h} | 23 +- boards/waveshare-nrf52840-eval-kit/Kconfig | 4 +- .../Makefile.features | 6 +- .../include/arduino_board.h | 104 ----- .../{arduino_pinmap.h => arduino_iomap.h} | 68 ++- doc/doxygen/riot.doxyfile | 1 + doc/doxygen/src/io-mapping-and-shields.md | 162 +++++++ doc/doxygen/src/kconfig/kconfig.md | 6 +- drivers/include/arduino_pinmap.h | 38 ++ drivers/include/periph/pwm.h | 9 +- kconfigs/Kconfig.features | 62 ++- sys/arduino/Kconfig | 2 +- sys/arduino/Makefile.dep | 9 +- sys/arduino/base.cpp | 24 +- sys/arduino/doc.txt | 56 +-- sys/arduino/include/arduino_board.h | 54 +++ sys/arduino/include/arduino_board_analog.h | 164 +++++++ sys/arduino/include/arduino_board_pins.h | 436 ++++++++++++++++++ sys/arduino/include/arduino_board_pwm.h | 164 +++++++ .../esp-ci-boards/esp32-ci/Kconfig | 2 +- .../esp-ci-boards/esp32c3-ci/Kconfig | 2 +- .../esp-ci-boards/esp32s2-ci/Kconfig | 2 +- .../esp-ci-boards/esp32s3-ci/Kconfig | 2 +- 199 files changed, 4522 insertions(+), 4955 deletions(-) delete mode 100644 boards/adafruit-grand-central-m4-express/include/arduino_board.h rename boards/adafruit-grand-central-m4-express/include/{arduino_pinmap.h => arduino_iomap.h} (69%) delete mode 100644 boards/common/arduino-atmega/include/arduino_board.h create mode 100644 boards/common/arduino-atmega/include/arduino_iomap.h delete mode 100644 boards/common/arduino-atmega/include/arduino_pinmap.h delete mode 100644 boards/common/arduino-due/include/arduino_board.h rename boards/common/arduino-due/include/{arduino_pinmap.h => arduino_iomap.h} (78%) delete mode 100644 boards/common/arduino-mkr/include/arduino_board.h create mode 100644 boards/common/arduino-mkr/include/arduino_iomap.h delete mode 100644 boards/common/arduino-mkr/include/arduino_pinmap.h delete mode 100644 boards/common/arduino-zero/include/arduino_board.h create mode 100644 boards/common/arduino-zero/include/arduino_iomap.h delete mode 100644 boards/common/arduino-zero/include/arduino_pinmap.h delete mode 100644 boards/common/nucleo144/include/arduino_board.h rename boards/common/nucleo144/include/{arduino_pinmap.h => arduino_iomap.h} (66%) delete mode 100644 boards/common/nucleo32/include/arduino_board.h rename boards/common/nucleo32/include/{arduino_pinmap.h => arduino_iomap.h} (67%) delete mode 100644 boards/common/nucleo64/include/arduino_board.h rename boards/common/nucleo64/include/{arduino_pinmap.h => arduino_iomap.h} (62%) delete mode 100644 boards/common/silabs/include/arduino_board.h rename boards/common/silabs/include/{arduino_pinmap.h => arduino_iomap.h} (55%) delete mode 100644 boards/esp32-heltec-lora32-v2/include/arduino_board.h create mode 100644 boards/esp32-heltec-lora32-v2/include/arduino_iomap.h delete mode 100644 boards/esp32-heltec-lora32-v2/include/arduino_pinmap.h delete mode 100644 boards/esp32-mh-et-live-minikit/include/arduino_board.h create mode 100644 boards/esp32-mh-et-live-minikit/include/arduino_iomap.h delete mode 100644 boards/esp32-mh-et-live-minikit/include/arduino_pinmap.h delete mode 100644 boards/esp32-olimex-evb/include/arduino_board.h create mode 100644 boards/esp32-olimex-evb/include/arduino_iomap.h delete mode 100644 boards/esp32-olimex-evb/include/arduino_pinmap.h delete mode 100644 boards/esp32-ttgo-t-beam/include/arduino_board.h create mode 100644 boards/esp32-ttgo-t-beam/include/arduino_iomap.h delete mode 100644 boards/esp32-ttgo-t-beam/include/arduino_pinmap.h delete mode 100644 boards/esp32-wemos-lolin-d32-pro/include/arduino_board.h create mode 100644 boards/esp32-wemos-lolin-d32-pro/include/arduino_iomap.h delete mode 100644 boards/esp32-wemos-lolin-d32-pro/include/arduino_pinmap.h delete mode 100644 boards/esp32-wroom-32/include/arduino_board.h create mode 100644 boards/esp32-wroom-32/include/arduino_iomap.h delete mode 100644 boards/esp32-wroom-32/include/arduino_pinmap.h delete mode 100644 boards/esp32-wrover-kit/include/arduino_board.h create mode 100644 boards/esp32-wrover-kit/include/arduino_iomap.h delete mode 100644 boards/esp32-wrover-kit/include/arduino_pinmap.h delete mode 100644 boards/esp32c3-devkit/include/arduino_board.h create mode 100644 boards/esp32c3-devkit/include/arduino_iomap.h delete mode 100644 boards/esp32c3-devkit/include/arduino_pinmap.h delete mode 100644 boards/esp32c3-wemos-mini/include/arduino_board.h create mode 100644 boards/esp32c3-wemos-mini/include/arduino_iomap.h delete mode 100644 boards/esp32c3-wemos-mini/include/arduino_pinmap.h delete mode 100644 boards/esp32s2-devkit/include/arduino_board.h create mode 100644 boards/esp32s2-devkit/include/arduino_iomap.h delete mode 100644 boards/esp32s2-devkit/include/arduino_pinmap.h delete mode 100644 boards/esp32s2-lilygo-ttgo-t8/include/arduino_board.h create mode 100644 boards/esp32s2-lilygo-ttgo-t8/include/arduino_iomap.h delete mode 100644 boards/esp32s2-lilygo-ttgo-t8/include/arduino_pinmap.h delete mode 100644 boards/esp32s3-devkit/include/arduino_board.h create mode 100644 boards/esp32s3-devkit/include/arduino_iomap.h delete mode 100644 boards/esp32s3-devkit/include/arduino_pinmap.h delete mode 100644 boards/esp32s3-pros3/include/arduino_board.h create mode 100644 boards/esp32s3-pros3/include/arduino_iomap.h delete mode 100644 boards/esp32s3-pros3/include/arduino_pinmap.h delete mode 100644 boards/esp8266-esp-12x/include/arduino_board.h create mode 100644 boards/esp8266-esp-12x/include/arduino_iomap.h delete mode 100644 boards/esp8266-olimex-mod/include/arduino_board.h create mode 100644 boards/esp8266-olimex-mod/include/arduino_iomap.h delete mode 100644 boards/esp8266-sparkfun-thing/include/arduino_board.h create mode 100644 boards/esp8266-sparkfun-thing/include/arduino_iomap.h delete mode 100644 boards/feather-m0/include/arduino_board.h rename boards/feather-m0/include/{arduino_pinmap.h => arduino_iomap.h} (55%) delete mode 100644 boards/hifive1b/include/arduino_board.h rename boards/hifive1b/include/{arduino_pinmap.h => arduino_iomap.h} (93%) delete mode 100644 boards/lora-e5-dev/include/arduino_board.h rename boards/lora-e5-dev/include/{arduino_pinmap.h => arduino_iomap.h} (79%) delete mode 100644 boards/nucleo-wl55jc/include/arduino_board.h rename boards/nucleo-wl55jc/include/{arduino_pinmap.h => arduino_iomap.h} (69%) delete mode 100644 boards/p-nucleo-wb55/include/arduino_board.h rename boards/p-nucleo-wb55/include/{arduino_pinmap.h => arduino_iomap.h} (71%) delete mode 100644 boards/remote-revb/include/arduino_board.h create mode 100644 boards/remote-revb/include/arduino_iomap.h delete mode 100644 boards/remote-revb/include/arduino_pinmap.h delete mode 100644 boards/saml21-xpro/include/arduino_board.h create mode 100644 boards/saml21-xpro/include/arduino_iomap.h delete mode 100644 boards/saml21-xpro/include/arduino_pinmap.h delete mode 100644 boards/sodaq-autonomo/include/arduino_board.h create mode 100644 boards/sodaq-autonomo/include/arduino_iomap.h delete mode 100644 boards/sodaq-explorer/include/arduino_board.h create mode 100644 boards/sodaq-explorer/include/arduino_iomap.h delete mode 100644 boards/sodaq-one/include/arduino_board.h create mode 100644 boards/sodaq-one/include/arduino_iomap.h delete mode 100644 boards/sodaq-sara-aff/include/arduino_board.h create mode 100644 boards/sodaq-sara-aff/include/arduino_iomap.h delete mode 100644 boards/sodaq-sara-sff/include/arduino_board.h create mode 100644 boards/sodaq-sara-sff/include/arduino_iomap.h delete mode 100644 boards/stm32f4discovery/include/arduino_board.h rename boards/stm32f4discovery/include/{arduino_pinmap.h => arduino_iomap.h} (90%) delete mode 100644 boards/stm32l496g-disco/include/arduino_board.h rename boards/stm32l496g-disco/include/{arduino_pinmap.h => arduino_iomap.h} (69%) rename boards/ublox-c030-u201/include/{arduino_pinmap.h => arduino_iomap.h} (70%) delete mode 100644 boards/waspmote-pro/include/arduino_board.h rename boards/waspmote-pro/include/{arduino_pinmap.h => arduino_iomap.h} (92%) delete mode 100644 boards/waveshare-nrf52840-eval-kit/include/arduino_board.h rename boards/waveshare-nrf52840-eval-kit/include/{arduino_pinmap.h => arduino_iomap.h} (55%) create mode 100644 doc/doxygen/src/io-mapping-and-shields.md create mode 100644 drivers/include/arduino_pinmap.h create mode 100644 sys/arduino/include/arduino_board.h create mode 100644 sys/arduino/include/arduino_board_analog.h create mode 100644 sys/arduino/include/arduino_board_pins.h create mode 100644 sys/arduino/include/arduino_board_pwm.h diff --git a/boards/adafruit-grand-central-m4-express/Kconfig b/boards/adafruit-grand-central-m4-express/Kconfig index 03891a8241..2d5ad9b22e 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 d16dabe903..e4cbb709d7 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 71624a051a..0000000000 --- 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 69% 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 c5dfc54ff6..7740dcf795 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,26 @@ 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 +/** @} */ + +/** + * @name 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 /** @} */ /** @@ -67,11 +81,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/arduino-duemilanove/Kconfig b/boards/arduino-duemilanove/Kconfig index f44d119798..f7bc97483b 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 fdceb9913c..95efe48e75 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 abaedbbfab..a812521834 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 20de13ea29..336eb979ec 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 aeac7061b6..e5dcdf3758 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 5e96764eff..8a9664dd17 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 ae6021b3d1..2ea9afe1a3 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 48fc32e6e9..bfa91efa4d 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 c0fe4cac20..0b14032872 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 d0831843dd..2f2e9dbd62 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 fdceb9913c..f6d2d1be93 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 addd49117b..c41b31e49d 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 fdceb9913c..95efe48e75 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 35e643afb9..a0fc47a27b 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 3bc938d8f6..a8416f1491 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 29ac70f6da..0000000000 --- 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 0000000000..74eec32453 --- /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 b68ac6c5cb..0000000000 --- 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 d596a65724..f80cc88b3d 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 45c1486344..2aa562cf8c 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 c0e434b123..0000000000 --- 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 78% rename from boards/common/arduino-due/include/arduino_pinmap.h rename to boards/common/arduino-due/include/arduino_iomap.h index 266f985efd..ac728680ba 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,28 @@ 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 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#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_DAC0 ARDUINO_PIN_66 +#define ARDUINO_PIN_DAC1 ARDUINO_PIN_67 /** @} */ /** @@ -130,6 +182,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 /** @} */ /** @@ -138,11 +192,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 5a4d2df3cb..d7547283a0 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 9888bd0a69..bf73961860 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 2704aa4cfe..0000000000 --- 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 0000000000..162c72c9d4 --- /dev/null +++ b/boards/common/arduino-mkr/include/arduino_iomap.h @@ -0,0 +1,119 @@ +/* + * 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 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_15 +#define ARDUINO_PIN_A1 ARDUINO_PIN_16 +#define ARDUINO_PIN_A2 ARDUINO_PIN_17 +#define ARDUINO_PIN_A3 ARDUINO_PIN_18 +#define ARDUINO_PIN_A4 ARDUINO_PIN_19 +#define ARDUINO_PIN_A5 ARDUINO_PIN_20 +#define ARDUINO_PIN_A6 ARDUINO_PIN_21 +/** @} */ + +/** + * @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 +/** @} */ + +/** + * @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 5924aaf6d4..0000000000 --- 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 6392e0373c..82b9a8378c 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 03ea2c00bb..ca9f191dda 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 4ac4b35cb2..0000000000 --- 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 0000000000..64f6a8b79e --- /dev/null +++ b/boards/common/arduino-zero/include/arduino_iomap.h @@ -0,0 +1,147 @@ +/* + * 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 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +/** @} */ + +/** + * @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 +/** @} */ + +/** + * @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 3e03ee20c2..0000000000 --- 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 996efda23b..1a9c276dbf 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 3f0ede6249..e266c15033 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 ead4e3fe18..c309ce3c37 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 c71c96c1a0..4b1205d621 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 71624a051a..0000000000 --- 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 66% rename from boards/common/nucleo144/include/arduino_pinmap.h rename to boards/common/nucleo144/include/arduino_iomap.h index a90ddad53b..c93c54bc33 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,37 @@ 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 +/** @} */ + +/** + * @name 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 /** @} */ /** @@ -86,11 +100,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/common/nucleo32/Kconfig b/boards/common/nucleo32/Kconfig index 552ff66158..a5ac1d7dfb 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 824e8a21f8..5f13dca921 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 818d751de5..0000000000 --- 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 67% rename from boards/common/nucleo32/include/arduino_pinmap.h rename to boards/common/nucleo32/include/arduino_iomap.h index 54e4836e5c..b8174fa29e 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,31 @@ 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 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +#define ARDUINO_PIN_A6 ARDUINO_PIN_20 +#define ARDUINO_PIN_A7 ARDUINO_PIN_21 /** @} */ /** @@ -76,11 +93,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 /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/common/nucleo64/Kconfig b/boards/common/nucleo64/Kconfig index 3b410fb4bd..577e0e91cf 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 824e8a21f8..75ae094f28 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 0164ce7bfb..0000000000 --- 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 62% rename from boards/common/nucleo64/include/arduino_pinmap.h rename to boards/common/nucleo64/include/arduino_iomap.h index 5983bee5c9..4844271eee 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,27 @@ 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 +/** @} */ + +/** + * @name 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 /** @} */ /** @@ -75,11 +117,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/common/silabs/Kconfig b/boards/common/silabs/Kconfig index c425c2b2c5..a37ec01c4f 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 bd382ec652..4463a2e027 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 ef02a9e874..0000000000 --- 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 55% rename from boards/common/silabs/include/arduino_pinmap.h rename to boards/common/silabs/include/arduino_iomap.h index aaf1592d27..e65ab2297b 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 +/** @} */ /** - * @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 +/** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/common/sodaq/Kconfig b/boards/common/sodaq/Kconfig index bab0e89688..ff32879a0b 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 4f6613e8d7..6b81dc6d03 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 65007058a2..2abb4fbd69 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 044b63dfe8..b16004dc0d 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 1a282efad0..0000000000 --- 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 0000000000..2dd774fa0c --- /dev/null +++ b/boards/esp32-heltec-lora32-v2/include/arduino_iomap.h @@ -0,0 +1,80 @@ +/* + * 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 pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO1 /**< Arduino pin 1 (TxD) */ + +#define ARDUINO_PIN_2 GPIO12 /**< Arduino pin 2 */ +#define ARDUINO_PIN_3 GPIO25 /**< Arduino pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO13 /**< Arduino pin 4 */ +#define ARDUINO_PIN_5 GPIO0 /**< Arduino pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO2 /**< Arduino pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO22 /**< Arduino pin 7 */ +#define ARDUINO_PIN_8 GPIO23 /**< Arduino pin 8 */ +#define ARDUINO_PIN_9 GPIO17 /**< Arduino pin 9 (PWM) */ + +#define ARDUINO_PIN_10 GPIO18 /**< Arduino pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO27 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO19 /**< Arduino pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO5 /**< Arduino pin 13 (SCK) */ + +/* analog pins as digital pin: */ +#define ARDUINO_PIN_14 GPIO36 /**< Arduino pin A0 */ +#define ARDUINO_PIN_15 GPIO39 /**< Arduino pin A1 */ +#define ARDUINO_PIN_16 GPIO37 /**< Arduino pin A2 */ +#define ARDUINO_PIN_17 GPIO38 /**< Arduino pin A3 */ + +#define ARDUINO_PIN_18 GPIO4 /**< Arduino pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO15 /**< Arduino pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 + +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +/** @} */ + +#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 90a16db74a..0000000000 --- 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 9228d1acd3..027f0365b1 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 e5812c733a..b5c030fcfb 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 685c48f9f4..0000000000 --- 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 0000000000..5756668df3 --- /dev/null +++ b/boards/esp32-mh-et-live-minikit/include/arduino_iomap.h @@ -0,0 +1,80 @@ +/* + * 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 pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO1 /**< Arduino pin 1 (TxD) */ + +#define ARDUINO_PIN_2 GPIO32 /**< Arduino pin 2 */ +#define ARDUINO_PIN_3 GPIO2 /**< Arduino pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO27 /**< Arduino pin 4 */ +#define ARDUINO_PIN_5 GPIO0 /**< Arduino pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO4 /**< Arduino pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO33 /**< Arduino pin 7 */ +#define ARDUINO_PIN_8 GPIO25 /**< Arduino pin 8 */ +#define ARDUINO_PIN_9 GPIO15 /**< Arduino pin 9 (PWM) */ + +#define ARDUINO_PIN_10 GPIO5 /**< Arduino pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO23 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO19 /**< Arduino pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO18 /**< Arduino pin 13 (SCK) */ + +/* analog pins as digital pin: */ +#define ARDUINO_PIN_14 GPIO34 /**< Arduino pin A0 */ +#define ARDUINO_PIN_15 GPIO35 /**< Arduino pin A1 */ +#define ARDUINO_PIN_16 GPIO36 /**< Arduino pin A2 */ +#define ARDUINO_PIN_17 GPIO39 /**< Arduino pin A3 */ + +#define ARDUINO_PIN_18 GPIO21 /**< Arduino pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO22 /**< Arduino pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 + +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +/** @} */ + +#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 0473a2d846..0000000000 --- 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 32232e3a7d..7b52efabd3 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 8f565d45d4..7db04be96b 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 7c7a119ec3..0000000000 --- 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 0000000000..cf5719b48a --- /dev/null +++ b/boards/esp32-olimex-evb/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_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 pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO1 /**< Arduino pin 1 (TxD) */ + +#define ARDUINO_PIN_2 GPIO32 /**< Arduino pin 2 */ +#define ARDUINO_PIN_3 GPIO33 /**< Arduino pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO4 /**< Arduino pin 4 */ +#define ARDUINO_PIN_5 GPIO9 /**< Arduino pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO10 /**< Arduino pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO7 /**< Arduino pin 7 */ +#define ARDUINO_PIN_8 GPIO8 /**< Arduino pin 8 */ + +#define ARDUINO_PIN_10 GPIO17 /**< Arduino pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO15 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO2 /**< Arduino pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO14 /**< Arduino pin 13 (SCK) */ + +#define ARDUINO_PIN_14 GPIO34 /**< Arduino pin A0 */ +#define ARDUINO_PIN_15 GPIO35 /**< Arduino pin A1 */ +#define ARDUINO_PIN_16 GPIO36 /**< Arduino pin A2 */ +#define ARDUINO_PIN_17 GPIO39 /**< Arduino pin A3 */ + +#define ARDUINO_PIN_18 GPIO13 /**< Arduino pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO16 /**< Arduino pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +/** @} */ + +#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 1a041304a9..0000000000 --- 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 c79c109d8e..c82b8d9a34 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 6dd1d4b7e7..af35e4bf5d 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 1d2173d3a5..0000000000 --- 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 0000000000..9f9ddb6f3b --- /dev/null +++ b/boards/esp32-ttgo-t-beam/include/arduino_iomap.h @@ -0,0 +1,71 @@ +/* + * 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 pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO1 /**< Arduino pin 1 (TxD) */ +#define ARDUINO_PIN_2 GPIO0 /**< Arduino pin 2 */ +#define ARDUINO_PIN_3 GPIO2 /**< Arduino pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO4 /**< Arduino pin 4 */ +#define ARDUINO_PIN_5 GPIO13 /**< Arduino pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO15 /**< Arduino pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO21 /**< Arduino pin 7 */ +#define ARDUINO_PIN_8 GPIO22 /**< Arduino pin 8 */ +#define ARDUINO_PIN_9 GPIO23 /**< Arduino pin 9 (PWM) */ +#define ARDUINO_PIN_13 GPIO14 /**< Arduino pin 13 (LED) */ +#define ARDUINO_PIN_14 GPIO25 /**< Arduino pin A0 */ +#define ARDUINO_PIN_15 GPIO32 /**< Arduino pin A1 */ +#define ARDUINO_PIN_16 GPIO33 /**< Arduino pin A2 */ +#define ARDUINO_PIN_17 GPIO35 /**< Arduino pin A3 */ +#define ARDUINO_PIN_18 GPIO36 /**< Arduino pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO39 /**< Arduino pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +/** @} */ + +#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 53e5a1c0d3..0000000000 --- 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 cb3aca4f15..e6196f6da4 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 650bddbd9a..e0d61206d8 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 a1d9e0d5c8..0000000000 --- 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 0000000000..962aba7166 --- /dev/null +++ b/boards/esp32-wemos-lolin-d32-pro/include/arduino_iomap.h @@ -0,0 +1,80 @@ +/* + * 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 pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO1 /**< Arduino pin 1 (TxD) */ + +#define ARDUINO_PIN_2 GPIO4 /**< Arduino pin 2 */ +#define ARDUINO_PIN_3 GPIO0 /**< Arduino pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO13 /**< Arduino pin 4 */ +#define ARDUINO_PIN_5 GPIO2 /**< Arduino pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO15 /**< Arduino pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO25 /**< Arduino pin 7 */ +#define ARDUINO_PIN_8 GPIO26 /**< Arduino pin 8 */ +#define ARDUINO_PIN_9 GPIO32 /**< Arduino pin 9 (PWM) */ + +#define ARDUINO_PIN_10 GPIO5 /**< Arduino pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO23 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO19 /**< Arduino pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO18 /**< Arduino pin 13 (SCK) */ + +/* analog pins as digital pin: */ +#define ARDUINO_PIN_14 GPIO36 /**< Arduino pin A0 */ +#define ARDUINO_PIN_15 GPIO39 /**< Arduino pin A1 */ +#define ARDUINO_PIN_16 GPIO34 /**< Arduino pin A2 */ +#define ARDUINO_PIN_17 GPIO35 /**< Arduino pin A3 */ + +#define ARDUINO_PIN_18 GPIO21 /**< Arduino pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO22 /**< Arduino pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 + +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +/** @} */ + +#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 1ad2e7d6d7..0000000000 --- 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 c1f52a2b66..dbf682aceb 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 e5812c733a..b5c030fcfb 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 8c0518e393..0000000000 --- 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_iomap.h b/boards/esp32-wroom-32/include/arduino_iomap.h new file mode 100644 index 0000000000..c0f1f284bb --- /dev/null +++ b/boards/esp32-wroom-32/include/arduino_iomap.h @@ -0,0 +1,80 @@ +/* + * 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 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 pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO1 /**< Arduino pin 1 (TxD) */ + +#define ARDUINO_PIN_2 GPIO12 /**< Arduino pin 2 */ +#define ARDUINO_PIN_3 GPIO27 /**< Arduino pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO2 /**< Arduino pin 4 */ +#define ARDUINO_PIN_5 GPIO32 /**< Arduino pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO33 /**< Arduino pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO13 /**< Arduino pin 7 */ +#define ARDUINO_PIN_8 GPIO14 /**< Arduino pin 8 */ +#define ARDUINO_PIN_9 GPIO0 /**< Arduino pin 9 (PWM) */ + +#define ARDUINO_PIN_10 GPIO5 /**< Arduino pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO23 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO19 /**< Arduino pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO18 /**< Arduino pin 13 (SCK) */ + +/* analog pins as digital pin: */ +#define ARDUINO_PIN_14 GPIO25 /**< Arduino pin A0 */ +#define ARDUINO_PIN_15 GPIO26 /**< Arduino pin A1 */ +#define ARDUINO_PIN_16 GPIO4 /**< Arduino pin A2 */ +#define ARDUINO_PIN_17 GPIO15 /**< Arduino pin A3 */ + +#define ARDUINO_PIN_18 GPIO21 /**< Arduino pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO22 /**< Arduino pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 + +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/esp32-wroom-32/include/arduino_pinmap.h b/boards/esp32-wroom-32/include/arduino_pinmap.h deleted file mode 100644 index 88f04e40df..0000000000 --- a/boards/esp32-wroom-32/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_wroom-32 - * @{ - * - * @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 GPIO27 /**< Arduino Uno pin 3 (PWM) */ -#define ARDUINO_PIN_4 GPIO2 /**< Arduino Uno pin 4 */ -#define ARDUINO_PIN_5 GPIO32 /**< Arduino Uno pin 5 (PWM) */ -#define ARDUINO_PIN_6 GPIO33 /**< Arduino Uno pin 6 (PWM) */ -#define ARDUINO_PIN_7 GPIO13 /**< Arduino Uno pin 7 */ -#define ARDUINO_PIN_8 GPIO14 /**< Arduino Uno pin 8 */ -#define ARDUINO_PIN_9 GPIO0 /**< 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 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 */ - -#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-wrover-kit/Kconfig b/boards/esp32-wrover-kit/Kconfig index de160dff49..e19495d7ef 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 2a0f9909d0..c93ac66276 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 bbca81e897..0000000000 --- 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 0000000000..09dec3729c --- /dev/null +++ b/boards/esp32-wrover-kit/include/arduino_iomap.h @@ -0,0 +1,78 @@ +/* + * 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 pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO1 /**< Arduino pin 1 (TxD) */ + +#define ARDUINO_PIN_2 GPIO19 /**< Arduino pin 2 */ +#define ARDUINO_PIN_3 GPIO0 /**< Arduino pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO22 /**< Arduino pin 4 */ +#define ARDUINO_PIN_5 GPIO4 /**< Arduino pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO23 /**< Arduino pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO25 /**< Arduino pin 7 */ +#define ARDUINO_PIN_8 GPIO9 /**< Arduino pin 8 */ +#define ARDUINO_PIN_9 GPIO10 /**< Arduino pin 9 (PWM) */ + +#define ARDUINO_PIN_10 GPIO13 /**< Arduino pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO15 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO2 /**< Arduino pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO14 /**< Arduino pin 13 (SCK) */ + +#define ARDUINO_PIN_14 GPIO34 /**< Arduino pin A0 */ +#define ARDUINO_PIN_15 GPIO35 /**< Arduino pin A1 */ +#define ARDUINO_PIN_16 GPIO36 /**< Arduino pin A2 */ +#define ARDUINO_PIN_17 GPIO39 /**< Arduino pin A3 */ + +#define ARDUINO_PIN_18 GPIO26 /**< Arduino pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO27 /**< Arduino pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +/** @} */ + +#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 5d00d007f2..0000000000 --- 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 514d3b6703..33eb7002a8 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 fcd5860031..b705976d68 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 389c486db3..0000000000 --- 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 0000000000..70601e8bda --- /dev/null +++ b/boards/esp32c3-devkit/include/arduino_iomap.h @@ -0,0 +1,80 @@ +/* + * 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 pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO21 /**< Arduino pin 1 (TxD) */ +#if !defined(MODULE_ESP_RTC_TIMER_32K) +#define ARDUINO_PIN_2 GPIO0 /**< Arduino pin 2 */ +#define ARDUINO_PIN_3 GPIO1 /**< Arduino pin 3 (PWM) */ +#endif +#define ARDUINO_PIN_5 GPIO3 /**< Arduino pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO4 /**< Arduino pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO8 /**< Arduino pin 7 */ + +#define ARDUINO_PIN_10 GPIO10 /**< Arduino pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO7 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO2 /**< Arduino pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO6 /**< Arduino pin 13 (SCK) */ + +/* analog pins as digital pins: */ +#define ARDUINO_PIN_14 GPIO0 /**< Arduino pin A0 */ +#if !defined(MODULE_ESP_RTC_TIMER_32K) +#define ARDUINO_PIN_15 GPIO1 /**< Arduino pin A1 */ +#endif +#define ARDUINO_PIN_16 GPIO2 /**< Arduino pin A2 */ +#define ARDUINO_PIN_17 GPIO3 /**< Arduino pin A3 */ + +#define ARDUINO_PIN_18 GPIO5 /**< Arduino pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO4 /**< Arduino pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 + +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +/** @} */ + +#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 45277cddfa..0000000000 --- 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 aedd829f56..4ae4007886 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 69bfcf330b..c857e9e2cd 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 5e5e5f6fe0..0000000000 --- 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 0000000000..aea991ebc2 --- /dev/null +++ b/boards/esp32c3-wemos-mini/include/arduino_iomap.h @@ -0,0 +1,87 @@ +/* + * 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 pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO21 /**< Arduino pin 1 (TxD) */ +#define ARDUINO_PIN_2 GPIO9 /**< Arduino pin 2 */ +#define ARDUINO_PIN_3 GPIO6 /**< Arduino pin 3 (PWM) */ + +#ifdef MODULE_ESP32C3_WEMOS_MINI_V1_0_0 +# define ARDUINO_PIN_5 GPIO7 /**< Arduino pin 5 (PWM) */ +# define ARDUINO_PIN_6 GPIO1 /**< Arduino pin 6 (PWM) */ +# define ARDUINO_PIN_7 GPIO0 /**< Arduino pin 7 */ +#else /* MODULE_ESP32C3_WEMOS_MINI_V2_1_0 */ +# define ARDUINO_PIN_6 GPIO2 /**< Arduino pin 6 (PWM) */ +# define ARDUINO_PIN_7 GPIO3 /**< Arduino pin 7 */ +#endif + +#ifdef MODULE_ESP32C3_WEMOS_MINI_V1_0_0 +# define ARDUINO_PIN_10 GPIO5 /**< Arduino pin 10 (CS0 / PWM) */ +# define ARDUINO_PIN_11 GPIO4 /**< Arduino pin 11 (MOSI / PWM) */ +# define ARDUINO_PIN_12 GPIO3 /**< Arduino pin 12 (MISO) */ +# define ARDUINO_PIN_13 GPIO2 /**< Arduino pin 13 (SCK) */ +#else /* MODULE_ESP32C3_WEMOS_MINI_V2_1_0 */ +# define ARDUINO_PIN_10 GPIO5 /**< Arduino pin 10 (CS0 / PWM) */ +# define ARDUINO_PIN_11 GPIO4 /**< Arduino pin 11 (MOSI / PWM) */ +# define ARDUINO_PIN_12 GPIO0 /**< Arduino pin 12 (MISO) */ +# define ARDUINO_PIN_13 GPIO1 /**< Arduino pin 13 (SCK) */ +#endif + +/* analog pins as digital pin: */ +#define ARDUINO_PIN_14 GPIO0 /**< Arduino pin A0 */ +#define ARDUINO_PIN_15 GPIO1 /**< Arduino pin A1 */ +#define ARDUINO_PIN_16 GPIO2 /**< Arduino pin A2 */ +#define ARDUINO_PIN_17 GPIO3 /**< Arduino pin A3 */ +#define ARDUINO_PIN_18 GPIO4 /**< Arduino pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO5 /**< Arduino pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +/** @} */ + +#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 ff3fc69967..0000000000 --- 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 c51b29253b..f8d28211e7 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 cb42fd74ee..d04a85b206 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 13bd88688a..0000000000 --- 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 0000000000..4085ca4dcc --- /dev/null +++ b/boards/esp32s2-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_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 pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO43 /**< Arduino pin 1 (TxD) */ +#define ARDUINO_PIN_2 GPIO0 /**< Arduino pin 2 */ +#define ARDUINO_PIN_3 GPIO10 /**< Arduino pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO3 /**< Arduino pin 4 */ +#define ARDUINO_PIN_5 GPIO11 /**< Arduino pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO12 /**< Arduino pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO6 /**< Arduino pin 7 */ +#define ARDUINO_PIN_8 GPIO7 /**< Arduino pin 8 */ +#define ARDUINO_PIN_9 GPIO13 /**< Arduino pin 9 (PWM) */ + +#define ARDUINO_PIN_10 GPIO38 /**< Arduino pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO35 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO37 /**< Arduino pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO36 /**< Arduino pin 13 (SCK) */ + +/* analog pins as digital pin */ +#define ARDUINO_PIN_14 GPIO1 /**< Arduino pin A0 */ +#define ARDUINO_PIN_15 GPIO2 /**< Arduino pin A1 */ +#define ARDUINO_PIN_16 GPIO4 /**< Arduino pin A2 */ +#define ARDUINO_PIN_17 GPIO5 /**< Arduino pin A3 */ + +#define ARDUINO_PIN_18 GPIO8 /**< Arduino pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO9 /**< Arduino pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 + +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +/** @} */ + +#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 f39513e016..0000000000 --- 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 e4c820fa49..f62d0d80a9 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 2a9342802b..024e2119d7 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 0fcca86b5f..0000000000 --- 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 0000000000..22adb1e91b --- /dev/null +++ b/boards/esp32s2-lilygo-ttgo-t8/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_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 pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO43 /**< Arduino pin 1 (TxD) */ +#define ARDUINO_PIN_2 GPIO21 /**< Arduino pin 2 */ +#define ARDUINO_PIN_3 GPIO39 /**< Arduino pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO21 /**< Arduino pin 4 */ +#define ARDUINO_PIN_5 GPIO40 /**< Arduino pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO41 /**< Arduino pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO17 /**< Arduino pin 7 */ +#define ARDUINO_PIN_8 GPIO18 /**< Arduino pin 8 */ +#define ARDUINO_PIN_9 GPIO42 /**< Arduino pin 9 (PWM) */ + +#define ARDUINO_PIN_10 GPIO38 /**< Arduino pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO35 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO37 /**< Arduino pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO36 /**< Arduino pin 13 (SCK) */ + +/* analog pins as digital pin: */ +#define ARDUINO_PIN_14 GPIO1 /**< Arduino pin A0 */ +#define ARDUINO_PIN_15 GPIO2 /**< Arduino pin A1 */ +#define ARDUINO_PIN_16 GPIO4 /**< Arduino pin A2 */ +#define ARDUINO_PIN_17 GPIO5 /**< Arduino pin A3 */ + +#define ARDUINO_PIN_18 GPIO7 /**< Arduino pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO8 /**< Arduino pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 + +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +/** @} */ + +#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 f1624c5689..0000000000 --- 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 5f1f8f2787..f13f62c980 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 e009433f58..ada35c5457 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 c666ee85d2..0000000000 --- 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 0000000000..5edfc444e3 --- /dev/null +++ b/boards/esp32s3-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_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 pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO43 /**< Arduino pin 1 (TxD) */ +#define ARDUINO_PIN_2 GPIO0 /**< Arduino pin 2 */ +#define ARDUINO_PIN_3 GPIO14 /**< Arduino pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO3 /**< Arduino pin 4 */ +#define ARDUINO_PIN_5 GPIO17 /**< Arduino pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO18 /**< Arduino pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO6 /**< Arduino pin 7 */ +#define ARDUINO_PIN_8 GPIO7 /**< Arduino pin 8 */ +#define ARDUINO_PIN_9 GPIO21 /**< Arduino pin 9 (PWM) */ + +#define ARDUINO_PIN_10 GPIO10 /**< Arduino pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO11 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO13 /**< Arduino pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO12 /**< Arduino pin 13 (SCK) */ + +#define ARDUINO_PIN_14 GPIO1 /**< Arduino pin A0 */ +#define ARDUINO_PIN_15 GPIO2 /**< Arduino pin A1 */ +#define ARDUINO_PIN_16 GPIO4 /**< Arduino pin A2 */ +#define ARDUINO_PIN_17 GPIO5 /**< Arduino pin A3 */ + +#define ARDUINO_PIN_18 GPIO8 /**< Arduino pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO9 /**< Arduino pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 + +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +/** @} */ + +#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 45fdd9f28f..0000000000 --- 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 85021934cf..e779ab0e6a 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 b3764b1939..ec6ebe9830 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 9731fb4440..0000000000 --- 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 0000000000..03cda0502f --- /dev/null +++ b/boards/esp32s3-pros3/include/arduino_iomap.h @@ -0,0 +1,77 @@ +/* + * 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 pin 0 (RxD) */ +#define ARDUINO_PIN_1 GPIO43 /**< Arduino pin 1 (TxD) */ +#define ARDUINO_PIN_2 GPIO0 /**< Arduino pin 2 */ +#define ARDUINO_PIN_3 GPIO12 /**< Arduino pin 3 (PWM) */ +#define ARDUINO_PIN_4 GPIO6 /**< Arduino pin 4 */ +#define ARDUINO_PIN_5 GPIO13 /**< Arduino pin 5 (PWM) */ +#define ARDUINO_PIN_6 GPIO14 /**< Arduino pin 6 (PWM) */ +#define ARDUINO_PIN_7 GPIO7 /**< Arduino pin 7 */ +#define ARDUINO_PIN_8 GPIO16 /**< Arduino pin 8 */ +#define ARDUINO_PIN_9 GPIO15 /**< Arduino pin 9 (PWM) */ + +#define ARDUINO_PIN_10 GPIO34 /**< Arduino pin 10 (CS0 / PWM) */ +#define ARDUINO_PIN_11 GPIO35 /**< Arduino pin 11 (MOSI / PWM) */ +#define ARDUINO_PIN_12 GPIO37 /**< Arduino pin 12 (MISO) */ +#define ARDUINO_PIN_13 GPIO36 /**< Arduino pin 13 (SCK) */ + +#define ARDUINO_PIN_14 GPIO1 /**< Arduino pin A0 */ +#define ARDUINO_PIN_15 GPIO2 /**< Arduino pin A1 */ +#define ARDUINO_PIN_16 GPIO4 /**< Arduino pin A2 */ +#define ARDUINO_PIN_17 GPIO5 /**< Arduino pin A3 */ + +#define ARDUINO_PIN_18 GPIO8 /**< Arduino pin A4 (SDA) */ +#define ARDUINO_PIN_19 GPIO9 /**< Arduino pin A5 (SCL) */ + +#define ARDUINO_PIN_LAST 19 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +/** @} */ + +#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 5cfc44ea62..0000000000 --- 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 c8e2e62dfb..0000000000 --- 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 0000000000..4ee7396194 --- /dev/null +++ b/boards/esp8266-esp-12x/include/arduino_iomap.h @@ -0,0 +1,70 @@ +/* + * 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 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +/** @} */ + +#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 188618a3f3..0000000000 --- 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 0000000000..bdb4a9688d --- /dev/null +++ b/boards/esp8266-olimex-mod/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_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 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +/** @} */ + +#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 7a65bf89d6..0000000000 --- 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 0000000000..88f13a8333 --- /dev/null +++ b/boards/esp8266-sparkfun-thing/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_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 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +/** @} */ + +#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 cd58db7a7f..b539599977 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 dcfbbf7224..3829f6c7e5 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 4e97255ff8..0000000000 --- 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 55% rename from boards/feather-m0/include/arduino_pinmap.h rename to boards/feather-m0/include/arduino_iomap.h index f28fcf0fcd..3c722a6b8b 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,51 +56,52 @@ extern "C" { #define ARDUINO_PIN_23 GPIO_PIN(PB, 10) /**< D23 (SPI MOSI) */ #define ARDUINO_PIN_24 GPIO_PIN(PB, 11) /**< D24 (SPI SCK) */ -#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) */ -#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 */ -#endif +#define ARDUINO_PIN_LAST 24 -#define ARDUINO_PIN_A0 ARDUINO_PIN_14 /**< A0 */ -#define ARDUINO_PIN_A1 ARDUINO_PIN_15 /**< A1 */ -#define ARDUINO_PIN_A2 ARDUINO_PIN_16 /**< A2 */ -#define ARDUINO_PIN_A3 ARDUINO_PIN_17 /**< A3 */ -#define ARDUINO_PIN_A4 ARDUINO_PIN_18 /**< A4 */ -#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /**< A5 */ -#define ARDUINO_PIN_A7 ARDUINO_PIN_9 /**< A7 */ +#if defined(BOARD_FEATHER_M0_WIFI) +# 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_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 +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 +#define ARDUINO_PIN_A7 ARDUINO_PIN_9 /** @} */ /** * @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 /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/hifive1b/Kconfig b/boards/hifive1b/Kconfig index 7c2f44c818..4f45f05176 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 6d183b3805..dbf41816ed 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 46a14a6e64..0000000000 --- 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 93% rename from boards/hifive1b/include/arduino_pinmap.h rename to boards/hifive1b/include/arduino_iomap.h index d2ee77400e..110dec3916 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 /** @} */ #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 ae10e390c3..ee0228f6e5 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 b0f90c175e..df60c40d43 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 4a6f34b0e6..0000000000 --- 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 d08616b3a5..51aa48561e 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 /** @} */ @@ -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 2c66431f4c..03845b2094 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 15879fcc26..0000000000 --- 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 faaeac9233..b743d846c5 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 1351bf5d2c..46a32593a4 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 9d17d84c53..a59e19133e 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 5695fe82dc..0000000000 --- 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 71% rename from boards/p-nucleo-wb55/include/arduino_pinmap.h rename to boards/p-nucleo-wb55/include/arduino_iomap.h index ead5821ca3..3e08f092dd 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,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_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 +/** @} */ + +/** + * @name 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 /** @} */ /** @@ -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 /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/remote-revb/Kconfig b/boards/remote-revb/Kconfig index e1cafa4b8c..dfba9af3f7 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 85a55f8ecf..2942e38d7d 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 ee26399393..0000000000 --- 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 0000000000..7d388eb53c --- /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 + +/* 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 +/** @} */ + +#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 ed50a62ca7..0000000000 --- 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 fb9f3f7735..0000000000 --- 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 0000000000..39c52691a5 --- /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 +/** @} */ + +/** + * @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 +/** @} */ + +#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 0c3f3bc615..0000000000 --- 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 aacb468936..0000000000 --- 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 0000000000..dfd298aa3f --- /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 +/** @} */ + +/** + * @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 +/** @} */ + +/** + * @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 8fe4a317cc..0000000000 --- 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 0000000000..2841c19c55 --- /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 +/** @} */ + +/** + * @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 +/** @} */ + +#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 19f8597fbf..0000000000 --- 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 0000000000..32e72f0981 --- /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 +/** @} */ + +/** + * @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 +/** @} */ + +#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 b0a78981b1..0000000000 --- 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 0000000000..63c2b1644e --- /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 +/** @} */ + +/** + * @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 +/** @} */ + +#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 84fae71689..0000000000 --- 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 0000000000..e61852126c --- /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 +/** @} */ + +/** + * @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 +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ diff --git a/boards/stm32f4discovery/Kconfig b/boards/stm32f4discovery/Kconfig index ad6d78d76d..0f8f388f35 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 24ec337fec..a7969b6073 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 1376f9bd9a..0000000000 --- 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 90% rename from boards/stm32f4discovery/include/arduino_pinmap.h rename to boards/stm32f4discovery/include/arduino_iomap.h index 40d0efbfbb..45135f676d 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 /** @} */ /** @@ -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 /** @} */ #ifdef __cplusplus } #endif -#endif /* ARDUINO_PINMAP_H */ +#endif /* ARDUINO_IOMAP_H */ /** @} */ diff --git a/boards/stm32l496g-disco/Kconfig b/boards/stm32l496g-disco/Kconfig index cc5a452ffe..44f34f387b 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 eaf67e7a6f..45a92f47d7 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 299855dd09..0000000000 --- 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 69% rename from boards/stm32l496g-disco/include/arduino_pinmap.h rename to boards/stm32l496g-disco/include/arduino_iomap.h index 73632548df..043d86c560 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,27 @@ 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 +/** @} */ + +/** + * @name 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 /** @} */ /** @@ -65,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 /** @} */ #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 70% rename from boards/ublox-c030-u201/include/arduino_pinmap.h rename to boards/ublox-c030-u201/include/arduino_iomap.h index a272a63798..bfaf0c8c0f 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,27 @@ 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 +/** @} */ + +/** + * @name 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 /** @} */ /** @@ -70,11 +85,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/waspmote-pro/Kconfig b/boards/waspmote-pro/Kconfig index 86b67817e1..2960776524 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 f36b525208..20b497f9e4 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 24ad73b805..0000000000 --- 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 92% rename from boards/waspmote-pro/include/arduino_pinmap.h rename to boards/waspmote-pro/include/arduino_iomap.h index dfc283f12d..665f0f883f 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 +/** @} */ + +/** + * @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 /** @} */ #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 840e411688..a238d61c83 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 0b795a74b5..81e7e7f8d4 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 a5d404a8c2..0000000000 --- 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 55% rename from boards/waveshare-nrf52840-eval-kit/include/arduino_pinmap.h rename to boards/waveshare-nrf52840-eval-kit/include/arduino_iomap.h index bfb0056861..c4f8cae325 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,30 @@ 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 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 ARDUINO_PIN_14 +#define ARDUINO_PIN_A1 ARDUINO_PIN_15 +#define ARDUINO_PIN_A2 ARDUINO_PIN_16 +#define ARDUINO_PIN_A3 ARDUINO_PIN_17 +#define ARDUINO_PIN_A4 ARDUINO_PIN_18 +#define ARDUINO_PIN_A5 ARDUINO_PIN_19 /** @} */ /** @@ -69,11 +83,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 +/** @} */ + +/** + * @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 0a8821f41b..f47934aa28 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 0000000000..4078c44af8 --- /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 3e3286dce4..715443fc3e 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 +config HAS_ARDUINO_PINS 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 0000000000..fcd272e2f9 --- /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 d3cedb2b9f..7f31aefebb 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 557406b58c..44c586f059 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 b1ffeff5f4..a6277517c3 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 6dea0e1621..d731373790 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 284d54d363..dc8ad8ff9a 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 53118a3a9c..71ed93ef76 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++. + * @note As prerequisite, the board must have support for C++. Support for + * the standard C++ lib (feature `libstdcpp`) is not required. * - * To add Arduino support to a board, it has to provide the following: + * As a minimum requirement, the features `arduino_pins` is a hard dependency. + * See @ref iomaps-mapping-gpio what a board needs to provide this. * - * 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 - * - * 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'. - * - * 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 0000000000..5d74c46436 --- /dev/null +++ b/sys/arduino/include/arduino_board.h @@ -0,0 +1,54 @@ +/* + * 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_board_analog.h" +#include "arduino_board_pins.h" +#include "arduino_board_pwm.h" + +#ifdef __cplusplus +extern "C" { +#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/sys/arduino/include/arduino_board_analog.h b/sys/arduino/include/arduino_board_analog.h new file mode 100644 index 0000000000..0177a115d9 --- /dev/null +++ b/sys/arduino/include/arduino_board_analog.h @@ -0,0 +1,164 @@ +/* + * 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 sys_arduino + * @{ + * + * @file + * @brief Arduino analog pin map + * + * @note The contents of this file are mostly generated using the + * python snippets documented. Do not edit these parts by hand, + * but rather adjust the python snippets and regenerate. + * + * @author Marian Buschsieweke + */ + +#ifndef ARDUINO_BOARD_ANALOG_H +#define ARDUINO_BOARD_ANALOG_H + +#include "periph/adc.h" +#include "arduino_iomap.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef DOXYGEN +/** + * @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 */ + +/* 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 + +#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[] = { +#ifndef DOXYGEN +#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 /* DOXYGEN */ +}; +#endif /* defined(ARDUINO_ANALOG_PIN_LAST) */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_BOARD_ANALOG_H */ +/** @} */ diff --git a/sys/arduino/include/arduino_board_pins.h b/sys/arduino/include/arduino_board_pins.h new file mode 100644 index 0000000000..5d1f3bbccd --- /dev/null +++ b/sys/arduino/include/arduino_board_pins.h @@ -0,0 +1,436 @@ +/* + * 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 sys_arduino + * @{ + * + * @file + * @brief Arduino digital pin map + * + * @note The contents of this file are mostly generated using the + * python snippets documented. Do not edit these parts by hand, + * but rather adjust the python snippets and regenerate. + * + * @author Marian Buschsieweke + */ + +#ifndef ARDUINO_BOARD_PINS_H +#define ARDUINO_BOARD_PINS_H + +#include "arduino_iomap.h" +#include "periph/gpio.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 */ +#endif /* DOXYGEN */ + +#if !defined(ARDUINO_LED) && !defined(DOXYGEN) +#define ARDUINO_LED (13) +#endif + +#ifndef ARDUINO_PIN_LAST +# error "ARDUINO_PIN_LAST undefined" +#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[] = { +#ifndef DOXYGEN +#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 +#endif /* DOXYGEN */ +}; + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_BOARD_PINS_H */ +/** @} */ diff --git a/sys/arduino/include/arduino_board_pwm.h b/sys/arduino/include/arduino_board_pwm.h new file mode 100644 index 0000000000..4fbba41100 --- /dev/null +++ b/sys/arduino/include/arduino_board_pwm.h @@ -0,0 +1,164 @@ +/* + * 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 sys_arduino + * @{ + * + * @file + * @brief Mapping of Arduino digital pin numbers to PWM settings + * + * @note The contents of this file are mostly generated using the + * python snippets documented. Do not edit these parts by hand, + * but rather adjust the python snippets and regenerate. + * + * @author Marian Buschsieweke + */ + +#ifndef ARDUINO_BOARD_PWM_H +#define ARDUINO_BOARD_PWM_H + +#include "arduino_iomap.h" +#include "periph/pwm.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#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 +}; + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_BOARD_PWM_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 a58f6fda0b..6c3df39115 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 d19e55bbe2..98f55d83a8 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 e49903ffe9..a565e64d09 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 53eb62ad6d..cccfc875d7 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