From 9737225d8861dec087540381ebd2c4c94025a2ca Mon Sep 17 00:00:00 2001 From: smlng Date: Tue, 19 Sep 2017 12:18:33 +0200 Subject: [PATCH] cpu, sam_common: add basic common files --- cpu/sam_common/Makefile | 1 + cpu/sam_common/Makefile.include | 11 +++ cpu/sam_common/doc.txt | 8 +++ cpu/sam_common/include/cpu_conf.h | 44 ++++++++++++ cpu/sam_common/include/vendor/README.md | 42 ++++++++++++ cpu/sam_common/include/vendor/sam.h | 90 +++++++++++++++++++++++++ 6 files changed, 196 insertions(+) create mode 100644 cpu/sam_common/Makefile create mode 100644 cpu/sam_common/Makefile.include create mode 100644 cpu/sam_common/doc.txt create mode 100644 cpu/sam_common/include/cpu_conf.h create mode 100644 cpu/sam_common/include/vendor/README.md create mode 100644 cpu/sam_common/include/vendor/sam.h diff --git a/cpu/sam_common/Makefile b/cpu/sam_common/Makefile new file mode 100644 index 0000000000..48422e909a --- /dev/null +++ b/cpu/sam_common/Makefile @@ -0,0 +1 @@ +include $(RIOTBASE)/Makefile.base diff --git a/cpu/sam_common/Makefile.include b/cpu/sam_common/Makefile.include new file mode 100644 index 0000000000..636bd18c95 --- /dev/null +++ b/cpu/sam_common/Makefile.include @@ -0,0 +1,11 @@ +# Define the CPU family so we can differentiate between them in the code +CFLAGS += -DCPU_FAM_$(shell echo $(CPU_FAM) | tr 'a-z-' 'A-Z_') + +# this CPU implementation doesn't use CMSIS initialization +export CFLAGS += -DDONT_USE_CMSIS_INIT + +# for the sam[drl] CPUs we hold all linkerscripts in the sam0 common folder +export LINKFLAGS += -L$(RIOTCPU)/sam_common/ldscripts + +# export the common include directory +export INCLUDES += -I$(RIOTCPU)/sam_common/include diff --git a/cpu/sam_common/doc.txt b/cpu/sam_common/doc.txt new file mode 100644 index 0000000000..1bf6602e97 --- /dev/null +++ b/cpu/sam_common/doc.txt @@ -0,0 +1,8 @@ +/** + * @defgroup cpu_sam_common Atmel SAM common + * @ingroup cpu + * @brief Atmel SAM common + * + * This module contains all common code and definition to all Atmel SAM cpu + * families supported by RIOT: @ref cpu_sam3, and cpu_sam4s. + */ diff --git a/cpu/sam_common/include/cpu_conf.h b/cpu/sam_common/include/cpu_conf.h new file mode 100644 index 0000000000..b1dc8c926c --- /dev/null +++ b/cpu/sam_common/include/cpu_conf.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2017 HAW Hamburg + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup cpu_sam_common + * @brief Implementation specific CPU configuration options + * @{ + * + * @file + * @brief Implementation specific CPU configuration options + * + * @author Sebastian Meiling + */ + +#ifndef CPU_CONF_H +#define CPU_CONF_H + +#include "cpu_conf_common.h" +#include "vendor/sam.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief ARM Cortex-M specific CPU configuration + * @{ + */ +#define CPU_DEFAULT_IRQ_PRIO (1U) +#define CPU_IRQ_NUMOF PERIPH_COUNT_IRQn +#define CPU_FLASH_BASE IFLASH0_ADDR +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* CPU_CONF_H */ +/** @} */ diff --git a/cpu/sam_common/include/vendor/README.md b/cpu/sam_common/include/vendor/README.md new file mode 100644 index 0000000000..e58ff72cb2 --- /dev/null +++ b/cpu/sam_common/include/vendor/README.md @@ -0,0 +1,42 @@ +# CMSIS from Atmel Software Foundation (ASF) + +The include files in the directory tree are copied from ASF (verion 3.35.1). + +The directory tree was copied "as is" from ASF path `sam/utils/cmsis/` and its +structure is as follows: + + cmsis + ├── sam3x + │ ├── include + │ │ ├── component + │ │ ├── instance + │ │ └── pio + │ └── source + │ ├── gcc + │ └── iar + . + . + . + ├── sam4s + │ ├── include + │ │ ├── component + │ │ ├── instance + │ │ └── pio + . └── source + . ├── gcc + . └── iar + +However, as only the header files in `include` and its subfolders are required, +all `source` folders are removed. + +Be aware that if you want to make changes to any file in this tree that the +changes will be lost when a new ASF release is going to be used. + +# Usage and porting for SAM based CPUs + +SAM based CPU should include `sam.h` in this directory, which will resolve any +CPU family specific includes required. + +Currently only SAM3X and SAM4S based CPUs are supported, i.e., only their CMSIS +header files are copied from the ASF. If other CPUs are needed copy CMSIS files +from the ASF for the respective CPU family here and adapt `sam.h` accordingly. diff --git a/cpu/sam_common/include/vendor/sam.h b/cpu/sam_common/include/vendor/sam.h new file mode 100644 index 0000000000..5aabd57cd9 --- /dev/null +++ b/cpu/sam_common/include/vendor/sam.h @@ -0,0 +1,90 @@ +/* + * Copyright (C) 2017 HAW Hamburg + * + * This file is subject to the terms and conditions of the GNU Lesser + * General Public License v2.1. See the file LICENSE in the top level + * directory for more details. + */ + +/** + * @ingroup cpu_sam_common + * @{ + * + * @file + * @brief Wrapper include file for specific SAM vendor headers + * + * @author Sebastian Meiling + */ + +#ifndef SAM_H +#define SAM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined(CPU_FAM_SAM3) && !defined(PERIPH_COUNT_IRQn) +/** + * @brief Number of periphical IRQs for SAM3 CPUs + */ +#define PERIPH_COUNT_IRQn (45U) +#endif + +#if defined(CPU_MODEL_SAM3A4C) + #include "vendor/sam3x/include/sam3a4c.h" +#elif defined(CPU_MODEL_SAM3A8C) + #include "vendor/sam3x/include/sam3a8c.h" +#elif defined(CPU_MODEL_SAM3X4C) + #include "vendor/sam3x/include/sam3x4c.h" +#elif defined(CPU_MODEL_SAM3X4E) + #include "vendor/sam3x/include/sam3x4e.h" +#elif defined(CPU_MODEL_SAM3X8C) + #include "vendor/sam3x/include/sam3x8c.h" +#elif defined(CPU_MODEL_SAM3X8E) + #include "vendor/sam3x/include/sam3x8e.h" +#elif defined(CPU_MODEL_SAM3X8H) + #include "vendor/sam3x/include/sam3x8h.h" + +#elif defined(CPU_MODEL_SAM4S2A) + #include "vendor/sam4s/include/sam4s2a.h" +#elif defined(CPU_MODEL_SAM4S2B) + #include "vendor/sam4s/include/sam4s2b.h" +#elif defined(CPU_MODEL_SAM4S2C) + #include "vendor/sam4s/include/sam4s2c.h" +#elif defined(CPU_MODEL_SAM4S4A) + #include "vendor/sam4s/include/sam4s4a.h" +#elif defined(CPU_MODEL_SAM4S4B) + #include "vendor/sam4s/include/sam4s4b.h" +#elif defined(CPU_MODEL_SAM4S4C) + #include "vendor/sam4s/include/sam4s4c.h" +#elif defined(CPU_MODEL_SAM4S8B) + #include "vendor/sam4s/include/sam4s8b.h" +#elif defined(CPU_MODEL_SAM4S8C) + #include "vendor/sam4s/include/sam4s8c.h" +#elif defined(CPU_MODEL_SAM4S16B) + #include "vendor/sam4s/include/sam4s16b.h" +#elif defined(CPU_MODEL_SAM4S16C) + #include "vendor/sam4s/include/sam4s16c.h" +#elif defined(CPU_MODEL_SAM4SA16B) + #include "vendor/sam4s/include/sam4sa16b.h" +#elif defined(CPU_MODEL_SAM4SA16C) + #include "vendor/sam4s/include/sam4sa16c.h" +#elif defined(CPU_MODEL_SAM4SD16B) + #include "vendor/sam4s/include/sam4sd16b.h" +#elif defined(CPU_MODEL_SAM4SD16C) + #include "vendor/sam4s/include/sam4sd16c.h" +#elif defined(CPU_MODEL_SAM4SD32B) + #include "vendor/sam4s/include/sam4sd32b.h" +#elif defined(CPU_MODEL_SAM4SD32C) + #include "vendor/sam4s/include/sam4sd32c.h" + +#else + #error "Unsupported Atmel SAM variant." +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* SAM0_H */ +/** @} */