From b51ea4ca2422ac0f024fb4c22b662459d34fa7cc Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Thu, 7 Dec 2023 10:29:40 +0100 Subject: [PATCH] boards: clean up MSP430 board configuration Move common configuration for MSP430 based boards to `boards/common/msp430` and make use of that. --- boards/common/msb-430/Makefile.include | 10 +-- boards/common/msp430/Makefile.include | 11 ++++ boards/common/msp430/doc.txt | 17 ++++++ .../msp430/include/cfg_timer_a_smclk_b_aclk.h | 61 +++++++++++++++++++ boards/msb-430/include/periph_conf.h | 25 +------- boards/msb-430h/include/periph_conf.h | 25 +------- boards/olimex-msp430-h1611/Makefile.include | 12 +--- .../olimex-msp430-h1611/include/periph_conf.h | 25 +------- boards/olimex-msp430-h2618/Makefile.include | 12 +--- .../olimex-msp430-h2618/include/periph_conf.h | 25 +------- boards/telosb/Makefile.include | 8 +-- boards/telosb/include/periph_conf.h | 25 +------- boards/z1/Makefile.include | 6 +- boards/z1/include/periph_conf.h | 25 +------- 14 files changed, 104 insertions(+), 183 deletions(-) create mode 100644 boards/common/msp430/Makefile.include create mode 100644 boards/common/msp430/doc.txt create mode 100644 boards/common/msp430/include/cfg_timer_a_smclk_b_aclk.h diff --git a/boards/common/msb-430/Makefile.include b/boards/common/msb-430/Makefile.include index cf53ed4586b6..ced846ef8d4b 100644 --- a/boards/common/msb-430/Makefile.include +++ b/boards/common/msb-430/Makefile.include @@ -1,11 +1,3 @@ INCLUDES += -I$(RIOTBOARD)/common/msb-430/include -# set default port depending on operating system -PORT_LINUX ?= /dev/ttyUSB0 -PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) - -# setup flash tool -PROGRAMMER ?= mspdebug -MSPDEBUG_PROGRAMMER ?= olimex - -PROGRAMMERS_SUPPORTED += mspdebug +include $(RIOTBOARD)/common/msp430/Makefile.include diff --git a/boards/common/msp430/Makefile.include b/boards/common/msp430/Makefile.include new file mode 100644 index 000000000000..0e75f748d2fe --- /dev/null +++ b/boards/common/msp430/Makefile.include @@ -0,0 +1,11 @@ +INCLUDES += -I$(RIOTBOARD)/common/msp430/include + +# set default port depending on operating system +PORT_LINUX ?= /dev/ttyUSB0 +PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) + +# setup flash tool +PROGRAMMER ?= mspdebug +MSPDEBUG_PROGRAMMER ?= olimex + +PROGRAMMERS_SUPPORTED += mspdebug diff --git a/boards/common/msp430/doc.txt b/boards/common/msp430/doc.txt new file mode 100644 index 000000000000..fa6c1f46e562 --- /dev/null +++ b/boards/common/msp430/doc.txt @@ -0,0 +1,17 @@ +/* + * 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. + */ + +/** + * @defgroup boards_common_msp430 Common Configuration Snippets for MSP430 boards + * @ingroup boards_common + * @brief Board configuration snippets for MSP430-based boards + * + * All boards using a CPU from the MSP430 family share certain parts of their + * configuration. This module provides a collection of fine grained + * configuration snippets that can be reused for different boards. + */ diff --git a/boards/common/msp430/include/cfg_timer_a_smclk_b_aclk.h b/boards/common/msp430/include/cfg_timer_a_smclk_b_aclk.h new file mode 100644 index 000000000000..3ae3cd66159c --- /dev/null +++ b/boards/common/msp430/include/cfg_timer_a_smclk_b_aclk.h @@ -0,0 +1,61 @@ +/* + * 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 boards_common_msp430 + * @{ + * + * @file + * @brief Common timer configuration for TIMER_A clocked by SMCLK and + * TIMER_B clocked by ACLK + * + * @author Marian Buschsieweke + */ + +#ifndef CFG_TIMER_A_SMCLK_B_ACLK_H +#define CFG_TIMER_A_SMCLK_B_ACLK_H + +#include "periph_cpu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Timer configuration + * @{ + */ +/** + * @brief Timer configuration + */ +static const timer_conf_t timer_conf[] = { + { + .timer = &TIMER_A, + .irq_flags = &TIMER_A_IRQFLAGS, + .clock_source = TIMER_CLOCK_SOURCE_SUBMAIN_CLOCK, + }, + { + .timer = &TIMER_B, + .irq_flags = &TIMER_B_IRQFLAGS, + .clock_source = TIMER_CLOCK_SOURCE_AUXILIARY_CLOCK, + } +}; +#define TIMER_NUMOF ARRAY_SIZE(timer_conf) /**< Number of timers available */ + +#define TIMER0_ISR_CC0 (TIMERA0_VECTOR) /**< IRQ vector for channel 0 of TIMER_DEV(0) */ +#define TIMER0_ISR_CCX (TIMERA1_VECTOR) /**< IRQ vector for channels !=0 of TIMER_DEV(0) */ +#define TIMER1_ISR_CC0 (TIMERB0_VECTOR) /**< IRQ vector for channel 0 of TIMER_DEV(0) */ +#define TIMER1_ISR_CCX (TIMERB1_VECTOR) /**< IRQ vector for channels !=0 of TIMER_DEV(1) */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* CFG_TIMER_A_SMCLK_B_ACLK_H */ +/** @} */ diff --git a/boards/msb-430/include/periph_conf.h b/boards/msb-430/include/periph_conf.h index a9de0994ecd4..f4c9f036535b 100644 --- a/boards/msb-430/include/periph_conf.h +++ b/boards/msb-430/include/periph_conf.h @@ -23,6 +23,7 @@ #include "periph_cpu.h" #include "macros/units.h" +#include "cfg_timer_a_smclk_b_aclk.h" #ifdef __cplusplus extern "C" { @@ -44,30 +45,6 @@ static const msp430_clock_params_t clock_params = { .has_r_osc = true, }; -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_conf[] = { - { - .timer = &TIMER_A, - .irq_flags = &TIMER_A_IRQFLAGS, - .clock_source = TIMER_CLOCK_SOURCE_SUBMAIN_CLOCK, - }, - { - .timer = &TIMER_B, - .irq_flags = &TIMER_B_IRQFLAGS, - .clock_source = TIMER_CLOCK_SOURCE_AUXILIARY_CLOCK, - } -}; -#define TIMER_NUMOF ARRAY_SIZE(timer_conf) - -#define TIMER0_ISR_CC0 (TIMERA0_VECTOR) -#define TIMER0_ISR_CCX (TIMERA1_VECTOR) -#define TIMER1_ISR_CC0 (TIMERB0_VECTOR) -#define TIMER1_ISR_CCX (TIMERB1_VECTOR) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/msb-430h/include/periph_conf.h b/boards/msb-430h/include/periph_conf.h index 2f5764db3b9e..d7151bbc3d37 100644 --- a/boards/msb-430h/include/periph_conf.h +++ b/boards/msb-430h/include/periph_conf.h @@ -22,6 +22,7 @@ #define PERIPH_CONF_H #include "periph_cpu.h" +#include "cfg_timer_a_smclk_b_aclk.h" #ifdef __cplusplus extern "C" { @@ -43,30 +44,6 @@ static const msp430_clock_params_t clock_params = { .has_r_osc = true, }; -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_conf[] = { - { - .timer = &TIMER_A, - .irq_flags = &TIMER_A_IRQFLAGS, - .clock_source = TIMER_CLOCK_SOURCE_SUBMAIN_CLOCK, - }, - { - .timer = &TIMER_B, - .irq_flags = &TIMER_B_IRQFLAGS, - .clock_source = TIMER_CLOCK_SOURCE_AUXILIARY_CLOCK, - } -}; -#define TIMER_NUMOF ARRAY_SIZE(timer_conf) - -#define TIMER0_ISR_CC0 (TIMERA0_VECTOR) -#define TIMER0_ISR_CCX (TIMERA1_VECTOR) -#define TIMER1_ISR_CC0 (TIMERB0_VECTOR) -#define TIMER1_ISR_CCX (TIMERB1_VECTOR) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/olimex-msp430-h1611/Makefile.include b/boards/olimex-msp430-h1611/Makefile.include index d49e656df6f8..e2fb1150be70 100644 --- a/boards/olimex-msp430-h1611/Makefile.include +++ b/boards/olimex-msp430-h1611/Makefile.include @@ -1,13 +1,3 @@ -# set default port depending on operating system -PORT_LINUX ?= /dev/ttyUSB0 -PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbserial-MXV*))) - -# flash tool configuration -PROGRAMMER ?= mspdebug -MSPDEBUG_PROGRAMMER ?= olimex - -PROGRAMMERS_SUPPORTED += mspdebug - # When freshly plugged in the Olimex MSP430-JTAG-Tiny debugger provides a # ttyACM interface, which is only available until the first flashing. A # `make term` or even a `make flash term` may pick the JTAG debugger instead @@ -24,3 +14,5 @@ TTY_SELECT_CMD := $(RIOTTOOLS)/usb-serial/ttys.py \ $(RIOTTOOLS)/usb-serial/ttys.py \ --most-recent \ --format path serial + +include $(RIOTBOARD)/common/msp430/Makefile.include diff --git a/boards/olimex-msp430-h1611/include/periph_conf.h b/boards/olimex-msp430-h1611/include/periph_conf.h index 7c04334c774d..79603ceccc3d 100644 --- a/boards/olimex-msp430-h1611/include/periph_conf.h +++ b/boards/olimex-msp430-h1611/include/periph_conf.h @@ -23,6 +23,7 @@ #include "periph_cpu.h" #include "macros/units.h" +#include "cfg_timer_a_smclk_b_aclk.h" #ifdef __cplusplus extern "C" { @@ -43,30 +44,6 @@ static const msp430_clock_params_t clock_params = { .auxiliary_clock_divier = AUXILIARY_CLOCK_DIVIDE_BY_1, }; -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_conf[] = { - { - .timer = &TIMER_A, - .irq_flags = &TIMER_A_IRQFLAGS, - .clock_source = TIMER_CLOCK_SOURCE_SUBMAIN_CLOCK, - }, - { - .timer = &TIMER_B, - .irq_flags = &TIMER_B_IRQFLAGS, - .clock_source = TIMER_CLOCK_SOURCE_AUXILIARY_CLOCK, - } -}; -#define TIMER_NUMOF ARRAY_SIZE(timer_conf) - -#define TIMER0_ISR_CC0 (TIMERA0_VECTOR) -#define TIMER0_ISR_CCX (TIMERA1_VECTOR) -#define TIMER1_ISR_CC0 (TIMERB0_VECTOR) -#define TIMER1_ISR_CCX (TIMERB1_VECTOR) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/olimex-msp430-h2618/Makefile.include b/boards/olimex-msp430-h2618/Makefile.include index d49e656df6f8..e2fb1150be70 100644 --- a/boards/olimex-msp430-h2618/Makefile.include +++ b/boards/olimex-msp430-h2618/Makefile.include @@ -1,13 +1,3 @@ -# set default port depending on operating system -PORT_LINUX ?= /dev/ttyUSB0 -PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbserial-MXV*))) - -# flash tool configuration -PROGRAMMER ?= mspdebug -MSPDEBUG_PROGRAMMER ?= olimex - -PROGRAMMERS_SUPPORTED += mspdebug - # When freshly plugged in the Olimex MSP430-JTAG-Tiny debugger provides a # ttyACM interface, which is only available until the first flashing. A # `make term` or even a `make flash term` may pick the JTAG debugger instead @@ -24,3 +14,5 @@ TTY_SELECT_CMD := $(RIOTTOOLS)/usb-serial/ttys.py \ $(RIOTTOOLS)/usb-serial/ttys.py \ --most-recent \ --format path serial + +include $(RIOTBOARD)/common/msp430/Makefile.include diff --git a/boards/olimex-msp430-h2618/include/periph_conf.h b/boards/olimex-msp430-h2618/include/periph_conf.h index d672b8782f74..d7375946dcf6 100644 --- a/boards/olimex-msp430-h2618/include/periph_conf.h +++ b/boards/olimex-msp430-h2618/include/periph_conf.h @@ -22,6 +22,7 @@ #include "periph_cpu.h" #include "macros/units.h" +#include "cfg_timer_a_smclk_b_aclk.h" #ifdef __cplusplus extern "C" { @@ -42,30 +43,6 @@ static const msp430_clock_params_t clock_params = { .auxiliary_clock_divier = AUXILIARY_CLOCK_DIVIDE_BY_1, }; -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_conf[] = { - { - .timer = &TIMER_A, - .irq_flags = &TIMER_A_IRQFLAGS, - .clock_source = TIMER_CLOCK_SOURCE_SUBMAIN_CLOCK, - }, - { - .timer = &TIMER_B, - .irq_flags = &TIMER_B_IRQFLAGS, - .clock_source = TIMER_CLOCK_SOURCE_AUXILIARY_CLOCK, - } -}; -#define TIMER_NUMOF ARRAY_SIZE(timer_conf) - -#define TIMER0_ISR_CC0 (TIMERA0_VECTOR) -#define TIMER0_ISR_CCX (TIMERA1_VECTOR) -#define TIMER1_ISR_CC0 (TIMERB0_VECTOR) -#define TIMER1_ISR_CCX (TIMERB1_VECTOR) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/telosb/Makefile.include b/boards/telosb/Makefile.include index 89ae2fdc8626..62146219f18b 100644 --- a/boards/telosb/Makefile.include +++ b/boards/telosb/Makefile.include @@ -1,11 +1,7 @@ -# set default port depending on operating system -PORT_LINUX ?= /dev/ttyUSB0 -PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbserial-MXV*))) -# setup serial terminal -BAUD ?= 9600 - # flash tool configuration PROGRAMMER ?= goodfet GOODFET_FLAGS ?= --telosb PROGRAMMERS_SUPPORTED += goodfet + +include $(RIOTBOARD)/common/msp430/Makefile.include diff --git a/boards/telosb/include/periph_conf.h b/boards/telosb/include/periph_conf.h index 5c03078339e7..b5d27ee68f33 100644 --- a/boards/telosb/include/periph_conf.h +++ b/boards/telosb/include/periph_conf.h @@ -23,6 +23,7 @@ #include "macros/units.h" #include "periph_cpu.h" +#include "cfg_timer_a_smclk_b_aclk.h" #ifdef __cplusplus extern "C" { @@ -43,30 +44,6 @@ static const msp430_clock_params_t clock_params = { .auxiliary_clock_divier = AUXILIARY_CLOCK_DIVIDE_BY_1, }; -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_conf[] = { - { - .timer = &TIMER_A, - .irq_flags = &TIMER_A_IRQFLAGS, - .clock_source = TIMER_CLOCK_SOURCE_SUBMAIN_CLOCK, - }, - { - .timer = &TIMER_B, - .irq_flags = &TIMER_B_IRQFLAGS, - .clock_source = TIMER_CLOCK_SOURCE_AUXILIARY_CLOCK, - } -}; -#define TIMER_NUMOF ARRAY_SIZE(timer_conf) - -#define TIMER0_ISR_CC0 (TIMERA0_VECTOR) -#define TIMER0_ISR_CCX (TIMERA1_VECTOR) -#define TIMER1_ISR_CC0 (TIMERB0_VECTOR) -#define TIMER1_ISR_CCX (TIMERB1_VECTOR) -/** @} */ - /** * @name UART configuration * @{ diff --git a/boards/z1/Makefile.include b/boards/z1/Makefile.include index 09ba9d15e1b5..5a5e2aaf0950 100644 --- a/boards/z1/Makefile.include +++ b/boards/z1/Makefile.include @@ -1,9 +1,7 @@ -# set default port depending on operating system -PORT_LINUX ?= /dev/ttyUSB0 -PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.SLAB_USBtoUART*))) - # setup flash tool PROGRAMMER ?= goodfet GOODFET_FLAGS ?= --z1 PROGRAMMERS_SUPPORTED += goodfet + +include $(RIOTBOARD)/common/msp430/Makefile.include diff --git a/boards/z1/include/periph_conf.h b/boards/z1/include/periph_conf.h index 018ce94e23b4..47230821604f 100644 --- a/boards/z1/include/periph_conf.h +++ b/boards/z1/include/periph_conf.h @@ -23,6 +23,7 @@ #include "macros/units.h" #include "periph_cpu.h" +#include "cfg_timer_a_smclk_b_aclk.h" #ifdef __cplusplus extern "C" { @@ -43,30 +44,6 @@ static const msp430_clock_params_t clock_params = { .auxiliary_clock_divier = AUXILIARY_CLOCK_DIVIDE_BY_1, }; -/** - * @name Timer configuration - * @{ - */ -static const timer_conf_t timer_conf[] = { - { - .timer = &TIMER_A, - .irq_flags = &TIMER_A_IRQFLAGS, - .clock_source = TIMER_CLOCK_SOURCE_SUBMAIN_CLOCK, - }, - { - .timer = &TIMER_B, - .irq_flags = &TIMER_B_IRQFLAGS, - .clock_source = TIMER_CLOCK_SOURCE_AUXILIARY_CLOCK, - } -}; -#define TIMER_NUMOF ARRAY_SIZE(timer_conf) - -#define TIMER0_ISR_CC0 (TIMERA0_VECTOR) -#define TIMER0_ISR_CCX (TIMERA1_VECTOR) -#define TIMER1_ISR_CC0 (TIMERB0_VECTOR) -#define TIMER1_ISR_CCX (TIMERB1_VECTOR) -/** @} */ - /** * @name UART configuration * @{