From a94919aeeda70fb68ada64500436791668093117 Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Fri, 2 Oct 2020 20:06:43 +0200 Subject: [PATCH] cpu/samd21: add support for SAMD10 --- cpu/samd21/Kconfig | 2 + cpu/samd21/Makefile | 5 +- cpu/samd21/Makefile.dep | 2 + cpu/samd21/Makefile.include | 3 + cpu/samd21/vectors/Kconfig | 12 +++ cpu/samd21/vectors/Makefile | 15 ++++ cpu/samd21/vectors/vectors_samd1x.c | 73 +++++++++++++++++++ .../{vectors.c => vectors/vectors_samd2x.c} | 0 8 files changed, 108 insertions(+), 4 deletions(-) create mode 100644 cpu/samd21/vectors/Kconfig create mode 100644 cpu/samd21/vectors/Makefile create mode 100644 cpu/samd21/vectors/vectors_samd1x.c rename cpu/samd21/{vectors.c => vectors/vectors_samd2x.c} (100%) diff --git a/cpu/samd21/Kconfig b/cpu/samd21/Kconfig index d2434f5c30..0447148522 100644 --- a/cpu/samd21/Kconfig +++ b/cpu/samd21/Kconfig @@ -37,4 +37,6 @@ config CPU source "$(RIOTCPU)/samd21/Kconfig.samd21" source "$(RIOTCPU)/samd21/Kconfig.samr21" +source "$(RIOTCPU)/samd21/vectors/Kconfig" + source "$(RIOTCPU)/sam0_common/Kconfig" diff --git a/cpu/samd21/Makefile b/cpu/samd21/Makefile index 8794dfbc47..4a244b4844 100644 --- a/cpu/samd21/Makefile +++ b/cpu/samd21/Makefile @@ -2,9 +2,6 @@ MODULE = cpu # add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common $(RIOTCPU)/sam0_common - -# (file triggers compiler bug. see #5775) -SRC_NOLTO += vectors.c +DIRS = periph $(RIOTCPU)/cortexm_common $(RIOTCPU)/sam0_common vectors include $(RIOTBASE)/Makefile.base diff --git a/cpu/samd21/Makefile.dep b/cpu/samd21/Makefile.dep index eccd575bc9..75b87be699 100644 --- a/cpu/samd21/Makefile.dep +++ b/cpu/samd21/Makefile.dep @@ -1 +1,3 @@ +USEMODULE += samd21_vectors + include $(RIOTCPU)/sam0_common/Makefile.dep diff --git a/cpu/samd21/Makefile.include b/cpu/samd21/Makefile.include index 311590e64b..034309953c 100644 --- a/cpu/samd21/Makefile.include +++ b/cpu/samd21/Makefile.include @@ -1,3 +1,6 @@ +ifneq (,$(filter samd10%,$(CPU_MODEL))) + CFLAGS += -DCPU_SAMD10 +endif ifneq (,$(filter samd21%a,$(CPU_MODEL))) CFLAGS += -DCPU_SAMD21A endif diff --git a/cpu/samd21/vectors/Kconfig b/cpu/samd21/vectors/Kconfig new file mode 100644 index 0000000000..ccbacc4f79 --- /dev/null +++ b/cpu/samd21/vectors/Kconfig @@ -0,0 +1,12 @@ +# Copyright (c) 2020 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. + +config MODULE_SAMD21_VECTORS + bool + default y + depends on CPU_COMMON_SAMD21 + help + SAM D1x/D2x interrupt vector table. diff --git a/cpu/samd21/vectors/Makefile b/cpu/samd21/vectors/Makefile new file mode 100644 index 0000000000..19fc4ee797 --- /dev/null +++ b/cpu/samd21/vectors/Makefile @@ -0,0 +1,15 @@ +MODULE = samd21_vectors + +NO_AUTO_SRC = 1 + +ifneq (,$(filter samd1%,$(CPU_MODEL))) + SRC_FILE = vectors_samd1x.c +else + SRC_FILE = vectors_samd2x.c +endif + +SRCS += $(SRC_FILE) +# (file triggers compiler bug. see #5775) +SRC_NOLTO += $(SRC_FILE) + +include $(RIOTBASE)/Makefile.base diff --git a/cpu/samd21/vectors/vectors_samd1x.c b/cpu/samd21/vectors/vectors_samd1x.c new file mode 100644 index 0000000000..86b052f72b --- /dev/null +++ b/cpu/samd21/vectors/vectors_samd1x.c @@ -0,0 +1,73 @@ +/* + * Copyright (C) 2020 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_samd21 + * @{ + * + * @file + * @brief Startup code and interrupt vector definition + * + * @author Benjamin Valentin + * + * @} + */ + +#include +#include "vectors_cortexm.h" +#include "cpu.h" + +/* define a local dummy handler as it needs to be in the same compilation unit + * as the alias definition */ +void dummy_handler(void) { + dummy_handler_default(); +} + +/* SAMR21 specific interrupt vector */ +WEAK_DEFAULT void isr_pm(void); +WEAK_DEFAULT void isr_sysctrl(void); +WEAK_DEFAULT void isr_wdt(void); +WEAK_DEFAULT void isr_rtc(void); +WEAK_DEFAULT void isr_eic(void); +WEAK_DEFAULT void isr_nvmctrl(void); +WEAK_DEFAULT void isr_dmac(void); +WEAK_DEFAULT void isr_usb(void); +WEAK_DEFAULT void isr_evsys(void); +WEAK_DEFAULT void isr_sercom0(void); +WEAK_DEFAULT void isr_sercom1(void); +WEAK_DEFAULT void isr_sercom2(void); +WEAK_DEFAULT void isr_tcc0(void); +WEAK_DEFAULT void isr_tc1(void); +WEAK_DEFAULT void isr_tc2(void); +WEAK_DEFAULT void isr_adc(void); +WEAK_DEFAULT void isr_ac(void); +WEAK_DEFAULT void isr_dac(void); +WEAK_DEFAULT void isr_ptc(void); + +/* CPU specific interrupt vector table */ +ISR_VECTOR(1) const isr_t vector_cpu[CPU_IRQ_NUMOF] = { + isr_pm, /* 0 Power Manager */ + isr_sysctrl, /* 1 System Control */ + isr_wdt, /* 2 Watchdog Timer */ + isr_rtc, /* 3 Real-Time Counter */ + isr_eic, /* 4 External Interrupt Controller */ + isr_nvmctrl, /* 5 Non-Volatile Memory Controller */ + isr_dmac, /* 6 Direct Memory Access Controller */ + isr_usb, /* 7 Universal Serial Bus */ + isr_evsys, /* 8 Event System Interface */ + isr_sercom0, /* 9 Serial Communication Interface 0 */ + isr_sercom1, /* 10 Serial Communication Interface 1 */ + isr_sercom2, /* 11 Serial Communication Interface 2 */ + isr_tcc0, /* 12 Timer Counter Control 0 */ + isr_tc1, /* 13 Basic Timer Control 1 */ + isr_tc2, /* 14 Basic Timer Control 2 */ + isr_adc, /* 15 Analog Digital Converter */ + isr_ac, /* 16 Analog Comparators */ + isr_dac, /* 17 Digital Analog Converter */ + isr_ptc, /* 18 Peripheral Touch Controller */ +}; diff --git a/cpu/samd21/vectors.c b/cpu/samd21/vectors/vectors_samd2x.c similarity index 100% rename from cpu/samd21/vectors.c rename to cpu/samd21/vectors/vectors_samd2x.c