From 0ccadc0f7beb3757ec37fad1c30433c3c2330727 Mon Sep 17 00:00:00 2001 From: Hauke Petersen <hauke.petersen@fu-berlin.de> Date: Fri, 11 Mar 2016 15:01:58 +0100 Subject: [PATCH] boards/nucleo: added and use common board folder --- boards/nucleo-common/Makefile | 3 ++ boards/nucleo-common/Makefile.include | 12 +++++ boards/nucleo-common/include/board_common.h | 60 +++++++++++++++++++++ boards/nucleo-f091/Makefile.include | 11 +--- boards/nucleo-f091/include/board.h | 41 +------------- boards/nucleo-f103/Makefile.include | 11 +--- boards/nucleo-f103/include/board.h | 39 +------------- boards/nucleo-f303/Makefile.include | 11 +--- boards/nucleo-f303/include/board.h | 41 +------------- boards/nucleo-f334/Makefile.include | 11 +--- boards/nucleo-f334/include/board.h | 41 +------------- boards/nucleo-f401/Makefile.include | 11 +--- boards/nucleo-f401/include/board.h | 39 +------------- boards/nucleo-l1/Makefile.include | 11 +--- boards/nucleo-l1/include/board.h | 41 +------------- 15 files changed, 93 insertions(+), 290 deletions(-) create mode 100644 boards/nucleo-common/Makefile create mode 100644 boards/nucleo-common/Makefile.include create mode 100644 boards/nucleo-common/include/board_common.h diff --git a/boards/nucleo-common/Makefile b/boards/nucleo-common/Makefile new file mode 100644 index 0000000000..79ef2678ed --- /dev/null +++ b/boards/nucleo-common/Makefile @@ -0,0 +1,3 @@ +MODULE = nucleo_common + +include $(RIOTBASE)/Makefile.base diff --git a/boards/nucleo-common/Makefile.include b/boards/nucleo-common/Makefile.include new file mode 100644 index 0000000000..6f653099fc --- /dev/null +++ b/boards/nucleo-common/Makefile.include @@ -0,0 +1,12 @@ +# define the default port depending on the host OS +PORT_LINUX ?= /dev/ttyACM0 +PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) + +# setup serial terminal +include $(RIOTBOARD)/Makefile.include.serial + +# this board uses openocd +include $(RIOTBOARD)/Makefile.include.openocd + +# add the common header files to the include path +INCLUDES += -I$(RIOTBOARD)/nucleo-common/include diff --git a/boards/nucleo-common/include/board_common.h b/boards/nucleo-common/include/board_common.h new file mode 100644 index 0000000000..97f397e4ba --- /dev/null +++ b/boards/nucleo-common/include/board_common.h @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2016 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. + */ + +/** + * @defgroup boards_nucleo_common STM Nucleo Common + * @ingroup drivers_periph + * @brief Common files for STM Nucleo boards + * @{ + * + * @file + * @brief Common pin definitions and board configuration options + * + * @author Hauke Petersen <hauke.petersen@fu-berlin.de> + */ + +#ifndef BOARD_COMMON__H +#define BOARD_COMMON__H + +#include "cpu.h" +#include "periph_conf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief LED pin definitions and handlers + * @{ + */ +#define LED0_PIN GPIO_PIN(PORT_A, 5) + +#define LED_MASK GPIOA +#define LED0_MASK (1 << 5) + +#define LED0_ON (GPIOA->BRR = ~LED0_MASK) +#define LED0_OFF (GPIOA->OSRR = LED0_MASK) +#define LED0_TOGGLE (GPIOA->ODR ^= LED0_MASK) +/** @} */ + +/** + * @brief User button + */ +#define BTN_B1_PIN GPIO_PIN(PORT_C, 13) + +/** + * @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/nucleo-f091/Makefile.include b/boards/nucleo-f091/Makefile.include index 55cf92fcc0..46a891574b 100644 --- a/boards/nucleo-f091/Makefile.include +++ b/boards/nucleo-f091/Makefile.include @@ -2,12 +2,5 @@ export CPU = stm32f0 export CPU_MODEL = stm32f091rc -#define the default port depending on the host OS -PORT_LINUX ?= /dev/ttyACM0 -PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) - -# setup serial terminal -include $(RIOTBOARD)/Makefile.include.serial - -# this board uses openocd -include $(RIOTBOARD)/Makefile.include.openocd +# load the common Makefile.include for Nucleo boards +include $(RIOTBOARD)/nucleo-common/Makefile.include diff --git a/boards/nucleo-f091/include/board.h b/boards/nucleo-f091/include/board.h index e0e275e870..470af2dee2 100644 --- a/boards/nucleo-f091/include/board.h +++ b/boards/nucleo-f091/include/board.h @@ -22,54 +22,15 @@ #ifndef BOARD_H_ #define BOARD_H_ -#include <stdint.h> - -#include "cpu.h" -#include "periph_conf.h" +#include "board_common.h" #ifdef __cplusplus extern "C" { #endif -/** - * @name LED pin definitions - * @{ - */ -#define LED_GREEN_PORT (GPIOA) -#define LED_GREEN_PIN (5) -/** @} */ - -/** - * @name Macros for controlling the on-board LEDs. - * @{ - */ -#define LED_RED_ON -#define LED_RED_OFF -#define LED_RED_TOGGLE - -#define LED_GREEN_ON (LED_GREEN_PORT->BSRR = (1 << LED_GREEN_PIN)) -#define LED_GREEN_OFF (LED_GREEN_PORT->BSRR = ((1 << LED_GREEN_PIN) << 16)) -#define LED_GREEN_TOGGLE (LED_GREEN_PORT->ODR ^= (1 << LED_GREEN_PIN)) - -#define LED_ORANGE_ON -#define LED_ORANGE_OFF -#define LED_ORANGE_TOGGLE -/** @} */ - -/** - * @brief User button - */ -#define BTN_B1_PIN GPIO_PIN(PORT_C, 13) - -/** - * @brief Initialize board specific hardware, including clock, LEDs and std-IO - */ -void board_init(void); - #ifdef __cplusplus } #endif #endif /* BOARD_H_ */ /** @} */ -/** @} */ diff --git a/boards/nucleo-f103/Makefile.include b/boards/nucleo-f103/Makefile.include index f1b362445f..1fe6635a94 100755 --- a/boards/nucleo-f103/Makefile.include +++ b/boards/nucleo-f103/Makefile.include @@ -2,12 +2,5 @@ export CPU = stm32f1 export CPU_MODEL = stm32f103rb -#define the default port depending on the host OS -PORT_LINUX ?= /dev/ttyUSB0 -PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) - -# setup serial terminal -include $(RIOTBOARD)/Makefile.include.serial - -# this board uses openocd -include $(RIOTBOARD)/Makefile.include.openocd +# load the common Makefile.include for Nucleo boards +include $(RIOTBOARD)/nucleo-common/Makefile.include diff --git a/boards/nucleo-f103/include/board.h b/boards/nucleo-f103/include/board.h index 7f39091dae..7641bd1b37 100755 --- a/boards/nucleo-f103/include/board.h +++ b/boards/nucleo-f103/include/board.h @@ -21,10 +21,7 @@ #ifndef BOARD_H_ #define BOARD_H_ -#include <stdint.h> - -#include "cpu.h" -#include "periph_conf.h" +#include "board_common.h" #ifdef __cplusplus extern "C" { @@ -42,40 +39,6 @@ extern "C" { #define XTIMER_BACKOFF 5 /** @} */ -/** - * @name LED pin definitions - * @{ - */ -#define LED_GREEN_GPIO GPIO_PIN(PORT_A, 5) -/** @} */ - -/** - * @name Macros for controlling the on-board LEDs. - * @{ - */ -#define LED_RED_ON -#define LED_RED_OFF -#define LED_RED_TOGGLE - -#define LED_GREEN_ON (GPIOA->BSRR = (1 << 5)) -#define LED_GREEN_OFF (GPIOA->BRR = (1 << 5)) -#define LED_GREEN_TOGGLE (GPIOA->ODR ^= (1 << 5)) - -#define LED_ORANGE_ON -#define LED_ORANGE_OFF -#define LED_ORANGE_TOGGLE -/** @} */ - -/** - * @brief User button - */ -#define BTN_B1_PIN GPIO_PIN(PORT_C, 13) - -/** - * @brief Initialize board specific hardware, including clock, LEDs and std-IO - */ -void board_init(void); - #ifdef __cplusplus } #endif diff --git a/boards/nucleo-f303/Makefile.include b/boards/nucleo-f303/Makefile.include index aca137caf3..c37c350a99 100755 --- a/boards/nucleo-f303/Makefile.include +++ b/boards/nucleo-f303/Makefile.include @@ -2,12 +2,5 @@ export CPU = stm32f3 export CPU_MODEL = stm32f303re -#define the default port depending on the host OS -PORT_LINUX ?= /dev/ttyUSB0 -PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) - -# setup serial terminal -include $(RIOTBOARD)/Makefile.include.serial - -# this board uses openocd -include $(RIOTBOARD)/Makefile.include.openocd +# load the common Makefile.include for Nucleo boards +include $(RIOTBOARD)/nucleo-common/Makefile.include diff --git a/boards/nucleo-f303/include/board.h b/boards/nucleo-f303/include/board.h index 66c1a96bb7..b756fb97fd 100755 --- a/boards/nucleo-f303/include/board.h +++ b/boards/nucleo-f303/include/board.h @@ -23,54 +23,15 @@ #ifndef BOARD_H_ #define BOARD_H_ -#include <stdint.h> - -#include "cpu.h" -#include "periph_conf.h" +#include "board_common.h" #ifdef __cplusplus extern "C" { #endif -/** - * @name LED pin definitions - * @{ - */ -#define LED_GREEN_PORT (GPIOA) -#define LED_GREEN_PIN (5) -/** @} */ - -/** - * @name Macros for controlling the on-board LEDs. - * @{ - */ -#define LED_RED_ON -#define LED_RED_OFF -#define LED_RED_TOGGLE - -#define LED_GREEN_ON (LED_GREEN_PORT->BSRRL = (1 << LED_GREEN_PIN)) -#define LED_GREEN_OFF (LED_GREEN_PORT->BSRRH = (1 << LED_GREEN_PIN)) -#define LED_GREEN_TOGGLE (LED_GREEN_PORT->ODR ^= (1 << LED_GREEN_PIN)) - -#define LED_ORANGE_ON -#define LED_ORANGE_OFF -#define LED_ORANGE_TOGGLE -/** @} */ - -/** - * @brief User button - */ -#define BTN_B1_PIN GPIO_PIN(PORT_C, 13) - -/** - * @brief Initialize board specific hardware, including clock, LEDs and std-IO - */ -void board_init(void); - #ifdef __cplusplus } #endif #endif /* BOARD_H_ */ /** @} */ -/** @} */ diff --git a/boards/nucleo-f334/Makefile.include b/boards/nucleo-f334/Makefile.include index edf7af4036..108e978264 100644 --- a/boards/nucleo-f334/Makefile.include +++ b/boards/nucleo-f334/Makefile.include @@ -2,12 +2,5 @@ export CPU = stm32f3 export CPU_MODEL = stm32f334r8 -#define the default port depending on the host OS -PORT_LINUX ?= /dev/ttyACM0 -PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) - -# setup serial terminal -include $(RIOTBOARD)/Makefile.include.serial - -# this board uses openocd -include $(RIOTBOARD)/Makefile.include.openocd +# load the common Makefile.include for Nucleo boards +include $(RIOTBOARD)/nucleo-common/Makefile.include diff --git a/boards/nucleo-f334/include/board.h b/boards/nucleo-f334/include/board.h index 6216c2b989..ffaefa782b 100644 --- a/boards/nucleo-f334/include/board.h +++ b/boards/nucleo-f334/include/board.h @@ -21,45 +21,12 @@ #ifndef BOARD_H_ #define BOARD_H_ -#include <stdint.h> - -#include "cpu.h" -#include "periph_conf.h" +#include "board_common.h" #ifdef __cplusplus extern "C" { #endif -/** - * @name LED pin definitions - * @{ - */ -#define LED_GREEN_PORT (GPIOA) -#define LED_GREEN_PIN (5) -/** @} */ - -/** - * @name Macros for controlling the on-board LEDs. - * @{ - */ -#define LED_RED_ON -#define LED_RED_OFF -#define LED_RED_TOGGLE - -#define LED_GREEN_ON (LED_GREEN_PORT->BSRRL = (1<<LED_GREEN_PIN)) -#define LED_GREEN_OFF (LED_GREEN_PORT->BSRRH = (1<<LED_GREEN_PIN)) -#define LED_GREEN_TOGGLE (LED_GREEN_PORT->ODR ^= (1<<LED_GREEN_PIN)) - -#define LED_ORANGE_ON -#define LED_ORANGE_OFF -#define LED_ORANGE_TOGGLE -/** @} */ - -/** - * @brief User button - */ -#define BTN_B1_PIN GPIO_PIN(PORT_C, 13) - /** * @name xtimer tuning values * @{ @@ -68,15 +35,9 @@ extern "C" { #define XTIMER_SHOOT_EARLY 2 /** @} */ -/** - * @brief Initialize board specific hardware, including clock, LEDs and std-IO - */ -void board_init(void); - #ifdef __cplusplus } #endif #endif /* BOARD_H_ */ /** @} */ -/** @} */ diff --git a/boards/nucleo-f401/Makefile.include b/boards/nucleo-f401/Makefile.include index d2ca4cad21..30cc7a5ba9 100644 --- a/boards/nucleo-f401/Makefile.include +++ b/boards/nucleo-f401/Makefile.include @@ -2,12 +2,5 @@ export CPU = stm32f4 export CPU_MODEL = stm32f401re -# define the default port depending on the host OS -PORT_LINUX ?= /dev/ttyACM0 -PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) - -# setup serial terminal -include $(RIOTBOARD)/Makefile.include.serial - -# this board uses openocd -include $(RIOTBOARD)/Makefile.include.openocd +# load the common Makefile.include for Nucleo boards +include $(RIOTBOARD)/nucleo-common/Makefile.include diff --git a/boards/nucleo-f401/include/board.h b/boards/nucleo-f401/include/board.h index 4078011f9a..29b08224e2 100644 --- a/boards/nucleo-f401/include/board.h +++ b/boards/nucleo-f401/include/board.h @@ -21,8 +21,7 @@ #ifndef BOARD_H_ #define BOARD_H_ -#include "cpu.h" -#include "periph_conf.h" +#include "board_common.h" #ifdef __cplusplus extern "C" { @@ -38,42 +37,6 @@ extern "C" { #define XTIMER_BACKOFF (5) /** @} */ -/** - * @name LED pin definitions - * @{ - */ -#define LED_GREEN_PORT (GPIOA) -#define LED_GREEN_PIN (5) -#define LED_GREEN_GPIO GPIO_PIN(PORT_A,5) -/** @} */ - -/** - * @name Macros for controlling the on-board LEDs. - * @{ - */ -#define LED_RED_ON -#define LED_RED_OFF -#define LED_RED_TOGGLE - -#define LED_GREEN_ON (LED_GREEN_PORT->BSRRL = (1<<LED_GREEN_PIN)) -#define LED_GREEN_OFF (LED_GREEN_PORT->BSRRH = (1<<LED_GREEN_PIN)) -#define LED_GREEN_TOGGLE (LED_GREEN_PORT->ODR ^= (1<<LED_GREEN_PIN)) - -#define LED_ORANGE_ON -#define LED_ORANGE_OFF -#define LED_ORANGE_TOGGLE -/** @} */ - -/** - * @brief User button - */ -#define BTN_B1_PIN GPIO_PIN(PORT_C, 13) - -/** - * @brief Initialize board specific hardware, including clock, LEDs and std-IO - */ -void board_init(void); - #ifdef __cplusplus } #endif diff --git a/boards/nucleo-l1/Makefile.include b/boards/nucleo-l1/Makefile.include index 4a9e698d24..2902085408 100644 --- a/boards/nucleo-l1/Makefile.include +++ b/boards/nucleo-l1/Makefile.include @@ -2,12 +2,5 @@ export CPU = stm32l1 export CPU_MODEL = stm32l152ret6 -# define the default port depending on the host OS -PORT_LINUX ?= /dev/ttyACM0 -PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) - -# setup serial terminal -include $(RIOTBOARD)/Makefile.include.serial - -# this board uses openocd -include $(RIOTBOARD)/Makefile.include.openocd +# load the common Makefile.include for Nucleo boards +include $(RIOTBOARD)/nucleo-common/Makefile.include diff --git a/boards/nucleo-l1/include/board.h b/boards/nucleo-l1/include/board.h index 9598c5e33e..5ae9db75af 100644 --- a/boards/nucleo-l1/include/board.h +++ b/boards/nucleo-l1/include/board.h @@ -21,10 +21,7 @@ #ifndef BOARD_H_ #define BOARD_H_ -#include <stdint.h> - -#include "cpu.h" -#include "periph_conf.h" +#include "board_common.h" #ifdef __cplusplus extern "C" { @@ -40,45 +37,9 @@ extern "C" { #define XTIMER_BACKOFF (3) /** @} */ -/** - * @name LED pin definitions - * @{ - */ -#define LED_GREEN_PORT (GPIOA) -#define LED_GREEN_PIN (5) -/** @} */ - -/** - * @name Macros for controlling the on-board LEDs. - * @{ - */ -#define LED_RED_ON -#define LED_RED_OFF -#define LED_RED_TOGGLE - -#define LED_GREEN_ON (LED_GREEN_PORT->ODR &= ~(1<<LED_GREEN_PIN)) -#define LED_GREEN_OFF (LED_GREEN_PORT->ODR |= (1<<LED_GREEN_PIN)) -#define LED_GREEN_TOGGLE (LED_GREEN_PORT->ODR ^= (1<<LED_GREEN_PIN)) - -#define LED_ORANGE_ON -#define LED_ORANGE_OFF -#define LED_ORANGE_TOGGLE -/** @} */ - -/** - * @brief User button - */ -#define BTN_B1_PIN GPIO_PIN(PORT_C, 13) - -/** - * @brief Initialize board specific hardware, including clock, LEDs and std-IO - */ -void board_init(void); - #ifdef __cplusplus } #endif #endif /* BOARD_H_ */ /** @} */ -/** @} */ -- GitLab