diff --git a/boards/nucleo32-common/Makefile b/boards/nucleo32-common/Makefile new file mode 100644 index 000000000000..66c35f5cff04 --- /dev/null +++ b/boards/nucleo32-common/Makefile @@ -0,0 +1,3 @@ +MODULE = nucleo32_common + +include $(RIOTBASE)/Makefile.base diff --git a/boards/nucleo32-common/Makefile.features b/boards/nucleo32-common/Makefile.features new file mode 100644 index 000000000000..984ac84fd9d3 --- /dev/null +++ b/boards/nucleo32-common/Makefile.features @@ -0,0 +1,3 @@ +# Various common features of Nucleo boards +FEATURES_PROVIDED += cpp +FEATURES_PROVIDED += arduino diff --git a/boards/nucleo32-common/Makefile.include b/boards/nucleo32-common/Makefile.include new file mode 100644 index 000000000000..e647e4f8880c --- /dev/null +++ b/boards/nucleo32-common/Makefile.include @@ -0,0 +1,5 @@ +# include nucleo common serial configuration +include $(RIOTBOARD)/nucleo-common/Makefile.include.serial + +# add the common header files to the include path +INCLUDES += -I$(RIOTBOARD)/nucleo32-common/include diff --git a/boards/nucleo32-common/include/arduino_board.h b/boards/nucleo32-common/include/arduino_board.h new file mode 100644 index 000000000000..2f2b5e3f3d4b --- /dev/null +++ b/boards/nucleo32-common/include/arduino_board.h @@ -0,0 +1,66 @@ +/* + * 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_nucleo32-common + * @{ + * + * @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 +}; + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_BOARD_H */ +/** @} */ diff --git a/boards/nucleo32-common/include/arduino_pinmap.h b/boards/nucleo32-common/include/arduino_pinmap.h new file mode 100644 index 000000000000..e60e0cebebd7 --- /dev/null +++ b/boards/nucleo32-common/include/arduino_pinmap.h @@ -0,0 +1,66 @@ +/* + * 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_nucleo32-common + * @{ + * + * @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" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Mapping of MCU pins to Arduino pins + * @{ + */ +#define ARDUINO_PIN_0 GPIO_PIN(PORT_A, 10) +#define ARDUINO_PIN_1 GPIO_PIN(PORT_A, 9) +#define ARDUINO_PIN_2 GPIO_PIN(PORT_A, 12) +#define ARDUINO_PIN_3 GPIO_PIN(PORT_B, 0) +#define ARDUINO_PIN_4 GPIO_PIN(PORT_B, 7) +#define ARDUINO_PIN_5 GPIO_PIN(PORT_B, 6) +#define ARDUINO_PIN_6 GPIO_PIN(PORT_B, 1) +#define ARDUINO_PIN_7 GPIO_PIN(PORT_C, 14) + +#define ARDUINO_PIN_8 GPIO_PIN(PORT_C, 15) +#define ARDUINO_PIN_9 GPIO_PIN(PORT_A, 8) +#define ARDUINO_PIN_10 GPIO_PIN(PORT_A, 11) +#define ARDUINO_PIN_11 GPIO_PIN(PORT_B, 5) +#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) +/** @ */ + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_PINMAP_H */ +/** @} */ diff --git a/boards/nucleo32-common/include/board_common.h b/boards/nucleo32-common/include/board_common.h new file mode 100644 index 000000000000..a72092f038f1 --- /dev/null +++ b/boards/nucleo32-common/include/board_common.h @@ -0,0 +1,52 @@ +/* + * 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. + */ + +/** + * @defgroup boards_nucleo32-common STM Nucleo-32 Common + * @ingroup boards + * @brief Common files for STM Nucleo-32 boards + * @{ + * + * @file + * @brief Common pin definitions and board configuration options + * + * @author Alexandre Abadie + */ + +#ifndef BOARD_COMMON_H +#define BOARD_COMMON_H + +#include "cpu.h" +#include "periph_conf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Macros for controlling the on-board LED (LD3). + * @{ + */ +#define LED0_PIN GPIO_PIN(PORT_B, 3) +#define LED0_MASK (1 << 3) +#define LED0_ON (GPIOB->BSRR = LED0_MASK) +#define LED0_OFF (GPIOB->BSRR = (LED0_MASK << 16)) +#define LED0_TOGGLE (GPIOB->ODR ^= LED0_MASK) +/** @} */ + +/** + * @brief Initialize board specific hardware, including clock, LEDs and std-IO + */ +void board_init(void); + +#ifdef __cplusplus +} +#endif + +#endif /* BOARD_COMMON_H */ +/** @} */ diff --git a/boards/nucleo32-common/include/gpio_params.h b/boards/nucleo32-common/include/gpio_params.h new file mode 100644 index 000000000000..a5362195307c --- /dev/null +++ b/boards/nucleo32-common/include/gpio_params.h @@ -0,0 +1,46 @@ +/* + * 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_nucleo32-common + * @{ + * + * @file + * @brief Board specific configuration of direct mapped GPIOs + * + * @author Alexandre Abadie + */ + +#ifndef GPIO_PARAMS_H +#define GPIO_PARAMS_H + +#include "board.h" +#include "saul/periph.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief GPIO pin configuration + */ +static const saul_gpio_params_t saul_gpio_params[] = +{ + { + .name = "LD3(green)", + .pin = LED0_PIN, + .mode = GPIO_OUT + } +}; + +#ifdef __cplusplus +} +#endif + +#endif /* GPIO_PARAMS_H */ +/** @} */