diff --git a/boards/nucleo-common/Makefile b/boards/nucleo-common/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..79ef2678ed958bcd7f8b727c547b3dad53eab77f --- /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 0000000000000000000000000000000000000000..6f653099fc64ce60d96d51be22ebcbd460a4fd9d --- /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 0000000000000000000000000000000000000000..97f397e4ba318bd77722bf91a5f7f8f360e66d79 --- /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 55cf92fcc0ad0e751d62ccce24e7f791cbc5a755..46a891574bd5a0fa61dd1f53ecc083e686491183 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 e0e275e8707ade6512ddcf3b4645724175e3fbc9..470af2dee2931e4c65771ac7798a5793e4a01fbc 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 f1b362445f250eb96299442891304e092b0eb2a1..1fe6635a940c042a2c164af541274e4a5c6bf7de 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 7f39091dae6052cd360ecb01a298ba00ca696b9f..7641bd1b37631bf9b67d3178ea1951a8a6d6404b 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 aca137caf3992bf2390481b3e0e93d494621b455..c37c350a99e4b280caa12cf7bb55c2901e9feb88 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 66c1a96bb7ba570459eb6722a683771db269a5c1..b756fb97fd1e2b71357e1ce381e1320c18e3d2c1 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 edf7af40360a4aae51c5f0c84c04d278c7dd0cc5..108e9782649281c940aabafd73387d915ece378c 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 6216c2b98943476360c516ed0cd142957169d705..ffaefa782b65d0e78c36c660ecae851cd72dbdc1 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 d2ca4cad2138180194857003d270c279f09e15fc..30cc7a5ba9b5424a2f8190ba6a79676bd929457c 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 4078011f9aad69db219f9fa0edcd3aead0722fe7..29b08224e2ed91f558e19c343453723906881928 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 4a9e698d24fb363e96addd59109dc19fe2b0b367..290208540805bcfa5861523e2b8da71f8b27c807 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 9598c5e33e6da01d7486c1e303a7f04e9ab85a01..5ae9db75af09b798efd99c2a9c0a90122da84e81 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_ */ /** @} */ -/** @} */