From 6b86f8aaf1160847f34c0464adf36e355111a036 Mon Sep 17 00:00:00 2001 From: Akshai M Date: Tue, 20 Apr 2021 19:00:18 +0200 Subject: [PATCH] boards/nucleo-wl55jc : Add arduino interfaces --- boards/nucleo-wl55jc/Kconfig | 1 + boards/nucleo-wl55jc/Makefile.features | 3 + boards/nucleo-wl55jc/include/arduino_board.h | 71 +++++++++++++++++ boards/nucleo-wl55jc/include/arduino_pinmap.h | 79 +++++++++++++++++++ 4 files changed, 154 insertions(+) create mode 100644 boards/nucleo-wl55jc/include/arduino_board.h create mode 100644 boards/nucleo-wl55jc/include/arduino_pinmap.h diff --git a/boards/nucleo-wl55jc/Kconfig b/boards/nucleo-wl55jc/Kconfig index 1cc002dbe7..f9f6e0fb53 100644 --- a/boards/nucleo-wl55jc/Kconfig +++ b/boards/nucleo-wl55jc/Kconfig @@ -23,6 +23,7 @@ config BOARD_NUCLEO_WL55JC select HAS_PERIPH_UART # Put other features for this board (in alphabetical order) + select HAS_ARDUINO select HAS_RIOTBOOT source "$(RIOTBOARD)/common/nucleo64/Kconfig" diff --git a/boards/nucleo-wl55jc/Makefile.features b/boards/nucleo-wl55jc/Makefile.features index ac87b8468a..a567d845b8 100644 --- a/boards/nucleo-wl55jc/Makefile.features +++ b/boards/nucleo-wl55jc/Makefile.features @@ -11,3 +11,6 @@ FEATURES_PROVIDED += periph_uart # Put other features for this board (in alphabetical order) FEATURES_PROVIDED += riotboot + +# load the common Makefile.features for Nucleo boards +include $(RIOTBOARD)/common/nucleo64/Makefile.features diff --git a/boards/nucleo-wl55jc/include/arduino_board.h b/boards/nucleo-wl55jc/include/arduino_board.h new file mode 100644 index 0000000000..15879fcc26 --- /dev/null +++ b/boards/nucleo-wl55jc/include/arduino_board.h @@ -0,0 +1,71 @@ +/* + * 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_pinmap.h new file mode 100644 index 0000000000..17ed0c44d2 --- /dev/null +++ b/boards/nucleo-wl55jc/include/arduino_pinmap.h @@ -0,0 +1,79 @@ +/* + * 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 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 Akshai M + * + */ + +#ifndef ARDUINO_PINMAP_H +#define ARDUINO_PINMAP_H + +#include "periph/gpio.h" +#include "periph/adc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Mapping of MCU pins to Arduino pins + * @{ + */ +#define ARDUINO_PIN_0 GPIO_PIN(PORT_B, 7) +#define ARDUINO_PIN_1 GPIO_PIN(PORT_B, 6) +#define ARDUINO_PIN_2 GPIO_PIN(PORT_B, 12) +#define ARDUINO_PIN_3 GPIO_PIN(PORT_B, 3) +#define ARDUINO_PIN_4 GPIO_PIN(PORT_B, 5) +#define ARDUINO_PIN_5 GPIO_PIN(PORT_B, 8) +#define ARDUINO_PIN_6 GPIO_PIN(PORT_B, 10) +#define ARDUINO_PIN_7 GPIO_PIN(PORT_C, 1) +#define ARDUINO_PIN_8 GPIO_PIN(PORT_C, 2) +#define ARDUINO_PIN_9 GPIO_PIN(PORT_A, 9) +#define ARDUINO_PIN_10 GPIO_PIN(PORT_A, 4) +#define ARDUINO_PIN_11 GPIO_PIN(PORT_A, 7) +#define ARDUINO_PIN_12 GPIO_PIN(PORT_A, 6) +#define ARDUINO_PIN_13 GPIO_PIN(PORT_A, 5) +#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) +/** @ */ + +/** + * @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 */ +/** @} */