From 0dabad20b44891b524392df46091b4a31f54b61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Fri, 27 Oct 2017 01:04:54 +0200 Subject: [PATCH 1/6] kinetis: Extract detailed information from CPU_MODEL --- cpu/kinetis_common/Makefile.include | 6 ++ cpu/kinetis_common/kinetis-info.mk | 146 ++++++++++++++++++++++++++++ 2 files changed, 152 insertions(+) create mode 100644 cpu/kinetis_common/kinetis-info.mk diff --git a/cpu/kinetis_common/Makefile.include b/cpu/kinetis_common/Makefile.include index d88fa57da5..d926c4f878 100644 --- a/cpu/kinetis_common/Makefile.include +++ b/cpu/kinetis_common/Makefile.include @@ -1,3 +1,9 @@ +ifeq (,$(KINETIS_SERIES)) + # Parse parameters from CPU_MODEL using the kinetis-info.mk script in the same + # directory as this Makefile. + include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/kinetis-info.mk +endif + # include module specific includes export INCLUDES += -I$(RIOTCPU)/kinetis_common/include diff --git a/cpu/kinetis_common/kinetis-info.mk b/cpu/kinetis_common/kinetis-info.mk new file mode 100644 index 0000000000..f547d5e4ad --- /dev/null +++ b/cpu/kinetis_common/kinetis-info.mk @@ -0,0 +1,146 @@ +# Split the part number into qualification, family, subfamily, core, memory, temperature, package, speed +KINETIS_INFO := $(shell printf '%s' '$(CPU_MODEL)' | tr 'a-z' 'A-Z' | sed -E -e 's/^(M|K|S9)K([ELMSVW]?|EA)([0-9]?)([0-9]?)([A-Z])([NX]?)([0-9][0-9M]?[0-9]?)([ABZ]?)(.*)$$/\1 \2 \3 \4 \5 \6 \7 \8:\9/' -e 's/^([^ ]*) /\1 K /' -e 's/^([^:]*):([CMV])(..)([0-9]*).*$$/\1 \2 \3 \4/' -e 's/ / _ /g' -e 's/ / _ /g') + + +export KINETIS_QUALIFICATION := $(word 1, $(KINETIS_INFO)) +export KINETIS_SERIES := $(word 2, $(KINETIS_INFO)) +export KINETIS_FAMILY := $(word 3, $(KINETIS_INFO)) +export KINETIS_SUBFAMILY := $(word 4, $(KINETIS_INFO)) +# Core type, D = Cortex-M4, F = Cortex-M4/M7 w/ FPU, Z = Cortex-M0 +export KINETIS_CORE := $(word 5, $(KINETIS_INFO)) +# FlexRAM (X) or not (N), does not apply to all families +export KINETIS_FLEXMEM := $(word 6, $(KINETIS_INFO)) +# ROM size, KiB +export KINETIS_ROMSIZE := $(word 7, $(KINETIS_INFO)) +# some special cases for ROM size, refactor when there are too many special cases +ifeq ($(KINETIS_ROMSIZE), 1M0) + export KINETIS_ROMSIZE = 1024 +else ifeq ($(KINETIS_ROMSIZE), 1M2) + export KINETIS_ROMSIZE = 1280 +else ifeq ($(KINETIS_ROMSIZE), 2M0) + export KINETIS_ROMSIZE = 2048 +endif +# Mask set revision, only some parts, see data sheet for details +export KINETIS_MASKREV := $(word 8, $(KINETIS_INFO)) +# Temperature range, C = -40--+85, V = -40--+105, M = -40--+125 +export KINETIS_TEMPRANGE := $(word 9, $(KINETIS_INFO)) +# Chip package code +export KINETIS_PACKAGE := $(word 10, $(KINETIS_INFO)) +# Maximum speed, MHz/10, max speed is usually 48 MHz if this number is missing +export KINETIS_SPEED := $(word 11, $(KINETIS_INFO)) + +ifeq ($(KINETIS_CORE), Z) + # Cortex-M0+ + export CPU_ARCH = cortex-m0plus + export CPU_FAMILY = klx +else ifeq ($(KINETIS_CORE), D) + # Cortex-M4 + export CPU_ARCH = cortex-m4 + export CPU_FAMILY = kx +else ifeq ($(KINETIS_CORE), F) + # Cortex-M4F or Cortex-M7 + # TODO: Add floating point support + export CPU_ARCH = cortex-m4 + export CPU_FAMILY = kx +endif + +# RAM sizes are a bit arbitrary, but are usually dependent on ROM size and core speed. +# KINETIS_RAMSIZE is used inside a $(( )) shell arithmetic block, so it is OK to +# use mathematical expressions here. +# This block is not complete, but it does cover all the CPUs supported by RIOT, and then some. +ifeq ($(KINETIS_SERIES),K) + # A majority of the models have this ratio of SRAM_L vs total SRAM size + KINETIS_SRAM_L_SIZE = $(KINETIS_RAMSIZE)/2 + ifeq ($(KINETIS_ROMSIZE),2048) + ifeq ($(firstword $(sort $(KINETIS_SUBFAMILY) 7)),7) + # subfamily >= 7 + # OCRAM in K27, K28 is not mapped here. + KINETIS_RAMSIZE = 512 + else + KINETIS_RAMSIZE = 256 + endif + else ifeq ($(KINETIS_ROMSIZE),1024) + ifeq ($(firstword $(sort $(KINETIS_SUBFAMILY) 3)),3) + # subfamily >= 3 + KINETIS_RAMSIZE = 256 + else + KINETIS_RAMSIZE = 128 + endif + else ifeq ($(KINETIS_ROMSIZE),512) + ifeq ($(KINETIS_SPEED),5) + KINETIS_RAMSIZE = 64 + else ifeq ($(KINETIS_SUBFAMILY),4) + KINETIS_RAMSIZE = 192 + else + KINETIS_RAMSIZE = 128 + endif + else ifeq ($(KINETIS_ROMSIZE),256) + ifeq ($(KINETIS_SPEED),5) + KINETIS_RAMSIZE = 32 + else ifeq ($(KINETIS_SPEED),15) + KINETIS_RAMSIZE = 256 + else ifeq ($(KINETIS_FAMILY)$(KINETIS_SUBFAMILY),22) + KINETIS_RAMSIZE = 48 + else ifeq ($(KINETIS_FAMILY)$(KINETIS_SUBFAMILY),24) + KINETIS_RAMSIZE = 256 + endif + else ifeq ($(KINETIS_ROMSIZE),128) + ifeq ($(KINETIS_FAMILY),0) + KINETIS_RAMSIZE = 16 + else ifeq ($(KINETIS_SUBFAMILY)$(KINETIS_SPEED),05) + KINETIS_RAMSIZE = 16 + else ifeq ($(KINETIS_CORE),F) + KINETIS_RAMSIZE = 24 + KINETIS_SRAM_L_SIZE = 8 + else + KINETIS_RAMSIZE = 32 + endif + else ifeq ($(KINETIS_ROMSIZE),64) + KINETIS_RAMSIZE = 16 + endif + ifneq (,$(filter $(KINETIS_RAMSIZE),192 256)) + # There seems to be a cap on SRAM_L at 64 kB across the whole K series + KINETIS_SRAM_L_SIZE = 64 + endif +else ifeq ($(KINETIS_SERIES),W) + KINETIS_RAMSIZE = $(KINETIS_ROMSIZE)/8 + ifeq ($(KINETIS_CORE),D) + KINETIS_SRAM_L_SIZE = $(KINETIS_RAMSIZE)/2 + else ifeq ($(KINETIS_FAMILY),0) + # 01Z + KINETIS_SRAM_L_SIZE = 4 + else ifeq ($(KINETIS_SUBFAMILY),0) + # 20Z, 30Z, 40Z + KINETIS_SRAM_L_SIZE = 4 + else ifeq ($(KINETIS_SUBFAMILY),1) + # 21Z, 31Z, 41Z + KINETIS_RAMSIZE = $(KINETIS_ROMSIZE)/4 + KINETIS_SRAM_L_SIZE = $(KINETIS_RAMSIZE)/4 + else + # TODO: KW35/36 + $(error Unknown Kinetis W) + endif +endif +export KINETIS_RAMSIZE +export KINETIS_SRAM_L_SIZE + +# Some debug output to use in case things are not being correctly detected +ifeq ($(KINETIS_INFO_DEBUG),1) + $(info Kinetis CPU info: $(KINETIS_INFO)) + $(info Qualification: $(KINETIS_QUALIFICATION)) + $(info Core: $(KINETIS_CORE)) + $(info Series: $(KINETIS_SERIES)) + $(info Family: $(KINETIS_FAMILY)) + $(info Subfamily: $(KINETIS_SUBFAMILY)) + $(info ROM size: $(KINETIS_ROMSIZE)) + $(info RAM size: $(shell printf '%-4s (%s)' $$(($(KINETIS_RAMSIZE))) '$(KINETIS_RAMSIZE)')) + $(info SRAM_L: $(shell printf '%-4s (%s)' $$(($(KINETIS_SRAM_L_SIZE))) '$(KINETIS_SRAM_L_SIZE)')) + $(info Max speed: $(KINETIS_SPEED)) + $(info Temperature range: $(KINETIS_TEMPRANGE)) + $(info Revision: $(KINETIS_MASKREV)) + $(info Package code: $(KINETIS_PACKAGE)) +endif + +ifeq (,$(KINETIS_RAMSIZE)) + $(error Unknown Kinetis RAM size, update kinetis-info.mk with your CPU) +endif From cb8e3f19a21ba6c86bf7a2776fcd0d95235c1dfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Fri, 27 Oct 2017 01:05:33 +0200 Subject: [PATCH 2/6] kinetis: Use one ldscript for all CPUs --- cpu/kinetis_common/Makefile.include | 24 +++++++++++++++++-- cpu/kinetis_common/ldscripts/kinetis.ld | 15 +++++++++++- .../ldscripts/kinetis_f1024l64u192.ld | 18 -------------- .../ldscripts/kinetis_f256l16u16.ld | 18 -------------- .../ldscripts/kinetis_f256l32u32.ld | 18 -------------- .../ldscripts/kinetis_f512l32u32.ld | 18 -------------- .../ldscripts/kinetis_f512l64u64.ld | 18 -------------- 7 files changed, 36 insertions(+), 93 deletions(-) delete mode 100644 cpu/kinetis_common/ldscripts/kinetis_f1024l64u192.ld delete mode 100644 cpu/kinetis_common/ldscripts/kinetis_f256l16u16.ld delete mode 100644 cpu/kinetis_common/ldscripts/kinetis_f256l32u32.ld delete mode 100644 cpu/kinetis_common/ldscripts/kinetis_f512l32u32.ld delete mode 100644 cpu/kinetis_common/ldscripts/kinetis_f512l64u64.ld diff --git a/cpu/kinetis_common/Makefile.include b/cpu/kinetis_common/Makefile.include index d926c4f878..24ece8ab4c 100644 --- a/cpu/kinetis_common/Makefile.include +++ b/cpu/kinetis_common/Makefile.include @@ -10,8 +10,28 @@ export INCLUDES += -I$(RIOTCPU)/kinetis_common/include # Add search path for linker scripts export LINKFLAGS += -L$(RIOTCPU)/kinetis_common/ldscripts -# Use generic linkerscripts for all Kinetis based CPUs -export LINKER_SCRIPT ?= $(LD_$(shell echo $(CPU_MODEL) | tr a-z A-Z)) +# Use generic linker script for all Kinetis based CPUs +LINKER_SCRIPT = kinetis.ld + +ROM_START_ADDR = 0x00000000 +RAM_BASE_ADDR = 0x20000000 +RAM_START_ADDR = $$(($(RAM_BASE_ADDR)-($(KINETIS_SRAM_L_SIZE) * 1024))) +ROM_LEN = $$(($(KINETIS_ROMSIZE) * 1024)) +RAM_LEN = $$(($(KINETIS_RAMSIZE) * 1024)) + +CFLAGS += \ + -DKINETIS_CORE_$(KINETIS_CORE) \ + -DKINETIS_SERIES_$(KINETIS_SERIES) \ + -DKINETIS_FAMILY=$(KINETIS_FAMILY) \ + -DKINETIS_SUBFAMILY=$(KINETIS_SUBFAMILY) \ + -DKINETIS_ROMSIZE=$(KINETIS_ROMSIZE) \ + # + +LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_rom_start_addr=$(ROM_START_ADDR) +LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_ram_base_addr=$(RAM_BASE_ADDR) +LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_ram_start_addr=$(RAM_START_ADDR) +LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_rom_length=$(ROM_LEN) +LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_ram_length=$(RAM_LEN) # add the CPU specific code for the linker export UNDEF += $(BINDIR)/kinetis_common/fcfield.o diff --git a/cpu/kinetis_common/ldscripts/kinetis.ld b/cpu/kinetis_common/ldscripts/kinetis.ld index cad7f77ba6..35060e709a 100644 --- a/cpu/kinetis_common/ldscripts/kinetis.ld +++ b/cpu/kinetis_common/ldscripts/kinetis.ld @@ -1,6 +1,6 @@ /* * Copyright (C) 2015 PHYTEC Messtechnik GmbH - * Copyright (C) 2015 Eistec AB + * Copyright (C) 2015-2017 Eistec AB * * 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 @@ -19,6 +19,19 @@ * * @} */ +OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") +OUTPUT_ARCH(arm) + +_vectors_length = 0x400; +_flashsec_length = 0x10; + +MEMORY +{ + vectors (rx) : ORIGIN = _rom_start_addr, LENGTH = _vectors_length + flashsec (rx) : ORIGIN = _rom_start_addr + _vectors_length, LENGTH = _flashsec_length + rom (rx) : ORIGIN = _rom_start_addr + _vectors_length + _flashsec_length, LENGTH = _rom_length - (_vectors_length + _flashsec_length) + ram (rwx) : ORIGIN = _ram_start_addr, LENGTH = _ram_length +} SECTIONS { diff --git a/cpu/kinetis_common/ldscripts/kinetis_f1024l64u192.ld b/cpu/kinetis_common/ldscripts/kinetis_f1024l64u192.ld deleted file mode 100644 index dd6b9e75c5..0000000000 --- a/cpu/kinetis_common/ldscripts/kinetis_f1024l64u192.ld +++ /dev/null @@ -1,18 +0,0 @@ -/* - * NXP Kinetis CPU with the following memory layout: - * 1024 kB flash @ 0x00000000 - * 256 kB RAM, split into two banks: 64 kB SRAM_L, 192 kB SRAM_U. - * SRAM_L ends at 0x1fffffff, SRAM_U begins at 0x20000000 - */ -OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") -OUTPUT_ARCH(arm) - -MEMORY -{ - vectors (rx) : ORIGIN = 0x00000000, LENGTH = 0x400 - flashsec (rx) : ORIGIN = 0x00000400, LENGTH = 0x10 - rom (rx) : ORIGIN = 0x00000410, LENGTH = 1024K - 0x410 - ram (rwx) : ORIGIN = 0x20000000 - 64K, LENGTH = 256K -} - -INCLUDE kinetis.ld diff --git a/cpu/kinetis_common/ldscripts/kinetis_f256l16u16.ld b/cpu/kinetis_common/ldscripts/kinetis_f256l16u16.ld deleted file mode 100644 index 04ca281718..0000000000 --- a/cpu/kinetis_common/ldscripts/kinetis_f256l16u16.ld +++ /dev/null @@ -1,18 +0,0 @@ -/* - * NXP Kinetis CPU with the following memory layout: - * 256 kB flash @ 0x00000000 - * 32 kB RAM, split into two banks: 16 kB SRAM_L, 16 kB SRAM_U. - * SRAM_L ends at 0x1fffffff, SRAM_U begins at 0x20000000 - */ -OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") -OUTPUT_ARCH(arm) - -MEMORY -{ - vectors (rx) : ORIGIN = 0x00000000, LENGTH = 0x400 - flashsec (rx) : ORIGIN = 0x00000400, LENGTH = 0x10 - rom (rx) : ORIGIN = 0x00000410, LENGTH = 256K - 0x410 - ram (rwx) : ORIGIN = 0x20000000 - 16K, LENGTH = 32K -} - -INCLUDE kinetis.ld diff --git a/cpu/kinetis_common/ldscripts/kinetis_f256l32u32.ld b/cpu/kinetis_common/ldscripts/kinetis_f256l32u32.ld deleted file mode 100644 index b05470c124..0000000000 --- a/cpu/kinetis_common/ldscripts/kinetis_f256l32u32.ld +++ /dev/null @@ -1,18 +0,0 @@ -/* - * NXP Kinetis CPU with the following memory layout: - * 256 kB flash @ 0x00000000 - * 64 kB RAM, split into two banks: 32 kB SRAM_L, 32 kB SRAM_U. - * SRAM_L ends at 0x1fffffff, SRAM_U begins at 0x20000000 - */ -OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") -OUTPUT_ARCH(arm) - -MEMORY -{ - vectors (rx) : ORIGIN = 0x00000000, LENGTH = 0x400 - flashsec (rx) : ORIGIN = 0x00000400, LENGTH = 0x10 - rom (rx) : ORIGIN = 0x00000410, LENGTH = 256K - 0x410 - ram (rwx) : ORIGIN = 0x20000000 - 32K, LENGTH = 64K -} - -INCLUDE kinetis.ld diff --git a/cpu/kinetis_common/ldscripts/kinetis_f512l32u32.ld b/cpu/kinetis_common/ldscripts/kinetis_f512l32u32.ld deleted file mode 100644 index db40a5ac30..0000000000 --- a/cpu/kinetis_common/ldscripts/kinetis_f512l32u32.ld +++ /dev/null @@ -1,18 +0,0 @@ -/* - * NXP Kinetis CPU with the following memory layout: - * 512 kB flash @ 0x00000000 - * 64 kB RAM, split into two banks: 32 kB SRAM_L, 32 kB SRAM_U. - * SRAM_L ends at 0x1fffffff, SRAM_U begins at 0x20000000 - */ -OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") -OUTPUT_ARCH(arm) - -MEMORY -{ - vectors (rx) : ORIGIN = 0x00000000, LENGTH = 0x400 - flashsec (rx) : ORIGIN = 0x00000400, LENGTH = 0x10 - rom (rx) : ORIGIN = 0x00000410, LENGTH = 512K - 0x410 - ram (rwx) : ORIGIN = 0x20000000 - 32K, LENGTH = 64K -} - -INCLUDE kinetis.ld diff --git a/cpu/kinetis_common/ldscripts/kinetis_f512l64u64.ld b/cpu/kinetis_common/ldscripts/kinetis_f512l64u64.ld deleted file mode 100644 index d32dc70299..0000000000 --- a/cpu/kinetis_common/ldscripts/kinetis_f512l64u64.ld +++ /dev/null @@ -1,18 +0,0 @@ -/* - * NXP Kinetis CPU with the following memory layout: - * 512 kB flash @ 0x00000000 - * 128 kB RAM, split into two banks: 64 kB SRAM_L, 64 kB SRAM_U. - * SRAM_L ends at 0x1fffffff, SRAM_U begins at 0x20000000 - */ -OUTPUT_FORMAT ("elf32-littlearm", "elf32-bigarm", "elf32-littlearm") -OUTPUT_ARCH(arm) - -MEMORY -{ - vectors (rx) : ORIGIN = 0x00000000, LENGTH = 0x400 - flashsec (rx) : ORIGIN = 0x00000400, LENGTH = 0x10 - rom (rx) : ORIGIN = 0x00000410, LENGTH = 512K - 0x410 - ram (rwx) : ORIGIN = 0x20000000 - 64K, LENGTH = 128K -} - -INCLUDE kinetis.ld From 22c52bd3a837127e34f2fcb8d9abb094e1d8f9c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Fri, 27 Oct 2017 01:26:26 +0200 Subject: [PATCH 3/6] kinetis: Unify all Kinetis CPUs in one directory --- boards/frdm-common/Makefile.include | 6 +- boards/frdm-k22f/Makefile.dep | 2 +- boards/frdm-k22f/Makefile.features | 3 +- boards/frdm-k22f/Makefile.include | 2 +- boards/frdm-k22f/include/periph_conf.h | 2 +- boards/frdm-k64f/Makefile.dep | 2 +- boards/frdm-k64f/Makefile.features | 3 +- boards/frdm-k64f/Makefile.include | 2 +- boards/frdm-k64f/include/periph_conf.h | 2 +- boards/mulle/Makefile.dep | 4 +- boards/mulle/Makefile.features | 3 +- boards/mulle/Makefile.include | 8 +- boards/mulle/include/periph_conf.h | 2 +- boards/pba-d-01-kw2x/Makefile.dep | 2 +- boards/pba-d-01-kw2x/Makefile.features | 3 +- boards/pba-d-01-kw2x/Makefile.include | 10 +- boards/pba-d-01-kw2x/include/periph_conf.h | 2 +- cpu/k22f/Makefile | 7 - cpu/k22f/Makefile.dep | 1 - cpu/k22f/Makefile.features | 1 - cpu/k22f/Makefile.include | 22 ---- cpu/k60/Makefile | 7 - cpu/k60/Makefile.features | 1 - cpu/k60/Makefile.include | 19 --- cpu/k60/include/cpu_conf.h | 51 -------- cpu/k60/periph/Makefile | 1 - cpu/k64f/Makefile | 7 - cpu/k64f/Makefile.dep | 1 - cpu/k64f/Makefile.features | 1 - cpu/k64f/Makefile.include | 19 --- cpu/k64f/include/cpu_conf.h | 45 ------- cpu/k64f/periph/Makefile | 1 - cpu/kinetis/Makefile | 10 ++ cpu/{kinetis_common => kinetis}/Makefile.dep | 0 cpu/kinetis/Makefile.features | 5 + .../Makefile.include | 21 ++- cpu/{kinetis_common => kinetis}/cpu.c | 2 +- cpu/{kinetis_common => kinetis}/dist/Makefile | 0 .../dist/README.md | 0 .../dist/calc_spi_scalers/Makefile | 0 .../dist/calc_spi_scalers/calc_spi_scalers.c | 0 .../dist/check-fcfield-elf.sh | 0 .../dist/check-fcfield-hex.sh | 0 .../dist/wdog-disable.s | 0 cpu/{kinetis_common => kinetis}/doc.txt | 76 +++++------ cpu/{kinetis_common => kinetis}/fcfield.c | 2 +- cpu/kinetis/include/cpu_conf.h | 50 ++++++++ .../include/cpu_conf_kinetis.h | 2 +- cpu/kinetis/include/cpu_conf_kinetis_k.h | 120 ++++++++++++++++++ .../include/cpu_conf_kinetis_l.h} | 25 ++-- cpu/kinetis/include/cpu_conf_kinetis_m.h | 40 ++++++ cpu/kinetis/include/cpu_conf_kinetis_v.h | 40 ++++++ cpu/kinetis/include/cpu_conf_kinetis_w.h | 79 ++++++++++++ cpu/{kinetis_common => kinetis}/include/mcg.h | 4 +- .../include/periph_cpu.h | 2 +- .../include/vectors_kinetis.h | 0 .../include/vendor/MK22F12.h | 0 .../include/vendor/MK22F12810.h | 0 .../include/vendor/MK22F25612.h | 0 .../include/vendor/MK22F51212.h | 0 .../include/vendor/MK22FA12.h | 0 cpu/{k60 => kinetis}/include/vendor/MK60D10.h | 0 .../include/vendor/MK64F12.h | 0 .../include/vendor/MKW21D5.h | 0 .../include/vendor/MKW22D5.h | 0 .../include/vendor/MKW24D5.h | 0 .../include/wdog.h | 4 +- cpu/{kinetis_common => kinetis}/isr_kinetis.c | 2 +- .../kinetis-info.mk | 0 .../ldscripts/kinetis.ld | 0 cpu/{k22f => kinetis}/periph/Makefile | 0 cpu/{kinetis_common => kinetis}/periph/adc.c | 2 +- cpu/{kinetis_common => kinetis}/periph/dac.c | 2 +- cpu/{kinetis_common => kinetis}/periph/gpio.c | 2 +- .../periph/hwrng.c | 2 +- cpu/{kinetis_common => kinetis}/periph/i2c.c | 0 cpu/{kinetis_common => kinetis}/periph/mcg.c | 2 +- cpu/{kinetis_common => kinetis}/periph/pm.c | 2 +- cpu/{kinetis_common => kinetis}/periph/pwm.c | 2 +- cpu/{kinetis_common => kinetis}/periph/rtc.c | 2 +- cpu/{kinetis_common => kinetis}/periph/rtt.c | 2 +- cpu/{kinetis_common => kinetis}/periph/spi.c | 2 +- .../periph/timer.c | 2 +- cpu/{kinetis_common => kinetis}/periph/uart.c | 2 +- cpu/{kinetis_common => kinetis}/periph/wdog.c | 2 +- cpu/{kinetis_common => kinetis}/vectors.c | 0 cpu/kinetis_common/Makefile | 9 -- cpu/kinetis_common/Makefile.features | 4 - cpu/kinetis_common/periph/Makefile | 3 - cpu/kinetis_common/periph/hwrng_rngb.c | 73 ----------- cpu/kw2xd/Makefile | 7 - cpu/kw2xd/Makefile.dep | 1 - cpu/kw2xd/Makefile.features | 1 - cpu/kw2xd/Makefile.include | 20 --- cpu/kw2xd/include/cpu_conf.h | 94 -------------- cpu/kw2xd/periph/Makefile | 1 - doc/doxygen/src/mainpage.md | 2 +- 97 files changed, 454 insertions(+), 513 deletions(-) delete mode 100644 cpu/k22f/Makefile delete mode 100644 cpu/k22f/Makefile.dep delete mode 100644 cpu/k22f/Makefile.features delete mode 100644 cpu/k22f/Makefile.include delete mode 100644 cpu/k60/Makefile delete mode 100644 cpu/k60/Makefile.features delete mode 100644 cpu/k60/Makefile.include delete mode 100644 cpu/k60/include/cpu_conf.h delete mode 100644 cpu/k60/periph/Makefile delete mode 100644 cpu/k64f/Makefile delete mode 100644 cpu/k64f/Makefile.dep delete mode 100644 cpu/k64f/Makefile.features delete mode 100644 cpu/k64f/Makefile.include delete mode 100644 cpu/k64f/include/cpu_conf.h delete mode 100644 cpu/k64f/periph/Makefile create mode 100644 cpu/kinetis/Makefile rename cpu/{kinetis_common => kinetis}/Makefile.dep (100%) create mode 100644 cpu/kinetis/Makefile.features rename cpu/{kinetis_common => kinetis}/Makefile.include (69%) rename cpu/{kinetis_common => kinetis}/cpu.c (96%) rename cpu/{kinetis_common => kinetis}/dist/Makefile (100%) rename cpu/{kinetis_common => kinetis}/dist/README.md (100%) rename cpu/{kinetis_common => kinetis}/dist/calc_spi_scalers/Makefile (100%) rename cpu/{kinetis_common => kinetis}/dist/calc_spi_scalers/calc_spi_scalers.c (100%) rename cpu/{kinetis_common => kinetis}/dist/check-fcfield-elf.sh (100%) rename cpu/{kinetis_common => kinetis}/dist/check-fcfield-hex.sh (100%) rename cpu/{kinetis_common => kinetis}/dist/wdog-disable.s (100%) rename cpu/{kinetis_common => kinetis}/doc.txt (89%) rename cpu/{kinetis_common => kinetis}/fcfield.c (97%) create mode 100644 cpu/kinetis/include/cpu_conf.h rename cpu/{kinetis_common => kinetis}/include/cpu_conf_kinetis.h (98%) create mode 100644 cpu/kinetis/include/cpu_conf_kinetis_k.h rename cpu/{k22f/include/cpu_conf.h => kinetis/include/cpu_conf_kinetis_l.h} (60%) create mode 100644 cpu/kinetis/include/cpu_conf_kinetis_m.h create mode 100644 cpu/kinetis/include/cpu_conf_kinetis_v.h create mode 100644 cpu/kinetis/include/cpu_conf_kinetis_w.h rename cpu/{kinetis_common => kinetis}/include/mcg.h (98%) rename cpu/{kinetis_common => kinetis}/include/periph_cpu.h (99%) rename cpu/{kinetis_common => kinetis}/include/vectors_kinetis.h (100%) rename cpu/{k22f => kinetis}/include/vendor/MK22F12.h (100%) rename cpu/{k22f => kinetis}/include/vendor/MK22F12810.h (100%) rename cpu/{k22f => kinetis}/include/vendor/MK22F25612.h (100%) rename cpu/{k22f => kinetis}/include/vendor/MK22F51212.h (100%) rename cpu/{k22f => kinetis}/include/vendor/MK22FA12.h (100%) rename cpu/{k60 => kinetis}/include/vendor/MK60D10.h (100%) rename cpu/{k64f => kinetis}/include/vendor/MK64F12.h (100%) rename cpu/{kw2xd => kinetis}/include/vendor/MKW21D5.h (100%) rename cpu/{kw2xd => kinetis}/include/vendor/MKW22D5.h (100%) rename cpu/{kw2xd => kinetis}/include/vendor/MKW24D5.h (100%) rename cpu/{kinetis_common => kinetis}/include/wdog.h (94%) rename cpu/{kinetis_common => kinetis}/isr_kinetis.c (99%) rename cpu/{kinetis_common => kinetis}/kinetis-info.mk (100%) rename cpu/{kinetis_common => kinetis}/ldscripts/kinetis.ld (100%) rename cpu/{k22f => kinetis}/periph/Makefile (100%) rename cpu/{kinetis_common => kinetis}/periph/adc.c (99%) rename cpu/{kinetis_common => kinetis}/periph/dac.c (98%) rename cpu/{kinetis_common => kinetis}/periph/gpio.c (99%) rename cpu/{kinetis_common => kinetis}/periph/hwrng.c (97%) rename cpu/{kinetis_common => kinetis}/periph/i2c.c (100%) rename cpu/{kinetis_common => kinetis}/periph/mcg.c (99%) rename cpu/{kinetis_common => kinetis}/periph/pm.c (96%) rename cpu/{kinetis_common => kinetis}/periph/pwm.c (99%) rename cpu/{kinetis_common => kinetis}/periph/rtc.c (98%) rename cpu/{kinetis_common => kinetis}/periph/rtt.c (99%) rename cpu/{kinetis_common => kinetis}/periph/spi.c (99%) rename cpu/{kinetis_common => kinetis}/periph/timer.c (99%) rename cpu/{kinetis_common => kinetis}/periph/uart.c (99%) rename cpu/{kinetis_common => kinetis}/periph/wdog.c (98%) rename cpu/{kinetis_common => kinetis}/vectors.c (100%) delete mode 100644 cpu/kinetis_common/Makefile delete mode 100644 cpu/kinetis_common/Makefile.features delete mode 100644 cpu/kinetis_common/periph/Makefile delete mode 100644 cpu/kinetis_common/periph/hwrng_rngb.c delete mode 100644 cpu/kw2xd/Makefile delete mode 100644 cpu/kw2xd/Makefile.dep delete mode 100644 cpu/kw2xd/Makefile.features delete mode 100644 cpu/kw2xd/Makefile.include delete mode 100644 cpu/kw2xd/include/cpu_conf.h delete mode 100644 cpu/kw2xd/periph/Makefile diff --git a/boards/frdm-common/Makefile.include b/boards/frdm-common/Makefile.include index b88c3a260e..b88ed26267 100644 --- a/boards/frdm-common/Makefile.include +++ b/boards/frdm-common/Makefile.include @@ -19,12 +19,12 @@ ifeq (1,$(USE_OLD_OPENOCD)) # wdog-disable.bin is a precompiled binary which will disable the watchdog and # return control to the debugger (OpenOCD) export OPENOCD_PRE_VERIFY_CMDS += \ - -c 'load_image $(RIOTCPU)/kinetis_common/dist/wdog-disable.bin 0x20000000 bin' \ + -c 'load_image $(RIOTCPU)/$(CPU)/dist/wdog-disable.bin 0x20000000 bin' \ -c 'resume 0x20000000' export OPENOCD_EXTRA_INIT .PHONY: flash -flash: $(RIOTCPU)/kinetis_common/dist/wdog-disable.bin +flash: $(RIOTCPU)/$(CPU)/dist/wdog-disable.bin # Reset the default goal. .DEFAULT_GOAL := @@ -36,7 +36,7 @@ endif export OPENOCD_CONFIG ?= $(RIOTBOARD)/frdm-common/dist/openocd-$(FRDM_IFACE)-$(CPU_FAMILY).cfg # Check the flash configuration field before flashing -export PRE_FLASH_CHECK_SCRIPT = $(RIOTCPU)/kinetis_common/dist/check-fcfield-elf.sh +export PRE_FLASH_CHECK_SCRIPT = $(RIOTCPU)/$(CPU)/dist/check-fcfield-elf.sh # setup serial terminal include $(RIOTMAKE)/tools/serial.inc.mk diff --git a/boards/frdm-k22f/Makefile.dep b/boards/frdm-k22f/Makefile.dep index 6ff51fd647..a73981801a 100644 --- a/boards/frdm-k22f/Makefile.dep +++ b/boards/frdm-k22f/Makefile.dep @@ -3,4 +3,4 @@ ifneq (,$(filter saul_default,$(USEMODULE))) USEMODULE += saul_adc endif --include $(RIOTCPU)/k22f/Makefile.dep +include $(RIOTCPU)/kinetis/Makefile.dep diff --git a/boards/frdm-k22f/Makefile.features b/boards/frdm-k22f/Makefile.features index b9d64e4911..6a5f7c94c3 100644 --- a/boards/frdm-k22f/Makefile.features +++ b/boards/frdm-k22f/Makefile.features @@ -1,6 +1,5 @@ # Put defined MCU peripherals here (in alphabetical order) FEATURES_PROVIDED += periph_adc -FEATURES_PROVIDED += periph_gpio FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_rtc @@ -12,4 +11,4 @@ FEATURES_PROVIDED += periph_uart # The board MPU family (used for grouping by the CI system) FEATURES_MCU_GROUP = cortex_m4_1 --include $(RIOTCPU)/k22f/Makefile.features +include $(RIOTCPU)/kinetis/Makefile.features diff --git a/boards/frdm-k22f/Makefile.include b/boards/frdm-k22f/Makefile.include index 5251374c92..d6d6feec03 100644 --- a/boards/frdm-k22f/Makefile.include +++ b/boards/frdm-k22f/Makefile.include @@ -1,5 +1,5 @@ # define the cpu used by the board -export CPU = k22f +export CPU = kinetis export CPU_MODEL = mk22fn512vlh12 # Include default FRDM board config diff --git a/boards/frdm-k22f/include/periph_conf.h b/boards/frdm-k22f/include/periph_conf.h index ea8e753bfa..937399c377 100644 --- a/boards/frdm-k22f/include/periph_conf.h +++ b/boards/frdm-k22f/include/periph_conf.h @@ -161,7 +161,7 @@ static const pwm_conf_t pwm_config[] = { * Clock configuration values based on the configured 48Mhz module clock. * * Auto-generated by: - * cpu/kinetis_common/dist/calc_spi_scalers/calc_spi_scalers.c + * cpu/kinetis/dist/calc_spi_scalers/calc_spi_scalers.c * * @{ */ diff --git a/boards/frdm-k64f/Makefile.dep b/boards/frdm-k64f/Makefile.dep index 45e7479a38..98782c48fb 100644 --- a/boards/frdm-k64f/Makefile.dep +++ b/boards/frdm-k64f/Makefile.dep @@ -1 +1 @@ --include $(RIOTCPU)/k64f/Makefile.dep +include $(RIOTCPU)/kinetis/Makefile.dep diff --git a/boards/frdm-k64f/Makefile.features b/boards/frdm-k64f/Makefile.features index 0c12be814e..6a5f7c94c3 100644 --- a/boards/frdm-k64f/Makefile.features +++ b/boards/frdm-k64f/Makefile.features @@ -1,6 +1,5 @@ # Put defined MCU peripherals here (in alphabetical order) FEATURES_PROVIDED += periph_adc -FEATURES_PROVIDED += periph_gpio FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_rtc @@ -12,4 +11,4 @@ FEATURES_PROVIDED += periph_uart # The board MPU family (used for grouping by the CI system) FEATURES_MCU_GROUP = cortex_m4_1 --include $(RIOTCPU)/k64f/Makefile.features +include $(RIOTCPU)/kinetis/Makefile.features diff --git a/boards/frdm-k64f/Makefile.include b/boards/frdm-k64f/Makefile.include index 4747c0d791..0599e132bd 100644 --- a/boards/frdm-k64f/Makefile.include +++ b/boards/frdm-k64f/Makefile.include @@ -1,5 +1,5 @@ # define the cpu used by the FRDM-K64F board -export CPU = k64f +export CPU = kinetis export CPU_MODEL = mk64fn1m0vll12 # Include default FRDM board config diff --git a/boards/frdm-k64f/include/periph_conf.h b/boards/frdm-k64f/include/periph_conf.h index ba79176c59..f99f67e4f4 100644 --- a/boards/frdm-k64f/include/periph_conf.h +++ b/boards/frdm-k64f/include/periph_conf.h @@ -156,7 +156,7 @@ static const pwm_conf_t pwm_config[] = { * Clock configuration values based on the configured 30Mhz module clock. * * Auto-generated by: - * cpu/kinetis_common/dist/calc_spi_scalers/calc_spi_scalers.c + * cpu/kinetis/dist/calc_spi_scalers/calc_spi_scalers.c * * @{ */ diff --git a/boards/mulle/Makefile.dep b/boards/mulle/Makefile.dep index fe3cb539a2..f6ca7bf86e 100644 --- a/boards/mulle/Makefile.dep +++ b/boards/mulle/Makefile.dep @@ -12,10 +12,12 @@ USEMODULE += nvram USEMODULE += devfs USEMODULE += mtd_spi_nor -# mulle always uses it's rtt +# mulle always uses the rtt for the oscillator USEMODULE += periph_rtt ifneq (,$(filter saul_default,$(USEMODULE))) USEMODULE += saul_gpio USEMODULE += saul_adc endif + +include $(RIOTCPU)/kinetis/Makefile.dep diff --git a/boards/mulle/Makefile.features b/boards/mulle/Makefile.features index 519a78a3f4..83519b33a0 100644 --- a/boards/mulle/Makefile.features +++ b/boards/mulle/Makefile.features @@ -1,7 +1,6 @@ # Put defined MCU peripherals here (in alphabetical order) FEATURES_PROVIDED += periph_adc FEATURES_PROVIDED += periph_dac -FEATURES_PROVIDED += periph_gpio FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_rtc @@ -13,4 +12,4 @@ FEATURES_PROVIDED += periph_uart # The board MPU family (used for grouping by the CI system) FEATURES_MCU_GROUP = cortex_m4_2 --include $(RIOTCPU)/k60/Makefile.features +include $(RIOTCPU)/kinetis/Makefile.features diff --git a/boards/mulle/Makefile.include b/boards/mulle/Makefile.include index fa6f4baa7a..620be56ca0 100644 --- a/boards/mulle/Makefile.include +++ b/boards/mulle/Makefile.include @@ -1,5 +1,5 @@ # define the cpu used by the Mulle board -export CPU = k60 +export CPU = kinetis # Default GDB port export GDBPORT ?= 3333 @@ -84,13 +84,13 @@ endif # wdog-disable.bin is a precompiled binary which will disable the watchdog and # return control to the debugger (OpenOCD) export OPENOCD_PRE_VERIFY_CMDS += \ - -c 'load_image $(RIOTCPU)/kinetis_common/dist/wdog-disable.bin 0x20000000 bin' \ + -c 'load_image $(RIOTCPU)/$(CPU)/dist/wdog-disable.bin 0x20000000 bin' \ -c 'resume 0x20000000' export OPENOCD_EXTRA_INIT -export PRE_FLASH_CHECK_SCRIPT = $(RIOTCPU)/kinetis_common/dist/check-fcfield-elf.sh +export PRE_FLASH_CHECK_SCRIPT = $(RIOTCPU)/$(CPU)/dist/check-fcfield-elf.sh .PHONY: flash -flash: $(RIOTCPU)/kinetis_common/dist/wdog-disable.bin +flash: $(RIOTCPU)/$(CPU)/dist/wdog-disable.bin # Reset the default goal. .DEFAULT_GOAL := diff --git a/boards/mulle/include/periph_conf.h b/boards/mulle/include/periph_conf.h index 8be821e343..d9a3dd0c45 100644 --- a/boards/mulle/include/periph_conf.h +++ b/boards/mulle/include/periph_conf.h @@ -238,7 +238,7 @@ static const pwm_conf_t pwm_config[] = { * Clock configuration values based on the configured 47988736Hz module clock. * * Auto-generated by: - * cpu/kinetis_common/dist/calc_spi_scalers/calc_spi_scalers.c + * cpu/kinetis/dist/calc_spi_scalers/calc_spi_scalers.c * * @{ */ diff --git a/boards/pba-d-01-kw2x/Makefile.dep b/boards/pba-d-01-kw2x/Makefile.dep index 28cd67a5dc..d35a2e11ea 100644 --- a/boards/pba-d-01-kw2x/Makefile.dep +++ b/boards/pba-d-01-kw2x/Makefile.dep @@ -12,4 +12,4 @@ ifneq (,$(filter saul_default,$(USEMODULE))) USEMODULE += tmp006 endif --include $(RIOTCPU)/kw2xd/Makefile.dep +include $(RIOTCPU)/kinetis/Makefile.dep diff --git a/boards/pba-d-01-kw2x/Makefile.features b/boards/pba-d-01-kw2x/Makefile.features index 51ba5500b9..ee69accdd4 100644 --- a/boards/pba-d-01-kw2x/Makefile.features +++ b/boards/pba-d-01-kw2x/Makefile.features @@ -1,6 +1,5 @@ # Put defined MCU peripherals here (in alphabetical order) FEATURES_PROVIDED += periph_adc -FEATURES_PROVIDED += periph_gpio FEATURES_PROVIDED += periph_i2c FEATURES_PROVIDED += periph_pwm FEATURES_PROVIDED += periph_rtc @@ -12,4 +11,4 @@ FEATURES_PROVIDED += periph_uart # The board MPU family (used for grouping by the CI system) FEATURES_MCU_GROUP = cortex_m4_3 --include $(RIOTCPU)/kw2xd/Makefile.features +include $(RIOTCPU)/kinetis/Makefile.features diff --git a/boards/pba-d-01-kw2x/Makefile.include b/boards/pba-d-01-kw2x/Makefile.include index 7d9871dd4d..84b620e03d 100644 --- a/boards/pba-d-01-kw2x/Makefile.include +++ b/boards/pba-d-01-kw2x/Makefile.include @@ -1,10 +1,10 @@ # define the cpu used by the phyWAVE-KW22 board -export CPU = kw2xd +export CPU = kinetis # the pba-d-01-kw2x board can embed either a kw21d256, kw21d512 or kw22d512 cpu. # The default set up is kw21d256, the variable is overrideable to use the other # cpu if needed. -export CPU_MODEL ?= kw21d256 +export CPU_MODEL ?= mkw21d256vha5 export MCPU = cortex-m4 @@ -13,7 +13,7 @@ PORT_LINUX ?= /dev/ttyACM0 PORT_DARWIN ?= $(firstword $(sort $(wildcard /dev/tty.usbmodem*))) .PHONY: flash -flash: $(RIOTCPU)/kinetis_common/dist/wdog-disable.bin +flash: $(RIOTCPU)/$(CPU)/dist/wdog-disable.bin # Reset the default goal. .DEFAULT_GOAL := @@ -23,10 +23,10 @@ flash: $(RIOTCPU)/kinetis_common/dist/wdog-disable.bin # wdog-disable.bin is a precompiled binary which will disable the watchdog and # return control to the debugger (OpenOCD) export OPENOCD_PRE_VERIFY_CMDS += \ - -c 'load_image $(RIOTCPU)/kinetis_common/dist/wdog-disable.bin 0x20000000 bin' \ + -c 'load_image $(RIOTCPU)/$(CPU)/dist/wdog-disable.bin 0x20000000 bin' \ -c 'resume 0x20000000' export OPENOCD_EXTRA_INIT -export PRE_FLASH_CHECK_SCRIPT = $(RIOTCPU)/kinetis_common/dist/check-fcfield-elf.sh +export PRE_FLASH_CHECK_SCRIPT = $(RIOTCPU)/$(CPU)/dist/check-fcfield-elf.sh # Add board selector (USB serial) to OpenOCD options if specified. # Use /dist/tools/usb-serial/list-ttys.sh to find out serial number. diff --git a/boards/pba-d-01-kw2x/include/periph_conf.h b/boards/pba-d-01-kw2x/include/periph_conf.h index 25ea7dbdb1..1e11edfe90 100644 --- a/boards/pba-d-01-kw2x/include/periph_conf.h +++ b/boards/pba-d-01-kw2x/include/periph_conf.h @@ -171,7 +171,7 @@ static const pwm_conf_t pwm_config[] = { * Clock configuration values based on the configured 48Mhz module clock. * * Auto-generated by: - * cpu/kinetis_common/dist/calc_spi_scalers/calc_spi_scalers.c + * cpu/kinetis/dist/calc_spi_scalers/calc_spi_scalers.c * * @{ */ diff --git a/cpu/k22f/Makefile b/cpu/k22f/Makefile deleted file mode 100644 index 4e53b72929..0000000000 --- a/cpu/k22f/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# define the module that is build -MODULE = cpu - -# add a list of subdirectories that should also be built -DIRS = periph $(RIOTCPU)/cortexm_common $(KINETIS_COMMON) - -include $(RIOTBASE)/Makefile.base diff --git a/cpu/k22f/Makefile.dep b/cpu/k22f/Makefile.dep deleted file mode 100644 index 419f33923e..0000000000 --- a/cpu/k22f/Makefile.dep +++ /dev/null @@ -1 +0,0 @@ --include $(RIOTCPU)/kinetis_common/Makefile.dep diff --git a/cpu/k22f/Makefile.features b/cpu/k22f/Makefile.features deleted file mode 100644 index e08d42cd26..0000000000 --- a/cpu/k22f/Makefile.features +++ /dev/null @@ -1 +0,0 @@ --include $(RIOTCPU)/kinetis_common/Makefile.features diff --git a/cpu/k22f/Makefile.include b/cpu/k22f/Makefile.include deleted file mode 100644 index 6d51867500..0000000000 --- a/cpu/k22f/Makefile.include +++ /dev/null @@ -1,22 +0,0 @@ -# define the CPU architecture for the k22f -export CPU_ARCH = cortex-m4 -export CPU_FAMILY = kx - -# map CPU models to generic Kinetis linker script -LD_MK22FN512VLH12 = kinetis_f512l64u64.ld -LD_MK22FN512VLL12 = kinetis_f512l64u64.ld -LD_MK22FN512VDC12 = kinetis_f512l64u64.ld -LD_MK22FN512VMP12 = kinetis_f512l64u64.ld - -# tell the build system that the CPU depends on the Kinetis common files -export USEMODULE += kinetis_common - -# define path to kinetis module, which is needed for this CPU -export KINETIS_COMMON = $(RIOTCPU)/kinetis_common/ -# CPU depends on the kinetis module, so include it -include $(KINETIS_COMMON)Makefile.include - -# this CPU implementation is using kinetis common startup -export COMMON_STARTUP = $(KINETIS_COMMON) - -include $(RIOTMAKE)/arch/cortexm.inc.mk diff --git a/cpu/k60/Makefile b/cpu/k60/Makefile deleted file mode 100644 index 12ba41f9cf..0000000000 --- a/cpu/k60/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# define the module that is build -MODULE = cpu - -# add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common $(KINETIS_COMMON) - -include $(RIOTBASE)/Makefile.base diff --git a/cpu/k60/Makefile.features b/cpu/k60/Makefile.features deleted file mode 100644 index e08d42cd26..0000000000 --- a/cpu/k60/Makefile.features +++ /dev/null @@ -1 +0,0 @@ --include $(RIOTCPU)/kinetis_common/Makefile.features diff --git a/cpu/k60/Makefile.include b/cpu/k60/Makefile.include deleted file mode 100644 index f5fb578716..0000000000 --- a/cpu/k60/Makefile.include +++ /dev/null @@ -1,19 +0,0 @@ -# define the CPU architecture for the k60 -export CPU_ARCH = cortex-m4 - -# map CPU models to generic Kinetis linkerscript -LD_MK60DN256VLL10 = kinetis_f256l16u16.ld -LD_MK60DN512VLL10 = kinetis_f512l64u64.ld - -# tell the build system that the CPU depends on the Kinetis common files -export USEMODULE += kinetis_common - -# define path to kinetis module, which is needed for this CPU -export KINETIS_COMMON = $(RIOTCPU)/kinetis_common/ -# CPU depends on the kinetis module, so include it -include $(KINETIS_COMMON)Makefile.include - -# this CPU implementation is using kinetis common startup -export COMMON_STARTUP = $(KINETIS_COMMON) - -include $(RIOTMAKE)/arch/cortexm.inc.mk diff --git a/cpu/k60/include/cpu_conf.h b/cpu/k60/include/cpu_conf.h deleted file mode 100644 index 942d954bcd..0000000000 --- a/cpu/k60/include/cpu_conf.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (C) 2015 Eistec AB - * - * This file is subject to the terms and conditions of the GNU Lesser General - * Public License v2.1. See the file LICENSE in the top level directory for more - * details. - */ - -/** - * @defgroup cpu_k60 NXP Kinetis K60 - * @ingroup cpu - * @brief CPU specific implementations for the NXP Kinetis K60 - * Cortex-M4 MCU - * @{ - * - * @file - * @brief Implementation specific CPU configuration options - * - * @author Joakim Nohlgård - */ - -#ifndef CPU_CONF_H -#define CPU_CONF_H - -#if defined(CPU_MODEL_MK60DN512VLL10) || defined(CPU_MODEL_MK60DN256VLL10) -#include "vendor/MK60D10.h" - -/* K60 rev 2.x replaced the RNG module in 1.x by the RNGA PRNG module */ -#define KINETIS_RNGA (RNG) -#else -#error Unknown CPU model. Update Makefile.include in the board directory. -#endif - -#include "cpu_conf_kinetis.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** - * @brief This CPU provides an additional ADC clock divider as CFG1[ADICLK]=1 - */ -#define KINETIS_HAVE_ADICLK_BUS_DIV_2 1 - -#ifdef __cplusplus -} -#endif - -#endif /* CPU_CONF_H */ -/** @} */ diff --git a/cpu/k60/periph/Makefile b/cpu/k60/periph/Makefile deleted file mode 100644 index a36df249ac..0000000000 --- a/cpu/k60/periph/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(RIOTMAKE)/periph.mk diff --git a/cpu/k64f/Makefile b/cpu/k64f/Makefile deleted file mode 100644 index 12ba41f9cf..0000000000 --- a/cpu/k64f/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# define the module that is build -MODULE = cpu - -# add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common $(KINETIS_COMMON) - -include $(RIOTBASE)/Makefile.base diff --git a/cpu/k64f/Makefile.dep b/cpu/k64f/Makefile.dep deleted file mode 100644 index 419f33923e..0000000000 --- a/cpu/k64f/Makefile.dep +++ /dev/null @@ -1 +0,0 @@ --include $(RIOTCPU)/kinetis_common/Makefile.dep diff --git a/cpu/k64f/Makefile.features b/cpu/k64f/Makefile.features deleted file mode 100644 index e08d42cd26..0000000000 --- a/cpu/k64f/Makefile.features +++ /dev/null @@ -1 +0,0 @@ --include $(RIOTCPU)/kinetis_common/Makefile.features diff --git a/cpu/k64f/Makefile.include b/cpu/k64f/Makefile.include deleted file mode 100644 index 3d0eb9a1cd..0000000000 --- a/cpu/k64f/Makefile.include +++ /dev/null @@ -1,19 +0,0 @@ -# define the CPU architecture for the k64f -export CPU_ARCH = cortex-m4 -export CPU_FAMILY = kx - -# map CPU models to generic Kinetis linkerscript -LD_MK64FN1M0VLL12 = kinetis_f1024l64u192.ld - -# tell the build system that the CPU depends on the Kinetis common files -export USEMODULE += kinetis_common - -# define path to kinetis module, which is needed for this CPU -export KINETIS_COMMON = $(RIOTCPU)/kinetis_common/ -# CPU depends on the kinetis module, so include it -include $(KINETIS_COMMON)Makefile.include - -# this CPU implementation is using kinetis common startup -export COMMON_STARTUP = $(KINETIS_COMMON) - -include $(RIOTMAKE)/arch/cortexm.inc.mk diff --git a/cpu/k64f/include/cpu_conf.h b/cpu/k64f/include/cpu_conf.h deleted file mode 100644 index ce8840a030..0000000000 --- a/cpu/k64f/include/cpu_conf.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2015 Freie Universität Berlin - * Copyright (C) 2015 PHYTEC Messtechnik 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. - */ - -/** - * @defgroup cpu_k64f NXP Kinetis K64F - * @ingroup cpu - * @brief CPU specific implementations for the NXP Kinetis K64F - * Cortex-M4 MCU - * @{ - * - * @file - * @brief Implementation specific CPU configuration options - * - * @author Hauke Petersen - * @author Johann Fischer - */ - -#ifndef CPU_CONF_H -#define CPU_CONF_H - -#ifdef CPU_MODEL_MK64FN1M0VLL12 -#include "vendor/MK64F12.h" -#else -#error "undefined CPU_MODEL" -#endif - -#include "cpu_conf_kinetis.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* CPU_CONF_H */ -/** @} */ diff --git a/cpu/k64f/periph/Makefile b/cpu/k64f/periph/Makefile deleted file mode 100644 index a36df249ac..0000000000 --- a/cpu/k64f/periph/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(RIOTMAKE)/periph.mk diff --git a/cpu/kinetis/Makefile b/cpu/kinetis/Makefile new file mode 100644 index 0000000000..88d8b3d2f0 --- /dev/null +++ b/cpu/kinetis/Makefile @@ -0,0 +1,10 @@ +# define the module that is build +MODULE = cpu + +# add a list of subdirectories that should also be built +DIRS = periph $(RIOTCPU)/cortexm_common + +# (file triggers compiler bug. see https://github.com/RIOT-OS/RIOT/issues/5775) +SRC_NOLTO += vectors.c + +include $(RIOTBASE)/Makefile.base diff --git a/cpu/kinetis_common/Makefile.dep b/cpu/kinetis/Makefile.dep similarity index 100% rename from cpu/kinetis_common/Makefile.dep rename to cpu/kinetis/Makefile.dep diff --git a/cpu/kinetis/Makefile.features b/cpu/kinetis/Makefile.features new file mode 100644 index 0000000000..2045a3cedd --- /dev/null +++ b/cpu/kinetis/Makefile.features @@ -0,0 +1,5 @@ +FEATURES_PROVIDED += periph_cpuid +FEATURES_PROVIDED += periph_hwrng +FEATURES_PROVIDED += periph_gpio + +include $(RIOTCPU)/cortexm_common/Makefile.features diff --git a/cpu/kinetis_common/Makefile.include b/cpu/kinetis/Makefile.include similarity index 69% rename from cpu/kinetis_common/Makefile.include rename to cpu/kinetis/Makefile.include index 24ece8ab4c..046337a006 100644 --- a/cpu/kinetis_common/Makefile.include +++ b/cpu/kinetis/Makefile.include @@ -4,11 +4,8 @@ ifeq (,$(KINETIS_SERIES)) include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/kinetis-info.mk endif -# include module specific includes -export INCLUDES += -I$(RIOTCPU)/kinetis_common/include - # Add search path for linker scripts -export LINKFLAGS += -L$(RIOTCPU)/kinetis_common/ldscripts +LINKFLAGS += -L$(RIOTCPU)/$(CPU)/ldscripts # Use generic linker script for all Kinetis based CPUs LINKER_SCRIPT = kinetis.ld @@ -33,14 +30,10 @@ LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_ram_start_addr=$(RAM_START_ADDR) LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_rom_length=$(ROM_LEN) LINKFLAGS += $(LINKFLAGPREFIX)--defsym=_ram_length=$(RAM_LEN) -# add the CPU specific code for the linker -export UNDEF += $(BINDIR)/kinetis_common/fcfield.o +# add the CPU specific flash configuration field for the linker +export UNDEF += $(BINDIR)/cpu/fcfield.o -# add the CPU specific interrupt vector table definition for the linker -export UNDEF += $(BINDIR)/kinetis_common/vectors.o - -# include kinetis common periph drivers -USEMODULE += kinetis_common_periph +# include common periph drivers USEMODULE += periph_common # select kinetis periph drivers @@ -48,8 +41,10 @@ USEMODULE += periph_mcg USEMODULE += periph_wdog # Define a recipe to build the watchdog disable binary, used when flashing -$(RIOTCPU)/kinetis_common/dist/wdog-disable.bin: $(RIOTCPU)/kinetis_common/dist/wdog-disable.s - $(Q)$(MAKE) -C $(RIOTCPU)/kinetis_common/dist/ $(notdir $@) +$(RIOTCPU)/$(CPU)/dist/wdog-disable.bin: $(RIOTCPU)/$(CPU)/dist/wdog-disable.s + $(Q)$(MAKE) -C $(RIOTCPU)/$(CPU)/dist/ $(notdir $@) # Reset the default goal to not make wdog-disable.bin the default target. .DEFAULT_GOAL := + +include $(RIOTMAKE)/arch/cortexm.inc.mk diff --git a/cpu/kinetis_common/cpu.c b/cpu/kinetis/cpu.c similarity index 96% rename from cpu/kinetis_common/cpu.c rename to cpu/kinetis/cpu.c index b4182c7334..2460cb7894 100644 --- a/cpu/kinetis_common/cpu.c +++ b/cpu/kinetis/cpu.c @@ -7,7 +7,7 @@ */ /** - * @ingroup cpu_kinetis_common + * @ingroup cpu_kinetis * @{ * * @file diff --git a/cpu/kinetis_common/dist/Makefile b/cpu/kinetis/dist/Makefile similarity index 100% rename from cpu/kinetis_common/dist/Makefile rename to cpu/kinetis/dist/Makefile diff --git a/cpu/kinetis_common/dist/README.md b/cpu/kinetis/dist/README.md similarity index 100% rename from cpu/kinetis_common/dist/README.md rename to cpu/kinetis/dist/README.md diff --git a/cpu/kinetis_common/dist/calc_spi_scalers/Makefile b/cpu/kinetis/dist/calc_spi_scalers/Makefile similarity index 100% rename from cpu/kinetis_common/dist/calc_spi_scalers/Makefile rename to cpu/kinetis/dist/calc_spi_scalers/Makefile diff --git a/cpu/kinetis_common/dist/calc_spi_scalers/calc_spi_scalers.c b/cpu/kinetis/dist/calc_spi_scalers/calc_spi_scalers.c similarity index 100% rename from cpu/kinetis_common/dist/calc_spi_scalers/calc_spi_scalers.c rename to cpu/kinetis/dist/calc_spi_scalers/calc_spi_scalers.c diff --git a/cpu/kinetis_common/dist/check-fcfield-elf.sh b/cpu/kinetis/dist/check-fcfield-elf.sh similarity index 100% rename from cpu/kinetis_common/dist/check-fcfield-elf.sh rename to cpu/kinetis/dist/check-fcfield-elf.sh diff --git a/cpu/kinetis_common/dist/check-fcfield-hex.sh b/cpu/kinetis/dist/check-fcfield-hex.sh similarity index 100% rename from cpu/kinetis_common/dist/check-fcfield-hex.sh rename to cpu/kinetis/dist/check-fcfield-hex.sh diff --git a/cpu/kinetis_common/dist/wdog-disable.s b/cpu/kinetis/dist/wdog-disable.s similarity index 100% rename from cpu/kinetis_common/dist/wdog-disable.s rename to cpu/kinetis/dist/wdog-disable.s diff --git a/cpu/kinetis_common/doc.txt b/cpu/kinetis/doc.txt similarity index 89% rename from cpu/kinetis_common/doc.txt rename to cpu/kinetis/doc.txt index 0eddb15312..d1461f2fbb 100644 --- a/cpu/kinetis_common/doc.txt +++ b/cpu/kinetis/doc.txt @@ -1,13 +1,13 @@ /** - * @defgroup cpu_kinetis_common NXP Kinetis MCU + * @defgroup cpu_kinetis NXP Kinetis * @ingroup cpu - * @brief NXP Kinetis CPU peripheral drivers + * @brief NXP Kinetis Cortex-M MCU specific implementation */ /** - * @defgroup cpu_kinetis_common_adc Kinetis ADC - * @ingroup cpu_kinetis_common - * @brief ADC driver + * @defgroup cpu_kinetis_adc Kinetis ADC + * @ingroup cpu_kinetis + * @brief Kinetis ADC driver * * ### ADC configuration example (for periph_conf.h) ### * @@ -25,17 +25,17 @@ */ /** - * @defgroup cpu_kinetis_common_cpuid Kinetis CPUID - * @ingroup cpu_kinetis_common - * @brief CPUID driver + * @defgroup cpu_kinetis_cpuid Kinetis CPUID + * @ingroup cpu_kinetis + * @brief Kinetis CPUID driver * * No configuration is necessary. */ /** - * @defgroup cpu_kinetis_common_gpio Kinetis GPIO - * @ingroup cpu_kinetis_common - * @brief GPIO driver + * @defgroup cpu_kinetis_gpio Kinetis GPIO + * @ingroup cpu_kinetis + * @brief Kinetis GPIO driver * * The GPIO driver uses the @ref GPIO_PIN(port, pin) macro to declare pins. * @@ -43,9 +43,9 @@ */ /** - * @defgroup cpu_kinetis_common_i2c Kinetis I2C - * @ingroup cpu_kinetis_common - * @brief I2C driver + * @defgroup cpu_kinetis_i2c Kinetis I2C + * @ingroup cpu_kinetis + * @brief Kinetis I2C driver * * ### I2C configuration example (for periph_conf.h) ### * @@ -81,9 +81,9 @@ */ /** - * @defgroup cpu_kinetis_common_pwm Kinetis PWM - * @ingroup cpu_kinetis_common - * @brief PWM driver + * @defgroup cpu_kinetis_pwm Kinetis PWM + * @ingroup cpu_kinetis + * @brief Kinetis PWM driver * * ### PWM configuration example (for periph_conf.h) ### * @@ -112,9 +112,9 @@ */ /** - * @defgroup cpu_kinetis_common_rnga Kinetis RNGA - * @ingroup cpu_kinetis_common - * @brief Driver for Freescale's RNGA module. RNGA generates data that + * @defgroup cpu_kinetis_rnga Kinetis RNGA + * @ingroup cpu_kinetis + * @brief Driver for NXP Kinetis RNGA module. RNGA generates data that * looks random. Reference Manual recommends to use the RNGA as entropy * source. * @@ -127,10 +127,10 @@ */ /** - * @defgroup cpu_kinetis_common_rngb Kinetis RNGB - * @ingroup cpu_kinetis_common + * @defgroup cpu_kinetis_rngb Kinetis RNGB + * @ingroup cpu_kinetis * @brief Low-level random number generator driver implementation. - * Driver for Freescale's RNGB module. RNGB generates data that + * Driver for NXP Kinetis RNGB module. RNGB generates data that * looks random. Reference Manual recommends to use the RNGB as entropy * source. * @@ -143,9 +143,12 @@ */ /** - * @defgroup cpu_kinetis_common_rtc Kinetis RTC - * @ingroup cpu_kinetis_common - * @brief RTC is clocked by a 32.768 kHz clock. + * @defgroup cpu_kinetis_rtc Kinetis RTC + * @ingroup cpu_kinetis + * @brief Kinetis RTC driver + * + * RTC is clocked by a 32.768 kHz clock. + * * Please note the manual of your MCU or SiP for the * clock setting for the RTC module. After initialization * Time Seconds Register (TSR) increments once a second. @@ -168,16 +171,16 @@ */ /** - * @defgroup cpu_kinetis_common_spi Kinetis SPI - * @ingroup cpu_kinetis_common - * @brief Kinetis SPI driver for MCUs with Cortex-M4 core. + * @defgroup cpu_kinetis_spi Kinetis SPI + * @ingroup cpu_kinetis + * @brief Kinetis SPI driver * * The SPI baud rate and other timings are generated from the bus * clock via prescalers, the hardware module allows for very * detailed timing configuration, but a tool exists to generate a * standard timing configuration for any given module clock frequency. * The timing configuration tool is found in - * cpu/kinetis_common/dist/calc_spi_scalers + * cpu/kinetis/dist/calc_spi_scalers * * Finer tuning of timings than the RIOT SPI API is capable of is * supported by modifying the generated configuration. See the @@ -203,7 +206,7 @@ * ### SPI configuration example (for periph_conf.h): ### * * static const uint32_t spi_clk_config[] = { - * // Use cpu/kinetis_common/dist/calc_spi_scalers to + * // Use cpu/kinetis/dist/calc_spi_scalers to * // generate the timing configuration * }; * @@ -244,8 +247,8 @@ */ /** - * @defgroup cpu_kinetis_common_timer Kinetis Timer - * @ingroup cpu_kinetis_common + * @defgroup cpu_kinetis_timer Kinetis Timer + * @ingroup cpu_kinetis * @brief Periodic Interrupt Timer (PIT) and Low-Power Timer (LPTMR) driver. * * The PIT is a count down timer, in order to use it with riot-os @@ -289,9 +292,10 @@ */ /** - * @defgroup cpu_kinetis_common_uart Kinetis UART - * @ingroup cpu_kinetis_common - * @brief Kinetis UART driver. + * @defgroup cpu_kinetis_uart Kinetis UART + * @ingroup cpu_kinetis + * @brief Kinetis UART driver + * * There are different implementations of the UART interface. * The treatment of interrupts is also slightly different. * The register UARTx_BDH to UARTx_C4 look almost the same. diff --git a/cpu/kinetis_common/fcfield.c b/cpu/kinetis/fcfield.c similarity index 97% rename from cpu/kinetis_common/fcfield.c rename to cpu/kinetis/fcfield.c index b09202416d..10e986919d 100644 --- a/cpu/kinetis_common/fcfield.c +++ b/cpu/kinetis/fcfield.c @@ -8,7 +8,7 @@ */ /** - * @ingroup cpu_kinetis_common + * @ingroup cpu_kinetis * @{ * * @file diff --git a/cpu/kinetis/include/cpu_conf.h b/cpu/kinetis/include/cpu_conf.h new file mode 100644 index 0000000000..c3391b19fe --- /dev/null +++ b/cpu/kinetis/include/cpu_conf.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) 2017 Eistec AB + * + * 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_kinetis + * @{ + * + * @file + * @brief Implementation specific CPU configuration options + * + * @author Joakim Nohlgård + */ + +#ifndef CPU_CONF_H +#define CPU_CONF_H + +/* Dispatch to a separate file per family */ +#if defined(KINETIS_SERIES_K) +#include "cpu_conf_kinetis_k.h" +#elif defined(KINETIS_SERIES_L) +#include "cpu_conf_kinetis_l.h" +#elif defined(KINETIS_SERIES_M) +#include "cpu_conf_kinetis_m.h" +#elif defined(KINETIS_SERIES_V) +#include "cpu_conf_kinetis_v.h" +#elif defined(KINETIS_SERIES_W) +#include "cpu_conf_kinetis_w.h" +#endif /* defined(KINETIS_SERIES_x) */ + +#ifndef MCU_MEM_MAP_VERSION +#error Missing vendor header for the chosen CPU_MODEL +#endif +#include "cpu_conf_kinetis.h" + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* CPU_CONF_H */ +/** @} */ diff --git a/cpu/kinetis_common/include/cpu_conf_kinetis.h b/cpu/kinetis/include/cpu_conf_kinetis.h similarity index 98% rename from cpu/kinetis_common/include/cpu_conf_kinetis.h rename to cpu/kinetis/include/cpu_conf_kinetis.h index 6a2299b595..dd5ef1da83 100644 --- a/cpu/kinetis_common/include/cpu_conf_kinetis.h +++ b/cpu/kinetis/include/cpu_conf_kinetis.h @@ -7,7 +7,7 @@ */ /** - * @ingroup cpu_kinetis_common + * @ingroup cpu_kinetis * @{ * * @file diff --git a/cpu/kinetis/include/cpu_conf_kinetis_k.h b/cpu/kinetis/include/cpu_conf_kinetis_k.h new file mode 100644 index 0000000000..9a3ac1aa27 --- /dev/null +++ b/cpu/kinetis/include/cpu_conf_kinetis_k.h @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2017 Eistec AB + * + * 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_kinetis + * @brief CPU specific implementations for the NXP Kinetis K series of + * Cortex-M MCUs + * @{ + * + * @file + * @brief Implementation specific CPU configuration options + * + * @author Joakim Nohlgård + */ + +#ifndef CPU_CONF_KINETIS_K_H +#define CPU_CONF_KINETIS_K_H + +#if (KINETIS_FAMILY == 2) +#if (KINETIS_SUBFAMILY == 2) +/* Kinetis K22 */ +#if defined(CPU_MODEL_MK22FX512VLH12) || \ + defined(CPU_MODEL_MK22FN1M0VLH12) || \ + defined(CPU_MODEL_MK22FX512VLK12) || \ + defined(CPU_MODEL_MK22FN1M0VLK12) || \ + defined(CPU_MODEL_MK22FX512VLL12) || \ + defined(CPU_MODEL_MK22FN1M0VLL12) || \ + defined(CPU_MODEL_MK22FX512VLQ12) || \ + defined(CPU_MODEL_MK22FN1M0VLQ12) || \ + defined(CPU_MODEL_MK22FX512VMC12) || \ + defined(CPU_MODEL_MK22FN1M0VMC12) || \ + defined(CPU_MODEL_MK22FX512VMD12) || \ + defined(CPU_MODEL_MK22FN1M0VMD12) +#include "vendor/MK22F12.h" +#elif defined(CPU_MODEL_MK22FN128VDC10) || \ + defined(CPU_MODEL_MK22FN128VLH10) || \ + defined(CPU_MODEL_MK22FN128VLL10) || \ + defined(CPU_MODEL_MK22FN128VMP10) +#include "vendor/MK22F12810.h" +#elif defined(CPU_MODEL_MK22FN128CAH12) || \ + defined(CPU_MODEL_MK22FN256CAH12) || \ + defined(CPU_MODEL_MK22FN256VDC12) || \ + defined(CPU_MODEL_MK22FN256VLH12) || \ + defined(CPU_MODEL_MK22FN256VLL12) || \ + defined(CPU_MODEL_MK22FN256VMP12) +#include "vendor/MK22F25612.h" +#elif defined(CPU_MODEL_MK22FN512CAP12) || \ + defined(CPU_MODEL_MK22FN512VDC12) || \ + defined(CPU_MODEL_MK22FN512VFX12) || \ + defined(CPU_MODEL_MK22FN512VLH12) || \ + defined(CPU_MODEL_MK22FN512VLL12) || \ + defined(CPU_MODEL_MK22FN512VMP12) +#include "vendor/MK22F51212.h" +#elif defined(CPU_MODEL_MK22FN1M0AVLH12) || \ + defined(CPU_MODEL_MK22FN1M0AVLK12) || \ + defined(CPU_MODEL_MK22FN1M0AVLL12) || \ + defined(CPU_MODEL_MK22FN1M0AVLQ12) || \ + defined(CPU_MODEL_MK22FN1M0AVMC12) || \ + defined(CPU_MODEL_MK22FN1M0AVMD12) || \ + defined(CPU_MODEL_MK22FX512AVLH12) || \ + defined(CPU_MODEL_MK22FX512AVLK12) || \ + defined(CPU_MODEL_MK22FX512AVLL12) || \ + defined(CPU_MODEL_MK22FX512AVLQ12) || \ + defined(CPU_MODEL_MK22FX512AVMC12) || \ + defined(CPU_MODEL_MK22FX512AVMD12) +#include "vendor/MK22FA12.h" +#endif +#endif /* (KINETIS_SUBFAMILY == y) */ +#elif (KINETIS_FAMILY == 6) +#if (KINETIS_SUBFAMILY == 0) +#if defined(CPU_MODEL_MK60DN256VLL10) || \ + defined(CPU_MODEL_MK60DN256VLQ10) || \ + defined(CPU_MODEL_MK60DN256VMC10) || \ + defined(CPU_MODEL_MK60DN256VMD10) || \ + defined(CPU_MODEL_MK60DN512VLL10) || \ + defined(CPU_MODEL_MK60DN512VLQ10) || \ + defined(CPU_MODEL_MK60DN512VMC10) || \ + defined(CPU_MODEL_MK60DN512VMD10) || \ + defined(CPU_MODEL_MK60DX256VLL10) || \ + defined(CPU_MODEL_MK60DX256VLQ10) || \ + defined(CPU_MODEL_MK60DX256VMC10) || \ + defined(CPU_MODEL_MK60DX256VMD10) +#include "vendor/MK60D10.h" +#endif +/** + * @brief This CPU provides an additional ADC clock divider as CFG1[ADICLK]=1 + */ +#define KINETIS_HAVE_ADICLK_BUS_DIV_2 1 + +#elif (KINETIS_SUBFAMILY == 4) +#if defined(CPU_MODEL_MK64FN1M0CAJ12) || \ + defined(CPU_MODEL_MK64FN1M0VDC12) || \ + defined(CPU_MODEL_MK64FN1M0VLL12) || \ + defined(CPU_MODEL_MK64FN1M0VLQ12) || \ + defined(CPU_MODEL_MK64FN1M0VMD12) || \ + defined(CPU_MODEL_MK64FX512VDC12) || \ + defined(CPU_MODEL_MK64FX512VLL12) || \ + defined(CPU_MODEL_MK64FX512VLQ12) || \ + defined(CPU_MODEL_MK64FX512VMD12) +#include "vendor/MK64F12.h" +#endif +#endif /* (KINETIS_SUBFAMILY == y) */ +#endif /* (KINETIS_FAMILY == x) */ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* CPU_CONF_KINETIS_K_H */ +/** @} */ diff --git a/cpu/k22f/include/cpu_conf.h b/cpu/kinetis/include/cpu_conf_kinetis_l.h similarity index 60% rename from cpu/k22f/include/cpu_conf.h rename to cpu/kinetis/include/cpu_conf_kinetis_l.h index 935d694ea5..e9e446e1b7 100644 --- a/cpu/k22f/include/cpu_conf.h +++ b/cpu/kinetis/include/cpu_conf_kinetis_l.h @@ -7,10 +7,9 @@ */ /** - * @defgroup cpu_k22f NXP Kinetis K22F - * @ingroup cpu - * @brief CPU specific implementations for the NXP Kinetis K22F - * Cortex-M4 MCU + * @ingroup cpu_kinetis + * @brief CPU specific implementations for the NXP Kinetis L series of + * Cortex-M MCUs * @{ * * @file @@ -19,16 +18,14 @@ * @author Joakim Nohlgård */ -#ifndef CPU_CONF_H -#define CPU_CONF_H +#ifndef CPU_CONF_KINETIS_L_H +#define CPU_CONF_KINETIS_L_H -#ifdef CPU_MODEL_MK22FN512VLH12 -#include "vendor/MK22F51212.h" -#else -#error "undefined CPU_MODEL" -#endif - -#include "cpu_conf_kinetis.h" +#if (KINETIS_FAMILY == 2) +#if (KINETIS_SUBFAMILY == 2) +/* Put your vendor includes here */ +#endif /* (KINETIS_SUBFAMILY == y) */ +#endif /* (KINETIS_FAMILY == x) */ #ifdef __cplusplus extern "C" @@ -39,5 +36,5 @@ extern "C" } #endif -#endif /* CPU_CONF_H */ +#endif /* CPU_CONF_KINETIS_L_H */ /** @} */ diff --git a/cpu/kinetis/include/cpu_conf_kinetis_m.h b/cpu/kinetis/include/cpu_conf_kinetis_m.h new file mode 100644 index 0000000000..3df55c0651 --- /dev/null +++ b/cpu/kinetis/include/cpu_conf_kinetis_m.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2017 Eistec AB + * + * 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_kinetis + * @brief CPU specific implementations for the NXP Kinetis M series of + * Cortex-M MCUs + * @{ + * + * @file + * @brief Implementation specific CPU configuration options + * + * @author Joakim Nohlgård + */ + +#ifndef CPU_CONF_KINETIS_M_H +#define CPU_CONF_KINETIS_M_H + +#if (KINETIS_FAMILY == 2) +#if (KINETIS_SUBFAMILY == 2) +/* Put your vendor includes here */ +#endif /* (KINETIS_SUBFAMILY == y) */ +#endif /* (KINETIS_FAMILY == x) */ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* CPU_CONF_KINETIS_M_H */ +/** @} */ diff --git a/cpu/kinetis/include/cpu_conf_kinetis_v.h b/cpu/kinetis/include/cpu_conf_kinetis_v.h new file mode 100644 index 0000000000..bffb164cf1 --- /dev/null +++ b/cpu/kinetis/include/cpu_conf_kinetis_v.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2017 Eistec AB + * + * 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_kinetis + * @brief CPU specific implementations for the NXP Kinetis V series of + * Cortex-M MCUs + * @{ + * + * @file + * @brief Implementation specific CPU configuration options + * + * @author Joakim Nohlgård + */ + +#ifndef CPU_CONF_KINETIS_V_H +#define CPU_CONF_KINETIS_V_H + +#if (KINETIS_FAMILY == 2) +#if (KINETIS_SUBFAMILY == 2) +/* Put your vendor includes here */ +#endif /* (KINETIS_SUBFAMILY == y) */ +#endif /* (KINETIS_FAMILY == x) */ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* CPU_CONF_KINETIS_V_H */ +/** @} */ diff --git a/cpu/kinetis/include/cpu_conf_kinetis_w.h b/cpu/kinetis/include/cpu_conf_kinetis_w.h new file mode 100644 index 0000000000..48ada52039 --- /dev/null +++ b/cpu/kinetis/include/cpu_conf_kinetis_w.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2017 Eistec AB + * + * 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_kinetis + * @brief CPU specific implementations for the NXP Kinetis K series of + * Cortex-M MCUs + * @{ + * + * @file + * @brief Implementation specific CPU configuration options + * + * @author Joakim Nohlgård + */ + +#ifndef CPU_CONF_KINETIS_W_H +#define CPU_CONF_KINETIS_W_H + +#if defined(KINETIS_CORE_D) +/* Kinetis KW2xD */ +#if defined(CPU_MODEL_MKW21D256VHA5) || \ + defined(CPU_MODEL_MKW21D512VHA5) +#include "vendor/MKW21D5.h" +#elif defined(CPU_MODEL_MKW22D512VHA5) +#include "vendor/MKW22D5.h" +#elif defined(CPU_MODEL_MKW24D512VHA5) +#include "vendor/MKW24D5.h" +#endif + +/** + * @brief This CPU provides an additional ADC clock divider as CFG1[ADICLK]=1 + */ +#define KINETIS_HAVE_ADICLK_BUS_DIV_2 1 +/** + * @name KW2XD SiP internal interconnects between MCU and radio + * + * @{ + */ +#define KW2XDRF_PORT_DEV PORTB /**< MCU Port connected to radio*/ +#define KW2XDRF_PORT PORT_B /**< MCU Port connected to radio*/ +#define KW2XDRF_GPIO GPIOB /**< GPIO Device connected to radio */ +#define KW2XDRF_PORT_IRQn PORTB_IRQn +/** Clock Enable for PORTB */ +#define KW2XDRF_PORT_CLKEN() (BITBAND_REG32(SIM->SCGC5, SIM_SCGC5_PORTB_SHIFT) = 1) +#define KW2XDRF_PIN_AF 2 /**< Pin Muxing Parameter for GPIO Device*/ +#define KW2XDRF_PCS0_PIN 10 /**< Radio SPI chip select pin */ +#define KW2XDRF_SCK_PIN 11 /**< Radio SPI clock pin */ +#define KW2XDRF_SOUT_PIN 16 /**< Radio SPI MOSI pin */ +#define KW2XDRF_SIN_PIN 17 /**< Radio SPI MISO pin */ +#define KW2XDRF_RST_PIN 19 /**< Radio reset pin */ +#define KW2XDRF_IRQ_PIN 3 /**< radio IRQ pin (active low) */ +#define KW2XDRF_CLK_CTRL_PORT PORT_C /**< CLK_OUT control pin port */ +#define KW2XDRF_CLK_CTRL_PORT_DEV PORTC /**< CLK_OUT control pin PORT device */ +#define KW2XDRF_CLK_CTRL_GPIO GPIOC /**< CLK_OUT control pin GPIO device */ +#define KW2XDRF_CLK_CTRL_CLKEN() (BITBAND_REG32(SIM->SCGC5, SIM_SCGC5_PORTC_SHIFT) = 1) +#define KW2XDRF_CLK_CTRL_PIN 0 /**< CLK_OUT control pin */ +/** @} */ + +#elif defined(KINETIS_CORE_Z) +/* Kinetis KWxxZ */ +/* TODO */ +#endif /* KINETIS_CORE_x */ + +#ifdef __cplusplus +extern "C" +{ +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* CPU_CONF_KINETIS_W_H */ +/** @} */ diff --git a/cpu/kinetis_common/include/mcg.h b/cpu/kinetis/include/mcg.h similarity index 98% rename from cpu/kinetis_common/include/mcg.h rename to cpu/kinetis/include/mcg.h index 04ebabb56d..241ed38f8a 100644 --- a/cpu/kinetis_common/include/mcg.h +++ b/cpu/kinetis/include/mcg.h @@ -8,8 +8,8 @@ */ /** - * @defgroup cpu_kinetis_common_mcg Kinetis MCG - * @ingroup cpu_kinetis_common + * @defgroup cpu_kinetis_mcg Kinetis MCG + * @ingroup cpu_kinetis * @brief Implementation of the Kinetis Multipurpose Clock Generator * (MCG) driver * diff --git a/cpu/kinetis_common/include/periph_cpu.h b/cpu/kinetis/include/periph_cpu.h similarity index 99% rename from cpu/kinetis_common/include/periph_cpu.h rename to cpu/kinetis/include/periph_cpu.h index 246fb0e87d..ba5f4a2da9 100644 --- a/cpu/kinetis_common/include/periph_cpu.h +++ b/cpu/kinetis/include/periph_cpu.h @@ -7,7 +7,7 @@ */ /** - * @ingroup cpu_kinetis_common + * @ingroup cpu_kinetis * @{ * * @file diff --git a/cpu/kinetis_common/include/vectors_kinetis.h b/cpu/kinetis/include/vectors_kinetis.h similarity index 100% rename from cpu/kinetis_common/include/vectors_kinetis.h rename to cpu/kinetis/include/vectors_kinetis.h diff --git a/cpu/k22f/include/vendor/MK22F12.h b/cpu/kinetis/include/vendor/MK22F12.h similarity index 100% rename from cpu/k22f/include/vendor/MK22F12.h rename to cpu/kinetis/include/vendor/MK22F12.h diff --git a/cpu/k22f/include/vendor/MK22F12810.h b/cpu/kinetis/include/vendor/MK22F12810.h similarity index 100% rename from cpu/k22f/include/vendor/MK22F12810.h rename to cpu/kinetis/include/vendor/MK22F12810.h diff --git a/cpu/k22f/include/vendor/MK22F25612.h b/cpu/kinetis/include/vendor/MK22F25612.h similarity index 100% rename from cpu/k22f/include/vendor/MK22F25612.h rename to cpu/kinetis/include/vendor/MK22F25612.h diff --git a/cpu/k22f/include/vendor/MK22F51212.h b/cpu/kinetis/include/vendor/MK22F51212.h similarity index 100% rename from cpu/k22f/include/vendor/MK22F51212.h rename to cpu/kinetis/include/vendor/MK22F51212.h diff --git a/cpu/k22f/include/vendor/MK22FA12.h b/cpu/kinetis/include/vendor/MK22FA12.h similarity index 100% rename from cpu/k22f/include/vendor/MK22FA12.h rename to cpu/kinetis/include/vendor/MK22FA12.h diff --git a/cpu/k60/include/vendor/MK60D10.h b/cpu/kinetis/include/vendor/MK60D10.h similarity index 100% rename from cpu/k60/include/vendor/MK60D10.h rename to cpu/kinetis/include/vendor/MK60D10.h diff --git a/cpu/k64f/include/vendor/MK64F12.h b/cpu/kinetis/include/vendor/MK64F12.h similarity index 100% rename from cpu/k64f/include/vendor/MK64F12.h rename to cpu/kinetis/include/vendor/MK64F12.h diff --git a/cpu/kw2xd/include/vendor/MKW21D5.h b/cpu/kinetis/include/vendor/MKW21D5.h similarity index 100% rename from cpu/kw2xd/include/vendor/MKW21D5.h rename to cpu/kinetis/include/vendor/MKW21D5.h diff --git a/cpu/kw2xd/include/vendor/MKW22D5.h b/cpu/kinetis/include/vendor/MKW22D5.h similarity index 100% rename from cpu/kw2xd/include/vendor/MKW22D5.h rename to cpu/kinetis/include/vendor/MKW22D5.h diff --git a/cpu/kw2xd/include/vendor/MKW24D5.h b/cpu/kinetis/include/vendor/MKW24D5.h similarity index 100% rename from cpu/kw2xd/include/vendor/MKW24D5.h rename to cpu/kinetis/include/vendor/MKW24D5.h diff --git a/cpu/kinetis_common/include/wdog.h b/cpu/kinetis/include/wdog.h similarity index 94% rename from cpu/kinetis_common/include/wdog.h rename to cpu/kinetis/include/wdog.h index 1f28e8685f..56870adb8e 100644 --- a/cpu/kinetis_common/include/wdog.h +++ b/cpu/kinetis/include/wdog.h @@ -8,8 +8,8 @@ */ /** - * @defgroup cpu_kinetis_common_wdog Kinetis WDOG - * @ingroup cpu_kinetis_common + * @defgroup cpu_kinetis_wdog Kinetis WDOG + * @ingroup cpu_kinetis * @brief Driver for Freescale WDOG device. * There are different implementations of the Watchdog devices. * Currently, it is only possible to turn the Watchdog off. diff --git a/cpu/kinetis_common/isr_kinetis.c b/cpu/kinetis/isr_kinetis.c similarity index 99% rename from cpu/kinetis_common/isr_kinetis.c rename to cpu/kinetis/isr_kinetis.c index 0ce5c0fbaf..2fa00cd8fa 100644 --- a/cpu/kinetis_common/isr_kinetis.c +++ b/cpu/kinetis/isr_kinetis.c @@ -7,7 +7,7 @@ */ /** - * @ingroup cpu_kinetis_common + * @ingroup cpu_kinetis * @{ * * @file diff --git a/cpu/kinetis_common/kinetis-info.mk b/cpu/kinetis/kinetis-info.mk similarity index 100% rename from cpu/kinetis_common/kinetis-info.mk rename to cpu/kinetis/kinetis-info.mk diff --git a/cpu/kinetis_common/ldscripts/kinetis.ld b/cpu/kinetis/ldscripts/kinetis.ld similarity index 100% rename from cpu/kinetis_common/ldscripts/kinetis.ld rename to cpu/kinetis/ldscripts/kinetis.ld diff --git a/cpu/k22f/periph/Makefile b/cpu/kinetis/periph/Makefile similarity index 100% rename from cpu/k22f/periph/Makefile rename to cpu/kinetis/periph/Makefile diff --git a/cpu/kinetis_common/periph/adc.c b/cpu/kinetis/periph/adc.c similarity index 99% rename from cpu/kinetis_common/periph/adc.c rename to cpu/kinetis/periph/adc.c index 15b6fc788c..072c64a6e0 100644 --- a/cpu/kinetis_common/periph/adc.c +++ b/cpu/kinetis/periph/adc.c @@ -9,7 +9,7 @@ */ /** - * @ingroup cpu_kinetis_common + * @ingroup cpu_kinetis * @ingroup drivers_periph_adc * @{ * diff --git a/cpu/kinetis_common/periph/dac.c b/cpu/kinetis/periph/dac.c similarity index 98% rename from cpu/kinetis_common/periph/dac.c rename to cpu/kinetis/periph/dac.c index b8034a6a64..36e4ac0c13 100644 --- a/cpu/kinetis_common/periph/dac.c +++ b/cpu/kinetis/periph/dac.c @@ -7,7 +7,7 @@ */ /** - * @ingroup cpu_kinetis_common + * @ingroup cpu_kinetis * @ingroup drivers_periph_dac * * @{ diff --git a/cpu/kinetis_common/periph/gpio.c b/cpu/kinetis/periph/gpio.c similarity index 99% rename from cpu/kinetis_common/periph/gpio.c rename to cpu/kinetis/periph/gpio.c index f665123c5a..c01ae9fa01 100644 --- a/cpu/kinetis_common/periph/gpio.c +++ b/cpu/kinetis/periph/gpio.c @@ -9,7 +9,7 @@ */ /** - * @ingroup cpu_kinetis_common + * @ingroup cpu_kinetis * @ingroup drivers_periph_gpio * * @{ diff --git a/cpu/kinetis_common/periph/hwrng.c b/cpu/kinetis/periph/hwrng.c similarity index 97% rename from cpu/kinetis_common/periph/hwrng.c rename to cpu/kinetis/periph/hwrng.c index a2d749e6c2..0348102b59 100644 --- a/cpu/kinetis_common/periph/hwrng.c +++ b/cpu/kinetis/periph/hwrng.c @@ -8,7 +8,7 @@ */ /** - * @ingroup cpu_kinetis_common + * @ingroup cpu_kinetis * @ingroup drivers_periph_hwng * * @{ diff --git a/cpu/kinetis_common/periph/i2c.c b/cpu/kinetis/periph/i2c.c similarity index 100% rename from cpu/kinetis_common/periph/i2c.c rename to cpu/kinetis/periph/i2c.c diff --git a/cpu/kinetis_common/periph/mcg.c b/cpu/kinetis/periph/mcg.c similarity index 99% rename from cpu/kinetis_common/periph/mcg.c rename to cpu/kinetis/periph/mcg.c index b5eaa3f734..6179fb1d3f 100644 --- a/cpu/kinetis_common/periph/mcg.c +++ b/cpu/kinetis/periph/mcg.c @@ -8,7 +8,7 @@ */ /** - * @ingroup cpu_kinetis_common + * @ingroup cpu_kinetis * @ingroup drivers_periph_mcg * @{ * diff --git a/cpu/kinetis_common/periph/pm.c b/cpu/kinetis/periph/pm.c similarity index 96% rename from cpu/kinetis_common/periph/pm.c rename to cpu/kinetis/periph/pm.c index 63373a87a9..4a9961ba7a 100644 --- a/cpu/kinetis_common/periph/pm.c +++ b/cpu/kinetis/periph/pm.c @@ -9,7 +9,7 @@ */ /** - * @ingroup cpu_kinetis_common + * @ingroup cpu_kinetis * @ingroup drivers_periph_pm * @{ * diff --git a/cpu/kinetis_common/periph/pwm.c b/cpu/kinetis/periph/pwm.c similarity index 99% rename from cpu/kinetis_common/periph/pwm.c rename to cpu/kinetis/periph/pwm.c index e5494ba58a..5f2fd448b7 100644 --- a/cpu/kinetis_common/periph/pwm.c +++ b/cpu/kinetis/periph/pwm.c @@ -9,7 +9,7 @@ */ /** - * @ingroup cpu_kinetis_common + * @ingroup cpu_kinetis * @ingroup drivers_periph_pwm * * @{ diff --git a/cpu/kinetis_common/periph/rtc.c b/cpu/kinetis/periph/rtc.c similarity index 98% rename from cpu/kinetis_common/periph/rtc.c rename to cpu/kinetis/periph/rtc.c index fe5489fcbd..f0d877a4c9 100644 --- a/cpu/kinetis_common/periph/rtc.c +++ b/cpu/kinetis/periph/rtc.c @@ -7,7 +7,7 @@ */ /** - * @ingroup cpu_kinetis_common + * @ingroup cpu_kinetis * @ingroup drivers_periph_rtc * * @{ diff --git a/cpu/kinetis_common/periph/rtt.c b/cpu/kinetis/periph/rtt.c similarity index 99% rename from cpu/kinetis_common/periph/rtt.c rename to cpu/kinetis/periph/rtt.c index 5fdbed8df6..1f5874bfb7 100644 --- a/cpu/kinetis_common/periph/rtt.c +++ b/cpu/kinetis/periph/rtt.c @@ -8,7 +8,7 @@ */ /** - * @ingroup cpu_kinetis_common + * @ingroup cpu_kinetis * @ingroup drivers_periph_rtt * * @{ diff --git a/cpu/kinetis_common/periph/spi.c b/cpu/kinetis/periph/spi.c similarity index 99% rename from cpu/kinetis_common/periph/spi.c rename to cpu/kinetis/periph/spi.c index 095fa50419..9ed06bd496 100644 --- a/cpu/kinetis_common/periph/spi.c +++ b/cpu/kinetis/periph/spi.c @@ -10,7 +10,7 @@ */ /** - * @ingroup cpu_kinetis_common + * @ingroup cpu_kinetis * @ingroup drivers_periph_spi * * @{ diff --git a/cpu/kinetis_common/periph/timer.c b/cpu/kinetis/periph/timer.c similarity index 99% rename from cpu/kinetis_common/periph/timer.c rename to cpu/kinetis/periph/timer.c index f928944420..ca1ea8130c 100644 --- a/cpu/kinetis_common/periph/timer.c +++ b/cpu/kinetis/periph/timer.c @@ -9,7 +9,7 @@ */ /** - * @ingroup cpu_kinetis_common + * @ingroup cpu_kinetis * @ingroup drivers_periph_timer * * @{ diff --git a/cpu/kinetis_common/periph/uart.c b/cpu/kinetis/periph/uart.c similarity index 99% rename from cpu/kinetis_common/periph/uart.c rename to cpu/kinetis/periph/uart.c index 40b153ad09..892701b57e 100644 --- a/cpu/kinetis_common/periph/uart.c +++ b/cpu/kinetis/periph/uart.c @@ -9,7 +9,7 @@ */ /** - * @ingroup cpu_kinetis_common + * @ingroup cpu_kinetis * @ingroup drivers_periph_uart * * @{ diff --git a/cpu/kinetis_common/periph/wdog.c b/cpu/kinetis/periph/wdog.c similarity index 98% rename from cpu/kinetis_common/periph/wdog.c rename to cpu/kinetis/periph/wdog.c index 530ba7a285..e0c995678a 100644 --- a/cpu/kinetis_common/periph/wdog.c +++ b/cpu/kinetis/periph/wdog.c @@ -8,7 +8,7 @@ */ /** - * @ingroup cpu_kinetis_common + * @ingroup cpu_kinetis * @ingroup drivers_periph_watchdog * * @{ diff --git a/cpu/kinetis_common/vectors.c b/cpu/kinetis/vectors.c similarity index 100% rename from cpu/kinetis_common/vectors.c rename to cpu/kinetis/vectors.c diff --git a/cpu/kinetis_common/Makefile b/cpu/kinetis_common/Makefile deleted file mode 100644 index 8b1b43dea4..0000000000 --- a/cpu/kinetis_common/Makefile +++ /dev/null @@ -1,9 +0,0 @@ -# define the module that is build -MODULE = kinetis_common - -DIRS += periph - -# (file triggers compiler bug. see #5775) -SRC_NOLTO += vectors.c - -include $(RIOTBASE)/Makefile.base diff --git a/cpu/kinetis_common/Makefile.features b/cpu/kinetis_common/Makefile.features deleted file mode 100644 index 894817aedb..0000000000 --- a/cpu/kinetis_common/Makefile.features +++ /dev/null @@ -1,4 +0,0 @@ -FEATURES_PROVIDED += periph_cpuid -FEATURES_PROVIDED += periph_hwrng - --include $(RIOTCPU)/cortexm_common/Makefile.features diff --git a/cpu/kinetis_common/periph/Makefile b/cpu/kinetis_common/periph/Makefile deleted file mode 100644 index 4cc46a1c00..0000000000 --- a/cpu/kinetis_common/periph/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -MODULE = kinetis_common_periph - -include $(RIOTMAKE)/periph.mk diff --git a/cpu/kinetis_common/periph/hwrng_rngb.c b/cpu/kinetis_common/periph/hwrng_rngb.c deleted file mode 100644 index 0a42eccf75..0000000000 --- a/cpu/kinetis_common/periph/hwrng_rngb.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2014-2016 Freie Universität Berlin - * Copyright (C) 2014 PHYTEC Messtechnik GmbH - * Copyright (C) 2015 Eistec AB - * - * 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_kinetis_common - * @ingroup drivers_periph_hwng - * @{ - * - * @file - * @brief HWRNG interface implementation - * - * @author Joakim Nohlgård (adaption for Freescale's RNGB) - * @author Johann Fischer (adaption for Freescale's RNGA) - * @author Hauke Petersen - * - * @} - */ - -#include "cpu.h" -#include "periph/hwrng.h" -#include "periph_conf.h" - -#ifdef KINETIS_RNGB - -void hwrng_init(void) -{ - /* nothing to be done here */ -} - -void hwrng_read(void *buf, unsigned int num) -{ - unsigned int count = 0; - uint8_t *b = (uint8_t *)buf; - - HWRNG_CLKEN(); - - if ((KINETIS_RNGB->VER & RNG_VER_TYPE_MASK) != 0b0001) { - /* Wrong type of RNG */ - /* TODO: Handle */ - } - - /* Software reset, bit is self-clearing */ - BITBAND_REG32(KINETIS_RNGB->CMD, RNG_CMD_SR_SHIFT) = 1; - /* Set up automatic reseed */ - KINETIS_RNGB->CR = RNG_CR_AR_MASK | RNG_CR_MASKERR_MASK | RNG_CR_MASKDONE_MASK; - - while (count < num) { - uint32_t tmp; - - /* wait for random data to be ready to read */ - while (!(KINETIS_RNGB->SR & RNG_SR_FIFO_LVL_MASK)); - - tmp = KINETIS_RNGB->OUT; - - /* copy data into result vector */ - for (int i = 0; i < 4 && count < num; i++) { - b[count++] = (uint8_t)tmp; - tmp = tmp >> 8; - } - } - - KINETIS_RNGB->CR = 0; - HWRNG_CLKDIS(); -} - -#endif /* KINETIS_RNGB */ diff --git a/cpu/kw2xd/Makefile b/cpu/kw2xd/Makefile deleted file mode 100644 index 12ba41f9cf..0000000000 --- a/cpu/kw2xd/Makefile +++ /dev/null @@ -1,7 +0,0 @@ -# define the module that is build -MODULE = cpu - -# add a list of subdirectories, that should also be build -DIRS = periph $(RIOTCPU)/cortexm_common $(KINETIS_COMMON) - -include $(RIOTBASE)/Makefile.base diff --git a/cpu/kw2xd/Makefile.dep b/cpu/kw2xd/Makefile.dep deleted file mode 100644 index 419f33923e..0000000000 --- a/cpu/kw2xd/Makefile.dep +++ /dev/null @@ -1 +0,0 @@ --include $(RIOTCPU)/kinetis_common/Makefile.dep diff --git a/cpu/kw2xd/Makefile.features b/cpu/kw2xd/Makefile.features deleted file mode 100644 index e08d42cd26..0000000000 --- a/cpu/kw2xd/Makefile.features +++ /dev/null @@ -1 +0,0 @@ --include $(RIOTCPU)/kinetis_common/Makefile.features diff --git a/cpu/kw2xd/Makefile.include b/cpu/kw2xd/Makefile.include deleted file mode 100644 index 7d634d17e5..0000000000 --- a/cpu/kw2xd/Makefile.include +++ /dev/null @@ -1,20 +0,0 @@ -# define the CPU architecture for the kw2xd -export CPU_ARCH = cortex-m4 - -# map CPU models to generic Kinetis linkerscript -LD_KW21D256 = kinetis_f256l16u16.ld -LD_KW21D512 = kinetis_f512l32u32.ld -LD_KW22D512 = kinetis_f512l32u32.ld - -# tell the build system that the CPU depends on the Kinetis common files -export USEMODULE += kinetis_common - -# define path to kinetis module, which is needed for this CPU -export KINETIS_COMMON = $(RIOTCPU)/kinetis_common/ -# CPU depends on the kinetis module, so include it -include $(KINETIS_COMMON)Makefile.include - -# this CPU implementation is using kinetis common startup -export COMMON_STARTUP = $(KINETIS_COMMON) - -include $(RIOTMAKE)/arch/cortexm.inc.mk diff --git a/cpu/kw2xd/include/cpu_conf.h b/cpu/kw2xd/include/cpu_conf.h deleted file mode 100644 index 53331f54ed..0000000000 --- a/cpu/kw2xd/include/cpu_conf.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) 2014 Freie Universität Berlin - * Copyright (C) 2014 PHYTEC Messtechnik 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. - */ - -/** - * @defgroup cpu_kw2xd NXP Kinetis KW2xD - * @ingroup cpu - * @brief CPU specific implementations for the NXP Kinetis KW2xD SiP - * - * The SiP incorporates a low power 2.4 GHz transceiver, and a - * Kinetis Cortex-M4 MCU. - * - * From the register map and functional description it seems - * like the transceiver is a close relative of the NXP MCR20A. - * @{ - * - * @file - * @brief Implementation specific CPU configuration options - * - * @author Hauke Petersen - * @author Johann Fischer - */ - -#ifndef CPU_CONF_H -#define CPU_CONF_H - -#ifdef CPU_MODEL_KW21D256 -#include "vendor/MKW22D5.h" -#elif CPU_MODEL_KW21D512 -#include "vendor/MKW22D5.h" -#elif CPU_MODEL_KW22D512 -#include "vendor/MKW22D5.h" -#else -#error "undefined CPU_MODEL" -#endif - -#include "cpu_conf_kinetis.h" - -#ifdef __cplusplus -extern "C" -{ -#endif - -/** - * @brief This CPU provides an additional ADC clock divider as CFG1[ADICLK]=1 - */ -#define KINETIS_HAVE_ADICLK_BUS_DIV_2 1 - -/** @name PORT module clock gates */ -/** @{ */ -#define PORTA_CLOCK_GATE (BITBAND_REG32(SIM->SCGC5, SIM_SCGC5_PORTA_SHIFT)) -#define PORTB_CLOCK_GATE (BITBAND_REG32(SIM->SCGC5, SIM_SCGC5_PORTB_SHIFT)) -#define PORTC_CLOCK_GATE (BITBAND_REG32(SIM->SCGC5, SIM_SCGC5_PORTC_SHIFT)) -#define PORTD_CLOCK_GATE (BITBAND_REG32(SIM->SCGC5, SIM_SCGC5_PORTD_SHIFT)) -#define PORTE_CLOCK_GATE (BITBAND_REG32(SIM->SCGC5, SIM_SCGC5_PORTE_SHIFT)) -/** @} */ - -/** - * @name KW2XD SiP internal interconnects between MCU and Modem. - * - * @{ - */ -#define KW2XDRF_PORT_DEV PORTB /**< MCU Port connected to Modem*/ -#define KW2XDRF_PORT PORT_B /**< MCU Port connected to Modem*/ -#define KW2XDRF_GPIO GPIOB /**< GPIO Device connected to Modem */ -#define KW2XDRF_PORT_IRQn PORTB_IRQn -/** Clock Enable for PORTB*/ -#define KW2XDRF_PORT_CLKEN() (PORTB_CLOCK_GATE = 1) -#define KW2XDRF_PIN_AF 2 /**< Pin Muxing Parameter for GPIO Device*/ -#define KW2XDRF_PCS0_PIN 10 /**< SPI Slave Select Pin */ -#define KW2XDRF_SCK_PIN 11 /**< SPI Clock Output Pin */ -#define KW2XDRF_SOUT_PIN 16 /**< SPI Master Data Output Pin */ -#define KW2XDRF_SIN_PIN 17 /**< SPI Master Data Input Pin */ -#define KW2XDRF_RST_PIN 19 /**< Reset pin */ -#define KW2XDRF_IRQ_PIN 3 /**< Modem's IRQ Output (activ low) */ -#define KW2XDRF_CLK_CTRL_PORT PORT_C /**< CLK_OUT control pin port */ -#define KW2XDRF_CLK_CTRL_PORT_DEV PORTC /**< CLK_OUT control pin PORT device */ -#define KW2XDRF_CLK_CTRL_GPIO GPIOC /**< CLK_OUT control pin GPIO device */ -#define KW2XDRF_CLK_CTRL_CLKEN() (PORTC_CLOCK_GATE = 1) -#define KW2XDRF_CLK_CTRL_PIN 0 /**< CLK_OUT control pin */ - -/** @} */ - -#ifdef __cplusplus -} -#endif - -#endif /* CPU_CONF_H */ -/** @} */ diff --git a/cpu/kw2xd/periph/Makefile b/cpu/kw2xd/periph/Makefile deleted file mode 100644 index a36df249ac..0000000000 --- a/cpu/kw2xd/periph/Makefile +++ /dev/null @@ -1 +0,0 @@ -include $(RIOTMAKE)/periph.mk diff --git a/doc/doxygen/src/mainpage.md b/doc/doxygen/src/mainpage.md index 2fcadd9394..e3c5adaf1e 100644 --- a/doc/doxygen/src/mainpage.md +++ b/doc/doxygen/src/mainpage.md @@ -150,7 +150,7 @@ CPUs share the same code for task switching and interrupt handling). This shared code is put in its own directories, following a `xxxxx_common` naming scheme. Examples for this is code shared across architectures (e.g. `cortexm_common`, `msp430_comon`) or code shared among vendors (e.g. -`kinetis_common`). +`stm32_common`). See @ref cpu for more detailed informtation. From 19d407a3e9c3de6b541a25b577bcbeb5a7f5ce28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Sat, 28 Oct 2017 17:17:13 +0200 Subject: [PATCH 4/6] kinetis: Add script for generating vendor header include lines --- .../generate-header-includes.awk | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 cpu/kinetis/dist/generate-cpu-files/generate-header-includes.awk diff --git a/cpu/kinetis/dist/generate-cpu-files/generate-header-includes.awk b/cpu/kinetis/dist/generate-cpu-files/generate-header-includes.awk new file mode 100644 index 0000000000..19f699a316 --- /dev/null +++ b/cpu/kinetis/dist/generate-cpu-files/generate-header-includes.awk @@ -0,0 +1,22 @@ +# Usage: awk -f vendor/MKxxxx.h vendor/MKxxyy.h vendor/MKzzz.h ... +/Processor[s]?:/ { + i=0; + if (FNR == NR) { + printf "#if"; + } else { + printf "#elif"; + } + while(match($0, /MK.*/)) { + if (i>0) { + printf " || \\\n "; + } + printf " defined(CPU_MODEL_%s)", substr($0, RSTART, RLENGTH); + getline; + i++; + } + printf("\n#include \"%s\"\n", FILENAME); + nextfile; +} +END { + print "#endif" +} From 925a908d957f11e40d2935130232322109cedd83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Thu, 9 Nov 2017 08:01:43 +0100 Subject: [PATCH 5/6] kinetis: Update RNGA driver configuration to automatically detect the module --- boards/frdm-k22f/include/periph_conf.h | 9 --------- boards/frdm-k64f/include/periph_conf.h | 9 --------- boards/mulle/include/periph_conf.h | 9 --------- boards/pba-d-01-kw2x/include/periph_conf.h | 10 ---------- cpu/kinetis/include/cpu_conf_kinetis.h | 16 ++++++++++++++++ cpu/kinetis/periph/hwrng.c | 3 ++- 6 files changed, 18 insertions(+), 38 deletions(-) diff --git a/boards/frdm-k22f/include/periph_conf.h b/boards/frdm-k22f/include/periph_conf.h index 937399c377..2fbdf8c2c1 100644 --- a/boards/frdm-k22f/include/periph_conf.h +++ b/boards/frdm-k22f/include/periph_conf.h @@ -269,15 +269,6 @@ static const spi_conf_t spi_config[] = { #define RTT_MAX_VALUE (0xffffffff) /** @} */ -/** - * @name Random Number Generator configuration - * @{ - */ -#define KINETIS_RNGA RNG -#define HWRNG_CLKEN() (SIM->SCGC6 |= (1 << 9)) -#define HWRNG_CLKDIS() (SIM->SCGC6 &= ~(1 << 9)) -/** @} */ - #ifdef __cplusplus } #endif diff --git a/boards/frdm-k64f/include/periph_conf.h b/boards/frdm-k64f/include/periph_conf.h index f99f67e4f4..2e01656a61 100644 --- a/boards/frdm-k64f/include/periph_conf.h +++ b/boards/frdm-k64f/include/periph_conf.h @@ -264,15 +264,6 @@ static const spi_conf_t spi_config[] = { #define RTT_MAX_VALUE (0xffffffff) /** @} */ -/** - * @name Random Number Generator configuration - * @{ - */ -#define KINETIS_RNGA RNG -#define HWRNG_CLKEN() (SIM->SCGC6 |= (1 << 9)) -#define HWRNG_CLKDIS() (SIM->SCGC6 &= ~(1 << 9)) -/** @} */ - #ifdef __cplusplus } #endif diff --git a/boards/mulle/include/periph_conf.h b/boards/mulle/include/periph_conf.h index d9a3dd0c45..87dc49346c 100644 --- a/boards/mulle/include/periph_conf.h +++ b/boards/mulle/include/periph_conf.h @@ -392,15 +392,6 @@ static const spi_conf_t spi_config[] = { /** @} */ - -/** - * @name Random Number Generator configuration - * @{ - */ -#define HWRNG_CLKEN() (BITBAND_REG32(SIM->SCGC3, SIM_SCGC3_RNGA_SHIFT) = 1) -#define HWRNG_CLKDIS() (BITBAND_REG32(SIM->SCGC3, SIM_SCGC3_RNGA_SHIFT) = 0) -/** @} */ - #ifdef __cplusplus } #endif diff --git a/boards/pba-d-01-kw2x/include/periph_conf.h b/boards/pba-d-01-kw2x/include/periph_conf.h index 1e11edfe90..461569f538 100644 --- a/boards/pba-d-01-kw2x/include/periph_conf.h +++ b/boards/pba-d-01-kw2x/include/periph_conf.h @@ -295,16 +295,6 @@ static const spi_conf_t spi_config[] = { #define RTT_MAX_VALUE (0xffffffff) /** @} */ -/** - * @name Random Number Generator configuration - * @{ - */ -#define KINETIS_RNGA RNG -#define HWRNG_CLKEN() (SIM->SCGC6 |= (1 << 9)) -#define HWRNG_CLKDIS() (SIM->SCGC6 &= ~(1 << 9)) - -/** @} */ - #ifdef __cplusplus } #endif diff --git a/cpu/kinetis/include/cpu_conf_kinetis.h b/cpu/kinetis/include/cpu_conf_kinetis.h index dd5ef1da83..135bdc9d09 100644 --- a/cpu/kinetis/include/cpu_conf_kinetis.h +++ b/cpu/kinetis/include/cpu_conf_kinetis.h @@ -112,6 +112,22 @@ extern "C" #endif /** @} */ +/** + * @name Hardware random number generator module configuration + * @{ + */ +#if !defined(HWRNG_CLKEN) && defined(RNG) && !defined(RNG_CMD_ST_MASK) +#define KINETIS_RNGA RNG +#if defined(SIM_SCGC3_RNGA_SHIFT) +#define HWRNG_CLKEN() (bit_set32(&SIM->SCGC3, SIM_SCGC3_RNGA_SHIFT)) +#define HWRNG_CLKDIS() (bit_clear32(&SIM->SCGC3, SIM_SCGC3_RNGA_SHIFT)) +#elif defined(SIM_SCGC6_RNGA_SHIFT) +#define HWRNG_CLKEN() (bit_set32(&SIM->SCGC6, SIM_SCGC6_RNGA_SHIFT)) +#define HWRNG_CLKDIS() (bit_clear32(&SIM->SCGC6, SIM_SCGC6_RNGA_SHIFT)) +#endif +#endif /* KINETIS_RNGA */ +/** @} */ + #ifdef __cplusplus } #endif diff --git a/cpu/kinetis/periph/hwrng.c b/cpu/kinetis/periph/hwrng.c index 0348102b59..3e409e040e 100644 --- a/cpu/kinetis/periph/hwrng.c +++ b/cpu/kinetis/periph/hwrng.c @@ -25,6 +25,7 @@ #include "cpu.h" #include "periph/hwrng.h" #include "periph_conf.h" +#include "bit.h" #ifdef KINETIS_RNGA @@ -60,7 +61,7 @@ void hwrng_read(void *buf, unsigned int num) } } - /* power of the device */ + /* power off the device */ KINETIS_RNGA->CR = 0; HWRNG_CLKDIS(); } From 33e751e8a882259e0527b98e53076e5ae687446e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= Date: Thu, 9 Nov 2017 13:31:01 +0100 Subject: [PATCH 6/6] kinetis: Remove periph driver xxx_NUMOF guards --- cpu/kinetis/periph/dac.c | 5 ----- cpu/kinetis/periph/i2c.c | 4 ---- cpu/kinetis/periph/rtc.c | 5 ----- cpu/kinetis/periph/rtt.c | 5 ----- 4 files changed, 19 deletions(-) diff --git a/cpu/kinetis/periph/dac.c b/cpu/kinetis/periph/dac.c index 36e4ac0c13..250259b2f4 100644 --- a/cpu/kinetis/periph/dac.c +++ b/cpu/kinetis/periph/dac.c @@ -31,9 +31,6 @@ #include "periph/dac.h" #include "periph_conf.h" -/* only compile this file if there are DAC lines defined */ -#ifdef DAC_NUMOF - static inline DAC_Type *dev(dac_t line) { return dac_config[line].dev; @@ -84,5 +81,3 @@ void dac_poweroff(dac_t line) bit_clear8(&dac_config[line].dev->C0, DAC_C0_DACEN_SHIFT); } - -#endif /* DAC_NUMOF */ diff --git a/cpu/kinetis/periph/i2c.c b/cpu/kinetis/periph/i2c.c index 908ddafac8..4afc994f58 100644 --- a/cpu/kinetis/periph/i2c.c +++ b/cpu/kinetis/periph/i2c.c @@ -43,8 +43,6 @@ #else #define TRACE(...) #endif -/* guard file in case no I2C device is defined */ -#if I2C_NUMOF /** * @brief Array holding one pre-initialized mutex for each I2C device @@ -518,5 +516,3 @@ void i2c_poweroff(i2c_t dev) #endif } } - -#endif /* I2C_NUMOF */ diff --git a/cpu/kinetis/periph/rtc.c b/cpu/kinetis/periph/rtc.c index f0d877a4c9..cf89681a5b 100644 --- a/cpu/kinetis/periph/rtc.c +++ b/cpu/kinetis/periph/rtc.c @@ -30,9 +30,6 @@ #define ENABLE_DEBUG (0) #include "debug.h" -#if RTC_NUMOF - - typedef struct { rtc_alarm_cb_t cb; /**< callback called from RTC interrupt */ } rtc_state_t; @@ -111,5 +108,3 @@ static void rtc_cb(void* arg) rtc_callback.cb(arg); } } - -#endif /* RTC_NUMOF */ diff --git a/cpu/kinetis/periph/rtt.c b/cpu/kinetis/periph/rtt.c index 1f5874bfb7..b7b537062a 100644 --- a/cpu/kinetis/periph/rtt.c +++ b/cpu/kinetis/periph/rtt.c @@ -35,9 +35,6 @@ #define ENABLE_DEBUG (0) #include "debug.h" -#if RTT_NUMOF - - #ifndef RTC_LOAD_CAP_BITS #define RTC_LOAD_CAP_BITS 0 #endif @@ -200,5 +197,3 @@ void RTT_ISR(void) cortexm_isr_end(); } - -#endif /* RTC_NUMOF */