From aa6dbbcffd4f0a5c7572b8aa1ef256794838f969 Mon Sep 17 00:00:00 2001 From: robert-hh Date: Wed, 8 Jun 2022 10:54:02 +0200 Subject: [PATCH] samd/mcu: Factor out MCU policy for SAMD21 and SAMD51. Which contains a mpconfigmcu.h, mpconfigmcu.mk and manifest.py file for each MCU group. That looks better than the previous choice. --- ports/samd/Makefile | 16 +++++----------- .../samd21/mpconfigmcu.h} | 0 ports/samd/mcu/samd21/mpconfigmcu.mk | 1 + .../samd51/mpconfigmcu.h} | 0 ports/samd/mcu/samd51/mpconfigmcu.mk | 1 + ports/samd/mpconfigport.h | 2 +- 6 files changed, 8 insertions(+), 12 deletions(-) rename ports/samd/{boards/mpconfig_samd21.h => mcu/samd21/mpconfigmcu.h} (100%) create mode 100644 ports/samd/mcu/samd21/mpconfigmcu.mk rename ports/samd/{boards/mpconfig_samd51.h => mcu/samd51/mpconfigmcu.h} (100%) create mode 100644 ports/samd/mcu/samd51/mpconfigmcu.mk diff --git a/ports/samd/Makefile b/ports/samd/Makefile index 43b6a1adc3..1455e748cc 100644 --- a/ports/samd/Makefile +++ b/ports/samd/Makefile @@ -9,14 +9,15 @@ ifeq ($(wildcard $(BOARD_DIR)/.),) $(error Invalid BOARD specified: $(BOARD_DIR)) endif +MCU_SERIES_LOWER = $(shell echo $(MCU_SERIES) | tr '[:upper:]' '[:lower:]') + include ../../py/mkenv.mk include $(BOARD_DIR)/mpconfigboard.mk +include mcu/$(MCU_SERIES_LOWER)/mpconfigmcu.mk # Qstr definitions (must come before including py.mk) QSTR_DEFS = qstrdefsport.h -QSTR_GLOBAL_DEPENDENCIES = $(BOARD_DIR)/mpconfigboard.h - -MCU_SERIES_LOWER = $(shell echo $(MCU_SERIES) | tr '[:upper:]' '[:lower:]') +QSTR_GLOBAL_DEPENDENCIES = $(BOARD_DIR)/mpconfigboard.h mcu/$(MCU_SERIES_LOWER)/mpconfigmcu.h FROZEN_MANIFEST ?= boards/manifest.py @@ -30,6 +31,7 @@ INC += -I. INC += -I$(TOP) INC += -I$(BUILD) INC += -I$(BOARD_DIR) +INC += -Imcu/$(MCU_SERIES_LOWER) INC += -I$(TOP)/lib/cmsis/inc INC += -I$(TOP)/lib/asf4/$(MCU_SERIES_LOWER)/hal/include INC += -I$(TOP)/lib/asf4/$(MCU_SERIES_LOWER)/hal/utils/include @@ -62,8 +64,6 @@ CFLAGS += $(CFLAGS_MOD) $(CFLAGS_EXTRA) CFLAGS += -DMPCONFIG_MCU_H='' CFLAGS += -DPIN_AF_TABLE_C='<$(BUILD)/$(GEN_PIN_AF)>' -QSTR_GLOBAL_DEPENDENCIES += boards/mpconfig_$(MCU_SERIES_LOWER).h - LDFLAGS = -nostdlib $(addprefix -T,$(LD_FILES)) -Map=$@.map --cref LDFLAGS += $(LDFLAGS_MOD) @@ -141,12 +141,6 @@ SRC_C += $(SRC_MOD) SRC_CXX += $(SRC_MOD_CXX) -ifeq ($(MCU_SERIES),SAMD21) -SRC_S = shared/runtime/gchelper_m0.s -else -SRC_S = shared/runtime/gchelper_m3.s -endif - # List of sources for qstr extraction SRC_QSTR += \ machine_adc.c \ diff --git a/ports/samd/boards/mpconfig_samd21.h b/ports/samd/mcu/samd21/mpconfigmcu.h similarity index 100% rename from ports/samd/boards/mpconfig_samd21.h rename to ports/samd/mcu/samd21/mpconfigmcu.h diff --git a/ports/samd/mcu/samd21/mpconfigmcu.mk b/ports/samd/mcu/samd21/mpconfigmcu.mk new file mode 100644 index 0000000000..cc435da8cc --- /dev/null +++ b/ports/samd/mcu/samd21/mpconfigmcu.mk @@ -0,0 +1 @@ +SRC_S += shared/runtime/gchelper_m0.s diff --git a/ports/samd/boards/mpconfig_samd51.h b/ports/samd/mcu/samd51/mpconfigmcu.h similarity index 100% rename from ports/samd/boards/mpconfig_samd51.h rename to ports/samd/mcu/samd51/mpconfigmcu.h diff --git a/ports/samd/mcu/samd51/mpconfigmcu.mk b/ports/samd/mcu/samd51/mpconfigmcu.mk new file mode 100644 index 0000000000..461a0182ef --- /dev/null +++ b/ports/samd/mcu/samd51/mpconfigmcu.mk @@ -0,0 +1 @@ +SRC_S += shared/runtime/gchelper_m3.s diff --git a/ports/samd/mpconfigport.h b/ports/samd/mpconfigport.h index 48631080d2..8a067d3482 100644 --- a/ports/samd/mpconfigport.h +++ b/ports/samd/mpconfigport.h @@ -29,7 +29,7 @@ // Board specific definitions #include "mpconfigboard.h" // MCU-Specific definitions -#include MPCONFIG_MCU_H +#include "mpconfigmcu.h" // Memory allocation policies #define MICROPY_GC_STACK_ENTRY_TYPE uint16_t