diff --git a/boards/common/msb-430/Makefile.features b/boards/common/msb-430/Makefile.features index abfe1698ee5d..6ebad6dc5d27 100644 --- a/boards/common/msb-430/Makefile.features +++ b/boards/common/msb-430/Makefile.features @@ -1,2 +1,2 @@ -CPU = msp430fxyz +CPU = msp430 CPU_MODEL = msp430f1612 diff --git a/boards/msb-430/include/periph_conf.h b/boards/msb-430/include/periph_conf.h index 24f3d5afa811..12c361a82e9b 100644 --- a/boards/msb-430/include/periph_conf.h +++ b/boards/msb-430/include/periph_conf.h @@ -28,12 +28,12 @@ extern "C" { #endif -#define CLOCK_CORECLOCK msp430_fxyz_dco_freq +#define CLOCK_CORECLOCK msp430_dco_freq /** * @brief Clock configuration */ -static const msp430_fxyz_clock_params_t clock_params = { +static const msp430_clock_params_t clock_params = { .target_dco_frequency = 7372800U, .lfxt1_frequency = 32768, .main_clock_source = MAIN_CLOCK_SOURCE_DCOCLK, @@ -49,7 +49,7 @@ static const msp430_fxyz_clock_params_t clock_params = { * @{ */ #define TIMER_NUMOF (1U) -#define TIMER_BASE (TIMER_A) +#define TIMER_BASE (&TIMER_A) #define TIMER_CHAN (3) #define TIMER_ISR_CC0 (TIMERA0_VECTOR) #define TIMER_ISR_CCX (TIMERA1_VECTOR) @@ -61,14 +61,12 @@ static const msp430_fxyz_clock_params_t clock_params = { */ #define UART_NUMOF (1U) -#define UART_BASE (USART_1) -#define UART_IE (SFR->IE2) -#define UART_IF (SFR->IFG2) +#define UART_BASE (&USART_1) +#define UART_SFR (&USART_1_SFR) #define UART_IE_RX_BIT (1 << 4) #define UART_IE_TX_BIT (1 << 5) -#define UART_ME (SFR->ME2) #define UART_ME_BITS (0x30) -#define UART_PORT (PORT_3) +#define UART_PORT (&PORT_3) #define UART_RX_PIN (1 << 6) #define UART_TX_PIN (1 << 7) #define UART_RX_ISR (USART1RX_VECTOR) @@ -82,12 +80,10 @@ static const msp430_fxyz_clock_params_t clock_params = { #define SPI_NUMOF (1U) /* SPI configuration */ -#define SPI_BASE (USART_0) -#define SPI_IE (SFR->IE1) -#define SPI_IF (SFR->IFG1) +#define SPI_BASE (&USART_0) +#define SPI_SFR (&USART_0_SFR) #define SPI_IE_RX_BIT (1 << 6) #define SPI_IE_TX_BIT (1 << 7) -#define SPI_ME (SFR->ME1) #define SPI_ME_BIT (1 << 6) #define SPI_PIN_MISO GPIO_PIN(P5, 2) #define SPI_PIN_MOSI GPIO_PIN(P5, 1) diff --git a/boards/msb-430h/include/periph_conf.h b/boards/msb-430h/include/periph_conf.h index 5dc02bb14396..7f0dc217e816 100644 --- a/boards/msb-430h/include/periph_conf.h +++ b/boards/msb-430h/include/periph_conf.h @@ -32,7 +32,7 @@ extern "C" { /** * @brief Clock configuration */ -static const msp430_fxyz_clock_params_t clock_params = { +static const msp430_clock_params_t clock_params = { .xt2_frequency = CLOCK_CORECLOCK, .lfxt1_frequency = 32768, .main_clock_source = MAIN_CLOCK_SOURCE_XT2CLK, @@ -48,7 +48,7 @@ static const msp430_fxyz_clock_params_t clock_params = { * @{ */ #define TIMER_NUMOF (1U) -#define TIMER_BASE (TIMER_A) +#define TIMER_BASE (&TIMER_A) #define TIMER_CHAN (3) #define TIMER_ISR_CC0 (TIMERA0_VECTOR) #define TIMER_ISR_CCX (TIMERA1_VECTOR) @@ -60,14 +60,12 @@ static const msp430_fxyz_clock_params_t clock_params = { */ #define UART_NUMOF (1U) -#define UART_BASE (USART_1) -#define UART_IE (SFR->IE2) -#define UART_IF (SFR->IFG2) +#define UART_BASE (&USART_1) +#define UART_SFR (&USART_1_SFR) #define UART_IE_RX_BIT (1 << 4) #define UART_IE_TX_BIT (1 << 5) -#define UART_ME (SFR->ME2) #define UART_ME_BITS (0x30) -#define UART_PORT (PORT_3) +#define UART_PORT (&PORT_3) #define UART_RX_PIN (1 << 6) #define UART_TX_PIN (1 << 7) #define UART_RX_ISR (USART1RX_VECTOR) @@ -81,12 +79,10 @@ static const msp430_fxyz_clock_params_t clock_params = { #define SPI_NUMOF (1U) /* SPI configuration */ -#define SPI_BASE (USART_0) -#define SPI_IE (SFR->IE1) -#define SPI_IF (SFR->IFG1) +#define SPI_BASE (&USART_0) +#define SPI_SFR (&USART_0_SFR) #define SPI_IE_RX_BIT (1 << 6) #define SPI_IE_TX_BIT (1 << 7) -#define SPI_ME (SFR->ME1) #define SPI_ME_BIT (1 << 6) #define SPI_PIN_MISO GPIO_PIN(P3, 2) #define SPI_PIN_MOSI GPIO_PIN(P3, 1) diff --git a/boards/olimex-msp430-h1611/Makefile.features b/boards/olimex-msp430-h1611/Makefile.features index 8178449bce71..3a6410cfab09 100644 --- a/boards/olimex-msp430-h1611/Makefile.features +++ b/boards/olimex-msp430-h1611/Makefile.features @@ -1,4 +1,4 @@ -CPU = msp430fxyz +CPU = msp430 CPU_MODEL = msp430f1611 # Put defined MCU peripherals here (in alphabetical order) diff --git a/boards/olimex-msp430-h1611/include/periph_conf.h b/boards/olimex-msp430-h1611/include/periph_conf.h index 865b620481e5..de59e548f20a 100644 --- a/boards/olimex-msp430-h1611/include/periph_conf.h +++ b/boards/olimex-msp430-h1611/include/periph_conf.h @@ -28,12 +28,12 @@ extern "C" { #endif -#define CLOCK_CORECLOCK msp430_fxyz_dco_freq +#define CLOCK_CORECLOCK msp430_dco_freq /** * @brief Clock configuration */ -static const msp430_fxyz_clock_params_t clock_params = { +static const msp430_clock_params_t clock_params = { .target_dco_frequency = MHZ(8), .lfxt1_frequency = 32768, .main_clock_source = MAIN_CLOCK_SOURCE_DCOCLK, @@ -48,7 +48,7 @@ static const msp430_fxyz_clock_params_t clock_params = { * @{ */ #define TIMER_NUMOF (1U) -#define TIMER_BASE (TIMER_A) +#define TIMER_BASE (&TIMER_A) #define TIMER_CHAN (3) #define TIMER_ISR_CC0 (TIMERA0_VECTOR) #define TIMER_ISR_CCX (TIMERA1_VECTOR) @@ -60,14 +60,12 @@ static const msp430_fxyz_clock_params_t clock_params = { */ #define UART_NUMOF (1U) -#define UART_BASE (USART_1) -#define UART_IE (SFR->IE2) -#define UART_IF (SFR->IFG2) +#define UART_BASE (&USART_1) +#define UART_SFR (&USART_1_SFR) #define UART_IE_RX_BIT (1 << 4) #define UART_IE_TX_BIT (1 << 5) -#define UART_ME (SFR->ME2) #define UART_ME_BITS (0x30) -#define UART_PORT (PORT_3) +#define UART_PORT (&PORT_3) #define UART_RX_PIN (1 << 6) #define UART_TX_PIN (1 << 7) #define UART_RX_ISR (USART1RX_VECTOR) @@ -81,12 +79,10 @@ static const msp430_fxyz_clock_params_t clock_params = { #define SPI_NUMOF (1U) /* SPI configuration */ -#define SPI_BASE (USART_0) -#define SPI_IE (SFR->IE1) -#define SPI_IF (SFR->IFG1) +#define SPI_BASE (&USART_0) +#define SPI_SFR (&USART_0_SFR) #define SPI_IE_RX_BIT (1 << 6) #define SPI_IE_TX_BIT (1 << 7) -#define SPI_ME (SFR->ME1) #define SPI_ME_BIT (1 << 6) #define SPI_PIN_MISO GPIO_PIN(P3, 2) #define SPI_PIN_MOSI GPIO_PIN(P3, 1) diff --git a/boards/olimex-msp430-h2618/Makefile.features b/boards/olimex-msp430-h2618/Makefile.features index 8250f412f726..fa98e8bda744 100644 --- a/boards/olimex-msp430-h2618/Makefile.features +++ b/boards/olimex-msp430-h2618/Makefile.features @@ -1,4 +1,4 @@ -CPU = msp430fxyz +CPU = msp430 CPU_MODEL = msp430f2618 # Put defined MCU peripherals here (in alphabetical order) diff --git a/boards/olimex-msp430-h2618/include/periph_conf.h b/boards/olimex-msp430-h2618/include/periph_conf.h index 92acdb9d1e11..ebec03431a70 100644 --- a/boards/olimex-msp430-h2618/include/periph_conf.h +++ b/boards/olimex-msp430-h2618/include/periph_conf.h @@ -27,12 +27,12 @@ extern "C" { #endif -#define CLOCK_CORECLOCK msp430_fxyz_dco_freq +#define CLOCK_CORECLOCK msp430_dco_freq /** * @brief Clock configuration */ -static const msp430_fxyz_clock_params_t clock_params = { +static const msp430_clock_params_t clock_params = { .target_dco_frequency = MHZ(16), .lfxt1_frequency = 32768, .main_clock_source = MAIN_CLOCK_SOURCE_DCOCLK, @@ -47,7 +47,7 @@ static const msp430_fxyz_clock_params_t clock_params = { * @{ */ #define TIMER_NUMOF (1U) -#define TIMER_BASE (TIMER_A) +#define TIMER_BASE (&TIMER_A) #define TIMER_CHAN (3) #define TIMER_ISR_CC0 (TIMERA0_VECTOR) #define TIMER_ISR_CCX (TIMERA1_VECTOR) @@ -59,15 +59,14 @@ static const msp430_fxyz_clock_params_t clock_params = { */ #define UART_NUMOF (1U) -#define UART_USE_USCI -#define UART_BASE (USCI_0) -#define UART_IE (SFR->IE2) -#define UART_IF (SFR->IFG2) +#define UART_BASE (&USCI_A0) +#define UART_IE (IE2) +#define UART_IF (IFG2) #define UART_IE_RX_BIT (1 << 0) #define UART_IE_TX_BIT (1 << 1) -#define UART_RX_PORT ((msp_port_t *)PORT_3) +#define UART_RX_PORT (&PORT_3) #define UART_RX_PIN (1 << 5) -#define UART_TX_PORT ((msp_port_t *)PORT_3) +#define UART_TX_PORT (&PORT_3) #define UART_TX_PIN (1 << 4) #define UART_RX_ISR (USCIAB0RX_VECTOR) #define UART_TX_ISR (USCIAB0TX_VECTOR) @@ -80,10 +79,9 @@ static const msp430_fxyz_clock_params_t clock_params = { #define SPI_NUMOF (1U) /* SPI configuration */ -#define SPI_USE_USCI -#define SPI_BASE (USCI_0_B_SPI) -#define SPI_IE (SFR->IE2) -#define SPI_IF (SFR->IFG2) +#define SPI_BASE (&USCI_B0) +#define SPI_IE (IE2) +#define SPI_IF (IFG2) #define SPI_IE_RX_BIT (1 << 2) #define SPI_IE_TX_BIT (1 << 3) #define SPI_PIN_MISO GPIO_PIN(P3, 2) diff --git a/boards/telosb/Makefile.features b/boards/telosb/Makefile.features index 8178449bce71..3a6410cfab09 100644 --- a/boards/telosb/Makefile.features +++ b/boards/telosb/Makefile.features @@ -1,4 +1,4 @@ -CPU = msp430fxyz +CPU = msp430 CPU_MODEL = msp430f1611 # Put defined MCU peripherals here (in alphabetical order) diff --git a/boards/telosb/include/periph_conf.h b/boards/telosb/include/periph_conf.h index 0cf65f8e66b9..5ee5a858d982 100644 --- a/boards/telosb/include/periph_conf.h +++ b/boards/telosb/include/periph_conf.h @@ -28,12 +28,12 @@ extern "C" { #endif -#define CLOCK_CORECLOCK msp430_fxyz_dco_freq +#define CLOCK_CORECLOCK msp430_dco_freq /** * @brief Clock configuration */ -static const msp430_fxyz_clock_params_t clock_params = { +static const msp430_clock_params_t clock_params = { .target_dco_frequency = 2457600U, .lfxt1_frequency = 32768, .main_clock_source = MAIN_CLOCK_SOURCE_DCOCLK, @@ -48,7 +48,7 @@ static const msp430_fxyz_clock_params_t clock_params = { * @{ */ #define TIMER_NUMOF (1U) -#define TIMER_BASE (TIMER_A) +#define TIMER_BASE (&TIMER_A) #define TIMER_CHAN (3) #define TIMER_ISR_CC0 (TIMERA0_VECTOR) #define TIMER_ISR_CCX (TIMERA1_VECTOR) @@ -60,14 +60,12 @@ static const msp430_fxyz_clock_params_t clock_params = { */ #define UART_NUMOF (1U) -#define UART_BASE (USART_1) -#define UART_IE (SFR->IE2) -#define UART_IF (SFR->IFG2) +#define UART_BASE (&USART_1) +#define UART_SFR (&USART_1_SFR) #define UART_IE_RX_BIT (1 << 4) #define UART_IE_TX_BIT (1 << 5) -#define UART_ME (SFR->ME2) #define UART_ME_BITS (0x30) -#define UART_PORT (PORT_3) +#define UART_PORT (&PORT_3) #define UART_RX_PIN (1 << 6) #define UART_TX_PIN (1 << 7) #define UART_RX_ISR (USART1RX_VECTOR) @@ -80,13 +78,10 @@ static const msp430_fxyz_clock_params_t clock_params = { */ #define SPI_NUMOF (1U) -/* SPI configuration */ -#define SPI_BASE (USART_0) -#define SPI_IE (SFR->IE1) -#define SPI_IF (SFR->IFG1) +#define SPI_BASE (&USART_0) +#define SPI_SFR (&USART_0_SFR) #define SPI_IE_RX_BIT (1 << 6) #define SPI_IE_TX_BIT (1 << 7) -#define SPI_ME (SFR->ME1) #define SPI_ME_BIT (1 << 6) #define SPI_PIN_MISO GPIO_PIN(P3, 2) #define SPI_PIN_MOSI GPIO_PIN(P3, 1) diff --git a/boards/z1/Makefile.features b/boards/z1/Makefile.features index 7a13d1dcebb1..fc3612506ddb 100644 --- a/boards/z1/Makefile.features +++ b/boards/z1/Makefile.features @@ -1,4 +1,4 @@ -CPU = msp430fxyz +CPU = msp430 CPU_MODEL = msp430f2617 # Put defined MCU peripherals here (in alphabetical order) diff --git a/boards/z1/include/periph_conf.h b/boards/z1/include/periph_conf.h index e12a26788532..b3c32638f8f5 100644 --- a/boards/z1/include/periph_conf.h +++ b/boards/z1/include/periph_conf.h @@ -28,12 +28,12 @@ extern "C" { #endif -#define CLOCK_CORECLOCK msp430_fxyz_dco_freq +#define CLOCK_CORECLOCK msp430_dco_freq /** * @brief Clock configuration */ -static const msp430_fxyz_clock_params_t clock_params = { +static const msp430_clock_params_t clock_params = { .target_dco_frequency = MHZ(8), .lfxt1_frequency = 32768, .main_clock_source = MAIN_CLOCK_SOURCE_DCOCLK, @@ -48,7 +48,7 @@ static const msp430_fxyz_clock_params_t clock_params = { * @{ */ #define TIMER_NUMOF (1U) -#define TIMER_BASE (TIMER_A) +#define TIMER_BASE (&TIMER_A) #define TIMER_CHAN (3) #define TIMER_ISR_CC0 (TIMERA0_VECTOR) #define TIMER_ISR_CCX (TIMERA1_VECTOR) @@ -60,15 +60,14 @@ static const msp430_fxyz_clock_params_t clock_params = { */ #define UART_NUMOF (1U) -#define UART_USE_USCI -#define UART_BASE (USCI_0) -#define UART_IE (SFR->IE2) -#define UART_IF (SFR->IFG2) +#define UART_BASE (&USCI_A0) +#define UART_IE (IE2) +#define UART_IF (IFG2) #define UART_IE_RX_BIT (1 << 0) #define UART_IE_TX_BIT (1 << 1) -#define UART_RX_PORT ((msp_port_t *)PORT_3) +#define UART_RX_PORT (&PORT_3) #define UART_RX_PIN (1 << 5) -#define UART_TX_PORT ((msp_port_t *)PORT_3) +#define UART_TX_PORT (&PORT_3) #define UART_TX_PIN (1 << 4) #define UART_RX_ISR (USCIAB0RX_VECTOR) #define UART_TX_ISR (USCIAB0TX_VECTOR) @@ -81,10 +80,9 @@ static const msp430_fxyz_clock_params_t clock_params = { #define SPI_NUMOF (1U) /* SPI configuration */ -#define SPI_USE_USCI -#define SPI_BASE (USCI_0_B_SPI) -#define SPI_IE (SFR->IE2) -#define SPI_IF (SFR->IFG2) +#define SPI_BASE (&USCI_B0) +#define SPI_IE (IE2) +#define SPI_IF (IFG2) #define SPI_IE_RX_BIT (1 << 2) #define SPI_IE_TX_BIT (1 << 3) #define SPI_PIN_MISO GPIO_PIN(P3, 2) diff --git a/cpu/msp430_common/Kconfig b/cpu/msp430/Kconfig similarity index 68% rename from cpu/msp430_common/Kconfig rename to cpu/msp430/Kconfig index aaf2b5d1cc89..91f95da20219 100644 --- a/cpu/msp430_common/Kconfig +++ b/cpu/msp430/Kconfig @@ -6,48 +6,42 @@ # directory for more details. # -config MODULE_MSP430_COMMON - bool - default y if CPU_CORE_MSP430 - depends on TEST_KCONFIG - imply MODULE_NEWLIB_NANO - select MODULE_MALLOC_THREAD_SAFE - help - Common code for MSP430 cores. - -config MODULE_MSP430_COMMON_PERIPH - bool - default y if CPU_CORE_MSP430 - depends on TEST_KCONFIG - select MODULE_PERIPH - help - Common peripheral code for MSP430 cores. - -choice LIBC_IMPLEMENTATION - default MODULE_NEWLIB -endchoice - config CPU_ARCH_MSP430 bool + imply MODULE_NEWLIB_NANO select HAS_ARCH_16BIT select HAS_ARCH_MSP430 + select HAS_CPU_MSP430 select HAS_DBGPIN + select HAS_NEWLIB select HAS_PERIPH_FLASHPAGE select HAS_PERIPH_FLASHPAGE_IN_ADDRESS_SPACE select HAS_PERIPH_FLASHPAGE_PAGEWISE - select HAS_NEWLIB select HAS_PERIPH_PM + select MODULE_MALLOC_THREAD_SAFE if TEST_KCONFIG + +config HAS_CPU_MSP430 + bool + help + Indicates that an 'MSP430' CPU is being used. -config CPU_CORE_MSP430 +config CPU_MSP430 bool select CPU_ARCH_MSP430 +choice LIBC_IMPLEMENTATION + default MODULE_NEWLIB +endchoice + ## Common CPU symbols config CPU_ARCH - default "msp430" if CPU_ARCH_MSP430 + default "msp430" if CPU_MSP430 + +config CPU + default "msp430" if CPU_MSP430 config CPU_CORE - default "msp430" if CPU_CORE_MSP430 + default "msp430" if CPU_MSP430 ## Definition of specific features config HAS_ARCH_MSP430 @@ -59,3 +53,7 @@ config HAS_ARCH_MSP430 config GNRC_PKTBUF_SIZE default 2560 depends on KCONFIG_USEMODULE_GNRC_PKTBUF_STATIC + +source "$(RIOTCPU)/msp430/periph/Kconfig" +source "$(RIOTCPU)/msp430/kconfigs/x1xx/Kconfig" +source "$(RIOTCPU)/msp430/kconfigs/f2xx_g2xx/Kconfig" diff --git a/cpu/msp430/Makefile b/cpu/msp430/Makefile new file mode 100644 index 000000000000..0de97feb6184 --- /dev/null +++ b/cpu/msp430/Makefile @@ -0,0 +1,5 @@ +MODULE = cpu + +DIRS := periph + +include $(RIOTBASE)/Makefile.base diff --git a/cpu/msp430_common/Makefile.dep b/cpu/msp430/Makefile.dep similarity index 74% rename from cpu/msp430_common/Makefile.dep rename to cpu/msp430/Makefile.dep index 613b06f87323..fd5f4e6f34c1 100644 --- a/cpu/msp430_common/Makefile.dep +++ b/cpu/msp430/Makefile.dep @@ -1,5 +1,4 @@ -USEMODULE += msp430_common -USEMODULE += msp430_common_periph +USEMODULE += newlib USEMODULE += periph ifneq (,$(filter newlib,$(USEMODULE))) diff --git a/cpu/msp430_common/Makefile.features b/cpu/msp430/Makefile.features similarity index 62% rename from cpu/msp430_common/Makefile.features rename to cpu/msp430/Makefile.features index b2d2886aa85d..fb3684e65398 100644 --- a/cpu/msp430_common/Makefile.features +++ b/cpu/msp430/Makefile.features @@ -1,8 +1,17 @@ CPU_ARCH = msp430 CPU_CORE = msp430 +ifneq (,$(filter msp430f2% msp430g2%,$(CPU_MODEL))) + CPU_FAM := msp430_f2xx_g2xx +endif + +ifneq (,$(filter msp430f1%,$(CPU_MODEL))) + CPU_FAM := msp430_x1xx +endif + FEATURES_PROVIDED += arch_16bit FEATURES_PROVIDED += arch_msp430 +FEATURES_PROVIDED += cpu_$(CPU_FAM) FEATURES_PROVIDED += dbgpin FEATURES_PROVIDED += newlib FEATURES_PROVIDED += periph_flashpage diff --git a/cpu/msp430_common/Makefile.include b/cpu/msp430/Makefile.include similarity index 57% rename from cpu/msp430_common/Makefile.include rename to cpu/msp430/Makefile.include index 5776456f0d19..ac6244137eb8 100644 --- a/cpu/msp430_common/Makefile.include +++ b/cpu/msp430/Makefile.include @@ -1,4 +1,5 @@ -INCLUDES += -I$(RIOTCPU)/msp430_common/include/ +INCLUDES += -I$(RIOTCPU)/msp430/include/ +INCLUDES += -I$(RIOTCPU)/msp430/include/$(subst msp430_,,$(CPU_FAM)) CFLAGS += -DCPU_MODEL_$(call uppercase_and_underscore,$(CPU_MODEL)) diff --git a/cpu/msp430fxyz/clock.c b/cpu/msp430/clock.c similarity index 97% rename from cpu/msp430fxyz/clock.c rename to cpu/msp430/clock.c index a289513841ab..eb27cd01ee4d 100644 --- a/cpu/msp430fxyz/clock.c +++ b/cpu/msp430/clock.c @@ -8,7 +8,7 @@ */ /** - * @ingroup cpu_msp430fxyz + * @ingroup cpu_msp430 * @{ * @file * @brief MSP430Fxzy clock initialization @@ -38,9 +38,9 @@ #define HAS_RSEL3 0 #endif -uint32_t msp430_fxyz_dco_freq; +uint32_t msp430_dco_freq; -static inline bool is_dco_in_use(const msp430_fxyz_clock_params_t *params) +static inline bool is_dco_in_use(const msp430_clock_params_t *params) { return ((params->main_clock_source == MAIN_CLOCK_SOURCE_DCOCLK) || (params->submain_clock_source == SUBMAIN_CLOCK_SOURCE_DCOCLK)); @@ -253,7 +253,7 @@ static void calibrate_dco(void) TACTL = 0; /* calculate actual DCO frequency */ - msp430_fxyz_dco_freq = (clock_params.lfxt1_frequency * actual_clock_ratio) >> 3; + msp430_dco_freq = (clock_params.lfxt1_frequency * actual_clock_ratio) >> 3; } void default_clock_init(void) @@ -348,7 +348,7 @@ void default_clock_init(void) __attribute__((weak, alias("default_clock_init"))) void clock_init(void); -uint32_t msp430_fxyz_submain_clock_freq(void) { +uint32_t msp430_submain_clock_freq(void) { uint16_t shift = (clock_params.submain_clock_divier >> 1) & 0x3; switch (clock_params.submain_clock_source) { case SUBMAIN_CLOCK_SOURCE_LFXT1CLK: @@ -361,11 +361,11 @@ uint32_t msp430_fxyz_submain_clock_freq(void) { return clock_params.lfxt1_frequency >> shift; default: case SUBMAIN_CLOCK_SOURCE_DCOCLK: - return msp430_fxyz_dco_freq >> shift; + return msp430_dco_freq >> shift; } } -uint32_t msp430_fxyz_auxiliary_clock_freq(void) +uint32_t msp430_auxiliary_clock_freq(void) { uint16_t shift = (clock_params.auxiliary_clock_divier >> 4) & 0x3; return clock_params.lfxt1_frequency >> shift; diff --git a/cpu/msp430_common/cpu.c b/cpu/msp430/cpu.c similarity index 100% rename from cpu/msp430_common/cpu.c rename to cpu/msp430/cpu.c diff --git a/cpu/msp430/doc.txt b/cpu/msp430/doc.txt new file mode 100644 index 000000000000..94d012a8f390 --- /dev/null +++ b/cpu/msp430/doc.txt @@ -0,0 +1,36 @@ +/** +@defgroup cpu_msp430 TI MSP430 +@ingroup cpu +@brief Texas Instruments MSP430 specific code + +Support for [TI MSP430] CPU architecture. Check the [MSP430 Dev Guide Book] +for an overview and a starting point for the CPU architecture. See +[MSP430 Programming With JTAG] on how to interface with the MCUs. + +[TI MSP430]: https://www.ti.com/microcontrollers-mcus-processors/msp430-microcontrollers/overview.html +[MSP430 Dev Guide Book]: https://www.ti.com/lit/ug/slau840a/slau840a.pdf +[MSP430 Programming With JTAG]: https://www.ti.com/lit/ug/slau320aj/slau320aj.pdf +*/ + + +/** +@defgroup cpu_msp430_f2xx_g2xx MSP430 F2xx/G2xx MCU family +@ingroup cpu_msp430 +@brief Common code for the MSP430 F2xx/G2xx MCU family + +This module contains code common to all of the [MSP430 F2xx/G2xx] MCU family. + +[MSP430 F2xx/G2xx]: https://www.ti.com/lit/ug/slau144k/slau144k.pdf +*/ + + +/** +@defgroup cpu_msp430_x1xx MSP430 x1xx MCU family +@ingroup cpu_msp430 +@brief Common code for the MSP430 x1xx MCU family + +This module contains code common to all of the [MSP430 x1xx] MCU family. + +[MSP430 x1xx]: https://www.ti.com/lit/ug/slau049f/slau049f.pdf + +*/ diff --git a/cpu/msp430_common/include/architecture_arch.h b/cpu/msp430/include/architecture_arch.h similarity index 95% rename from cpu/msp430_common/include/architecture_arch.h rename to cpu/msp430/include/architecture_arch.h index c43db0f24fe0..895724bb7d0e 100644 --- a/cpu/msp430_common/include/architecture_arch.h +++ b/cpu/msp430/include/architecture_arch.h @@ -7,7 +7,7 @@ */ /** - * @ingroup cpu_msp430_common + * @ingroup cpu_msp430 * @{ * * @file diff --git a/cpu/msp430_common/include/atomic_utils_arch.h b/cpu/msp430/include/atomic_utils_arch.h similarity index 97% rename from cpu/msp430_common/include/atomic_utils_arch.h rename to cpu/msp430/include/atomic_utils_arch.h index 59c45e6c72d3..ced1f326095e 100644 --- a/cpu/msp430_common/include/atomic_utils_arch.h +++ b/cpu/msp430/include/atomic_utils_arch.h @@ -7,7 +7,7 @@ */ /** - * @ingroup cpu_msp430_common + * @ingroup cpu_msp430 * * @{ * diff --git a/cpu/msp430_common/include/c11_atomics_compat_cpu.hpp b/cpu/msp430/include/c11_atomics_compat_cpu.hpp similarity index 100% rename from cpu/msp430_common/include/c11_atomics_compat_cpu.hpp rename to cpu/msp430/include/c11_atomics_compat_cpu.hpp diff --git a/cpu/msp430_common/include/cpu.h b/cpu/msp430/include/cpu.h similarity index 97% rename from cpu/msp430_common/include/cpu.h rename to cpu/msp430/include/cpu.h index 28a61943aa9a..32e75a014379 100644 --- a/cpu/msp430_common/include/cpu.h +++ b/cpu/msp430/include/cpu.h @@ -8,8 +8,7 @@ */ /** - * @defgroup cpu_msp430_common TI MSP430 - * @ingroup cpu + * @ingroup cpu_msp430 * @brief Texas Instruments MSP430 specific code * * @{ diff --git a/cpu/msp430_common/include/cpu_conf.h b/cpu/msp430/include/cpu_conf.h similarity index 98% rename from cpu/msp430_common/include/cpu_conf.h rename to cpu/msp430/include/cpu_conf.h index 4128d180dc9d..f8cac63c6a49 100644 --- a/cpu/msp430_common/include/cpu_conf.h +++ b/cpu/msp430/include/cpu_conf.h @@ -7,7 +7,7 @@ */ /** - * @ingroup cpu_msp430_common + * @ingroup cpu_msp430 * @{ * * @file diff --git a/cpu/msp430/include/f2xx_g2xx/msp430_regs.h b/cpu/msp430/include/f2xx_g2xx/msp430_regs.h new file mode 100644 index 000000000000..c91ff80368f9 --- /dev/null +++ b/cpu/msp430/include/f2xx_g2xx/msp430_regs.h @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2015 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 cpu_msp430_f2xx_g2xx + * @{ + * + * @file + * @brief Cortex CMSIS style definition of MSP430 registers + * + * @todo This file is incomplete, not all registers are listed. Further + * There are probably some inconsistencies throughout the MSP430 + * family which need to be addressed. + * + * @author Hauke Petersen + */ + +#ifndef F2XX_G2XX_MSP430_REGS_H +#define F2XX_G2XX_MSP430_REGS_H + +#include +#include + +#include "msp430_regs_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Universal Serial Control Interface Type A (USCI_A) Registers + */ +typedef struct { + REG8 ABCTL; /**< auto baud rate control */ + REG8 IRTCTL; /**< IrDA transmit control */ + REG8 IRRCTL; /**< IrDA receive control */ + REG8 CTL0; /**< control 0 */ + REG8 CTL1; /**< control 1 */ + REG8 BR0; /**< baud rate control 0 */ + REG8 BR1; /**< baud rate control 1 */ + REG8 MCTL; /**< modulation control */ + REG8 STAT; /**< status register */ + REG8 RXBUF; /**< receive buffer */ + REG8 TXBUF; /**< transmit buffer */ +} msp_usci_a_t; + +/** + * @brief Universal Serial Control Interface Type B (USCI_B) Registers + */ +typedef struct { + REG8 CTL0; /**< control 0 */ + REG8 CTL1; /**< control 1 */ + REG8 BR0; /**< baud rate control 0 */ + REG8 BR1; /**< baud rate control 1 */ + REG8 MCTL; /**< modulation control */ + REG8 STAT; /**< status register */ + REG8 RXBUF; /**< receive buffer */ + REG8 TXBUF; /**< transmit buffer */ +} msp_usci_b_t; + +/** + * @name USCI clock selection + * + * The vendor header files expose clock configurations with hard to read + * names. So we provide alias with better names + * + * @{ + */ +#define UCSSEL_UCLKI UCSSEL_0 /**< Clock USCI using CLKI (n/a in SPI mode) */ +#define UCSSEL_ACLK UCSSEL_1 /**< Clock USCI using auxiliary clock */ +#define UCSSEL_SMCLK UCSSEL_2 /**< Clock USCI using sub-system master clock */ +/** @} */ + +/** + * @name USCI Modulation Control fields + * + * The vendor header files provides bitmasks for each of the possible values + * from 0..7. But rather than creating a look up table, we can just shift the + * number in place, if there only would be a UCRBS_SHIFT macro. + * @{ + */ +#define UCBRS_MASK UCBRS_7 /**< Bitmask to retrieve the UCRBS field of the + USCI modulation control register */ +#if (UCBRS_7 == 0x0E) || defined(DOXYGEN) +#define UCBRS_POS 1 /**< Position of the UCRBS field in the + UCAxMCTL register */ +#else +/* The datasheet for the whole MCU family states the field is in bits 3-1, + * but let's better be safe than sorry here */ +#error "UCBRS field in the UCAxMCTL register at unexpected position." +#endif + +/** @} */ + +/** + * @brief "Convert" a USCI A into an USCI B interface + * + * The USCI peripheral come in two flavors: USCI A and USCI B with the following + * feature set. When comparing the memory map USCI B is a subset of USCI A + * registers, which conveniently have the same offsets. It is therefore possible + * to address USCI A registers as if it was a USCI B interface when operated + * in SPI mode. This makes implementation of SPI easier. + * + * | Name | UART | SPI | I2C | IrDA | + * |:------ |:----- |:----- |:----- |:----- | + * | USCI A | ✔ | ✔ | ✗ | ✔ | + * | USCI B | ✗ | ✔ | ✔ | ✗ | + */ +static inline msp_usci_b_t * msp430_usci_b_from_usci_a(msp_usci_a_t *usci_a) +{ + uintptr_t usci_b = (uintptr_t)usci_a + offsetof(msp_usci_a_t, CTL0); + return (msp_usci_b_t *)usci_b; +} + +/** + * @name Typing of base register objects + * @{ + */ +/** + * @brief USCI_A0 register map + * + * @details Provided by linker + */ +extern msp_usci_a_t USCI_A0; +/** + * @brief USCI_A1 register map + * + * @details Provided by linker + */ +extern msp_usci_a_t USCI_A1; +/** + * @brief USCI_B0 register map + * + * @details Provided by linker + */ +extern msp_usci_a_t USCI_B0; +/** + * @brief USCI_B1 register map + * + * @details Provided by linker + */ +extern msp_usci_a_t USCI_B1; +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* F2XX_G2XX_MSP430_REGS_H */ +/** @} */ diff --git a/cpu/msp430/include/f2xx_g2xx/periph_cpu.h b/cpu/msp430/include/f2xx_g2xx/periph_cpu.h new file mode 100644 index 000000000000..8153592284c6 --- /dev/null +++ b/cpu/msp430/include/f2xx_g2xx/periph_cpu.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2015 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 cpu_msp430_f2xx_g2xx + * @{ + * + * @file + * @brief CPU specific definitions for internal peripheral handling + * + * @author Hauke Petersen + */ + +#ifndef F2XX_G2XX_PERIPH_CPU_H +#define F2XX_G2XX_PERIPH_CPU_H + +#include + +#include "periph_cpu_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Override SPI mode selection values + * @{ + */ +#define HAVE_SPI_MODE_T /**< MSP430 F2xx/G2xx has a custom spi_mode_t */ +/** + * @brief Support SPI modes + * + * | Field | Name | Description | + * |:------ |:--------------------- |:----------------------------------------------------- | + * | UCCKPH | Clock phase select | 0 = capture on second edge, 1 = capture on first | + * | UCCKPL | Clock polarity select | 0 = clock is idle-low, 1 = clock is high idle-high | + */ +typedef enum { + SPI_MODE_0 = (UCCKPH), /**< CPOL=0, CPHA=0 */ + SPI_MODE_1 = 0, /**< CPOL=0, CPHA=1 */ + SPI_MODE_2 = (UCCKPL | UCCKPH), /**< CPOL=1, CPHA=0 */ + SPI_MODE_3 = (UCCKPL) /**< CPOL=1, CPHA=1 */ +} spi_mode_t; +/** @} */ + +/** + * @name Override SPI clock speed selection values + * @{ + */ +#define HAVE_SPI_CLK_T /**< MSP430 F2xx/G2xx has a custom spi_clock_t */ +/** + * @brief Support SPI clock frequencies + */ +typedef enum { + SPI_CLK_100KHZ = 100000, /**< 100 kHz */ + SPI_CLK_400KHZ = 400000, /**< 400 kHz */ + SPI_CLK_1MHZ = 1000000, /**< 1 MHz */ + SPI_CLK_5MHZ = 5000000, /**< 5 MHz */ + SPI_CLK_10MHZ = SPI_CLK_5MHZ, /**< 10 MHz not supported, falling back to 5 MHz */ +} spi_clk_t; +/** @} */ + +/** + * @name declare needed generic SPI functions + * @{ + */ +#define PERIPH_SPI_NEEDS_INIT_CS /**< use shared spi_init_cs() */ +#define PERIPH_SPI_NEEDS_TRANSFER_BYTE /**< use shared spi_transfer_byte() */ +#define PERIPH_SPI_NEEDS_TRANSFER_REG /**< use shared spi_transfer_reg() */ +#define PERIPH_SPI_NEEDS_TRANSFER_REGS /**< use shared spi_transfer_regs() */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* F2XX_G2XX_PERIPH_CPU_H */ +/** @} */ diff --git a/cpu/msp430_common/include/irq_arch.h b/cpu/msp430/include/irq_arch.h similarity index 98% rename from cpu/msp430_common/include/irq_arch.h rename to cpu/msp430/include/irq_arch.h index abfd0b206704..97735e7dbf30 100644 --- a/cpu/msp430_common/include/irq_arch.h +++ b/cpu/msp430/include/irq_arch.h @@ -8,7 +8,7 @@ */ /** - * @ingroup cpu_msp430_common + * @ingroup cpu_msp430 * @{ * * @file diff --git a/cpu/msp430/include/msp430_regs_common.h b/cpu/msp430/include/msp430_regs_common.h new file mode 100644 index 000000000000..0796e474f451 --- /dev/null +++ b/cpu/msp430/include/msp430_regs_common.h @@ -0,0 +1,184 @@ +/* + * Copyright (C) 2015 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 cpu_msp430 + * @{ + * + * @file + * @brief Cortex CMSIS style definition of MSP430 registers + * + * @todo This file is incomplete, not all registers are listed. Further + * There are probably some inconsistencies throughout the MSP430 + * family which need to be addressed. + * + * @author Hauke Petersen + */ + +#ifndef MSP430_REGS_COMMON_H +#define MSP430_REGS_COMMON_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Shortcut to specify 8-bit wide registers + */ +#define REG8 volatile uint8_t + +/** + * @brief Shortcut to specify 16-bit wide registers + */ +#define REG16 volatile uint16_t + +/** + * @name Timer SSEL Values + * + * @details When using the macros in the vendor header files such as TASSEL_0 + * the actually used clock is non-obvious. Hence, provide aliases + * with obvious names. + * @{ + */ +#define TXSSEL_TXCLK TASSEL_0 /**< External TxCLK as clock source */ +#define TXSSEL_ACLK TASSEL_1 /**< Auxiliary clock as clock source */ +#define TXSSEL_SMCLK TASSEL_2 /**< Sub-system master clock as clock source */ +#define TXSSEL_INCLK TASSEL_3 /**< External INCLK as clock source */ +/** @} */ + +/** + * @name Timer Input Divider Values + * + * @details The vendor header macros are again non-obvious in their naming, so + * provide better alies names. + * @{ + */ +#define TXID_DIV_1 ID_0 /**< Input Divider: Divide by 1 */ +#define TXID_DIV_2 ID_1 /**< Input Divider: Divide by 2 */ +#define TXID_DIV_4 ID_2 /**< Input Divider: Divide by 4 */ +#define TXID_DIV_8 ID_3 /**< Input Divider: Divide by 4 */ +/** @} */ + +/** + * @name Timer Mode Control Values + * + * @details The vendor header macros are again non-obvious in their naming, so + * provide better alies names. + * @{ + */ +#define TXMC_STOP MC_0 /**< Stop Mode */ +#define TXMC_UP MC_1 /**< Up to CCR0 Mode*/ +#define TXMC_CONT MC_2 /**< Continuous Mode */ +#define TXMC_UP_DOWN MC_3 /**< Up/Down Mode */ +#define TXMC_MASK MC_3 /**< Bitmask to retrieve MC field */ +/** @} */ + +/** + * @brief Common MSP GPIO Port Registers + */ +typedef struct { + REG8 IN; /**< input data */ + REG8 OD; /**< output data */ + REG8 DIR; /**< pin direction */ +} msp_port_t; + +/** + * @brief GPIO Port 1/2 (with interrupt functionality) + */ +typedef struct { + msp_port_t base; /**< common GPIO port registers */ + REG8 IFG; /**< interrupt flag */ + REG8 IES; /**< interrupt edge select */ + REG8 IE; /**< interrupt enable */ + REG8 SEL; /**< alternative function select */ +} msp_port_p1_p2_t; + +/** + * @brief GPIO Port 3..6 (without interrupt functionality) + */ +typedef struct { + msp_port_t base; /**< common GPIO port registers */ + REG8 SEL; /**< alternative function select */ +} msp_port_p3_p6_t; + + +/** + * @brief Timer interrupt status registers + */ +typedef struct { + REG16 TBIV; /**< TIMER_A interrupt status */ + REG16 reserved[7]; /**< reserved */ + REG16 TAIV; /**< TIMER_B interrupt status */ +} msp_timer_ivec_t; + +/** + * @brief Timer module registers + */ +typedef struct { + REG16 CTL; /**< timer control */ + REG16 CCTL[7]; /**< capture compare channel control */ + REG16 R; /**< current counter value */ + REG16 CCR[7]; /**< capture compare channel values */ +} msp_timer_t; + +/** + * @name MSP430 Common Peripheral Register Maps + * + * @details The addresses will be provided by the linker script using the + * vendor files. + * @{ + */ +/** + * @brief Register map of GPIO PORT 1 + */ +extern msp_port_p1_p2_t PORT_1; +/** + * @brief Register map of GPIO PORT 2 + */ +extern msp_port_p1_p2_t PORT_2; +/** + * @brief Register map of GPIO PORT 3 + */ +extern msp_port_p3_p6_t PORT_3; +/** + * @brief Register map of GPIO PORT 4 + */ +extern msp_port_p3_p6_t PORT_4; +/** + * @brief Register map of GPIO PORT 5 + */ +extern msp_port_p3_p6_t PORT_5; +/** + * @brief Register map of GPIO PORT 6 + */ +extern msp_port_p3_p6_t PORT_6; + +/** + * @brief Register map of the timer interrupt control registers + */ +extern msp_timer_ivec_t TIMER_IVEC; + +/** + * @brief Register map of the timer A control registers + */ +extern msp_timer_t TIMER_A; + +/** + * @brief Register map of the timer B control registers + */ +extern msp_timer_t TIMER_B; +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* MSP430_REGS_COMMON_H */ +/** @} */ diff --git a/cpu/msp430fxyz/include/periph_cpu.h b/cpu/msp430/include/periph_cpu_common.h similarity index 77% rename from cpu/msp430fxyz/include/periph_cpu.h rename to cpu/msp430/include/periph_cpu_common.h index d00643c433aa..69dbf3628668 100644 --- a/cpu/msp430fxyz/include/periph_cpu.h +++ b/cpu/msp430/include/periph_cpu_common.h @@ -7,9 +7,7 @@ */ /** - * @defgroup cpu_msp430fxyz TI MSP430F - * @ingroup cpu - * @brief Texas Instruments MSP430F family specific code + * @ingroup cpu_msp430_x1xx * @{ * * @file @@ -18,8 +16,8 @@ * @author Hauke Petersen */ -#ifndef PERIPH_CPU_H -#define PERIPH_CPU_H +#ifndef PERIPH_CPU_COMMON_H +#define PERIPH_CPU_COMMON_H #include @@ -54,12 +52,14 @@ typedef uint16_t gpio_t; */ #define SPI_HWCS(x) (SPI_CS_UNDEF) -#ifndef DOXYGEN /** - * @brief Override flank selection values + * @name Override flank selection values * @{ */ -#define HAVE_GPIO_FLANK_T +#define HAVE_GPIO_FLANK_T /**< MSP430 has a custom gpio_flank_t */ +/** + * @brief Enumeration of supported GPIO flanks + */ typedef enum { GPIO_FALLING = 0xff, /**< emit interrupt on falling flank */ GPIO_RISING = 0x00, /**< emit interrupt on rising flank */ @@ -67,43 +67,6 @@ typedef enum { } gpio_flank_t; /** @} */ -/** - * @brief Override SPI mode selection values - * @{ - */ -#define HAVE_SPI_MODE_T -#ifndef SPI_USE_USCI -typedef enum { - SPI_MODE_0 = (USART_TCTL_CKPH), /**< CPOL=0, CPHA=0 */ - SPI_MODE_1 = 0, /**< CPOL=0, CPHA=1 */ - SPI_MODE_2 = (USART_TCTL_CKPL | USART_TCTL_CKPH), /**< CPOL=1, CPHA=0 */ - SPI_MODE_3 = (USART_TCTL_CKPL) /**< CPOL=1, CPHA=1 */ -} spi_mode_t; -#else -typedef enum { - SPI_MODE_0 = (USCI_SPI_CTL0_CKPH), /**< CPOL=0, CPHA=0 */ - SPI_MODE_1 = 0, /**< CPOL=0, CPHA=1 */ - SPI_MODE_2 = (USCI_SPI_CTL0_CKPL | USCI_SPI_CTL0_CKPH), /**< CPOL=1, CPHA=0 */ - SPI_MODE_3 = (USCI_SPI_CTL0_CKPL) /**< CPOL=1, CPHA=1 */ -} spi_mode_t; -#endif -/** @} */ - -/** - * @brief Override SPI clock speed selection values - * @{ - */ -#define HAVE_SPI_CLK_T -typedef enum { - SPI_CLK_100KHZ = 100000, /**< 100KHz */ - SPI_CLK_400KHZ = 400000, /**< 400KHz */ - SPI_CLK_1MHZ = 1000000, /**< 1MHz */ - SPI_CLK_5MHZ = 5000000, /**< 5MHz */ - SPI_CLK_10MHZ = 0, /**< not supported */ -} spi_clk_t; -/** @} */ -#endif /* ndef DOXYGEN */ - /** * @brief Available ports on MSP430 platforms */ @@ -124,23 +87,13 @@ enum { */ void gpio_periph_mode(gpio_t pin, bool enable); -/** - * @brief declare needed generic SPI functions - * @{ - */ -#define PERIPH_SPI_NEEDS_INIT_CS -#define PERIPH_SPI_NEEDS_TRANSFER_BYTE -#define PERIPH_SPI_NEEDS_TRANSFER_REG -#define PERIPH_SPI_NEEDS_TRANSFER_REGS -/** @} */ - /** * @brief The measured DCO frequency * * @warning This will have a value of 0 if the DCO is not enabled in the boards * `periph_conf.h` */ -extern uint32_t msp430_fxyz_dco_freq; +extern uint32_t msp430_dco_freq; /** * @brief Possible clock sources to generate the main clock from @@ -163,7 +116,7 @@ typedef enum { * between 450 kHz and 8 MHz */ MAIN_CLOCK_SOURCE_LFXT1CLK = SELM_3, -} msp430_fxyz_main_clock_source_t; +} msp430_main_clock_source_t; /** * @brief Possible clock sources to generate the submain clock from @@ -192,7 +145,7 @@ typedef enum { * in the config to avoid confusion. */ SUBMAIN_CLOCK_SOURCE_LFXT1CLK = SELS, -} msp430_fxyz_submain_clock_source_t; +} msp430_submain_clock_source_t; /** * @brief Clock dividers for the main clock @@ -214,7 +167,7 @@ typedef enum { * @brief Divide the main clock by 8 */ MAIN_CLOCK_DIVIDE_BY_8 = DIVM_3, -} msp430_fxyz_main_clock_divider_t; +} msp430_main_clock_divider_t; /** * @brief Clock dividers for the submain clock @@ -236,7 +189,7 @@ typedef enum { * @brief Divide the main clock by 8 */ SUBMAIN_CLOCK_DIVIDE_BY_8 = DIVS_3, -} msp430_fxyz_submain_clock_divider_t; +} msp430_submain_clock_divider_t; /** * @brief Clock dividers for the auxiliary clock @@ -258,7 +211,7 @@ typedef enum { * @brief Divide the main clock by 8 */ AUXILIARY_CLOCK_DIVIDE_BY_8 = DIVA_3, -} msp430_fxyz_auxiliary_clock_divider_t; +} msp430_auxiliary_clock_divider_t; /** * @brief MSP430Fxzy Basic Clock System Parameters @@ -301,25 +254,25 @@ typedef struct { * * @details This is the clock the CPU will run at */ - msp430_fxyz_main_clock_source_t main_clock_source; + msp430_main_clock_source_t main_clock_source; /** * @brief The clock source to select for the submain CPU clock * * @details This is the clock high speed peripherals will run at */ - msp430_fxyz_submain_clock_source_t submain_clock_source; + msp430_submain_clock_source_t submain_clock_source; /** * @brief Divider of the main clock */ - msp430_fxyz_main_clock_divider_t main_clock_divier; + msp430_main_clock_divider_t main_clock_divier; /** * @brief Divider of the submain clock */ - msp430_fxyz_submain_clock_divider_t submain_clock_divier; + msp430_submain_clock_divider_t submain_clock_divier; /** * @brief Divider of the auxiliary clock */ - msp430_fxyz_auxiliary_clock_divider_t auxiliary_clock_divier; + msp430_auxiliary_clock_divider_t auxiliary_clock_divier; /** * @brief An external resistor connected to source the current for the DCO * @@ -334,14 +287,14 @@ typedef struct { * XT2IN and XT2OUT */ bool has_xt2; -} msp430_fxyz_clock_params_t; +} msp430_clock_params_t; /** * @brief Initialize the basic clock system to provide the main clock, * the subsystem clock, and the auxiliary clock. * * The main clock, the subsystem clock, and the auxiliary clock will be set up - * as specified by `static const msp430_fxyz_clock_params_t clock_params` in + * as specified by `static const msp430_clock_params_t clock_params` in * the `periph_conf.h` of the board. * * @note This function takes some time and typically is only called during @@ -368,18 +321,18 @@ void clock_init(void); * * @note This is only useful when implementing MSP430 peripheral drivers */ -uint32_t msp430_fxyz_submain_clock_freq(void); +uint32_t msp430_submain_clock_freq(void); /** * @brief Get the configured auxiliary clock frequency * * @note This is only useful when implementing MSP430 peripheral drivers */ -uint32_t msp430_fxyz_auxiliary_clock_freq(void); +uint32_t msp430_auxiliary_clock_freq(void); #ifdef __cplusplus } #endif -#endif /* PERIPH_CPU_H */ +#endif /* PERIPH_CPU_COMMON_H */ /** @} */ diff --git a/cpu/msp430_common/include/thread_arch.h b/cpu/msp430/include/thread_arch.h similarity index 94% rename from cpu/msp430_common/include/thread_arch.h rename to cpu/msp430/include/thread_arch.h index 4faddca08678..b27a394a27db 100644 --- a/cpu/msp430_common/include/thread_arch.h +++ b/cpu/msp430/include/thread_arch.h @@ -8,7 +8,7 @@ */ /** - * @ingroup cpu_msp430_common + * @ingroup cpu_msp430 * @{ * * @file diff --git a/cpu/msp430/include/x1xx/msp430_regs.h b/cpu/msp430/include/x1xx/msp430_regs.h new file mode 100644 index 000000000000..d16c1b33b1c5 --- /dev/null +++ b/cpu/msp430/include/x1xx/msp430_regs.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2015 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 cpu_msp430_x1xx + * @{ + * + * @file + * @brief Cortex CMSIS style definition of MSP430 registers + * + * @todo This file is incomplete, not all registers are listed. Further + * There are probably some inconsistencies throughout the MSP430 + * family which need to be addressed. + * + * @author Hauke Petersen + */ + +#ifndef X1XX_MSP430_REGS_H +#define X1XX_MSP430_REGS_H + +#include + +#include "msp430_regs_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief USART (UART, SPI and I2C) Registers + */ +typedef struct { + REG8 CTL; /**< USART control */ + REG8 TCTL; /**< transmit control */ + REG8 RCTL; /**< receive control */ + REG8 MCTL; /**< modulation control */ + REG8 BR0; /**< baud rate control 0 */ + REG8 BR1; /**< baud rate control 1 */ + REG8 RXBUF; /**< receive buffer */ + REG8 TXBUF; /**< transmit buffer */ +} msp_usart_t; + +/** + * @brief USART Special Function Registers (SFR) + * + * Despite being part of the USART peripheral, the SFR registers location is + * completely different. Even more confusing, the IE register of USART 1 + * follows the IE register of USART 0. Hence, the SFR register map of the two + * USART peripherals will overlap (with the IE register of the second USART + * being located at the first padding of the first USART). The padding bytes + * are intentionally declared as `const` to aid in preventing accidentally + * overwriting registers of the other USART's SFR registers. + */ +typedef struct { + REG8 IE; /**< USART Interrupt Enable Register */ + const uint8_t _pad1;/**< Padding */ + REG8 IFG; /**< USART Interrupt Flag Register */ + const uint8_t _pad2;/**< Padding */ + REG8 ME; /**< Module Enable Register */ +} msp_usart_sfr_t; + +/** + * @name USART clock selection + * + * The vendor header files expose clock configurations selection field as one + * bitmask per bit. This is pretty hard to read in the code, so we provide + * alias with better names. + * + * @{ + */ +#define UXTCTL_SSEL_UCLKI 0 /**< Clock USART using UCLKI clock */ +#define UXTCTL_SSEL_ACLK SSEL0 /**< Clock USART using auxiliary clock */ +#define UXTCTL_SSEL_SMCLK SSEL1 /**< Clock USART using sub-system master clock */ +#define UXTCTL_SSEL_MASK (SSEL0 | SSEL1) /**< Mask to retrieve SSEL field */ +/** @} */ + +/** + * @name Typing of base register objects + * @{ + */ +/** + * @brief USART 0 SFR register map + */ +extern msp_usart_sfr_t USART_0_SFR; +/** + * @brief USART 1 SFR register map + */ +extern msp_usart_sfr_t USART_1_SFR; +/** + * @brief USART 0 register map + * + * @details The address is provided by the linker script + */ +extern msp_usart_t USART_0; +/** + * @brief USART 1 register map + * + * @details The address is provided by the linker script + */ +extern msp_usart_t USART_1; +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* X1XX_MSP430_REGS_H */ +/** @} */ diff --git a/cpu/msp430/include/x1xx/periph_cpu.h b/cpu/msp430/include/x1xx/periph_cpu.h new file mode 100644 index 000000000000..700e20aa38f1 --- /dev/null +++ b/cpu/msp430/include/x1xx/periph_cpu.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2015 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 cpu_msp430_x1xx + * @{ + * + * @file + * @brief CPU specific definitions for internal peripheral handling + * + * @author Hauke Petersen + */ + +#ifndef X1XX_PERIPH_CPU_H +#define X1XX_PERIPH_CPU_H + +#include + +#include "periph_cpu_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Override SPI mode selection values + * @{ + */ +#define HAVE_SPI_MODE_T /**< MSP430 x1xx has a custom spi_mode_t */ +/** + * @brief Support SPI modes + * + * | Field | Name | Description | + * |:------ |:--------------------- |:----------------------------------------------------- | + * | CKPH | Clock phase select | 0 = capture on second edge, 1 = capture on first | + * | CKPL | Clock polarity select | 0 = clock is idle-low, 1 = clock is high idle-high | + */ +typedef enum { + SPI_MODE_0 = (CKPH), /**< CPOL=0, CPHA=0 */ + SPI_MODE_1 = 0, /**< CPOL=0, CPHA=1 */ + SPI_MODE_2 = (CKPL | CKPH), /**< CPOL=1, CPHA=0 */ + SPI_MODE_3 = (CKPL) /**< CPOL=1, CPHA=1 */ +} spi_mode_t; +/** @} */ + +/** + * @name Override SPI clock speed selection values + * @{ + */ +#define HAVE_SPI_CLK_T /**< MSP430 x1xx has a custom spi_clock_t */ +/** + * @brief Support SPI clock frequencies + */ +typedef enum { + SPI_CLK_100KHZ = 100000, /**< 100 kHz */ + SPI_CLK_400KHZ = 400000, /**< 400 kHz */ + SPI_CLK_1MHZ = 1000000, /**< 1 MHz */ + SPI_CLK_5MHZ = 5000000, /**< 5 MHz */ + SPI_CLK_10MHZ = SPI_CLK_5MHZ, /**< 10 MHz not supported, falling back to 5 MHz */ +} spi_clk_t; +/** @} */ + +/** + * @name declare needed generic SPI functions + * @{ + */ +#define PERIPH_SPI_NEEDS_INIT_CS /**< use shared spi_init_cs() */ +#define PERIPH_SPI_NEEDS_TRANSFER_BYTE /**< use shared spi_transfer_byte() */ +#define PERIPH_SPI_NEEDS_TRANSFER_REG /**< use shared spi_transfer_reg() */ +#define PERIPH_SPI_NEEDS_TRANSFER_REGS /**< use shared spi_transfer_regs() */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* X1XX_PERIPH_CPU_H */ +/** @} */ diff --git a/cpu/msp430_common/irq.c b/cpu/msp430/irq.c similarity index 93% rename from cpu/msp430_common/irq.c rename to cpu/msp430/irq.c index f6bcc1ad66ce..841375ea57cf 100644 --- a/cpu/msp430_common/irq.c +++ b/cpu/msp430/irq.c @@ -7,7 +7,7 @@ */ /** - * @ingroup cpu_msp430_common + * @ingroup cpu_msp430 * @{ * * @file diff --git a/cpu/msp430/kconfigs/f2xx_g2xx/Kconfig b/cpu/msp430/kconfigs/f2xx_g2xx/Kconfig new file mode 100644 index 000000000000..349d2cff9496 --- /dev/null +++ b/cpu/msp430/kconfigs/f2xx_g2xx/Kconfig @@ -0,0 +1,35 @@ +# Copyright (c) 2020 Freie Universität Berlin +# 2020 HAW Hamburg +# +# 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. +# + +config CPU_FAM_MSP430_F2XX_G2XX + bool + select CPU_MSP430 + select HAS_CPU_MSP430_F2XX_G2XX + +## CPU Models +config CPU_MODEL_MSP430F2617 + bool + select CPU_FAM_MSP430_F2XX_G2XX + +config CPU_MODEL_MSP430F2618 + bool + select CPU_FAM_MSP430_F2XX_G2XX + +## Definition of specific features +config HAS_CPU_MSP430_F2XX_G2XX + bool + help + Indicates that an 'MSP430 F2xx/G2xx' CPU is being used. + +## Common CPU symbols +config CPU_FAM + default "msp430_f2xx_g2xx" if HAS_CPU_MSP430_F2XX_G2XX + +config CPU_MODEL + default "msp430f2617" if CPU_MODEL_MSP430F2617 + default "msp430f2618" if CPU_MODEL_MSP430F2618 diff --git a/cpu/msp430/kconfigs/x1xx/Kconfig b/cpu/msp430/kconfigs/x1xx/Kconfig new file mode 100644 index 000000000000..97cdc18a7b68 --- /dev/null +++ b/cpu/msp430/kconfigs/x1xx/Kconfig @@ -0,0 +1,35 @@ +# Copyright (c) 2020 Freie Universität Berlin +# 2020 HAW Hamburg +# +# 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. +# + +config CPU_FAM_MSP430_X1XX + bool + select CPU_MSP430 + select HAS_CPU_MSP430_X1XX + +## CPU Models +config CPU_MODEL_MSP430F1611 + bool + select CPU_FAM_MSP430_X1XX + +config CPU_MODEL_MSP430F1612 + bool + select CPU_FAM_MSP430_X1XX + +## Definition of specific features +config HAS_CPU_MSP430_X1XX + bool + help + Indicates that an 'MSP430 x1xx' cpu is being used. + +## Common CPU symbols +config CPU_FAM + default "msp430_x1xx" if HAS_CPU_MSP430_X1XX + +config CPU_MODEL + default "msp430f1611" if CPU_MODEL_MSP430F1611 + default "msp430f1612" if CPU_MODEL_MSP430F1612 diff --git a/cpu/msp430_common/ldscripts/msp430_common.ld b/cpu/msp430/ldscripts/msp430_common.ld similarity index 50% rename from cpu/msp430_common/ldscripts/msp430_common.ld rename to cpu/msp430/ldscripts/msp430_common.ld index 93474c22dbc6..a214c2a35de4 100644 --- a/cpu/msp430_common/ldscripts/msp430_common.ld +++ b/cpu/msp430/ldscripts/msp430_common.ld @@ -20,3 +20,20 @@ SECTIONS _end_fw = . ; } > ROM } + +/* provide address for register maps by taking the address of the first + * register (as provided by the vendor files) */ + +PROVIDE(PORT_1 = P1IN); +PROVIDE(PORT_2 = P2IN); +PROVIDE(PORT_3 = P3IN); +PROVIDE(PORT_3 = P3IN); +PROVIDE(PORT_4 = P4IN); +PROVIDE(PORT_5 = P5IN); +PROVIDE(PORT_6 = P6IN); + +/* no typo: TBIV indeed comes before TAIV in memory, see msp_timer_ivec_t */ +PROVIDE(TIMER_IVEC = TBIV); + +PROVIDE(TIMER_A = TACTL); +PROVIDE(TIMER_B = TBCTL); diff --git a/cpu/msp430/ldscripts/msp430_f2xx_g2xx.ld b/cpu/msp430/ldscripts/msp430_f2xx_g2xx.ld new file mode 100644 index 000000000000..cb90d22587f2 --- /dev/null +++ b/cpu/msp430/ldscripts/msp430_f2xx_g2xx.ld @@ -0,0 +1,6 @@ +/* provide address for USCI register map by taking the address of the first + * register (as provided by the vendor files) */ +PROVIDE(USCI_A0 = UCA0ABCTL); +PROVIDE(USCI_A1 = UCA1ABCTL); +PROVIDE(USCI_B0 = UCB0CTL0); +PROVIDE(USCI_B1 = UCB1CTL0); diff --git a/cpu/msp430/ldscripts/msp430_x1xx.ld b/cpu/msp430/ldscripts/msp430_x1xx.ld new file mode 100644 index 000000000000..1789e7e16734 --- /dev/null +++ b/cpu/msp430/ldscripts/msp430_x1xx.ld @@ -0,0 +1,7 @@ +/* provide address for UASRT register map by taking the address of the first + * register (as provided by the vendor files) */ +PROVIDE(USART_0_SFR = IE1); +PROVIDE(USART_1_SFR = IE2); + +PROVIDE(USART_0 = U0CTL); +PROVIDE(USART_1 = U1CTL); diff --git a/cpu/msp430_common/ldscripts/riot-msp430f1611.ld b/cpu/msp430/ldscripts/riot-msp430f1611.ld similarity index 73% rename from cpu/msp430_common/ldscripts/riot-msp430f1611.ld rename to cpu/msp430/ldscripts/riot-msp430f1611.ld index 1cdecc69ab0e..2a867b97dc69 100644 --- a/cpu/msp430_common/ldscripts/riot-msp430f1611.ld +++ b/cpu/msp430/ldscripts/riot-msp430f1611.ld @@ -1,3 +1,4 @@ INCLUDE msp430f1611.ld INCLUDE msp430_common.ld +INCLUDE msp430_x1xx.ld INCLUDE xfa.ld diff --git a/cpu/msp430_common/ldscripts/riot-msp430f1612.ld b/cpu/msp430/ldscripts/riot-msp430f1612.ld similarity index 73% rename from cpu/msp430_common/ldscripts/riot-msp430f1612.ld rename to cpu/msp430/ldscripts/riot-msp430f1612.ld index 6f5b4016d4ab..bea375f722d6 100644 --- a/cpu/msp430_common/ldscripts/riot-msp430f1612.ld +++ b/cpu/msp430/ldscripts/riot-msp430f1612.ld @@ -1,3 +1,4 @@ INCLUDE msp430f1612.ld INCLUDE msp430_common.ld +INCLUDE msp430_x1xx.ld INCLUDE xfa.ld diff --git a/cpu/msp430_common/ldscripts/riot-msp430f1617.ld b/cpu/msp430/ldscripts/riot-msp430f1617.ld similarity index 73% rename from cpu/msp430_common/ldscripts/riot-msp430f1617.ld rename to cpu/msp430/ldscripts/riot-msp430f1617.ld index 97987d26e1ca..b5b6fe3f5edd 100644 --- a/cpu/msp430_common/ldscripts/riot-msp430f1617.ld +++ b/cpu/msp430/ldscripts/riot-msp430f1617.ld @@ -1,3 +1,4 @@ INCLUDE msp430f1617.ld INCLUDE msp430_common.ld +INCLUDE msp430_x1xx.ld INCLUDE xfa.ld diff --git a/cpu/msp430_common/ldscripts/riot-msp430f2617.ld b/cpu/msp430/ldscripts/riot-msp430f2617.ld similarity index 69% rename from cpu/msp430_common/ldscripts/riot-msp430f2617.ld rename to cpu/msp430/ldscripts/riot-msp430f2617.ld index 5e94f010b367..b475508b1fbc 100644 --- a/cpu/msp430_common/ldscripts/riot-msp430f2617.ld +++ b/cpu/msp430/ldscripts/riot-msp430f2617.ld @@ -1,3 +1,4 @@ INCLUDE msp430f2617.ld INCLUDE msp430_common.ld +INCLUDE msp430_f2xx_g2xx.ld INCLUDE xfa.ld diff --git a/cpu/msp430_common/ldscripts/riot-msp430f2618.ld b/cpu/msp430/ldscripts/riot-msp430f2618.ld similarity index 69% rename from cpu/msp430_common/ldscripts/riot-msp430f2618.ld rename to cpu/msp430/ldscripts/riot-msp430f2618.ld index a6bf50c33d74..754a0fea746d 100644 --- a/cpu/msp430_common/ldscripts/riot-msp430f2618.ld +++ b/cpu/msp430/ldscripts/riot-msp430f2618.ld @@ -1,3 +1,4 @@ INCLUDE msp430f2618.ld INCLUDE msp430_common.ld +INCLUDE msp430_f2xx_g2xx.ld INCLUDE xfa.ld diff --git a/cpu/msp430_common/ldscripts/xfa.ld b/cpu/msp430/ldscripts/xfa.ld similarity index 100% rename from cpu/msp430_common/ldscripts/xfa.ld rename to cpu/msp430/ldscripts/xfa.ld diff --git a/cpu/msp430_common/msp430-main.c b/cpu/msp430/msp430-main.c similarity index 100% rename from cpu/msp430_common/msp430-main.c rename to cpu/msp430/msp430-main.c diff --git a/cpu/msp430_common/mspgcc-supplement.c b/cpu/msp430/mspgcc-supplement.c similarity index 100% rename from cpu/msp430_common/mspgcc-supplement.c rename to cpu/msp430/mspgcc-supplement.c diff --git a/cpu/msp430/periph/Kconfig b/cpu/msp430/periph/Kconfig new file mode 100644 index 000000000000..19f0cda43a4f --- /dev/null +++ b/cpu/msp430/periph/Kconfig @@ -0,0 +1,12 @@ +# Copyright (c) 2023 Marian Buschsieweke +# +# 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. +# + +config MODULE_PERIPH + bool + default y + help + MSP430 peripheral drivers. diff --git a/cpu/msp430/periph/Makefile b/cpu/msp430/periph/Makefile new file mode 100644 index 000000000000..4c9c3578a733 --- /dev/null +++ b/cpu/msp430/periph/Makefile @@ -0,0 +1,23 @@ +MODULE = periph + +# All supported MSP430 families use special serial IP block that implements +# various serial bus interfaces using the same hardware block. For the +# MSP430 x1xx family, the block is called USART. For the MSP430 F2xx/G2xx +# family it is the (incompatible) USCI. +ifeq (msp430_x1xx,$(CPU_FAM)) + SERIAL_IP_BLOCK := usart +endif +ifeq (msp430_f2xx_g2xx,$(CPU_FAM)) + SERIAL_IP_BLOCK := usci +endif + +# select family specific peripheral drivers. +ifneq (,$(filter periph_uart,$(USEMODULE))) + SRC += uart_$(SERIAL_IP_BLOCK).c +endif + +ifneq (,$(filter periph_spi,$(USEMODULE))) + SRC += spi_$(SERIAL_IP_BLOCK).c +endif + +include $(RIOTMAKE)/periph.mk diff --git a/cpu/msp430_common/periph/flashpage.c b/cpu/msp430/periph/flashpage.c similarity index 98% rename from cpu/msp430_common/periph/flashpage.c rename to cpu/msp430/periph/flashpage.c index 54973ac540f0..53c751a3285c 100644 --- a/cpu/msp430_common/periph/flashpage.c +++ b/cpu/msp430/periph/flashpage.c @@ -8,7 +8,7 @@ */ /** - * @ingroup cpu_msp430fxyz + * @ingroup cpu_msp430 * @{ * * @file diff --git a/cpu/msp430fxyz/periph/gpio.c b/cpu/msp430/periph/gpio.c similarity index 77% rename from cpu/msp430fxyz/periph/gpio.c rename to cpu/msp430/periph/gpio.c index 2c3ce701810c..fafd69c43a7b 100644 --- a/cpu/msp430fxyz/periph/gpio.c +++ b/cpu/msp430/periph/gpio.c @@ -7,7 +7,7 @@ */ /** - * @ingroup cpu_msp430fxyz + * @ingroup cpu_msp430 * @ingroup drivers_periph_gpio * @{ * @@ -19,8 +19,9 @@ * @} */ -#include "cpu.h" #include "bitarithm.h" +#include "container.h" +#include "cpu.h" #include "periph/gpio.h" /** @@ -36,20 +37,20 @@ static msp_port_t *_port(gpio_t pin) { switch (pin >> 8) { - case 1: - return PORT_1; - case 2: - return PORT_2; - case 3: - return PORT_3; - case 4: - return PORT_4; - case 5: - return PORT_5; - case 6: - return PORT_6; - default: - return NULL; + case 1: + return &PORT_1.base; + case 2: + return &PORT_2.base; + case 3: + return &PORT_3.base; + case 4: + return &PORT_4.base; + case 5: + return &PORT_5.base; + case 6: + return &PORT_6.base; + default: + return NULL; } } @@ -58,12 +59,15 @@ static inline uint8_t _pin(gpio_t pin) return (uint8_t)(pin & 0xff); } -static inline msp_port_isr_t *_isr_port(gpio_t pin) +static inline msp_port_p1_p2_t *_isr_port(gpio_t pin) { - msp_port_t *p = _port(pin); - if ((p == PORT_1) || (p == PORT_2)) { - return (msp_port_isr_t *)p; + /* checking for (pin >> 8) <= 2 requires 6 byte of .text more than + * checking the resulting address */ + msp_port_p1_p2_t *port = container_of(_port(pin), msp_port_p1_p2_t, base); + if ((port == &PORT_1) || (port == &PORT_2)) { + return port; } + return NULL; } @@ -90,12 +94,12 @@ int gpio_init(gpio_t pin, gpio_mode_t mode) void gpio_periph_mode(gpio_t pin, bool enable) { REG8 *sel; - msp_port_isr_t *isrport = _isr_port(pin); + msp_port_p1_p2_t *isrport = _isr_port(pin); if (isrport) { sel = &(isrport->SEL); } else { - msp_port_t *port = _port(pin); + msp_port_p3_p6_t *port = container_of(_port(pin), msp_port_p3_p6_t, base); if (port) { sel = &(port->SEL); } @@ -156,13 +160,13 @@ static gpio_isr_ctx_t isr_ctx[ISR_NUMOF]; static int _ctx(gpio_t pin) { int i = bitarithm_lsb(_pin(pin)); - return (_port(pin) == PORT_1) ? i : (i + 8); + return (_port(pin) == &PORT_1.base) ? i : (i + 8); } int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, gpio_cb_t cb, void *arg) { - msp_port_isr_t *port = _isr_port(pin); + msp_port_p1_p2_t *port = _isr_port(pin); /* check if port, pull resistor and flank configuration are valid */ if ((port == NULL) || (flank == GPIO_BOTH)) { @@ -189,7 +193,7 @@ int gpio_init_int(gpio_t pin, gpio_mode_t mode, gpio_flank_t flank, void gpio_irq_enable(gpio_t pin) { - msp_port_isr_t *port = _isr_port(pin); + msp_port_p1_p2_t *port = _isr_port(pin); if (port) { port->IE |= _pin(pin); } @@ -197,13 +201,13 @@ void gpio_irq_enable(gpio_t pin) void gpio_irq_disable(gpio_t pin) { - msp_port_isr_t *port = _isr_port(pin); + msp_port_p1_p2_t *port = _isr_port(pin); if (port) { port->IE &= ~(_pin(pin)); } } -static inline void isr_handler(msp_port_isr_t *port, int ctx) +static inline void isr_handler(msp_port_p1_p2_t *port, int ctx) { for (unsigned i = 0; i < PINS_PER_PORT; i++) { if ((port->IE & (1 << i)) && (port->IFG & (1 << i))) { @@ -216,14 +220,14 @@ static inline void isr_handler(msp_port_isr_t *port, int ctx) ISR(PORT1_VECTOR, isr_port1) { __enter_isr(); - isr_handler((msp_port_isr_t *)PORT_1, 0); + isr_handler(&PORT_1, 0); __exit_isr(); } ISR(PORT2_VECTOR, isr_port2) { __enter_isr(); - isr_handler((msp_port_isr_t *)PORT_2, 8); + isr_handler(&PORT_2, 8); __exit_isr(); } #endif /* MODULE_PERIPH_GPIO_IRQ */ diff --git a/cpu/msp430_common/periph/pm.c b/cpu/msp430/periph/pm.c similarity index 94% rename from cpu/msp430_common/periph/pm.c rename to cpu/msp430/periph/pm.c index 85e70122bb7e..dfbd0c9c6360 100644 --- a/cpu/msp430_common/periph/pm.c +++ b/cpu/msp430/periph/pm.c @@ -7,7 +7,7 @@ */ /** - * @ingroup cpu_msp430_common + * @ingroup cpu_msp430 * @ingroup drivers_periph_pm * @{ * diff --git a/cpu/msp430/periph/spi_usart.c b/cpu/msp430/periph/spi_usart.c new file mode 100644 index 000000000000..c3b7170fe539 --- /dev/null +++ b/cpu/msp430/periph/spi_usart.c @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2015-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. + */ + +/** + * @ingroup cpu_msp430_x1xx + * @ingroup drivers_periph_spi + * @{ + * + * @file + * @brief Low-level SPI driver implementation + * + * This SPI driver implementation does only support one single SPI device for + * now. This is sufficient, as most MSP430 x1xx CPU's only support two serial + * devices - one used as UART and one as SPI. + * + * @author Hauke Petersen + * + * @} + */ + +#include + +#include "cpu.h" +#include "mutex.h" +#include "periph/spi.h" + +/** + * @brief Mutex for locking the SPI device + */ +static mutex_t spi_lock = MUTEX_INIT; + +void spi_init(spi_t bus) +{ + assert((unsigned)bus < SPI_NUMOF); + + /* put SPI device in reset state */ + SPI_BASE->CTL = SWRST; + SPI_BASE->CTL |= (CHAR | SYNC | MM); + SPI_BASE->RCTL = 0; + SPI_BASE->MCTL = 0; + /* enable SPI mode */ + SPI_SFR->ME |= SPI_ME_BIT; + + /* trigger the pin configuration */ + spi_init_pins(bus); +} + +void spi_init_pins(spi_t bus) +{ + (void)bus; + + gpio_periph_mode(SPI_PIN_MISO, true); + gpio_periph_mode(SPI_PIN_MOSI, true); + gpio_periph_mode(SPI_PIN_CLK, true); +} + +void spi_acquire(spi_t bus, spi_cs_t cs, spi_mode_t mode, spi_clk_t clk) +{ + (void)bus; + (void)cs; + assert((unsigned)bus < SPI_NUMOF); + assert(clk != SPI_CLK_10MHZ); + + /* lock the bus */ + mutex_lock(&spi_lock); + + /* calculate baudrate */ + uint32_t br = msp430_submain_clock_freq() / clk; + /* make sure the is not smaller then 2 */ + if (br < 2) { + br = 2; + } + SPI_BASE->BR0 = (uint8_t)br; + SPI_BASE->BR1 = (uint8_t)(br >> 8); + + /* configure bus mode */ + /* configure mode */ + SPI_BASE->TCTL = (UXTCTL_SSEL_SMCLK | STC | mode); + /* release from software reset */ + SPI_BASE->CTL &= ~(SWRST); +} + +void spi_release(spi_t bus) +{ + (void)bus; + /* put SPI device back in reset state */ + SPI_BASE->CTL |= SWRST; + + /* release the bus */ + mutex_unlock(&spi_lock); +} + +void spi_transfer_bytes(spi_t bus, spi_cs_t cs, bool cont, + const void *out, void *in, size_t len) +{ + (void)bus; + + const uint8_t *out_buf = out; + uint8_t *in_buf = in; + + assert(out_buf || in_buf); + + if (cs != SPI_CS_UNDEF) { + gpio_clear((gpio_t)cs); + } + + /* if we only send out data, we do this the fast way... */ + if (!in_buf) { + for (size_t i = 0; i < len; i++) { + while (!(SPI_SFR->IFG & SPI_IE_TX_BIT)) {} + SPI_BASE->TXBUF = out_buf[i]; + } + /* finally we need to wait, until all transfers are complete */ + while (!(SPI_SFR->IFG & SPI_IE_TX_BIT) || !(SPI_SFR->IFG & SPI_IE_RX_BIT)) {} + SPI_BASE->RXBUF; + } + else if (!out_buf) { + for (size_t i = 0; i < len; i++) { + SPI_BASE->TXBUF = 0; + while (!(SPI_SFR->IFG & SPI_IE_RX_BIT)) {} + in_buf[i] = (char)SPI_BASE->RXBUF; + } + } + else { + for (size_t i = 0; i < len; i++) { + while (!(SPI_SFR->IFG & SPI_IE_TX_BIT)) {} + SPI_BASE->TXBUF = out_buf[i]; + while (!(SPI_SFR->IFG & SPI_IE_RX_BIT)) {} + in_buf[i] = (char)SPI_BASE->RXBUF; + } + } + + if ((!cont) && (cs != SPI_CS_UNDEF)) { + gpio_set((gpio_t)cs); + } +} diff --git a/cpu/msp430fxyz/periph/spi.c b/cpu/msp430/periph/spi_usci.c similarity index 71% rename from cpu/msp430fxyz/periph/spi.c rename to cpu/msp430/periph/spi_usci.c index 648dabb6ed14..fbbff950032f 100644 --- a/cpu/msp430fxyz/periph/spi.c +++ b/cpu/msp430/periph/spi_usci.c @@ -7,7 +7,7 @@ */ /** - * @ingroup cpu_msp430fxyz + * @ingroup cpu_msp430_f2xx_g2xx * @ingroup drivers_periph_spi * @{ * @@ -38,20 +38,9 @@ void spi_init(spi_t bus) { assert((unsigned)bus < SPI_NUMOF); -/* we need to differentiate between the legacy SPI device and USCI */ -#ifndef SPI_USE_USCI - /* put SPI device in reset state */ - SPI_BASE->CTL = USART_CTL_SWRST; - SPI_BASE->CTL |= (USART_CTL_CHAR | USART_CTL_SYNC | USART_CTL_MM); - SPI_BASE->RCTL = 0; - SPI_BASE->MCTL = 0; - /* enable SPI mode */ - SPI_ME |= SPI_ME_BIT; -#else /* reset SPI device */ - SPI_BASE->CTL1 = USCI_SPI_CTL1_SWRST; - SPI_BASE->CTL1 |= (USCI_SPI_CTL1_SSEL_SMCLK); -#endif + SPI_BASE->CTL1 = UCSWRST; + SPI_BASE->CTL1 |= UCSSEL_SMCLK; /* trigger the pin configuration */ spi_init_pins(bus); @@ -77,7 +66,7 @@ void spi_acquire(spi_t bus, spi_cs_t cs, spi_mode_t mode, spi_clk_t clk) mutex_lock(&spi_lock); /* calculate baudrate */ - uint32_t br = msp430_fxyz_submain_clock_freq() / clk; + uint32_t br = msp430_submain_clock_freq() / clk; /* make sure the is not smaller then 2 */ if (br < 2) { br = 2; @@ -86,29 +75,17 @@ void spi_acquire(spi_t bus, spi_cs_t cs, spi_mode_t mode, spi_clk_t clk) SPI_BASE->BR1 = (uint8_t)(br >> 8); /* configure bus mode */ -#ifndef SPI_USE_USCI /* configure mode */ - SPI_BASE->TCTL = (USART_TCTL_SSEL_SMCLK | USART_TCTL_STC | mode); + SPI_BASE->CTL0 = (UCSYNC | UCMST | UCMODE_0 | UCMSB | mode); /* release from software reset */ - SPI_BASE->CTL &= ~(USART_CTL_SWRST); -#else - /* configure mode */ - SPI_BASE->CTL0 = (USCI_SPI_CTL0_UCSYNC | USCI_SPI_CTL0_MST| - USCI_SPI_CTL0_MODE_0 | USCI_SPI_CTL0_MSB | mode); - /* release from software reset */ - SPI_BASE->CTL1 &= ~(USCI_SPI_CTL1_SWRST); -#endif + SPI_BASE->CTL1 &= ~(UCSWRST); } void spi_release(spi_t bus) { (void)bus; /* put SPI device back in reset state */ -#ifndef SPI_USE_USCI - SPI_BASE->CTL |= (USART_CTL_SWRST); -#else - SPI_BASE->CTL1 |= (USCI_SPI_CTL1_SWRST); -#endif + SPI_BASE->CTL1 |= UCSWRST; /* release the bus */ mutex_unlock(&spi_lock); @@ -135,11 +112,7 @@ void spi_transfer_bytes(spi_t bus, spi_cs_t cs, bool cont, SPI_BASE->TXBUF = out_buf[i]; } /* finally we need to wait, until all transfers are complete */ -#ifndef SPI_USE_USCI - while (!(SPI_IF & SPI_IE_TX_BIT) || !(SPI_IF & SPI_IE_RX_BIT)) {} -#else - while (SPI_BASE->STAT & USCI_SPI_STAT_UCBUSY) {} -#endif + while (SPI_BASE->STAT & UCBUSY) {} SPI_BASE->RXBUF; } else if (!out_buf) { diff --git a/cpu/msp430fxyz/periph/timer.c b/cpu/msp430/periph/timer.c similarity index 79% rename from cpu/msp430fxyz/periph/timer.c rename to cpu/msp430/periph/timer.c index 1e4b5444bdf3..6150a90d7585 100644 --- a/cpu/msp430fxyz/periph/timer.c +++ b/cpu/msp430/periph/timer.c @@ -7,7 +7,7 @@ */ /** - * @ingroup cpu_msp430fxyz + * @ingroup cpu_msp430 * @ingroup drivers_periph_timer * @{ * @@ -52,18 +52,18 @@ int timer_init(tim_t dev, uint32_t freq, timer_cb_t cb, void *arg) } /* reset the timer A configuration */ - TIMER_BASE->CTL = TIMER_CTL_CLR; + TIMER_BASE->CTL = TACLR; /* save callback */ isr_cb = cb; isr_arg = arg; /* configure timer to use the SMCLK with prescaler of 8 */ - TIMER_BASE->CTL = (TIMER_CTL_TASSEL_SMCLK | TIMER_CTL_ID_DIV8); + TIMER_BASE->CTL = (TXSSEL_SMCLK | TXID_DIV_8); /* configure CC channels */ for (int i = 0; i < TIMER_CHAN; i++) { TIMER_BASE->CCTL[i] = 0; } /* start the timer in continuous mode */ - TIMER_BASE->CTL |= TIMER_CTL_MC_CONT; + TIMER_BASE->CTL |= TXMC_CONT; return 0; } @@ -73,8 +73,8 @@ int timer_set_absolute(tim_t dev, int channel, unsigned int value) return -1; } TIMER_BASE->CCR[channel] = value; - TIMER_BASE->CCTL[channel] &= ~(TIMER_CCTL_CCIFG); - TIMER_BASE->CCTL[channel] |= (TIMER_CCTL_CCIE); + TIMER_BASE->CCTL[channel] &= ~(CCIFG); + TIMER_BASE->CCTL[channel] |= CCIE; return 0; } @@ -83,7 +83,7 @@ int timer_clear(tim_t dev, int channel) if (dev != 0 || channel >= TIMER_CHAN) { return -1; } - TIMER_BASE->CCTL[channel] &= ~(TIMER_CCTL_CCIE); + TIMER_BASE->CCTL[channel] &= ~(CCIE); return 0; } @@ -96,20 +96,20 @@ unsigned int timer_read(tim_t dev) void timer_start(tim_t dev) { (void)dev; - TIMER_BASE->CTL |= TIMER_CTL_MC_CONT; + TIMER_BASE->CTL |= TXMC_CONT; } void timer_stop(tim_t dev) { (void)dev; - TIMER_BASE->CTL &= ~(TIMER_CTL_MC_MASK); + TIMER_BASE->CTL &= ~(TXMC_MASK); } ISR(TIMER_ISR_CC0, isr_timer_a_cc0) { __enter_isr(); - TIMER_BASE->CCTL[0] &= ~(TIMER_CCTL_CCIE); + TIMER_BASE->CCTL[0] &= ~(CCIE); isr_cb(isr_arg, 0); __exit_isr(); @@ -119,8 +119,8 @@ ISR(TIMER_ISR_CCX, isr_timer_a_ccx) { __enter_isr(); - int chan = (int)(TIMER_IVEC->TAIV >> 1); - TIMER_BASE->CCTL[chan] &= ~(TIMER_CCTL_CCIE); + int chan = (int)(TIMER_IVEC.TAIV >> 1); + TIMER_BASE->CCTL[chan] &= ~(CCIE); isr_cb(isr_arg, chan); __exit_isr(); diff --git a/cpu/msp430/periph/uart_usart.c b/cpu/msp430/periph/uart_usart.c new file mode 100644 index 000000000000..c30618a0bea0 --- /dev/null +++ b/cpu/msp430/periph/uart_usart.c @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2015 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 cpu_msp430_x1xx + * @ingroup drivers_periph_uart + * @{ + * + * @file + * @brief Low-level UART driver implementation + * + * @author Hauke Petersen + * + * @} + */ + +#include "cpu.h" +#include "periph_cpu.h" +#include "periph_conf.h" +#include "periph/uart.h" + +/** + * @brief Keep track of the interrupt context + * @{ + */ +static uart_rx_cb_t ctx_rx_cb; +static void *ctx_isr_arg; +/** @} */ + +static int init_base(uart_t uart, uint32_t baudrate); + +int uart_init(uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg) +{ + int res = init_base(uart, baudrate); + if (res != UART_OK) { + return res; + } + + /* save interrupt context */ + ctx_rx_cb = rx_cb; + ctx_isr_arg = arg; + /* reset interrupt flags and enable RX interrupt */ + UART_SFR->IE &= ~(UART_IE_TX_BIT); + UART_SFR->IFG &= ~(UART_IE_RX_BIT); + UART_SFR->IFG |= (UART_IE_TX_BIT); + UART_SFR->IE |= (UART_IE_RX_BIT); + return UART_OK; +} + +static int init_base(uart_t uart, uint32_t baudrate) +{ + if (uart != 0) { + return UART_NODEV; + } + + /* get the default UART for now -> TODO: enable for multiple devices */ + msp_usart_t *dev = UART_BASE; + + /* power off and reset device */ + uart_poweroff(uart); + dev->CTL = SWRST; + /* configure to 8N1 and using the SMCLK*/ + dev->CTL |= CHAR; + dev->TCTL = (TXEPT | UXTCTL_SSEL_SMCLK); + dev->RCTL = 0x00; + /* baudrate configuration */ + uint16_t br = (uint16_t)(msp430_submain_clock_freq() / baudrate); + dev->BR0 = (uint8_t)br; + dev->BR1 = (uint8_t)(br >> 8); + /* TODO: calculate value for modulation register */ + dev->MCTL = 0; + /* configure pins -> TODO: move into GPIO driver (once implemented) */ + UART_PORT->SEL |= (UART_RX_PIN | UART_TX_PIN); + msp_port_t *port = &UART_PORT->base; + port->OD |= UART_RX_PIN; + port->OD &= ~(UART_TX_PIN); + port->DIR |= UART_TX_PIN; + port->DIR &= ~(UART_RX_PIN); + /* enable receiver and transmitter */ + uart_poweron(uart); + /* and finally release the software reset bit */ + dev->CTL &= ~(SWRST); + return UART_OK; +} + +void uart_write(uart_t uart, const uint8_t *data, size_t len) +{ + (void)uart; + msp_usart_t *dev = UART_BASE; + + for (size_t i = 0; i < len; i++) { + while (!(dev->TCTL & TXEPT)) {} + dev->TXBUF = data[i]; + } +} + +void uart_poweron(uart_t uart) +{ + (void)uart; + UART_SFR->ME |= UART_ME_BITS; +} + +void uart_poweroff(uart_t uart) +{ + (void)uart; + UART_SFR->ME &= ~(UART_ME_BITS); +} + +ISR(UART_RX_ISR, isr_uart_0_rx) +{ + __enter_isr(); + + /* read character (resets interrupt flag) */ + char c = UART_BASE->RXBUF; + + /* only call callback if there was no receive error */ + if(! (UART_BASE->RCTL & RXERR)) { + ctx_rx_cb(ctx_isr_arg, c); + } + + __exit_isr(); +} diff --git a/cpu/msp430/periph/uart_usci.c b/cpu/msp430/periph/uart_usci.c new file mode 100644 index 000000000000..9d86d6476736 --- /dev/null +++ b/cpu/msp430/periph/uart_usci.c @@ -0,0 +1,125 @@ +/* + * Copyright (C) 2015 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 cpu_msp430_f2xx_g2xx + * @ingroup drivers_periph_uart + * @{ + * + * @file + * @brief Low-level UART driver implementation + * + * @author Hauke Petersen + * + * @} + */ + +#include "cpu.h" +#include "periph_cpu.h" +#include "periph_conf.h" +#include "periph/uart.h" + +/** + * @brief Keep track of the interrupt context + * @{ + */ +static uart_rx_cb_t ctx_rx_cb; +static void *ctx_isr_arg; +/** @} */ + +static int init_base(uart_t uart, uint32_t baudrate); + +int uart_init(uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg) +{ + if (init_base(uart, baudrate) < 0) { + return -1; + } + + /* save interrupt context */ + ctx_rx_cb = rx_cb; + ctx_isr_arg = arg; + /* reset interrupt flags and enable RX interrupt */ + UART_IF &= ~(UART_IE_RX_BIT); + UART_IF |= (UART_IE_TX_BIT); + UART_IE |= (UART_IE_RX_BIT); + UART_IE &= ~(UART_IE_TX_BIT); + return 0; +} + +static int init_base(uart_t uart, uint32_t baudrate) +{ + if (uart != 0) { + return -1; + } + + /* get the default UART for now -> TODO: enable for multiple devices */ + msp_usci_a_t *dev = UART_BASE; + + /* put device in reset mode while configuration is going on */ + dev->CTL1 = UCSWRST; + /* configure to UART, using SMCLK in 8N1 mode */ + dev->CTL1 |= UCSSEL_SMCLK; + dev->CTL0 = 0; + dev->STAT = 0; + /* configure baudrate */ + uint32_t base = ((msp430_submain_clock_freq() << 7) / baudrate); + uint16_t br = (uint16_t)(base >> 7); + uint8_t brs = (((base & 0x3f) * 8) >> 7); + dev->BR0 = (uint8_t)br; + dev->BR1 = (uint8_t)(br >> 8); + dev->MCTL = (brs << UCBRS_POS); + /* pin configuration -> TODO: move to GPIO driver once implemented */ + UART_RX_PORT->SEL |= UART_RX_PIN; + UART_TX_PORT->SEL |= UART_TX_PIN; + UART_RX_PORT->base.DIR &= ~(UART_RX_PIN); + UART_TX_PORT->base.DIR |= UART_TX_PIN; + /* releasing the software reset bit starts the UART */ + dev->CTL1 &= ~(UCSWRST); + return 0; +} + +void uart_write(uart_t uart, const uint8_t *data, size_t len) +{ + (void)uart; + + for (size_t i = 0; i < len; i++) { + while (!(UART_IF & UART_IE_TX_BIT)) {} + UART_BASE->TXBUF = data[i]; + } +} + +void uart_poweron(uart_t uart) +{ + (void)uart; + /* n/a */ +} + +void uart_poweroff(uart_t uart) +{ + (void)uart; + /* n/a */ +} + +ISR(UART_RX_ISR, isr_uart_0_rx) +{ + __enter_isr(); + + uint8_t stat = UART_BASE->STAT; + uint8_t data = (uint8_t)UART_BASE->RXBUF; + + if (stat & (UCFE | UCOE | UCPE | UCBRK)) { + /* some error which we do not handle, just do a pseudo read to reset the + * status register */ + (void)data; + } + else { + ctx_rx_cb(ctx_isr_arg, data); + } + + __exit_isr(); +} diff --git a/cpu/msp430_common/startup.c b/cpu/msp430/startup.c similarity index 100% rename from cpu/msp430_common/startup.c rename to cpu/msp430/startup.c diff --git a/cpu/msp430_common/vendor/README.md b/cpu/msp430/vendor/README.md similarity index 100% rename from cpu/msp430_common/vendor/README.md rename to cpu/msp430/vendor/README.md diff --git a/cpu/msp430_common/vendor/msp430-gcc-support-files/Revisions_Header.txt b/cpu/msp430/vendor/msp430-gcc-support-files/Revisions_Header.txt similarity index 100% rename from cpu/msp430_common/vendor/msp430-gcc-support-files/Revisions_Header.txt rename to cpu/msp430/vendor/msp430-gcc-support-files/Revisions_Header.txt diff --git a/cpu/msp430_common/vendor/msp430-gcc-support-files/include/devices.csv b/cpu/msp430/vendor/msp430-gcc-support-files/include/devices.csv similarity index 100% rename from cpu/msp430_common/vendor/msp430-gcc-support-files/include/devices.csv rename to cpu/msp430/vendor/msp430-gcc-support-files/include/devices.csv diff --git a/cpu/msp430_common/vendor/msp430-gcc-support-files/include/in430.h b/cpu/msp430/vendor/msp430-gcc-support-files/include/in430.h similarity index 100% rename from cpu/msp430_common/vendor/msp430-gcc-support-files/include/in430.h rename to cpu/msp430/vendor/msp430-gcc-support-files/include/in430.h diff --git a/cpu/msp430_common/vendor/msp430-gcc-support-files/include/iomacros.h b/cpu/msp430/vendor/msp430-gcc-support-files/include/iomacros.h similarity index 100% rename from cpu/msp430_common/vendor/msp430-gcc-support-files/include/iomacros.h rename to cpu/msp430/vendor/msp430-gcc-support-files/include/iomacros.h diff --git a/cpu/msp430_common/vendor/msp430-gcc-support-files/include/legacy.h b/cpu/msp430/vendor/msp430-gcc-support-files/include/legacy.h similarity index 100% rename from cpu/msp430_common/vendor/msp430-gcc-support-files/include/legacy.h rename to cpu/msp430/vendor/msp430-gcc-support-files/include/legacy.h diff --git a/cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430.h b/cpu/msp430/vendor/msp430-gcc-support-files/include/msp430.h similarity index 100% rename from cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430.h rename to cpu/msp430/vendor/msp430-gcc-support-files/include/msp430.h diff --git a/cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f1611.h b/cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f1611.h similarity index 100% rename from cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f1611.h rename to cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f1611.h diff --git a/cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f1611.ld b/cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f1611.ld similarity index 100% rename from cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f1611.ld rename to cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f1611.ld diff --git a/cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f1611_symbols.ld b/cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f1611_symbols.ld similarity index 100% rename from cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f1611_symbols.ld rename to cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f1611_symbols.ld diff --git a/cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f1612.h b/cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f1612.h similarity index 100% rename from cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f1612.h rename to cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f1612.h diff --git a/cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f1612.ld b/cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f1612.ld similarity index 100% rename from cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f1612.ld rename to cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f1612.ld diff --git a/cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f1612_symbols.ld b/cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f1612_symbols.ld similarity index 100% rename from cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f1612_symbols.ld rename to cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f1612_symbols.ld diff --git a/cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f2617.h b/cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f2617.h similarity index 100% rename from cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f2617.h rename to cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f2617.h diff --git a/cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f2617.ld b/cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f2617.ld similarity index 100% rename from cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f2617.ld rename to cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f2617.ld diff --git a/cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f2617_symbols.ld b/cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f2617_symbols.ld similarity index 100% rename from cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f2617_symbols.ld rename to cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f2617_symbols.ld diff --git a/cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f2618.h b/cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f2618.h similarity index 100% rename from cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f2618.h rename to cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f2618.h diff --git a/cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f2618.ld b/cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f2618.ld similarity index 100% rename from cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f2618.ld rename to cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f2618.ld diff --git a/cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f2618_symbols.ld b/cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f2618_symbols.ld similarity index 100% rename from cpu/msp430_common/vendor/msp430-gcc-support-files/include/msp430f2618_symbols.ld rename to cpu/msp430/vendor/msp430-gcc-support-files/include/msp430f2618_symbols.ld diff --git a/cpu/msp430_common/vendor/update.sh b/cpu/msp430/vendor/update.sh similarity index 100% rename from cpu/msp430_common/vendor/update.sh rename to cpu/msp430/vendor/update.sh diff --git a/cpu/msp430_common/Makefile b/cpu/msp430_common/Makefile deleted file mode 100644 index c8b2ffd8f1e6..000000000000 --- a/cpu/msp430_common/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -MODULE = msp430_common - -DIRS = periph - -include $(RIOTBASE)/Makefile.base diff --git a/cpu/msp430_common/Makefile.default b/cpu/msp430_common/Makefile.default deleted file mode 100644 index 0a5f9cc4c8d4..000000000000 --- a/cpu/msp430_common/Makefile.default +++ /dev/null @@ -1,2 +0,0 @@ -# msp430 uses newlib by default -DEFAULT_MODULE += newlib diff --git a/cpu/msp430_common/periph/Makefile b/cpu/msp430_common/periph/Makefile deleted file mode 100644 index 9e15e7a2ac2e..000000000000 --- a/cpu/msp430_common/periph/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -MODULE = msp430_common_periph - -include $(RIOTMAKE)/periph.mk diff --git a/cpu/msp430fxyz/Kconfig b/cpu/msp430fxyz/Kconfig deleted file mode 100644 index 2f30bd6a38c1..000000000000 --- a/cpu/msp430fxyz/Kconfig +++ /dev/null @@ -1,50 +0,0 @@ -# Copyright (c) 2020 Freie Universität Berlin -# 2020 HAW Hamburg -# -# 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. -# - -config CPU_FAM_MSP430F - bool - select CPU_CORE_MSP430 - select HAS_CPU_MSP430FXYZ - -## CPU Models -config CPU_MODEL_MSP430F1611 - bool - select CPU_FAM_MSP430F - -config CPU_MODEL_MSP430F1612 - bool - select CPU_FAM_MSP430F - -config CPU_MODEL_MSP430F2617 - bool - select CPU_FAM_MSP430F - -config CPU_MODEL_MSP430F2618 - bool - select CPU_FAM_MSP430F - -## Definition of specific features -config HAS_CPU_MSP430FXYZ - bool - help - Indicates that an 'msp430fxyz' cpu is being used. - -## Common CPU symbols -config CPU_FAM - default "msp430f" if CPU_FAM_MSP430F - -config CPU_MODEL - default "msp430f1611" if CPU_MODEL_MSP430F1611 - default "msp430f1612" if CPU_MODEL_MSP430F1612 - default "msp430f2617" if CPU_MODEL_MSP430F2617 - default "msp430f2618" if CPU_MODEL_MSP430F2618 - -config CPU - default "msp430fxyz" if CPU_FAM_MSP430F - -source "$(RIOTCPU)/msp430_common/Kconfig" diff --git a/cpu/msp430fxyz/Makefile b/cpu/msp430fxyz/Makefile deleted file mode 100644 index 5fe0beeda735..000000000000 --- a/cpu/msp430fxyz/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -MODULE =cpu - -include $(RIOTCPU)/$(CPU)/Makefile.include - -DIRS = $(RIOTCPU)/msp430_common periph - -include $(RIOTBASE)/Makefile.base diff --git a/cpu/msp430fxyz/Makefile.default b/cpu/msp430fxyz/Makefile.default deleted file mode 100644 index 72e709ca8f52..000000000000 --- a/cpu/msp430fxyz/Makefile.default +++ /dev/null @@ -1 +0,0 @@ -include $(RIOTCPU)/msp430_common/Makefile.default diff --git a/cpu/msp430fxyz/Makefile.dep b/cpu/msp430fxyz/Makefile.dep deleted file mode 100644 index fa687b6fad06..000000000000 --- a/cpu/msp430fxyz/Makefile.dep +++ /dev/null @@ -1 +0,0 @@ -include $(RIOTCPU)/msp430_common/Makefile.dep diff --git a/cpu/msp430fxyz/Makefile.features b/cpu/msp430fxyz/Makefile.features deleted file mode 100644 index c9fbba866fd3..000000000000 --- a/cpu/msp430fxyz/Makefile.features +++ /dev/null @@ -1,3 +0,0 @@ -CPU_FAM = msp430f - -include $(RIOTCPU)/msp430_common/Makefile.features diff --git a/cpu/msp430fxyz/Makefile.include b/cpu/msp430fxyz/Makefile.include deleted file mode 100644 index d84a5ee8207d..000000000000 --- a/cpu/msp430fxyz/Makefile.include +++ /dev/null @@ -1 +0,0 @@ -include $(RIOTCPU)/msp430_common/Makefile.include diff --git a/cpu/msp430fxyz/include/msp430_regs.h b/cpu/msp430fxyz/include/msp430_regs.h deleted file mode 100644 index 5cf0b959035e..000000000000 --- a/cpu/msp430fxyz/include/msp430_regs.h +++ /dev/null @@ -1,445 +0,0 @@ -/* - * Copyright (C) 2015 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 cpu_msp430fxyz - * @{ - * - * @file - * @brief Cortex CMSIS style definition of MSP430 registers - * - * @todo This file is incomplete, not all registers are listed. Further - * There are probably some inconsistencies throughout the MSP430 - * family which need to be addressed. - * - * @author Hauke Petersen - */ - -#ifndef MSP430_REGS_H -#define MSP430_REGS_H - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Shortcut to specify 8-bit wide registers - */ -#define REG8 volatile uint8_t - -/** - * @brief Shortcut to specify 16-bit wide registers - */ -#define REG16 volatile uint16_t - -/** - * @brief Special function registers - */ -typedef struct { - REG8 IE1; /**< interrupt enable 1 */ - REG8 IE2; /**< interrupt enable 2 */ - REG8 IFG1; /**< interrupt flag 1 */ - REG8 IFG2; /**< interrupt flag 2 */ - REG8 ME1; /**< module enable 1 */ - REG8 ME2; /**< module enable 2 */ -} msp_sfr_t; - -/** - * @brief Digital I/O Port w/o interrupt functionality (P3-P6) - */ -typedef struct { - REG8 IN; /**< input data */ - REG8 OD; /**< output data */ - REG8 DIR; /**< pin direction */ - REG8 SEL; /**< alternative function select */ -} msp_port_t; - -/** - * @brief Digital I/O Port with interrupt functionality (P1 & P2) - */ -typedef struct { - REG8 IN; /**< input data */ - REG8 OD; /**< output data */ - REG8 DIR; /**< pin direction */ - REG8 IFG; /**< interrupt flag */ - REG8 IES; /**< interrupt edge select */ - REG8 IE; /**< interrupt enable */ - REG8 SEL; /**< alternative function select */ -} msp_port_isr_t; - -/** - * @brief USART (UART, SPI and I2C) registers - */ -typedef struct { - REG8 CTL; /**< USART control */ - REG8 TCTL; /**< transmit control */ - REG8 RCTL; /**< receive control */ - REG8 MCTL; /**< modulation control */ - REG8 BR0; /**< baud rate control 0 */ - REG8 BR1; /**< baud rate control 1 */ - REG8 RXBUF; /**< receive buffer */ - REG8 TXBUF; /**< transmit buffer */ -} msp_usart_t; - -/** - * @brief USCI universal serial control interface registers - */ -typedef struct { - REG8 ABCTL; /**< auto baud rate control */ - REG8 IRTCTL; /**< IrDA transmit control */ - REG8 IRRCTL; /**< IrDA receive control */ - REG8 ACTL0; /**< A control 0 */ - REG8 ACTL1; /**< A control 1 */ - REG8 ABR0; /**< A baud rate control 0 */ - REG8 ABR1; /**< A baud rate control 1 */ - REG8 AMCTL; /**< A modulation control */ - REG8 ASTAT; /**< A status */ - REG8 ARXBUF; /**< A receive buffer */ - REG8 ATXBUF; /**< A transmit buffer */ - REG8 BCTL0; /**< B control 0 */ - REG8 BCTL1; /**< B control 1 */ - REG8 BBR0; /**< B baud rate 0 */ - REG8 BBR1; /**< B baud rate 1 */ - REG8 BI2CIE; /**< I2C interrupt enable */ - REG8 BSTAT; /**< B status */ - REG8 BRXBUF; /**< B receive buffer */ - REG8 BTXBUF; /**< B transmit buffer */ -} msp_usci_t; - -/** - * @brief USCI SPI specific registers - */ -typedef struct { - REG8 CTL0; /**< control 0 */ - REG8 CTL1; /**< control 1 */ - REG8 BR0; /**< baud rate 0 */ - REG8 BR1; /**< baud rate 1 */ - REG8 reserved; /**< reserved */ - REG8 STAT; /**< status */ - REG8 RXBUF; /**< receive buffer */ - REG8 TXBUF; /**< transmit buffer */ -} msp_usci_spi_t; - -/** - * @brief Timer interrupt status registers - */ -typedef struct { - REG16 TBIV; /**< TIMER_A interrupt status */ - REG16 reserved[7]; /**< reserved */ - REG16 TAIV; /**< TIMER_B interrupt status */ -} msp_timer_ivec_t; - -/** - * @brief Timer module registers - */ -typedef struct { - REG16 CTL; /**< timer control */ - REG16 CCTL[7]; /**< capture compare channel control */ - REG16 R; /**< current counter value */ - REG16 CCR[7]; /**< capture compare channel values */ -} msp_timer_t; - -/** - * @brief SFR interrupt enable 1 register bitmap - * @{ - */ -#define SFR_IE1_OFIE (0x02) -#define SFR_IE1_URXIE0 (0x40) -#define SFR_IE1_UTXIE0 (0x80) -/** @} */ - -/** - * @brief SFR interrupt enable 2 register bitmap - * @{ - */ -#define SFR_IE2_UCA0RXIE (0x01) -#define SFR_IE2_UCA0TXIE (0x02) -#define SFR_IE2_URXIE2 (0x10) -#define SFR_IE2_UTXIE2 (0x20) -/** @} */ - -/** - * @brief SFR interrupt flag 1 register bitmap - * @{ - */ -#define SFR_IFG1_OFIFG (0x02) -#define SFR_IFG1_URXIFG0 (0x40) -#define SFR_IFG1_UTXIFG0 (0x80) -/** @} */ - -/** - * @brief SFR interrupt flag 2 register bitmap - * @{ - */ -#define SFR_IFG2_UCA0RXIFG (0x01) -#define SFR_IFG2_UCA0TXIFG (0x02) -#define SFR_IFG2_URXIFG1 (0x10) -#define SFR_IFG2_UTXIFG1 (0x20) -/** @} */ - -/** - * @brief SFR module enable register 1 - * @{ - */ -#define SFR_ME1_USPIE0 (0x40) -/** @} */ - -/** - * @brief SFR module enable register 2 - * @{ - */ -#define SFR_ME2_USPIE1 (0x10) -/** @} */ - -/** - * @brief USART control register bitmap - * @{ - */ -#define USART_CTL_SWRST (0x01) -#define USART_CTL_MM (0x02) -#define USART_CTL_SYNC (0x04) -#define USART_CTL_LISTEN (0x08) -#define USART_CTL_CHAR (0x10) -#define USART_CTL_SPB (0x20) -#define USART_CTL_PEV (0x40) -#define USART_CTL_PENA (0x80) -/** @} */ - -/** - * @brief USART transmit control register bitmap - * @{ - */ -#define USART_TCTL_TXEPT (0x01) -#define USART_TCTL_STC (0x02) -#define USART_TCTL_TXWAKE (0x04) -#define USART_TCTL_URXSE (0x08) -#define USART_TCTL_SSEL_MASK (0x30) -#define USART_TCTL_SSEL_UCLKI (0x00) -#define USART_TCTL_SSEL_ACLK (0x10) -#define USART_TCTL_SSEL_SMCLK (0x20) -#define USART_TCTL_CKPL (0x40) -#define USART_TCTL_CKPH (0x80) -/** @} */ - -/** - * @brief USART receive control register bitmap - * @{ - */ -#define USART_RCTL_RXERR (0x01) -#define USART_RCTL_RXWAKE (0x02) -#define USART_RCTL_URXWIE (0x04) -#define USART_RCTL_URXEIE (0x08) -#define USART_RCTL_BRK (0x10) -#define USART_RCTL_OE (0x20) -#define USART_RCTL_PE (0x40) -#define USART_RCTL_FE (0x80) -/** @} */ - -/** - * @brief USCI control A register 0 bitmap - * @{ - */ -#define USCI_ACTL0_UCSYNC (0x01) -#define USCI_ACTL0_MODE_MASK (0x06) -#define USCI_ACTL0_MODE_UART (0x00) -#define USCI_ACTL0_MODE_ILMM (0x02) -#define USCI_ACTL0_MODE_ABMM (0x04) -#define USCI_ACTL0_MODE_UART_ABR (0x06) -#define USCI_ACTL0_SPB (0x08) -#define USCI_ACTL0_7BIT (0x10) -#define USCI_ACTL0_MSB (0x20) -#define USCI_ACTL0_PAR (0x40) -#define USCI_ACTL0_PEN (0x80) -/** @} */ - -/** - * @brief USCI control register 0 bitmap SPI mode - * @{ - */ -#define USCI_SPI_CTL0_UCSYNC (0x01) -#define USCI_SPI_CTL0_MODE_3 (0x06) -#define USCI_SPI_CTL0_MODE_0 (0x00) -#define USCI_SPI_CTL0_MODE_1 (0x02) -#define USCI_SPI_CTL0_MODE_2 (0x04) -#define USCI_SPI_CTL0_MST (0x08) -#define USCI_SPI_CTL0_7BIT (0x10) -#define USCI_SPI_CTL0_MSB (0x20) -#define USCI_SPI_CTL0_CKPL (0x40) -#define USCI_SPI_CTL0_CKPH (0x80) -/** @} */ - -/** - * @brief USCI status register bitmap SPI mode - * @{ - */ -#define USCI_SPI_STAT_UCBUSY (0x01) -#define USCI_SPI_STAT_UCOE (0x20) -#define USCI_SPI_STAT_UCFE (0x40) -#define USCI_SPI_STAT_UCLISTEN (0x80) -/** @} */ - -/** - * @brief USCI control A register 1 bitmap - * @{ - */ -#define USCI_ACTL1_SWRST (0x01) -#define USCI_ACTL1_TXBRK (0x02) -#define USCI_ACTL1_TXADDR (0x04) -#define USCI_ACTL1_DORM (0x08) -#define USCI_ACTL1_BRKIE (0x10) -#define USCI_ACTL1_RXEIE (0x20) -#define USCI_ACTL1_SSEL_MASK (0xc0) -#define USCI_ACTL1_SSEL_UCLK (0x00) -#define USCI_ACTL1_SSEL_ACLK (0x40) -#define USCI_ACTL1_SSEL_SMCLK (0xc0) -/** @} */ - -/** - * @brief USCI control register 1 bitmap SPI mode - * @{ - */ -#define USCI_SPI_CTL1_SWRST (0x01) -#define USCI_SPI_CTL1_SSEL_MASK (0xc0) -#define USCI_SPI_CTL1_SSEL_NA (0x00) -#define USCI_SPI_CTL1_SSEL_ACLK (0x40) -#define USCI_SPI_CTL1_SSEL_SMCLK (0xc0) -/** @} */ - -/** - * @brief USCI modulation A control register - * @{ - */ -#define USCI_AMCTL_OS16 (0x01) -#define USCI_AMCTL_BRS_MASK (0xe0) -#define USCI_AMCTL_BRS_SHIFT (1U) -#define USCI_AMCTL_BRF_MASK (0xf0) -#define USCI_AMCTL_BRF_SHIFT (4U) -/** @} */ - -/** - * @brief USCI status A register bitmap - * @{ - */ -#define USCI_ASTAT_BUSY (0x01) -#define USCI_ASTAT_IDLE (0x02) -#define USCI_ASTAT_ADDR (0x02) -#define USCI_ASTAT_RXERR (0x04) -#define USCI_ASTAT_BRK (0x08) -#define USCI_ASTAT_PE (0x10) -#define USCI_ASTAT_OE (0x20) -#define USCI_ASTAT_FE (0x40) -#define USCI_ASTAT_LISTEN (0x80) -/** @} */ - -/** - * @brief Timer Control register bitmap - * @{ - */ -#define TIMER_CTL_IFG (0x0001) -#define TIMER_CTL_IE (0x0002) -#define TIMER_CTL_CLR (0x0004) -#define TIMER_CTL_MC_MASK (0x0030) -#define TIMER_CTL_MC_STOP (0x0000) -#define TIMER_CTL_MC_UP (0x0010) -#define TIMER_CTL_MC_CONT (0x0020) -#define TIMER_CTL_MC_UPDOWN (0x0030) -#define TIMER_CTL_ID_MASK (0x00c0) -#define TIMER_CTL_ID_DIV1 (0x0000) -#define TIMER_CTL_ID_DIV2 (0x0040) -#define TIMER_CTL_ID_DIV4 (0x0080) -#define TIMER_CTL_ID_DIV8 (0x00c0) -#define TIMER_CTL_TASSEL_MASK (0x0300) -#define TIMER_CTL_TASSEL_TCLK (0x0000) -#define TIMER_CTL_TASSEL_ACLK (0x0100) -#define TIMER_CTL_TASSEL_SMCLK (0x0200) -#define TIMER_CTL_TASSEL_INV_TCLK (0x0300) -/** @} */ - -/** - * @brief Timer Channel Control register bitmap - * @{ - */ -#define TIMER_CCTL_CCIFG (0x0001) -#define TIMER_CCTL_COV (0x0002) -#define TIMER_CCTL_OUT (0x0004) -#define TIMER_CCTL_CCI (0x0008) -#define TIMER_CCTL_CCIE (0x0010) -#define TIMER_CCTL_OUTMOD_MASK (0x00e0) -#define TIMER_CCTL_OUTMOD_OUTVAL (0x0000) -#define TIMER_CCTL_OUTMOD_SET (0x0020) -#define TIMER_CCTL_OUTMOD_TOG_RESET (0x0040) -#define TIMER_CCTL_OUTMOD_SET_RESET (0x0060) -#define TIMER_CCTL_OUTMOD_TOGGLE (0x0080) -#define TIMER_CCTL_OUTMOD_RESET (0x00a0) -#define TIMER_CCTL_OUTMOD_TOG_SET (0x00c0) -#define TIMER_CCTL_OUTMOD_RESET_SET (0x00e0) -#define TIMER_CCTL_CAP (0x0100) -#define TIMER_CCTL_CLLD_MASK (0x0600) -#define TIMER_CCTL_SCS (0x0800) -#define TIMER_CCTL_CCIS_MASK (0x3000) -#define TIMER_CCTL_CM_MASK (0xc000) -/** @} */ - -/** - * @brief Base register address definitions - * @{ - */ -#define SFR_BASE ((uint16_t)0x0000) -#define PORT_1_BASE ((uint16_t)0x0020) -#define PORT_2_BASE ((uint16_t)0x0028) -#define PORT_3_BASE ((uint16_t)0x0018) -#define PORT_4_BASE ((uint16_t)0x001c) -#define PORT_5_BASE ((uint16_t)0x0030) -#define PORT_6_BASE ((uint16_t)0x0034) -#define CLK_BASE ((uint16_t)0x0053) -#define USART_0_BASE ((uint16_t)0x0070) -#define USART_1_BASE ((uint16_t)0x0078) -#define TIMER_IVEC_BASE ((uint16_t)0x011e) -#define TIMER_A_BASE ((uint16_t)0x0160) -#define TIMER_B_BASE ((uint16_t)0x0180) -#define WD_BASE ((uint16_t)0x0120) -#define USCI_0_BASE ((uint16_t)0x005d) -#define USCI_0_A_BASE ((uint16_t)0x0060) -#define USCI_0_B_BASE ((uint16_t)0x0068) -#define USCI_1_BASE ((uint16_t)0x00cd) -#define USCI_1_A_BASE ((uint16_t)0x00d0) -#define USCI_1_B_BASE ((uint16_t)0x00d8) -/** @} */ - -/** - * @brief Typing of base register objects - * @{ - */ -#define SFR ((msp_sfr_t *)SFR_BASE) -#define PORT_1 ((msp_port_t *)PORT_1_BASE) -#define PORT_2 ((msp_port_t *)PORT_2_BASE) -#define PORT_3 ((msp_port_t *)PORT_3_BASE) -#define PORT_4 ((msp_port_t *)PORT_4_BASE) -#define PORT_5 ((msp_port_t *)PORT_5_BASE) -#define PORT_6 ((msp_port_t *)PORT_6_BASE) -#define CLK ((msp_clk_t *)CLK_BASE) -#define USART_0 ((msp_usart_t *)USART_0_BASE) -#define USART_1 ((msp_usart_t *)USART_1_BASE) -#define TIMER_IVEC ((msp_timer_ivec_t *)TIMER_IVEC_BASE) -#define TIMER_A ((msp_timer_t *)TIMER_A_BASE) -#define TIMER_B ((msp_timer_t *)TIMER_B_BASE) -#define WD ((msp_wd_t *)WD_BASE) -#define USCI_0 ((msp_usci_t *)USCI_0_BASE) -#define USCI_1 ((msp_usci_t *)USCI_1_BASE) -#define USCI_0_A_SPI ((msp_usci_spi_t *)USCI_0_A_BASE) -#define USCI_0_B_SPI ((msp_usci_spi_t *)USCI_0_B_BASE) -#define USCI_1_A ((msp_usci_t *)USCI_1_A_BASE) -#define USCI_1_B ((msp_usci_t *)USCI_1_B_BASE) -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* MSP430_REGS_H */ -/** @} */ diff --git a/cpu/msp430fxyz/periph/Makefile b/cpu/msp430fxyz/periph/Makefile deleted file mode 100644 index a36df249ac1d..000000000000 --- a/cpu/msp430fxyz/periph/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(RIOTMAKE)/periph.mk diff --git a/cpu/msp430fxyz/periph/uart.c b/cpu/msp430fxyz/periph/uart.c deleted file mode 100644 index e8b51fb4cf2f..000000000000 --- a/cpu/msp430fxyz/periph/uart.c +++ /dev/null @@ -1,225 +0,0 @@ -/* - * Copyright (C) 2015 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 cpu_msp430fxyz - * @ingroup drivers_periph_uart - * @{ - * - * @file - * @brief Low-level UART driver implementation - * - * @author Hauke Petersen - * - * @} - */ - -#include "cpu.h" -#include "periph_cpu.h" -#include "periph_conf.h" -#include "periph/uart.h" - -/** - * @brief Keep track of the interrupt context - * @{ - */ -static uart_rx_cb_t ctx_rx_cb; -static void *ctx_isr_arg; -/** @} */ - -static int init_base(uart_t uart, uint32_t baudrate); - -/* per default, we use the legacy MSP430 USART module for UART functionality */ -#ifndef UART_USE_USCI - -int uart_init(uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg) -{ - int res = init_base(uart, baudrate); - if (res != UART_OK) { - return res; - } - - /* save interrupt context */ - ctx_rx_cb = rx_cb; - ctx_isr_arg = arg; - /* reset interrupt flags and enable RX interrupt */ - UART_IE &= ~(UART_IE_TX_BIT); - UART_IF &= ~(UART_IE_RX_BIT); - UART_IF |= (UART_IE_TX_BIT); - UART_IE |= (UART_IE_RX_BIT); - return UART_OK; -} - -static int init_base(uart_t uart, uint32_t baudrate) -{ - if (uart != 0) { - return UART_NODEV; - } - - /* get the default UART for now -> TODO: enable for multiple devices */ - msp_usart_t *dev = UART_BASE; - - /* power off and reset device */ - uart_poweroff(uart); - dev->CTL = USART_CTL_SWRST; - /* configure to 8N1 and using the SMCLK*/ - dev->CTL |= USART_CTL_CHAR; - dev->TCTL = (USART_TCTL_TXEPT | USART_TCTL_SSEL_SMCLK); - dev->RCTL = 0x00; - /* baudrate configuration */ - uint16_t br = (uint16_t)(msp430_fxyz_submain_clock_freq() / baudrate); - dev->BR0 = (uint8_t)br; - dev->BR1 = (uint8_t)(br >> 8); - /* TODO: calculate value for modulation register */ - dev->MCTL = 0; - /* configure pins -> TODO: move into GPIO driver (once implemented) */ - UART_PORT->SEL |= (UART_RX_PIN | UART_TX_PIN); - UART_PORT->OD |= UART_RX_PIN; - UART_PORT->OD &= ~(UART_TX_PIN); - UART_PORT->DIR |= UART_TX_PIN; - UART_PORT->DIR &= ~(UART_RX_PIN); - /* enable receiver and transmitter */ - uart_poweron(uart); - /* and finally release the software reset bit */ - dev->CTL &= ~(USART_CTL_SWRST); - return UART_OK; -} - -void uart_write(uart_t uart, const uint8_t *data, size_t len) -{ - (void)uart; - msp_usart_t *dev = UART_BASE; - - for (size_t i = 0; i < len; i++) { - while (!(dev->TCTL & USART_TCTL_TXEPT)) {} - dev->TXBUF = data[i]; - } -} - -void uart_poweron(uart_t uart) -{ - (void)uart; - UART_ME |= UART_ME_BITS; -} - -void uart_poweroff(uart_t uart) -{ - (void)uart; - UART_ME &= ~(UART_ME_BITS); -} - -ISR(UART_RX_ISR, isr_uart_0_rx) -{ - __enter_isr(); - - /* read character (resets interrupt flag) */ - char c = UART_BASE->RXBUF; - - /* only call callback if there was no receive error */ - if(! (UART_BASE->RCTL & RXERR)) { - ctx_rx_cb(ctx_isr_arg, c); - } - - __exit_isr(); -} - -/* we use alternative UART code in case the board used the USCI module for UART - * in case of the (older) USART module */ -#else - -int uart_init(uart_t uart, uint32_t baudrate, uart_rx_cb_t rx_cb, void *arg) -{ - if (init_base(uart, baudrate) < 0) { - return -1; - } - - /* save interrupt context */ - ctx_rx_cb = rx_cb; - ctx_isr_arg = arg; - /* reset interrupt flags and enable RX interrupt */ - UART_IF &= ~(UART_IE_RX_BIT); - UART_IF |= (UART_IE_TX_BIT); - UART_IE |= (UART_IE_RX_BIT); - UART_IE &= ~(UART_IE_TX_BIT); - return 0; -} - -static int init_base(uart_t uart, uint32_t baudrate) -{ - if (uart != 0) { - return -1; - } - - /* get the default UART for now -> TODO: enable for multiple devices */ - msp_usci_t *dev = UART_BASE; - - /* put device in reset mode while configuration is going on */ - dev->ACTL1 = USCI_ACTL1_SWRST; - /* configure to UART, using SMCLK in 8N1 mode */ - dev->ACTL1 |= USCI_ACTL1_SSEL_SMCLK; - dev->ACTL0 = 0; - dev->ASTAT = 0; - /* configure baudrate */ - uint32_t base = ((msp430_fxyz_submain_clock_freq() << 7) / baudrate); - uint16_t br = (uint16_t)(base >> 7); - uint8_t brs = (((base & 0x3f) * 8) >> 7); - dev->ABR0 = (uint8_t)br; - dev->ABR1 = (uint8_t)(br >> 8); - dev->AMCTL = (brs << USCI_AMCTL_BRS_SHIFT); - /* pin configuration -> TODO: move to GPIO driver once implemented */ - UART_RX_PORT->SEL |= UART_RX_PIN; - UART_TX_PORT->SEL |= UART_TX_PIN; - UART_RX_PORT->DIR &= ~(UART_RX_PIN); - UART_TX_PORT->DIR |= UART_TX_PIN; - /* releasing the software reset bit starts the UART */ - dev->ACTL1 &= ~(USCI_ACTL1_SWRST); - return 0; -} - -void uart_write(uart_t uart, const uint8_t *data, size_t len) -{ - (void)uart; - - for (size_t i = 0; i < len; i++) { - while (!(UART_IF & UART_IE_TX_BIT)) {} - UART_BASE->ATXBUF = data[i]; - } -} - -void uart_poweron(uart_t uart) -{ - (void)uart; - /* n/a */ -} - -void uart_poweroff(uart_t uart) -{ - (void)uart; - /* n/a */ -} - -ISR(UART_RX_ISR, isr_uart_0_rx) -{ - __enter_isr(); - - uint8_t stat = UART_BASE->ASTAT; - uint8_t data = (uint8_t)UART_BASE->ARXBUF; - - if (stat & (USCI_ASTAT_FE | USCI_ASTAT_OE | USCI_ASTAT_PE | USCI_ASTAT_BRK)) { - /* some error which we do not handle, just do a pseudo read to reset the - * status register */ - (void)data; - } - else { - ctx_rx_cb(ctx_isr_arg, data); - } - - __exit_isr(); -} - -#endif diff --git a/dist/tools/doccheck/exclude_simple b/dist/tools/doccheck/exclude_simple index f23f978a1127..9f3f9d56549a 100644 --- a/dist/tools/doccheck/exclude_simple +++ b/dist/tools/doccheck/exclude_simple @@ -1401,12 +1401,10 @@ warning: Member CLK1 (macro definition) of file periph_conf.h is not documented. warning: Member CLK40 (macro definition) of file periph_conf.h is not documented. warning: Member CLK50 (macro definition) of file periph_conf.h is not documented. warning: Member CLK80 (macro definition) of file periph_conf.h is not documented. -warning: Member CLK_BASE (macro definition) of file msp430_regs.h is not documented. warning: Member clk_div_config[] (variable) of file periph_conf.h is not documented. warning: Member CLK_DIV_NUMOF (macro definition) of file periph_conf.h is not documented. warning: Member CLKLOADCTL_LOADDONE (macro definition) of file cc26x0_cc13x0_prcm.h is not documented. warning: Member CLKLOADCTL_LOADDONE (macro definition) of file cc26x2_cc13x2_prcm.h is not documented. -warning: Member CLK (macro definition) of file msp430_regs.h is not documented. warning: Member clk_mux_config[] (variable) of file periph_conf.h is not documented. warning: Member CLK_MUX_NUMOF (macro definition) of file periph_conf.h is not documented. warning: Member CLOCK_8MHZ (macro definition) of file periph_conf.h is not documented. @@ -2565,7 +2563,6 @@ warning: Member GPIO_PIN(x, y) (macro definition) of file periph_cpu_common.h is warning: Member GPIO_PIN(x, y) (macro definition) of file periph_cpu.h is not documented. warning: Member gpio_t (typedef) of file periph_cpu_common.h is not documented. warning: Member gpio_t (typedef) of file periph_cpu.h is not documented. -warning: Member gpio_t (typedef) of group cpu_msp430fxyz is not documented. warning: Member GPRS_PIN (macro definition) of file waspmote_pinmap.h is not documented. warning: Member GPRS_PW (macro definition) of file waspmote_pinmap.h is not documented. warning: Member GPS_ENABLE_MASK (macro definition) of file board.h is not documented. @@ -5627,13 +5624,10 @@ warning: Member PERIPH_INIT_LED0 (macro definition) of group boards_common_nucle warning: Member PERIPH_SPI_NEEDS_INIT_CS (macro definition) of file periph_cpu.h is not documented. warning: Member PERIPH_SPI_NEEDS_TRANSFER_BYTE (macro definition) of file periph_cpu_common.h is not documented. warning: Member PERIPH_SPI_NEEDS_TRANSFER_BYTE (macro definition) of file periph_cpu.h is not documented. -warning: Member PERIPH_SPI_NEEDS_TRANSFER_BYTE (macro definition) of group cpu_msp430fxyz is not documented. warning: Member PERIPH_SPI_NEEDS_TRANSFER_REG (macro definition) of file periph_cpu_common.h is not documented. warning: Member PERIPH_SPI_NEEDS_TRANSFER_REG (macro definition) of file periph_cpu.h is not documented. -warning: Member PERIPH_SPI_NEEDS_TRANSFER_REG (macro definition) of group cpu_msp430fxyz is not documented. warning: Member PERIPH_SPI_NEEDS_TRANSFER_REGS (macro definition) of file periph_cpu_common.h is not documented. warning: Member PERIPH_SPI_NEEDS_TRANSFER_REGS (macro definition) of file periph_cpu.h is not documented. -warning: Member PERIPH_SPI_NEEDS_TRANSFER_REGS (macro definition) of group cpu_msp430fxyz is not documented. warning: Member PHCON1_PDPXMD (macro definition) of file enc28j60_regs.h is not documented. warning: Member PHCON1_PLOOPBK (macro definition) of file enc28j60_regs.h is not documented. warning: Member PHCON1_PPWRSV (macro definition) of file enc28j60_regs.h is not documented. @@ -5711,18 +5705,6 @@ warning: Member PN532_FW_FEATURES(fwver) (macro definition) of group drivers_pn5 warning: Member PN532_FW_REVISION(fwver) (macro definition) of group drivers_pn532 is not documented. warning: Member PN532_FW_VERSION(fwver) (macro definition) of group drivers_pn532 is not documented. warning: Member PN532_IC_VERSION(fwver) (macro definition) of group drivers_pn532 is not documented. -warning: Member PORT_1_BASE (macro definition) of file msp430_regs.h is not documented. -warning: Member PORT_1 (macro definition) of file msp430_regs.h is not documented. -warning: Member PORT_2_BASE (macro definition) of file msp430_regs.h is not documented. -warning: Member PORT_2 (macro definition) of file msp430_regs.h is not documented. -warning: Member PORT_3_BASE (macro definition) of file msp430_regs.h is not documented. -warning: Member PORT_3 (macro definition) of file msp430_regs.h is not documented. -warning: Member PORT_4_BASE (macro definition) of file msp430_regs.h is not documented. -warning: Member PORT_4 (macro definition) of file msp430_regs.h is not documented. -warning: Member PORT_5_BASE (macro definition) of file msp430_regs.h is not documented. -warning: Member PORT_5 (macro definition) of file msp430_regs.h is not documented. -warning: Member PORT_6_BASE (macro definition) of file msp430_regs.h is not documented. -warning: Member PORT_6 (macro definition) of file msp430_regs.h is not documented. warning: Member PORT_delayRx (macro definition) of file board_info.h is not documented. warning: Member PORT_delayTx (macro definition) of file board_info.h is not documented. warning: Member PORT_delayTx (macro definition) of file openwsn_defs.h is not documented. @@ -6397,16 +6379,6 @@ warning: Member SET_MUX_SOCKET1 (macro definition) of file board.h is not docume warning: Member SET_MUX_USB_MODULE (macro definition) of file board.h is not documented. warning: Member setsockopt(int socket, int level, int option_name, const void *option_value, socklen_t option_len) (function) of group posix_sockets is not documented. warning: Member setup_fpu(void) (function) of group cpu_lm4f120 is not documented. -warning: Member SFR_IE1_URXIE0 (macro definition) of file msp430_regs.h is not documented. -warning: Member SFR_IE1_UTXIE0 (macro definition) of file msp430_regs.h is not documented. -warning: Member SFR_IE2_UCA0TXIE (macro definition) of file msp430_regs.h is not documented. -warning: Member SFR_IE2_URXIE2 (macro definition) of file msp430_regs.h is not documented. -warning: Member SFR_IE2_UTXIE2 (macro definition) of file msp430_regs.h is not documented. -warning: Member SFR_IFG1_URXIFG0 (macro definition) of file msp430_regs.h is not documented. -warning: Member SFR_IFG1_UTXIFG0 (macro definition) of file msp430_regs.h is not documented. -warning: Member SFR_IFG2_UCA0TXIFG (macro definition) of file msp430_regs.h is not documented. -warning: Member SFR_IFG2_URXIFG1 (macro definition) of file msp430_regs.h is not documented. -warning: Member SFR_IFG2_UTXIFG1 (macro definition) of file msp430_regs.h is not documented. warning: Member SGP30_PARAM_I2C_DEV (macro definition) of file sgp30_params.h is not documented. warning: Member SGP30_PARAMS (macro definition) of file sgp30_params.h is not documented. warning: Member SGP30_SAUL_INFO (macro definition) of file sgp30_params.h is not documented. @@ -6732,6 +6704,7 @@ warning: Member SOFT_UART_PARAM_TIMER_TX (macro definition) of file soft_uart_pa warning: Member SOFT_UART_PARAM_TX (macro definition) of file soft_uart_params.h is not documented. warning: Member SPEAKER_PIN (macro definition) of file board.h is not documented. warning: Member SPI_BASE (macro definition) of file periph_conf.h is not documented. +warning: Member SPI_SFR (macro definition) of file periph_conf.h is not documented. warning: Member spi_clk_config[] (variable) of file periph_conf_common.h is not documented. warning: Member spi_clk_config[] (variable) of file periph_conf.h is not documented. warning: Member spi_clk_t (enumeration) of file periph_cpu.h is not documented. @@ -8072,29 +8045,7 @@ warning: Member TIMER_2_ISR (macro definition) of file periph_conf.h is not docu warning: Member TIMER_2 (macro definition) of file default_timer_config.h is not documented. warning: Member TIMER_2_MASK (macro definition) of file default_timer_config.h is not documented. warning: Member TIMER_3_ISR (macro definition) of file cfg_timer_default.h is not documented. -warning: Member TIMER_A_BASE (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_A (macro definition) of file msp430_regs.h is not documented. warning: Member TIMER_BASE (macro definition) of file periph_conf.h is not documented. -warning: Member TIMER_B_BASE (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_B (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CCTL_CAP (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CCTL_CCIE (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CCTL_CCI (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CCTL_CCIS_MASK (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CCTL_CLLD_MASK (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CCTL_CM_MASK (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CCTL_COV (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CCTL_OUT (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CCTL_OUTMOD_MASK (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CCTL_OUTMOD_OUTVAL (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CCTL_OUTMOD_RESET (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CCTL_OUTMOD_RESET_SET (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CCTL_OUTMOD_SET (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CCTL_OUTMOD_SET_RESET (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CCTL_OUTMOD_TOGGLE (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CCTL_OUTMOD_TOG_RESET (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CCTL_OUTMOD_TOG_SET (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CCTL_SCS (macro definition) of file msp430_regs.h is not documented. warning: Member TIMER_CHAN (macro definition) of file periph_conf.h is not documented. warning: Member TIMER_CHANNEL_NUMOF (macro definition) of file default_timer_config.h is not documented. warning: Member TIMER_CHANNEL_NUMOF (macro definition) of file periph_cpu.h is not documented. @@ -8105,30 +8056,11 @@ warning: Member timer_config[] (variable) of file cfg_timer_tim2.h is not docume warning: Member timer_config[] (variable) of file cfg_timer_tim5.h is not documented. warning: Member timer_config[] (variable) of file periph_conf_common.h is not documented. warning: Member timer_config[] (variable) of file periph_conf.h is not documented. -warning: Member TIMER_CTL_CLR (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CTL_ID_DIV1 (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CTL_ID_DIV2 (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CTL_ID_DIV4 (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CTL_ID_DIV8 (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CTL_ID_MASK (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CTL_IE (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CTL_MC_CONT (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CTL_MC_MASK (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CTL_MC_STOP (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CTL_MC_UPDOWN (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CTL_MC_UP (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CTL_TASSEL_ACLK (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CTL_TASSEL_INV_TCLK (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CTL_TASSEL_MASK (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CTL_TASSEL_SMCLK (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_CTL_TASSEL_TCLK (macro definition) of file msp430_regs.h is not documented. warning: Member timer_div_t (enumeration) of file periph_cpu_common.h is not documented. warning: Member TIMER_IRQ_PRIO (macro definition) of file cfg_timer_default.h is not documented. warning: Member TIMER_IRQ_PRIO (macro definition) of file periph_conf.h is not documented. warning: Member TIMER_ISR_CC0 (macro definition) of file periph_conf.h is not documented. warning: Member TIMER_ISR_CCX (macro definition) of file periph_conf.h is not documented. -warning: Member TIMER_IVEC_BASE (macro definition) of file msp430_regs.h is not documented. -warning: Member TIMER_IVEC (macro definition) of file msp430_regs.h is not documented. warning: Member TIMER_MAX_VALUE (macro definition) of file periph_cpu.h is not documented. warning: Member TIMER_NUMOF (macro definition) of file cfg_timer_012.h is not documented. warning: Member TIMER_NUMOF (macro definition) of file cfg_timer_01.h is not documented. @@ -8281,6 +8213,7 @@ warning: Member UART_4_ISR (macro definition) of file periph_conf.h is not docum warning: Member UART_6_DMA_ISR (macro definition) of file periph_conf.h is not documented. warning: Member UART_6_ISR (macro definition) of file periph_conf.h is not documented. warning: Member UART_BASE (macro definition) of file periph_conf.h is not documented. +warning: Member UART_SFR (macro definition) of file periph_conf.h is not documented. warning: Member UARTCLKGDS_CLK_EN_UART0 (macro definition) of file cc26x0_cc13x0_prcm.h is not documented. warning: Member UARTCLKGDS_CLK_EN_UART0 (macro definition) of file cc26x2_cc13x2_prcm.h is not documented. warning: Member UARTCLKGDS_CLK_EN_UART1 (macro definition) of file cc26x2_cc13x2_prcm.h is not documented. @@ -8382,33 +8315,6 @@ warning: Member UNLOCK_TCPIP_CORE() (macro definition) of file sys_arch.h is not warning: Member UNLOCK_TCPIP_CORE() (macro definition) of group pkg_lwip_sys is not documented. warning: Member UPDATE_CCA (macro definition) of file board.h is not documented. warning: Member UPDATE_CCA (macro definition) of group boards_common_remote is not documented. -warning: Member USART_0_BASE (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_0 (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_1_BASE (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_1 (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_CTL_CHAR (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_CTL_LISTEN (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_CTL_MM (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_CTL_PENA (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_CTL_PEV (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_CTL_SPB (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_CTL_SYNC (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_RCTL_BRK (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_RCTL_FE (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_RCTL_OE (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_RCTL_PE (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_RCTL_RXWAKE (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_RCTL_URXEIE (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_RCTL_URXWIE (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_TCTL_CKPH (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_TCTL_CKPL (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_TCTL_SSEL_ACLK (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_TCTL_SSEL_MASK (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_TCTL_SSEL_SMCLK (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_TCTL_SSEL_UCLKI (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_TCTL_STC (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_TCTL_TXWAKE (macro definition) of file msp430_regs.h is not documented. -warning: Member USART_TCTL_URXSE (macro definition) of file msp430_regs.h is not documented. warning: Member USB_APP_MODE_SLOT_NAME (macro definition) of file usb_dfu.h is not documented. warning: Member usbdev_mock_ep_state_t (enumeration) of group drivers_usbdev_mock is not documented. warning: Member USB_DFU_DETACH_TIMEOUT_MS (macro definition) of group usb_dfu is not documented. @@ -8431,65 +8337,6 @@ warning: Member USB_HID_SUBCLASS_BOOT (macro definition) of group usb_hid is not warning: Member USB_HID_SUBCLASS_NONE (macro definition) of group usb_hid is not documented. warning: Member USB_XBEE_RX (macro definition) of file waspmote_pinmap.h is not documented. warning: Member USB_XBEE_TX (macro definition) of file waspmote_pinmap.h is not documented. -warning: Member USCI_0_A_BASE (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_0_A_SPI (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_0_BASE (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_0_B_BASE (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_0_B_SPI (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_0 (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_1_A_BASE (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_1_A (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_1_BASE (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_1_B_BASE (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_1_B (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_1 (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL0_7BIT (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL0_MODE_ABMM (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL0_MODE_ILMM (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL0_MODE_MASK (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL0_MODE_UART_ABR (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL0_MODE_UART (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL0_MSB (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL0_PAR (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL0_PEN (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL0_SPB (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL1_BRKIE (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL1_DORM (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL1_RXEIE (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL1_SSEL_ACLK (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL1_SSEL_MASK (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL1_SSEL_SMCLK (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL1_SSEL_UCLK (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL1_TXADDR (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ACTL1_TXBRK (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_AMCTL_BRF_MASK (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_AMCTL_BRF_SHIFT (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_AMCTL_BRS_MASK (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_AMCTL_BRS_SHIFT (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ASTAT_ADDR (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ASTAT_BRK (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ASTAT_FE (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ASTAT_IDLE (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ASTAT_LISTEN (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ASTAT_OE (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ASTAT_PE (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_ASTAT_RXERR (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_SPI_CTL0_7BIT (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_SPI_CTL0_CKPH (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_SPI_CTL0_CKPL (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_SPI_CTL0_MODE_0 (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_SPI_CTL0_MODE_1 (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_SPI_CTL0_MODE_2 (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_SPI_CTL0_MODE_3 (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_SPI_CTL0_MSB (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_SPI_CTL0_MST (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_SPI_CTL1_SSEL_ACLK (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_SPI_CTL1_SSEL_MASK (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_SPI_CTL1_SSEL_NA (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_SPI_CTL1_SSEL_SMCLK (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_SPI_STAT_UCFE (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_SPI_STAT_UCLISTEN (macro definition) of file msp430_regs.h is not documented. -warning: Member USCI_SPI_STAT_UCOE (macro definition) of file msp430_regs.h is not documented. warning: Member UUID_VERSION_MASK (macro definition) of group sys_uuid is not documented. warning: Member VCC33 (macro definition) of file board.h is not documented. warning: Member VCNL40X0_AMBIENT_MASK_PARA_AUTO_OFFSET (macro definition) of file vcnl40x0_internals.h is not documented. @@ -8593,8 +8440,6 @@ warning: Member W5100_PARAM_EVT (macro definition) of group boards_common_arduin warning: Member W5100_PARAM_EVT (macro definition) of group boards_common_arduino_due is not documented. warning: Member W5100_PARAMS (macro definition) of file w5100_params.h is not documented. warning: Member Watchdog_IRQn (macro definition) of file cpu_conf.h is not documented. -warning: Member WD_BASE (macro definition) of file msp430_regs.h is not documented. -warning: Member WD (macro definition) of file msp430_regs.h is not documented. warning: Member WDT_CLOCK_HZ (macro definition) of file periph_cpu.h is not documented. warning: Member WDT_HAS_INIT (macro definition) of file periph_cpu.h is not documented. warning: Member WDT_HAS_STOP (macro definition) of file periph_cpu.h is not documented. diff --git a/dist/tools/doccheck/generic_exclude_patterns b/dist/tools/doccheck/generic_exclude_patterns index 4f86b5c7e9d4..45f56c164fd2 100644 --- a/dist/tools/doccheck/generic_exclude_patterns +++ b/dist/tools/doccheck/generic_exclude_patterns @@ -43,9 +43,6 @@ warning: Member LED[0-9]_PIN_NUM \(macro definition\) of warning: Member LED[0-9]_PORT \(macro definition\) of warning: Member LED[0-9]_PORT_NUM \(macro definition\) of warning: Member LED[0-9]_TOGGLE \(macro definition\) of -warning: Member MSP430_HAS_DCOR \(macro definition\) of -warning: Member MSP430_HAS_EXTERNAL_CRYSTAL \(macro definition\) of -warning: Member MSP430_INITIAL_CPU_SPEED \(macro definition\) of warning: Member PIR_PARAM_ACTIVE_HIGH \(macro definition\) of warning: Member PIR_PARAM_GPIO \(macro definition\) of warning: Member PIR_SAUL_INFO \(macro definition\) of diff --git a/doc/doxygen/riot.doxyfile b/doc/doxygen/riot.doxyfile index 0a8821f41bbd..ee13e793e672 100644 --- a/doc/doxygen/riot.doxyfile +++ b/doc/doxygen/riot.doxyfile @@ -834,8 +834,8 @@ EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = */board/*/tools/* \ */cpu/atmega_common/include/sys/*.h \ - */cpu/msp430_common/include/stdatomic.h \ - */cpu/msp430_common/include/sys/*.h \ + */cpu/msp430/include/stdatomic.h \ + */cpu/msp430/include/sys/*.h \ */cpu/native/osx-libc-extra \ */cpu/x86/include/* \ */drivers/kw2xrf/include/overwrites.h \ diff --git a/makefiles/arch/msp430.inc.mk b/makefiles/arch/msp430.inc.mk index 5325a3821e72..c28a1d50e15f 100644 --- a/makefiles/arch/msp430.inc.mk +++ b/makefiles/arch/msp430.inc.mk @@ -2,7 +2,7 @@ TARGET_ARCH_MSP430 ?= msp430-elf TARGET_ARCH ?= $(TARGET_ARCH_MSP430) -MSP430_SUPPORT_FILES ?= $(RIOTCPU)/msp430_common/vendor/msp430-gcc-support-files +MSP430_SUPPORT_FILES ?= $(RIOTCPU)/msp430/vendor/msp430-gcc-support-files # define build specific options CFLAGS_CPU = -mmcu=$(CPU_MODEL) -isystem $(MSP430_SUPPORT_FILES)/include @@ -19,14 +19,15 @@ NEEDS_NEW_LINKER_SCRIPT := $(call version_is_greater_or_equal,$(BINUTILS_VERSION LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) LINKFLAGS += -Wl,--gc-sections LINKFLAGS += -Wl,-L$(MSP430_SUPPORT_FILES)/include -LINKFLAGS += -Wl,-L$(RIOTCPU)/msp430_common/ldscripts +LINKFLAGS += -Wl,-L$(RIOTCPU)/msp430/ldscripts ifeq (1,$(NEEDS_NEW_LINKER_SCRIPT)) LINKFLAGS += -T riot-$(CPU_MODEL).ld else LINKFLAGS += -T $(MSP430_SUPPORT_FILES)/include/$(CPU_MODEL).ld - LINKFLAGS += -T $(RIOTCPU)/msp430_common/ldscripts/msp430_common.ld - LINKFLAGS += $(RIOTCPU)/msp430_common/ldscripts/xfa.ld + LINKFLAGS += -T $(RIOTCPU)/msp430/ldscripts/msp430_common.ld + LINKFLAGS += -T $(RIOTCPU)/msp430/ldscripts/$(CPU_FAM).ld + LINKFLAGS += $(RIOTCPU)/msp430/ldscripts/xfa.ld endif OPTIONAL_CFLAGS_BLACKLIST += -fdiagnostics-color diff --git a/sys/include/byteorder.h b/sys/include/byteorder.h index 4e401fa17d56..6cebdae9c376 100644 --- a/sys/include/byteorder.h +++ b/sys/include/byteorder.h @@ -397,15 +397,7 @@ static inline unsigned short __builtin_bswap16(unsigned short a) static inline uint16_t byteorder_swaps(uint16_t v) { -#ifndef MODULE_MSP430_COMMON return __builtin_bswap16(v); -#else - network_uint16_t result = { v }; - uint8_t tmp = result.u8[0]; - result.u8[0] = result.u8[1]; - result.u8[1] = tmp; - return result.u16; -#endif } static inline uint32_t byteorder_swapl(uint32_t v) diff --git a/sys/newlib_syscalls_default/syscalls.c b/sys/newlib_syscalls_default/syscalls.c index cf969f1fa1da..a5d59eca3843 100644 --- a/sys/newlib_syscalls_default/syscalls.c +++ b/sys/newlib_syscalls_default/syscalls.c @@ -60,7 +60,7 @@ #define NUM_HEAPS 1 #endif -#ifdef MODULE_MSP430_COMMON +#ifdef __MSP430__ /* the msp430 linker scripts define the end of all memory as __stack, which in * turn is used as the initial stack. RIOT also uses __stack as SP on isr * entry. This logic makes __stack - ISR_STACKSIZE the heap end. @@ -70,7 +70,7 @@ extern char __heap_start__; #define _sheap __heap_start__ #define __eheap (char *)((uintptr_t)&__stack - ISR_STACKSIZE) -#else /* MODULE_MSP430_COMMON */ +#else /* __MSP430__ */ /** * @brief manage the heap diff --git a/tests/pkg/c25519/Makefile b/tests/pkg/c25519/Makefile index edfc7f5cd115..f9844cfef25e 100644 --- a/tests/pkg/c25519/Makefile +++ b/tests/pkg/c25519/Makefile @@ -10,7 +10,7 @@ include $(RIOTBASE)/Makefile.include ifneq (,$(filter cortex-%,$(CPU_CORE))) CFLAGS += -DTHREAD_STACKSIZE_MAIN=\(THREAD_STACKSIZE_DEFAULT+THREAD_EXTRA_STACKSIZE_PRINTF\) else -ifneq (,$(filter atmega_common msp430_common,$(USEMODULE))) +ifneq (,$(filter atmega_common msp430,$(USEMODULE))) CFLAGS += -DTHREAD_STACKSIZE_MAIN=\(5*THREAD_STACKSIZE_DEFAULT+THREAD_EXTRA_STACKSIZE_PRINTF\) else CFLAGS += -DTHREAD_STACKSIZE_MAIN=\(3*THREAD_STACKSIZE_DEFAULT+THREAD_EXTRA_STACKSIZE_PRINTF\)