From bd1953dd8022c47fd371f9748e321993e2ccc2fe Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Thu, 6 Feb 2020 19:52:05 +0100 Subject: [PATCH] cpu/sam0_common: use vendor files to dispatch MCU headers Instead of manually re-creating the files from ASF, just use the vendor provided dispatch headers and ease the maintainance burden. --- cpu/sam0_common/Makefile.include | 3 + cpu/sam0_common/include/cpu_conf.h | 43 ++++++- cpu/sam0_common/include/vendor/sam0.h | 149 ------------------------ cpu/sam0_common/include/vendor/sam23.h | 78 ------------- cpu/sam0_common/include/vendor/samd5x.h | 79 ------------- cpu/samd21/Makefile.include | 16 +++ cpu/samd5x/Makefile.include | 7 ++ cpu/saml1x/Makefile.include | 7 ++ cpu/saml21/Makefile.include | 13 +++ 9 files changed, 83 insertions(+), 312 deletions(-) delete mode 100644 cpu/sam0_common/include/vendor/sam0.h delete mode 100644 cpu/sam0_common/include/vendor/sam23.h delete mode 100644 cpu/sam0_common/include/vendor/samd5x.h diff --git a/cpu/sam0_common/Makefile.include b/cpu/sam0_common/Makefile.include index d08c446d65..85cbbe3e1f 100644 --- a/cpu/sam0_common/Makefile.include +++ b/cpu/sam0_common/Makefile.include @@ -1,6 +1,9 @@ # Define the CPU family so we can differentiate between them in the code CFLAGS += -DCPU_FAM_$(call uppercase_and_underscore,$(CPU_FAM)) +# Generate ASF compatible model definition +CFLAGS += -D__$(call uppercase_and_underscore,$(CPU_MODEL))__ + # Set ROM and RAM lengths according to CPU model ifneq (,$(filter samd21g18a samd21j18a saml21j18b saml21j18a samr21e18a \ samr21g18a samr30g18a samr34j18b,$(CPU_MODEL))) diff --git a/cpu/sam0_common/include/cpu_conf.h b/cpu/sam0_common/include/cpu_conf.h index a35a866042..6b07d8e263 100644 --- a/cpu/sam0_common/include/cpu_conf.h +++ b/cpu/sam0_common/include/cpu_conf.h @@ -22,12 +22,43 @@ #define CPU_CONF_H #include "cpu_conf_common.h" -#if defined(CPU_SAML1X) -#include "vendor/sam23.h" -#elif defined(CPU_SAMD5X) -#include "vendor/samd5x.h" -#else -#include "vendor/sam0.h" + +/* Workaround redefinition of LITTLE_ENDIAN macro (part1) */ +#ifdef LITTLE_ENDIAN +#define __TMP_LITTLE_ENDIAN LITTLE_ENDIAN +#undef LITTLE_ENDIAN +#endif + +#if defined(CPU_SAMD21A) || defined(CPU_SAMD21B) || \ + defined(CPU_SAMD21C) || defined(CPU_SAMD21D) +#include "vendor/samd21/include/samd21.h" +#elif defined(CPU_SAMD51) +#include "vendor/samd51/include/samd51.h" +#elif defined(CPU_SAME54) +#include "vendor/same54/include/same54.h" +#elif defined(CPU_SAML10) +#include "vendor/saml10/include/sam.h" +#elif defined(CPU_SAML11) +#include "vendor/saml11/include/sam.h" +#elif defined(CPU_SAML21A) +#include "vendor/saml21/include/saml21.h" +#elif defined(CPU_SAML21B) +#include "vendor/saml21/include_b/saml21.h" +#elif defined(CPU_SAMR21) +#include "vendor/samr21/include/samr21.h" +#elif defined(CPU_SAMR30) +#include "vendor/samr30/include/samr30.h" +#elif defined(CPU_SAMR34) +#include "vendor/samr34/include/samr34.h" +#endif + +/* Workaround redefinition of LITTLE_ENDIAN macro (part2) */ +#ifdef LITTLE_ENDIAN +#undef LITTLE_ENDIAN +#endif + +#ifdef __TMP_LITTLE_ENDIAN +#define LITTLE_ENDIAN __TMP_LITTLE_ENDIAN #endif #ifdef __cplusplus diff --git a/cpu/sam0_common/include/vendor/sam0.h b/cpu/sam0_common/include/vendor/sam0.h deleted file mode 100644 index 405a5a4173..0000000000 --- a/cpu/sam0_common/include/vendor/sam0.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (C) 2016 Kees Bakker - * 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_sam0_common - * @{ - * - * @file - * @brief Wrapper include file for including the specific SAM0 vendor - * header - * - * @author Kees Bakker - * @author Hauke Petersen - */ - -#ifndef SAM0_H -#define SAM0_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Workaround redefinition of LITTLE_ENDIAN macro (part1) */ -#ifdef LITTLE_ENDIAN -#define __TMP_LITTLE_ENDIAN LITTLE_ENDIAN -#undef LITTLE_ENDIAN -#endif - -#if defined(CPU_MODEL_SAML21E18A) - #include "vendor/saml21/include/saml21e18a.h" -#elif defined(CPU_MODEL_SAML21G18A) - #include "vendor/saml21/include/saml21g18a.h" -#elif defined(CPU_MODEL_SAML21J18A) - #include "vendor/saml21/include/saml21j18a.h" -#elif defined(CPU_MODEL_SAML21E15B) - #include "vendor/saml21/include_b/saml21e15b.h" -#elif defined(CPU_MODEL_SAML21E16B) - #include "vendor/saml21/include_b/saml21e16b.h" -#elif defined(CPU_MODEL_SAML21E17B) - #include "vendor/saml21/include_b/saml21e17b.h" -#elif defined(CPU_MODEL_SAML21E18B) - #include "vendor/saml21/include_b/saml21e18b.h" -#elif defined(CPU_MODEL_SAML21G16B) - #include "vendor/saml21/include_b/saml21g16b.h" -#elif defined(CPU_MODEL_SAML21G17B) - #include "vendor/saml21/include_b/saml21g17b.h" -#elif defined(CPU_MODEL_SAML21G18B) - #include "vendor/saml21/include_b/saml21g18b.h" -#elif defined(CPU_MODEL_SAML21J16B) - #include "vendor/saml21/include_b/saml21j16b.h" -#elif defined(CPU_MODEL_SAML21J17B) - #include "vendor/saml21/include_b/saml21j17b.h" -#elif defined(CPU_MODEL_SAML21J18B) - #include "vendor/saml21/include_b/saml21j18b.h" - -#elif defined(CPU_MODEL_SAMR21E16A) - #include "vendor/samr21/include/samr21e16a.h" -#elif defined(CPU_MODEL_SAMR21E17A) - #include "vendor/samr21/include/samr21e17a.h" -#elif defined(CPU_MODEL_SAMR21E18A) - #include "vendor/samr21/include/samr21e18a.h" -#elif defined(CPU_MODEL_SAMR21G16A) - #include "vendor/samr21/include/samr21g16a.h" -#elif defined(CPU_MODEL_SAMR21G17A) - #include "vendor/samr21/include/samr21g17a.h" -#elif defined(CPU_MODEL_SAMR21G18A) - #include "vendor/samr21/include/samr21g18a.h" - -#elif defined(CPU_MODEL_SAMD21E15A) - #include "vendor/samd21/include/samd21e15a.h" -#elif defined(CPU_MODEL_SAMD21E16A) - #include "vendor/samd21/include/samd21e16a.h" -#elif defined(CPU_MODEL_SAMD21E17A) - #include "vendor/samd21/include/samd21e17a.h" -#elif defined(CPU_MODEL_SAMD21E18A) - #include "vendor/samd21/include/samd21e18a.h" -#elif defined(CPU_MODEL_SAMD21G15A) - #include "vendor/samd21/include/samd21g15a.h" -#elif defined(CPU_MODEL_SAMD21G16A) - #include "vendor/samd21/include/samd21g16a.h" -#elif defined(CPU_MODEL_SAMD21G17A) - #include "vendor/samd21/include/samd21g17a.h" -#elif defined(CPU_MODEL_SAMD21G17AU) - #include "vendor/samd21/include/samd21g17au.h" -#elif defined(CPU_MODEL_SAMD21G18A) - #include "vendor/samd21/include/samd21g18a.h" -#elif defined(CPU_MODEL_SAMD21G18AU) - #include "vendor/samd21/include/samd21g18au.h" -#elif defined(CPU_MODEL_SAMD21J15A) - #include "vendor/samd21/include/samd21j15a.h" -#elif defined(CPU_MODEL_SAMD21J16A) - #include "vendor/samd21/include/samd21j16a.h" -#elif defined(CPU_MODEL_SAMD21J17A) - #include "vendor/samd21/include/samd21j17a.h" -#elif defined(CPU_MODEL_SAMD21J18A) - #include "vendor/samd21/include/samd21j18a.h" -#elif defined(CPU_MODEL_SAMD21E15B) - #include "vendor/samd21/include/samd21e15b.h" -#elif defined(CPU_MODEL_SAMD21E15BU) - #include "vendor/samd21/include/samd21e15bu.h" -#elif defined(CPU_MODEL_SAMD21E15L) - #include "vendor/samd21/include/samd21e15l.h" -#elif defined(CPU_MODEL_SAMD21E16B) - #include "vendor/samd21/include/samd21e16b.h" -#elif defined(CPU_MODEL_SAMD21E16BU) - #include "vendor/samd21/include/samd21e16bu.h" -#elif defined(CPU_MODEL_SAMD21E16L) - #include "vendor/samd21/include/samd21e16l.h" -#elif defined(CPU_MODEL_SAMD21G15B) - #include "vendor/samd21/include/samd21g15b.h" -#elif defined(CPU_MODEL_SAMD21G15L) - #include "vendor/samd21/include/samd21g15l.h" -#elif defined(CPU_MODEL_SAMD21G16B) - #include "vendor/samd21/include/samd21g16b.h" -#elif defined(CPU_MODEL_SAMD21G16L) - #include "vendor/samd21/include/samd21g16l.h" -#elif defined(CPU_MODEL_SAMD21J15B) - #include "vendor/samd21/include/samd21j15b.h" -#elif defined(CPU_MODEL_SAMD21J16B) - #include "vendor/samd21/include/samd21j16b.h" -#elif defined(CPU_MODEL_SAMR30G18A) - #include "vendor/samr30/include/samr30g18a.h" -#elif defined(CPU_MODEL_SAMR34J18B) - #include "vendor/samr34/include/samr34j18b.h" -#else - #error "Unsupported SAM0 variant." -#endif - -/* Workaround redefinition of LITTLE_ENDIAN macro (part2) */ -#ifdef LITTLE_ENDIAN -#undef LITTLE_ENDIAN -#endif - -#ifdef __TMP_LITTLE_ENDIAN -#define LITTLE_ENDIAN __TMP_LITTLE_ENDIAN -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SAM0_H */ -/** @} */ diff --git a/cpu/sam0_common/include/vendor/sam23.h b/cpu/sam0_common/include/vendor/sam23.h deleted file mode 100644 index 6937b172df..0000000000 --- a/cpu/sam0_common/include/vendor/sam23.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (C) 2018 Mesotic SAS - * - * 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_saml1x - * @{ - * - * @file - * @brief Wrapper include file for including the specific - * SAML10/SAML11 vendor header - * - * @author Dylan Laduranty - */ - -#ifndef SAM23_H -#define SAM23_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Workaround redefinition of LITTLE_ENDIAN macro (part1) */ -#ifdef LITTLE_ENDIAN -#define __TMP_LITTLE_ENDIAN LITTLE_ENDIAN -#undef LITTLE_ENDIAN -#endif - -#if defined(CPU_MODEL_SAML10D14A) - #include "vendor/saml10/include/saml10d14a.h" -#elif defined(CPU_MODEL_SAML10D15A) - #include "vendor/saml10/include/saml10d15a.h" -#elif defined(CPU_MODEL_SAML10D16A) - #include "vendor/saml10/include/saml10d16a.h" -#elif defined(CPU_MODEL_SAML10E14A) - #include "vendor/saml10/include/saml10e14a.h" -#elif defined(CPU_MODEL_SAML10E15A) - #include "vendor/saml10/include/saml10e15a.h" -#elif defined(CPU_MODEL_SAML10E16A) - #include "vendor/saml10/include/saml10e16a.h" - -#elif defined(CPU_MODEL_SAML11D14A) - #include "vendor/saml11/include/saml11d14a.h" -#elif defined(CPU_MODEL_SAML11D15A) - #include "vendor/saml11/include/saml11d15a.h" -#elif defined(CPU_MODEL_SAML11D16A) - #include "vendor/saml11/include/saml11d16a.h" -#elif defined(CPU_MODEL_SAML11E14A) - #include "vendor/saml11/include/saml11e14a.h" -#elif defined(CPU_MODEL_SAML11E15A) - #include "vendor/saml11/include/saml11e15a.h" -#elif defined(CPU_MODEL_SAML11E16A) - #include "vendor/saml11/include/saml11e16a.h" - - -#else - #error "Unsupported SAM23 variant." -#endif - -/* Workaround redefinition of LITTLE_ENDIAN macro (part2) */ -#ifdef LITTLE_ENDIAN -#undef LITTLE_ENDIAN -#endif - -#ifdef __TMP_LITTLE_ENDIAN -#define LITTLE_ENDIAN __TMP_LITTLE_ENDIAN -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SAM23_H */ -/** @} */ diff --git a/cpu/sam0_common/include/vendor/samd5x.h b/cpu/sam0_common/include/vendor/samd5x.h deleted file mode 100644 index d0f398bd36..0000000000 --- a/cpu/sam0_common/include/vendor/samd5x.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (C) 2019 ML!PA Consulting GmbH - * - * 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_samd5x - * @{ - * - * @file - * @brief Wrapper include file for including the specific - * SAMD5x/SAME5x vendor header - * - * @author Benjamin Valentin - */ - -#ifndef SAMD5X_H -#define SAMD5X_H - -#ifdef __cplusplus -extern "C" { -#endif - -/* Workaround redefinition of LITTLE_ENDIAN macro (part1) */ -#ifdef LITTLE_ENDIAN -#define __TMP_LITTLE_ENDIAN LITTLE_ENDIAN -#undef LITTLE_ENDIAN -#endif - -#if defined(CPU_MODEL_SAMD51G18A) - #include "vendor/samd51/include/samd51g18a.h" -#elif defined(CPU_MODEL_SAMD51G19A) - #include "vendor/samd51/include/samd51g19a.h" -#elif defined(CPU_MODEL_SAMD51J18A) - #include "vendor/samd51/include/samd51j18a.h" -#elif defined(CPU_MODEL_SAMD51J19A) - #include "vendor/samd51/include/samd51j19a.h" -#elif defined(CPU_MODEL_SAMD51J20A) - #include "vendor/samd51/include/samd51j20a.h" -#elif defined(CPU_MODEL_SAMD51N19A) - #include "vendor/samd51/include/samd51n19a.h" -#elif defined(CPU_MODEL_SAMD51N20A) - #include "vendor/samd51/include/samd51n20a.h" -#elif defined(CPU_MODEL_SAMD51P19A) - #include "vendor/samd51/include/samd51p19a.h" -#elif defined(CPU_MODEL_SAMD51P20A) - #include "vendor/samd51/include/samd51p20a.h" - -#elif defined(CPU_MODEL_SAME54N19A) - #include "vendor/same54/include/same54n19a.h" -#elif defined(CPU_MODEL_SAME54N20A) - #include "vendor/same54/include/same54n20a.h" -#elif defined(CPU_MODEL_SAME54P19A) - #include "vendor/same54/include/same54p19a.h" -#elif defined(CPU_MODEL_SAME54P20A) - #include "vendor/same54/include/same54p20a.h" - -#else - #error "Unsupported SAMD5x/SAME5x variant." -#endif - -/* Workaround redefinition of LITTLE_ENDIAN macro (part2) */ -#ifdef LITTLE_ENDIAN -#undef LITTLE_ENDIAN -#endif - -#ifdef __TMP_LITTLE_ENDIAN -#define LITTLE_ENDIAN __TMP_LITTLE_ENDIAN -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* SAMD5x_H */ -/** @} */ diff --git a/cpu/samd21/Makefile.include b/cpu/samd21/Makefile.include index 30f4ae9d0c..c7ab2ab978 100644 --- a/cpu/samd21/Makefile.include +++ b/cpu/samd21/Makefile.include @@ -1,5 +1,21 @@ CPU_ARCH = cortex-m0plus CPU_FAM = samd21 +ifneq (,$(filter samd21%a,$(CPU_MODEL))) + CFLAGS += -DCPU_SAMD21A +endif +ifneq (,$(filter samd21%b,$(CPU_MODEL))) + CFLAGS += -DCPU_SAMD21B +endif +ifneq (,$(filter samd21%c,$(CPU_MODEL))) + CFLAGS += -DCPU_SAMD21C +endif +ifneq (,$(filter samd21%d,$(CPU_MODEL))) + CFLAGS += -DCPU_SAMD21D +endif +ifneq (,$(filter samr21%,$(CPU_MODEL))) + CFLAGS += -DCPU_SAMR21 +endif + include $(RIOTCPU)/sam0_common/Makefile.include include $(RIOTMAKE)/arch/cortexm.inc.mk diff --git a/cpu/samd5x/Makefile.include b/cpu/samd5x/Makefile.include index 6e33db8efc..e7778c35e4 100644 --- a/cpu/samd5x/Makefile.include +++ b/cpu/samd5x/Makefile.include @@ -1,6 +1,13 @@ CPU_ARCH = cortex-m4f CPU_FAM = samd5x +ifneq (,$(filter samd51%,$(CPU_MODEL))) + CFLAGS += -DCPU_SAMD51 +endif +ifneq (,$(filter same54%,$(CPU_MODEL))) + CFLAGS += -DCPU_SAME54 +endif + # Slot size is determined by "((total_flash_size - RIOTBOOT_LEN) / 2)". # If RIOTBOOT_LEN uses an uneven number of flashpages, the remainder of the # flash cannot be divided by two slots while staying FLASHPAGE_SIZE aligned. diff --git a/cpu/saml1x/Makefile.include b/cpu/saml1x/Makefile.include index 5f85fa02ea..4067e6c0da 100644 --- a/cpu/saml1x/Makefile.include +++ b/cpu/saml1x/Makefile.include @@ -1,4 +1,11 @@ CPU_ARCH = cortex-m23 +ifneq (,$(filter saml10%,$(CPU_MODEL))) + CFLAGS += -DCPU_SAML10 +endif +ifneq (,$(filter saml11%,$(CPU_MODEL))) + CFLAGS += -DCPU_SAML11 +endif + include $(RIOTCPU)/sam0_common/Makefile.include include $(RIOTMAKE)/arch/cortexm.inc.mk diff --git a/cpu/saml21/Makefile.include b/cpu/saml21/Makefile.include index 233886256a..d93cf4da43 100644 --- a/cpu/saml21/Makefile.include +++ b/cpu/saml21/Makefile.include @@ -1,6 +1,19 @@ CPU_ARCH = cortex-m0plus CPU_FAM = saml21 +ifneq (,$(filter saml21%a,$(CPU_MODEL))) + CFLAGS += -DCPU_SAML21A +endif +ifneq (,$(filter saml21%b,$(CPU_MODEL))) + CFLAGS += -DCPU_SAML21B +endif +ifneq (,$(filter samr30%,$(CPU_MODEL))) + CFLAGS += -DCPU_SAMR30 +endif +ifneq (,$(filter samr34%,$(CPU_MODEL))) + CFLAGS += -DCPU_SAMR34 +endif + ifneq (,$(filter saml21j18b saml21j18a samr30g18a samr34j18b,$(CPU_MODEL))) BACKUP_RAM_ADDR = 0x30000000 BACKUP_RAM_LEN = 0x2000