2 \page templates_pg CMSIS-Core Device Templates
6 Arm supplies CMSIS-Core device template files for the all supported Cortex-M processors and various compiler vendors.
7 Refer to the list of \ref tested_tools_sec for compliance.
10 These CMSIS-Core device template files include the following:
11 - Register names of the Core Peripherals and names of the Core Exception Vectors.
12 - Functions to access core peripherals, special CPU instructions and SIMD instructions (for Cortex-M4 and Cortex-M7)
13 - Generic startup code and system configuration code.
15 The detailed file structure of the CMSIS-Core device templates is shown in the following picture.
17 \image html "CMSIS_CORE_Files.png" "CMSIS-Core File Structure"
19 \section CMSIS_Processor_files CMSIS-Core Processor Files
21 The CMSIS-Core processor files provided by Arm are in the directory .\\CMSIS\\Core\\Include. These header files define all processor specific attributes do not need any modifications.
22 The <b>core_<cpu>.h</b> defines the core peripherals and provides helper functions that access the core registers. One file is available for each supported Cortex-M processor:
24 Header File | Processor
25 :----------------|:------------------------------
26 core_cm0.h | for the Cortex-M0 processor
27 core_cm0plus.h | for the Cortex-M0+ processor
28 core_cm3.h | for the Cortex-M3 processor
29 core_cm4.h | for the Cortex-M4 processor
30 core_cm7.h | for the Cortex-M7 processor
32 core_cm23.h | for the Cortex-M23 processor
33 core_cm33.h | for the Cortex-M33 processor
34 core_cm35p.h | for the Cortex-M35P processor
37 core_sc000.h | for the SecurCore SC000 processor
38 core_sc300.h | for the SecurCore SC300 processor
41 core_armv8mbl.h | for the Armv8-M Baseline processor
42 core_armv8mml.h | for the Armv8-M Mainline processor
44 \section device_examples Device Examples
46 The CMSIS Software Pack defines several devices that are based on the various processors. The device related CMSIS-Core files are in the directory .\\Device\\ARM
47 and include CMSIS-Core processor file explained before. The following sample devices are defined in the CMSIS-Pack description file <b>ARM.CMSIS.pdsc</b>:
49 Family | Device | Description
50 :------------------|:-------------------|:---------------------------------
51 ARM Cortex-M0 | ARMCM0 | Cortex-M0 based device
52 ARM Cortex-M0 plus | ARMCM0P | Cortex-M0+ based device
53 ARM Cortex-M3 | ARMCM3 | Cortex-M3 based device
54 ARM Cortex-M4 | ARMCM4 | Cortex-M4 based device without floating-point hardware
55 ARM Cortex-M4 | ARMCM4_FP | Cortex-M4 based device with floating-point hardware
56 ARM Cortex-M7 | ARMCM7 | Cortex-M4 based device without floating-point hardware
57 ARM Cortex-M7 | ARMCM7_FP | Cortex-M7 based device with single precision floating-point unit (FPU)
58 ARM Cortex-M7 | ARMCM7_DP | Cortex-M7 based device with double precision floating-point unit
59 ARM Cortex-M7 | ARMCM7 | Cortex-M7 based device without floating-point hardware
61 ARM Cortex-M23 | ARMCM23 | Cortex-M23 based device without TrustZone
62 ARM Cortex-M23 | ARMCM23_TZ | Cortex-M23 based device with TrustZone
63 ARM Cortex-M33 | ARMCM33 | Cortex-M33 based device without TrustZone, SIMD, FPU
64 ARM Cortex-M33 | ARMCM33_TZ | Cortex-M33 based device with TrustZone, no SIMD, no FPU
65 ARM Cortex-M33 | ARMCM33_DSP_FP | Cortex-M33 based device with SIMD, FPU, no TrustZone
66 ARM Cortex-M33 | ARMCM33_DSP_FP_TZ | Cortex-M33 based device with TrustZone, SIMD, FPU
67 ARM Cortex-M35P | ARMCM35P | Cortex-M35P based device without TrustZone, SIMD, FPU
68 ARM Cortex-M35P | ARMCM35P_TZ | Cortex-M35P based device with TrustZone, no SIMD, no FPU
69 ARM Cortex-M35P | ARMCM35P_DSP_FP | Cortex-M35P based device with SIMD, FPU, no TrustZone
70 ARM Cortex-M35P | ARMCM35P_DSP_FP_TZ | Cortex-M35P based device with TrustZone, SIMD, FPU
73 ARM SC000 | ARM SC000 | SC000 based device
74 ARM SC300 | ARM SC300 | SC300 based device
77 ARMv8-M Baseline | ARMv8MBL | Armv8-M Baseline based device with TrustZone
78 ARMv8-M Mainline | ARMv8MML | Armv8-M Mainline based device with TrustZone
79 ARMv8-M Mainline | ARMv8MML_DP | Armv8-M Mainline based device with TrustZone and double precision FPU
80 ARMv8-M Mainline | ARMv8MML_SP | Armv8-M Mainline based device with TrustZone and single precision FPU
81 ARMv8-M Mainline | ARMv8MML_DSP | Armv8-M Mainline based device with TrustZone and SIMD
82 ARMv8-M Mainline | ARMv8MML_DSP_DP | Armv8-M Mainline based device with TrustZone, SIMD, and double precision FPU
83 ARMv8-M Mainline | ARMv8MML_DSP_SP | Armv8-M Mainline based device with TrustZone, SIMD, and single precision FPU
86 \section template_files_sec Template Files
88 To simplify the creation of CMSIS-Core device files, the following template files are provided that should be extended by the silicon vendor to reflect the actual device and device peripherals.
89 Silicon vendors add to these template files the following information:
90 - <b>Device Peripheral Access Layer</b> that provides definitions for device-specific peripherals.
91 - <b>Access Functions for Peripherals</b> (optional) that provides additional helper functions to access device-specific peripherals.
92 - <b>Interrupt vectors</b> in the startup file that are device specific.
94 <table class="cmtable">
96 <th>Template File</th>
100 <td>.\\Device\\\_Template_Vendor\\Vendor\\Device\\Source\\ARM\\startup_Device.s</td>
101 <td>Startup file template for Arm C/C++ Compiler.</td>
104 <td>.\\Device\\\_Template_Vendor\\Vendor\\Device\\Source\\GCC\\startup_Device.s</td>
105 <td>Startup file template for GNU GCC Arm Embedded Compiler.</td>
108 <td>.\\Device\\\_Template_Vendor\\Vendor\\Device\\Source\\IAR\\startup_Device.s</td>
109 <td>Startup file template for IAR C/C++ Compiler.</td>
112 <td>.\\Device\\\_Template_Vendor\\Vendor\\Device\\Source\\system_Device.c</td>
113 <td>Generic system_Device.c file for system configuration (i.e. processor clock and memory bus system).</td>
116 <td>.\\Device\\\_Template_Vendor\\Vendor\\Device\\Include\\Device.h</td>
117 <td>Generic device header file. Needs to be extended with the device-specific peripheral registers. Optionally functions that access the peripherals
118 can be part of that file.</td>
121 <td>.\\Device\\\_Template_Vendor\\Vendor\\Device\\Include\\system_Device.h</td>
122 <td>Generic system device configuration include file.</td>
127 <b>Adapt Template Files to a Device</b>
129 The following steps describe how to adopt the template files to a specific device or device family.
130 Copy the complete all files in the template directory and replace:
131 - directory name 'Vendor' with the abbreviation for the device vendor e.g.: NXP.
132 - directory name 'Device' with the specific device name e.g.: LPC17xx.
133 - in the file names 'Device' with the specific device name e.g.: LPC17xx.
135 Each template file contains comments that start with \b ToDo: that describe a required modification.
136 The template files contain place holders:
138 <table class="cmtable">
141 <th>Replaced with</th>
144 <td><Device></td>
145 <td>the specific device name or device family name; i.e. LPC17xx.</td>
148 <td><DeviceInterrupt></td>
149 <td>a specific interrupt name of the device; i.e. TIM1 for Timer 1.</td>
151 <td><DeviceAbbreviation></td>
152 <td>short name or abbreviation of the device family; i.e. LPC.</td>
156 <td>the specific Cortex-M processor name; i.e. Cortex-M3.</td>
161 The device configuration of the template files is described in detail on the following pages:
162 - \subpage startup_c_pg
163 - \subpage startup_s_pg (deprecated)
164 - \subpage system_c_pg
165 - \subpage device_h_pg
167 - \subpage partition_h_pg
171 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
173 \page startup_c_pg Startup File startup_<device>.c
175 The \ref startup_c_pg contains:
176 - The reset handler which is executed after CPU reset and typically calls the \ref SystemInit function.
177 - The setup values for the Main Stack Pointer (MSP).
178 - Exception vectors of the Cortex-M Processor with weak functions that implement default routines.
179 - Interrupt vectors that are device specific with weak functions that implement default routines.
181 The file exists for each supported toolchain and is the only tool-chain specific CMSIS file.
183 To adapt the file to a new device only the interrupt vector table needs to be extended with
184 the device-specific interrupt handlers. The naming convention for the interrupt handler names are
185 <interrupt_name>_IRQHandler. This table needs to be consistent with \ref IRQn_Type that defines all the
186 IRQ numbers for each interrupt.
190 The following example shows the extension of the interrupt vector table for the LPC1100 device family.
193 /*----------------------------------------------------------------------------
194 Exception / Interrupt Handler
195 *----------------------------------------------------------------------------*/
197 void WAKEUP0_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
198 void WAKEUP1_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
199 void WAKEUP2_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
202 void EINT1_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
203 void EINT2_IRQHandler (void) __attribute__ ((weak, alias("Default_Handler")));
207 /*----------------------------------------------------------------------------
208 Exception / Interrupt Vector table
209 *----------------------------------------------------------------------------*/
210 extern const pFunc __VECTOR_TABLE[240];
211 const pFunc __VECTOR_TABLE[240] __VECTOR_TABLE_ATTRIBUTE = {
212 (pFunc)(&__INITIAL_SP), /* Initial Stack Pointer */
213 Reset_Handler, /* Reset Handler */
214 NMI_Handler, /* -14 NMI Handler */
215 HardFault_Handler, /* -13 Hard Fault Handler */
216 MemManage_Handler, /* -12 MPU Fault Handler */
217 BusFault_Handler, /* -11 Bus Fault Handler */
218 UsageFault_Handler, /* -10 Usage Fault Handler */
223 SVC_Handler, /* -5 SVCall Handler */
224 DebugMon_Handler, /* -4 Debug Monitor Handler */
226 PendSV_Handler, /* -2 PendSV Handler */
227 SysTick_Handler, /* -1 SysTick Handler */
230 WAKEUP0_IRQHandler, /* 0 Wakeup PIO0.0 */
231 WAKEUP1_IRQHandler, /* 1 Wakeup PIO0.1 */
232 WAKEUP2_IRQHandler, /* 2 Wakeup PIO0.2 */
235 EINT1_IRQHandler, /* 30 PIO INT1 */
236 EINT2_IRQHandler, /* 31 PIO INT2 */
242 \section startup_c_sec startup_Device.c Template File
244 A compiler agnostic \ref startup_c_sec for an Armv7-M processor like Cortex-M3 is shown below.
245 The C startup file relys on certain compiler specific preprocessor defines specified in CMSIS compiler headers:
248 - \ref __PROGRAM_START
249 - \ref __VECTOR_TABLE
250 - \ref __VECTOR_TABLE_ATTRIBUTE
252 \verbinclude "Source\startup_Device.c"
255 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
257 \page startup_s_pg Startup File startup_<device>.s (deprecated)
259 The \ref startup_s_pg contains:
260 - The reset handler which is executed after CPU reset and typically calls the \ref SystemInit function.
261 - The setup values for the Main Stack Pointer (MSP).
262 - Exception vectors of the Cortex-M Processor with weak functions that implement default routines.
263 - Interrupt vectors that are device specific with weak functions that implement default routines.
265 The file exists for each supported toolchain and is the only tool-chain specific CMSIS file.
267 To adapt the file to a new device only the interrupt vector table needs to be extended with
268 the device-specific interrupt handlers. The naming convention for the interrupt handler names are
269 <interrupt_name>_IRQHandler. This table needs to be consistent with \ref IRQn_Type that defines all the
270 IRQ numbers for each interrupt.
274 The following example shows the extension of the interrupt vector table for the LPC1100 device family.
277 ; External Interrupts
278 DCD WAKEUP0_IRQHandler ; 16+ 0: Wakeup PIO0.0
279 DCD WAKEUP1_IRQHandler ; 16+ 1: Wakeup PIO0.1
280 DCD WAKEUP2_IRQHandler ; 16+ 2: Wakeup PIO0.2
283 DCD EINT1_IRQHandler ; 16+30: PIO INT1
284 DCD EINT0_IRQHandler ; 16+31: PIO INT0
287 EXPORT WAKEUP0_IRQHandler [WEAK]
288 EXPORT WAKEUP1_IRQHandler [WEAK]
289 EXPORT WAKEUP2_IRQHandler [WEAK]
292 EXPORT EINT1_IRQHandler [WEAK]
293 EXPORT EINT0_IRQHandler [WEAK]
306 \section startup_s_sec startup_Device.s Template File
308 An Arm Compiler \ref startup_s_sec for an Armv7-M processor like Cortex-M3 is shown below.
309 The files for other compiler vendors differ slightly in the syntax, but not in the overall structure.
311 \verbinclude "Source\ARM\startup_Device.s"
314 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
316 \page system_c_pg System Configuration Files system_<device>.c and system_<device>.h
318 The \ref system_c_pg provides as a minimum the functions described under \ref system_init_gr.
319 These functions are device specific and need adaptations. In addition, the file might have
320 configuration settings for the device such as XTAL frequency or PLL prescaler settings.
322 For devices with external memory BUS the system_<device>.c also configures the BUS system.
324 The silicon vendor might expose other functions (i.e. for power configuration) in the system_<device>.c file.
325 In case of additional features the function prototypes need to be added to the system_<device>.h header file.
327 \section system_Device_sec system_Device.c Template File
329 The \ref system_Device_sec for the Cortex-M3 is shown below.
331 \verbinclude "Source\system_Device.c"
333 \section system_Device_h_sec system_Device.h Template File
335 The system_<device>.h header file contains prototypes to access the public functions in the system_<device>.c file.
336 The \ref system_Device_h_sec is shown below.
338 \verbinclude "Include\system_Device.h"
342 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
344 \page device_h_pg Device Header File <device.h>
346 The \ref device_h_pg contains the following sections that are device specific:
348 - \ref interrupt_number_sec provides interrupt numbers (IRQn) for all exceptions and interrupts of the device.
349 - \ref core_config_sect reflect the features of the device.
350 - \ref device_access provides definitions for the \ref peripheral_gr to all device peripherals. It contains all data structures and the address mapping for device-specific peripherals.
351 - <b>Access Functions for Peripherals (optional)</b> provide additional helper functions for peripherals that are useful for programming of these peripherals. Access Functions may be provided as inline functions or can be extern references to a device-specific library provided by the silicon vendor.
353 <a href="Modules.html">\b Reference </a> describes the standard features and functions of the \ref device_h_pg in detail.
355 \section interrupt_number_sec Interrupt Number Definition
357 \ref device_h_pg contains the enumeration \ref IRQn_Type that defines all exceptions and interrupts of the device.
358 - Negative IRQn values represent processor core exceptions (internal interrupts).
359 - Positive IRQn values represent device-specific exceptions (external interrupts). The first device-specific interrupt has the IRQn value 0.
360 The IRQn values needs extension to reflect the device-specific interrupt vector table in the \ref startup_s_pg.
364 The following example shows the extension of the interrupt vector table for the LPC1100 device family.
369 /****** Cortex-M0 Processor Exceptions Numbers ***************************************************/
370 NonMaskableInt_IRQn = -14, /*!< 2 Non Maskable Interrupt */
371 HardFault_IRQn = -13, /*!< 3 Cortex-M0 Hard Fault Interrupt */
372 SVCall_IRQn = -5, /*!< 11 Cortex-M0 SV Call Interrupt */
373 PendSV_IRQn = -2, /*!< 14 Cortex-M0 Pend SV Interrupt */
374 SysTick_IRQn = -1, /*!< 15 Cortex-M0 System Tick Interrupt */
376 /****** LPC11xx/LPC11Cxx Specific Interrupt Numbers **********************************************/
377 WAKEUP0_IRQn = 0, /*!< All I/O pins can be used as wakeup source. */
378 WAKEUP1_IRQn = 1, /*!< There are 13 pins in total for LPC11xx */
382 EINT1_IRQn = 30, /*!< External Interrupt 1 Interrupt */
383 EINT0_IRQn = 31, /*!< External Interrupt 0 Interrupt */
387 \section core_config_sect Configuration of the Processor and Core Peripherals
389 The \ref device_h_pg configures the Cortex-M or SecurCore processor and the core peripherals with <i>\#defines</i>
390 that are set prior to including the file <b>core_<cpu>.h</b>.
392 The following tables list the <i>\#defines</i> along with the possible values for each processor core.
393 If these <i>\#defines</i> are missing default values are used.
396 <table class="cmtable">
407 <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
410 <td>__NVIC_PRIO_BITS</td>
413 <td>Number of priority bits implemented in the NVIC (device specific)</td>
416 <td>__Vendor_SysTickConfig</td>
419 <td>If this define is set to 1, then the default <b>SysTick_Config</b> function
420 is excluded. In this case, the file <i><b>device.h</b></i>
421 must contain a vendor specific implementation of this function.</td>
426 <table class="cmtable">
434 <td>__CM0PLUS_REV</td>
437 <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
440 <td>__NVIC_PRIO_BITS</td>
443 <td>Number of priority bits implemented in the NVIC (device specific)</td>
446 <td>__Vendor_SysTickConfig</td>
449 <td>If this define is set to 1, then the default <b>SysTick_Config</b> function
450 is excluded. In this case, the file <i><b>device.h</b></i>
451 must contain a vendor specific implementation of this function.</td>
456 <table class="cmtable">
465 <td>0x0101 | 0x0200</td>
467 <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
470 <td>__NVIC_PRIO_BITS</td>
473 <td>Number of priority bits implemented in the NVIC (device specific)</td>
476 <td>__MPU_PRESENT</td>
479 <td>Defines if a MPU is present or not</td>
482 <td>__Vendor_SysTickConfig</td>
485 <td>If this define is set to 1, then the default <b>SysTick_Config</b> function
486 is excluded. In this case, the file <i><b>device.h</b></i>
487 must contain a vendor specific implementation of this function.</td>
492 <table class="cmtable">
503 <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
506 <td>__NVIC_PRIO_BITS</td>
509 <td>Number of priority bits implemented in the NVIC (device specific)</td>
512 <td>__MPU_PRESENT</td>
515 <td>Defines if a MPU is present or not</td>
518 <td>__FPU_PRESENT</td>
521 <td>Defines if a FPU is present or not</td>
524 <td>__Vendor_SysTickConfig</td>
527 <td>If this define is set to 1, then the default <b>SysTick_Config</b> function
528 is excluded. In this case, the file <i><b>device.h</b></i>
529 must contain a vendor specific implementation of this function.</td>
534 <table class="cmtable" summary="">
545 <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
548 <td>__MPU_PRESENT</td>
551 <td>Defines if a MPU is present or not</td>
554 <td>__NVIC_PRIO_BITS</td>
557 <td>Number of priority bits implemented in the NVIC (device specific)</td>
560 <td>__Vendor_SysTickConfig</td>
563 <td>If this define is set to 1, then the default <b>SysTick_Config</b> function
564 is excluded. In this case, the file <i><b>device.h</b></i>
565 must contain a vendor specific implementation of this function.</td>
568 <td>__FPU_PRESENT</td>
571 <td>Defines if a FPU is present or not. See <b>__FPU_DP</b> description below.</td>
577 <td>The combination of the defines <b>__FPU_PRESENT</b> and <b>__FPU_DP</b>
578 determine the whether the FPU is with single or double precision as shown in the table below.
580 <table class="cmtable" summary="">
582 <td><b>__FPU_PRESENT</b></td>
583 <td><b>__FPU_DP</b></td>
584 <td><b>Description</b></td>
587 <td align="center">0</td>
588 <td align="center"><i>ignored</i></td>
589 <td>Processor has no FPU. The value set for <b>__FPU_DP</b> has no influence. </td>
592 <td align="center">1</td>
593 <td align="center">0</td>
594 <td>Processor with FPU with single precision. The file <b>ARMCM7_SP.h</b> has preconfigured settings for this combination.</td>
597 <td align="center">1</td>
598 <td align="center">1</td>
599 <td>Processor with FPU with double precision. The file <b>ARMCM7_DP.h</b> has preconfigured settings for this combination.</td>
605 <td>__ICACHE_PRESENT</td>
608 <td>Instruction Chache present or not</td>
611 <td>__DCACHE_PRESENT</td>
614 <td>Data Chache present or not</td>
617 <td>__DTCM_PRESENT</td>
620 <td>Data Tightly Coupled Memory is present or not</td>
626 <table class="cmtable">
637 <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
640 <td>__NVIC_PRIO_BITS</td>
643 <td>Number of priority bits implemented in the NVIC (device specific)</td>
646 <td>__MPU_PRESENT</td>
649 <td>Defines if a MPU is present or not</td>
652 <td>__Vendor_SysTickConfig</td>
655 <td>If this define is set to 1, then the default <b>SysTick_Config</b> function
656 is excluded. In this case, the file <i><b>device.h</b></i>
657 must contain a vendor specific implementation of this function.</td>
664 <table class="cmtable">
675 <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
678 <td>__NVIC_PRIO_BITS</td>
681 <td>Number of priority bits implemented in the NVIC (device specific)</td>
684 <td>__MPU_PRESENT</td>
687 <td>Defines if a MPU is present or not</td>
690 <td>__Vendor_SysTickConfig</td>
693 <td>If this define is set to 1, then the default <b>SysTick_Config</b> function
694 is excluded. In this case, the file <i><b>device.h</b></i>
695 must contain a vendor specific implementation of this function.</td>
701 \b core_CM23.h or \b core_ARMv8MBL.h
702 <table class="cmtable">
710 <td>__ARMv8MBL_REV</td>
713 <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
716 <td>__MPU_PRESENT</td>
719 <td>Defines if a MPU is present or not</td>
722 <td>__SAUREGION_PRESENT</td>
725 <td>Defines if SAU regions are present or not</td>
728 <td>__VTOR_PRESENT</td>
731 <td>Defines if a VTOR register is present or not</td>
734 <td>__NVIC_PRIO_BITS</td>
737 <td>Number of priority bits implemented in the NVIC (device specific)</td>
740 <td>__Vendor_SysTickConfig</td>
743 <td>If this define is set to 1, then the default <b>SysTick_Config</b> function
744 is excluded. In this case, the file <i><b>device.h</b></i>
745 must contain a vendor specific implementation of this function.</td>
751 \b core_CM33.h or \b core_cm35p.h or \b core_ARMv8MML.h
752 <table class="cmtable">
760 <td>__ARMv8MML_REV</td>
763 <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
766 <td>__MPU_PRESENT</td>
769 <td>Defines if a MPU is present or not</td>
772 <td>__SAUREGION_PRESENT</td>
775 <td>Defines if SAU regions are present or not</td>
778 <td>__FPU_PRESENT</td>
781 <td>Defines if a FPU is present or not</td>
784 <td>__NVIC_PRIO_BITS</td>
787 <td>Number of priority bits implemented in the NVIC (device specific)</td>
790 <td>__Vendor_SysTickConfig</td>
793 <td>If this define is set to 1, then the default <b>SysTick_Config</b> function
794 is excluded. In this case, the file <i><b>device.h</b></i>
795 must contain a vendor specific implementation of this function.</td>
802 The following code exemplifies the configuration of the Cortex-M4 Processor and Core Peripherals.
805 #define __CM4_REV 0x0001 /* Core revision r0p1 */
806 #define __MPU_PRESENT 1 /* MPU present or not */
807 #define __NVIC_PRIO_BITS 3 /* Number of Bits used for Priority Levels */
808 #define __Vendor_SysTickConfig 0 /* Set to 1 if different SysTick Config is used */
809 #define __FPU_PRESENT 1 /* FPU present or not */
812 #include <core_cm4.h> /* Cortex-M4 processor and core peripherals */
816 \section core_version_sect CMSIS Version and Processor Information
818 Defines in the core_<i>cpu</i>.h file identify the version of the CMSIS-Core (Cortex-M) and the processor used.
819 The following shows the defines in the various core_<i>cpu</i>.h files that may be used in the \ref device_h_pg
820 to verify a minimum version or ensure that the right processor core is used.
824 #define __CM0_CMSIS_VERSION_MAIN (5U) /* [31:16] CMSIS HAL main version */
825 #define __CM0_CMSIS_VERSION_SUB (0U) /* [15:0] CMSIS HAL sub version */
826 #define __CM0_CMSIS_VERSION ((__CM0_CMSIS_VERSION_MAIN << 16U) | \
827 __CM0_CMSIS_VERSION_SUB ) /* CMSIS HAL version number */
829 #define __CORTEX_M (0U) /* Cortex-M Core */
835 #define __CM0PLUS_CMSIS_VERSION_MAIN (5U) /* [31:16] CMSIS HAL main version */
836 #define __CM0PLUS_CMSIS_VERSION_SUB (0U) /* [15:0] CMSIS HAL sub version */
837 #define __CM0PLUS_CMSIS_VERSION ((__CM0P_CMSIS_VERSION_MAIN << 16U) | \
838 __CM0P_CMSIS_VERSION_SUB ) /* CMSIS HAL version number */
840 #define __CORTEX_M (0U) /* Cortex-M Core */
846 #define __CM1_CMSIS_VERSION_MAIN (__CM_CMSIS_VERSION_MAIN) /*!< \deprecated [31:16] CMSIS HAL main version */
847 #define __CM1_CMSIS_VERSION_SUB (__CM_CMSIS_VERSION_SUB) /*!< \deprecated [15:0] CMSIS HAL sub version */
848 #define __CM1_CMSIS_VERSION ((__CM1_CMSIS_VERSION_MAIN << 16U) | \
849 __CM1_CMSIS_VERSION_SUB ) /*!< \deprecated CMSIS HAL version number */
851 #define __CORTEX_M (1U) /*!< Cortex-M Core */
856 #define __CM3_CMSIS_VERSION_MAIN (5U) /* [31:16] CMSIS HAL main version */
857 #define __CM3_CMSIS_VERSION_SUB (0U) /* [15:0] CMSIS HAL sub version */
858 #define __CM3_CMSIS_VERSION ((__CM3_CMSIS_VERSION_MAIN << 16U) | \
859 __CM3_CMSIS_VERSION_SUB ) /* CMSIS HAL version number */
861 #define __CORTEX_M (3U) /* Cortex-M Core */
866 #define __CM4_CMSIS_VERSION_MAIN (5U) /* [31:16] CMSIS HAL main version */
867 #define __CM4_CMSIS_VERSION_SUB (0U) /* [15:0] CMSIS HAL sub version */
868 #define __CM4_CMSIS_VERSION ((__CM4_CMSIS_VERSION_MAIN << 16U) | \
869 __CM4_CMSIS_VERSION_SUB ) /* CMSIS HAL version number */
871 #define __CORTEX_M (4U) /* Cortex-M Core */
876 #define __CM7_CMSIS_VERSION_MAIN (5U) /* [31:16] CMSIS HAL main version */
877 #define __CM7_CMSIS_VERSION_SUB (0U) /* [15:0] CMSIS HAL sub version */
878 #define __CM7_CMSIS_VERSION ((__CM7_CMSIS_VERSION_MAIN << 16U) | \
879 __CM7_CMSIS_VERSION_SUB ) /* CMSIS HAL version number */
881 #define __CORTEX_M (7U) /* Cortex-M Core */
887 #define __SC000_CMSIS_VERSION_MAIN (5U) /* [31:16] CMSIS HAL main version */
888 #define __SC000_CMSIS_VERSION_SUB (0U) /* [15:0] CMSIS HAL sub version */
889 #define __SC000_CMSIS_VERSION ((__SC000_CMSIS_VERSION_MAIN << 16U) | \
890 __SC000_CMSIS_VERSION_SUB ) /* CMSIS HAL version number */
892 #define __CORTEX_SC (0U) /* Cortex secure core */
899 #define __SC300_CMSIS_VERSION_MAIN (5U) /* [31:16] CMSIS HAL main version */
900 #define __SC300_CMSIS_VERSION_SUB (0U) /* [15:0] CMSIS HAL sub version */
901 #define __SC300_CMSIS_VERSION ((__SC300_CMSIS_VERSION_MAIN << 16U) | \
902 __SC300_CMSIS_VERSION_SUB ) /* CMSIS HAL version number */
904 #define __CORTEX_SC (300U) /* Cortex secure core */
911 #define __ARMv8MBL_CMSIS_VERSION_MAIN (5U) /* [31:16] CMSIS HAL main version */
912 #define __ARMv8MBL_CMSIS_VERSION_SUB (0U) /* [15:0] CMSIS HAL sub version */
913 #define __ARMv8MBL_CMSIS_VERSION ((__ARMv8MBL_CMSIS_VERSION_MAIN << 16U) | \
914 __ARMv8MBL_CMSIS_VERSION_SUB ) /* CMSIS HAL version number */
916 #define __CORTEX_M (tbd) /* Cortex secure core */
923 #define __ARMv8MML_CMSIS_VERSION_MAIN (5U) /* [31:16] CMSIS HAL main version */
924 #define __ARMv8MML_CMSIS_VERSION_SUB (0U) /* [15:0] CMSIS HAL sub version */
925 #define __ARMv8MML_CMSIS_VERSION ((__ARMv8MML_CMSIS_VERSION_MAIN << 16U) | \
926 __ARMv8MML_CMSIS_VERSION_SUB ) /* CMSIS HAL version number */
928 #define __CORTEX_M (tbd) /* Cortex secure core */
932 \section device_access Device Peripheral Access Layer
934 The \ref device_h_pg contains for each peripheral:
935 - Register Layout Typedef
939 The section \ref peripheral_gr shows examples for peripheral definitions.
941 \section device_h_sec Device.h Template File
943 The silicon vendor needs to extend the Device.h template file with the CMSIS features described above.
944 In addition the \ref device_h_pg may contain functions to access device-specific peripherals.
945 The \ref system_Device_h_sec which is provided as part of the CMSIS specification is shown below.
947 \verbinclude "Include\Device.h"
953 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
955 \if ARMv8M \page partition_h_pg System Partition Header File partition_<device>.h
957 The \ref partition_h_pg contains the initial setup of the TrustZone hardware in an Armv8-M system.
958 The function \ref TZ_SAU_Setup is call from \ref SystemInit and uses the settings in this file to
959 initialize the Secure Attribute Unit (SAU) and define non-secure interrupts (register NVIC_INIT_ITNS).
960 The following initializations are performed:
962 - \ref sau_ctrlregister_sec provides settings for the SAU CTRL register.
963 - \ref sau_regions_sect provides configuration of the SAU Address Regions.
964 - \ref sau_sleepexception_sec provides device-specific deepsleep and exception settings.
965 - \ref sau_interrupttarget_sec provides device-specific interrupt target settings.
967 \section sau_ctrlregister_sec SAU CTRL register settings
968 <table class="cmtable">
976 <td>SAU_INIT_CTRL</td>
979 <td>Initialize SAU CTRL register or not
980 - 0: do not initialize SAU CTRL register
981 - 1: initialize SAU CTRL register</td>
984 <td>SAU_INIT_CTRL_ENABLE</td>
987 <td>enable/disable the SAU
992 <td>SAU_INIT_CTRL_ALLNS</td>
995 <td>value for SAU_CTRL register bit ALLNS
996 - 0: all Memory is Secure
997 - 1: all Memory is Non-Secure</td>
1001 \section sau_regions_sect Configuration of the SAU Address Regions
1002 <table class="cmtable">
1005 <th>Value Range</th>
1007 <th>Description</th>
1010 <td>SAU_REGIONS_MAX</td>
1013 <td>maximum number of SAU regions</td>
1016 <td>SAU_INIT_REGION<number></td>
1019 <td>initialize SAU region or not
1020 - 0: do not initialize SAU region
1021 - 1: initialize SAU region</td>
1024 <td>SAU_INIT_START<number></td>
1025 <td>0x00000000 .. 0xFFFFFFE0\n
1026 [in steps of 32]</td>
1028 <td>region start address</td>
1031 <td>SAU_INIT_END<number></td>
1032 <td>0x00000000 .. 0xFFFFFFE0\n
1033 [in steps of 32]</td>
1035 <td>region start address</td>
1038 <td>SAU_INIT_NSC<number></td>
1041 <td>SAU region attribute
1043 - 1: Secure, Non-Secure callable</td>
1047 The range of \<number\> is from 0 .. SAU_REGIONS_MAX.
1048 A set of these macros must exist for each \<number\>.
1050 The following example shows a set of SAU region macros.
1053 #define SAU_REGIONS_MAX 8 /* Max. number of SAU regions */
1055 #define SAU_INIT_REGION0 1
1056 #define SAU_INIT_START0 0x00000000 /* start address of SAU region 0 */
1057 #define SAU_INIT_END0 0x001FFFE0 /* end address of SAU region 0 */
1058 #define SAU_INIT_NSC0 1
1060 #define SAU_INIT_REGION1 1
1061 #define SAU_INIT_START1 0x00200000 /* start address of SAU region 1 */
1062 #define SAU_INIT_END1 0x003FFFE0 /* end address of SAU region 1 */
1063 #define SAU_INIT_NSC1 0
1065 #define SAU_INIT_REGION2 1
1066 #define SAU_INIT_START2 0x20200000 /* start address of SAU region 2 */
1067 #define SAU_INIT_END2 0x203FFFE0 /* end address of SAU region 2 */
1068 #define SAU_INIT_NSC2 0
1070 #define SAU_INIT_REGION3 1
1071 #define SAU_INIT_START3 0x40000000 /* start address of SAU region 3 */
1072 #define SAU_INIT_END3 0x40040000 /* end address of SAU region 3 */
1073 #define SAU_INIT_NSC3 0
1075 #define SAU_INIT_REGION4 0
1076 #define SAU_INIT_START4 0x00000000 /* start address of SAU region 4 */
1077 #define SAU_INIT_END4 0x00000000 /* end address of SAU region 4 */
1078 #define SAU_INIT_NSC4 0
1080 #define SAU_INIT_REGION5 0
1081 #define SAU_INIT_START5 0x00000000 /* start address of SAU region 5 */
1082 #define SAU_INIT_END5 0x00000000 /* end address of SAU region 5 */
1083 #define SAU_INIT_NSC5 0
1085 #define SAU_INIT_REGION6 0
1086 #define SAU_INIT_START6 0x00000000 /* start address of SAU region 6 */
1087 #define SAU_INIT_END6 0x00000000 /* end address of SAU region 6 */
1088 #define SAU_INIT_NSC6 0
1090 #define SAU_INIT_REGION7 0
1091 #define SAU_INIT_START7 0x00000000 /* start address of SAU region 7 */
1092 #define SAU_INIT_END7 0x00000000 /* end address of SAU region 7 */
1093 #define SAU_INIT_NSC7 0
1097 \section sau_sleepexception_sec Configuration of Sleep and Exception behaviour
1098 <table class="cmtable">
1101 <th>Value Range</th>
1103 <th>Description</th>
1106 <td>CSR_INIT_DEEPSLEEPS</td>
1109 <td>value for SCB_CSR register bit DEEPSLEEPS
1110 - 0: Deep Sleep can be enabled by Secure and Non-Secure state
1111 - 1: Deep Sleep can be enabled by Secure state only</td>
1114 <td>AIRCR_INIT_SYSRESETREQS</td>
1117 <td>value for SCB_AIRCR register bit SYSRESETREQS
1118 - 0: System reset request accessible from Secure and Non-Secure state
1119 - 1: System reset request accessible from Secure state only</td>
1122 <td>AIRCR_INIT_PRIS</td>
1125 <td>value for SCB_AIRCR register bit PRIS
1126 - 0: Priority of Non-Secure exceptions is Not altered
1127 - 1: Priority of Non-Secure exceptions is Lowered to 0x80-0xFF</td>
1130 <td>AIRCR_INIT_BFHFNMINS</td>
1133 <td>value for SCB_AIRCR register bit BFHFNMINS
1134 - 0: BusFault, HardFault, and NMI target are Secure state
1135 - 1: BusFault, HardFault, and NMI target are Non-Secure state</td>
1139 \section sau_interrupttarget_sec Configuration of Interrupt Target settings
1141 Each interrupt has a configuration bit that defines the execution
1142 in Secure or Non-secure state. The Non-Secure interrupts have a separate
1143 vector table. Refer to \ref Model_TrustZone for more information.
1145 <table class="cmtable">
1148 <th>Value Range</th>
1150 <th>Description</th>
1153 <td>NVIC_INIT_ITNS<number></td>
1154 <td>0x00000000 .. 0xFFFFFFFF\n
1155 [each bit represents an interrupt]</td>
1157 <td>Interrupt vector target
1159 - 1: Non-Secure state</td>
1163 The range of \<number\> is 0 .. (\<number of external interrupts\> + 31) / 32.
1165 The following example shows the configuration for a maximum of 64 external interrupts.
1168 #define NVIC_INIT_ITNS0 0x0000122B
1169 #define NVIC_INIT_ITNS1 0x0000003A