]> begriffs open source - cmsis/blob - CMSIS/DoxyGen/Core/src/Template.txt
Merge branch 'develop' of https://github.com/ARM-software/CMSIS_5 into develop
[cmsis] / CMSIS / DoxyGen / Core / src / Template.txt
1 /**
2 \page templates_pg Template Files
3
4 \details
5
6 ARM supplies CMSIS-CORE 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.
8 These template files include the following:
9  - Register names of the Core Peripherals and names of the Core Exception Vectors.
10  - Functions to access core peripherals, special CPU instructions and SIMD instructions (for Cortex-M4 and Cortex-M7)
11  - Generic startup code and system configuration code.
12
13 The detailed file structure of the CMSIS-CORE is shown in the following picture.
14
15 \image html "CMSIS_CORE_Files.png" "CMSIS-CORE File Structure"
16
17
18 \section template_files_sec Template Files
19
20 The CMSIS-CORE template files should be extended by the silicon vendor to reflect the actual device and device peripherals.
21 Silicon vendors add in this context the:
22  - <b>Device Peripheral Access Layer</b> that provides definitions for device-specific peripherals.
23  - <b>Access Functions for Peripherals</b> (optional) that provides additional helper functions to access device-specific peripherals.
24  - <b>Interrupt vectors</b> in the startup file that are device specific.
25
26 <table class="cmtable">
27     <tr>
28       <th>Template File</th>
29       <th>Description</th>
30     </tr>
31     <tr>
32       <td>.\\Device\\\_Template_Vendor\\Vendor\\Device\\Source\\ARM\\startup_Device.s</td>
33       <td>Startup file template for ARM C/C++ Compiler.</td>
34     </tr>
35     <tr>
36       <td>.\\Device\\\_Template_Vendor\\Vendor\\Device\\Source\\GCC\\startup_Device.s</td>
37       <td>Startup file template for GNU GCC ARM Embedded Compiler.</td>
38     </tr>
39     <tr>
40       <td>.\\Device\\\_Template_Vendor\\Vendor\\Device\\Source\\IAR\\startup_Device.s</td>
41       <td>Startup file template for IAR C/C++ Compiler.</td>
42     </tr>
43     <tr>
44       <td>.\\Device\\\_Template_Vendor\\Vendor\\Device\\Source\\system_Device.c</td>
45       <td>Generic system_Device.c file for system configuration (i.e. processor clock and memory bus system).</td>
46     </tr>
47     <tr>
48       <td>.\\Device\\\_Template_Vendor\\Vendor\\Device\\Include\\Device.h</td>
49       <td>Generic device header file. Needs to be extended with the device-specific peripheral registers. Optionally functions that access the peripherals
50       can be part of that file.</td>
51     </tr>
52     <tr>
53       <td>.\\Device\\\_Template_Vendor\\Vendor\\Device\\Include\\system_Device.h</td>
54       <td>Generic system device configuration include file.</td>
55     </tr>
56 </table>
57
58
59 In addition ARM provides the following core header files that do not need any modifications.
60
61 <table class="cmtable">
62     <tr>
63       <th>Core Header Files</th>
64       <th>Description</th>
65     </tr>
66     <tr>
67       <td><b>core_&lt;cpu&gt;.h</b></td>
68       <td>Defines the core peripherals and provides helper functions that access the core registers. This file is available for all supported processors:
69              - core_cm0.h: for the Cortex-M0 processor
70              - core_cm0plus.h: for the Cortex-M0+ processor
71              - core_cm3.h: for the Cortex-M3 processor
72              - core_cm4.h: for the Cortex-M4 processor
73              - core_cm7.h: for the Cortex-M7 processor
74              - core_sc000.h: for the SecurCore SC000 processor
75              - core_sc300.h: for the SecurCore SC300 processor
76              - core_armv8mbl.h: for the ARMv8-M Baseline processor
77              - core_armv8mml.h: for the ARMv8-M Mainline processor
78           </td>
79     </tr>
80 </table>
81
82
83 \section adapt_template_files_sec Adaption of Template Files to Devices
84
85 Copy the complete folder including files and replace:
86   - folder name 'Vendor' with the abbreviation for the device vendor  e.g.: NXP.
87   - folder name 'Device' with the specific device name e.g.: LPC17xx.
88   - in the filenames 'Device' with the specific device name e.g.: LPC17xx.
89
90 Each template file contains comments that start with \b ToDo: that describe a required modification.
91 The template files contain placeholders:
92
93 <table class="cmtable">
94     <tr>
95       <th>Placeholder</th>
96       <th>Replaced with</th>
97     </tr>
98     <tr>
99       <td>&lt;Device&gt;</td>
100       <td>the specific device name or device family name; i.e. LPC17xx.</td>
101     </tr>
102     <tr>
103       <td>&lt;DeviceInterrupt&gt;</td>
104       <td>a specific interrupt name of the device; i.e. TIM1 for Timer 1.</td>
105     <tr>
106       <td>&lt;DeviceAbbreviation&gt;</td>
107       <td>short name or abbreviation of the device family; i.e. LPC.</td>
108     </tr>
109     <tr>
110       <td>Cortex-M#</td>
111       <td>the specific Cortex-M processor name; i.e. Cortex-M3.</td>
112     </tr>
113 </table>
114
115
116 The adaption of the template files is described in detail on the following pages:
117   - \subpage startup_s_pg
118   - \subpage system_c_pg
119   - \subpage device_h_pg
120   - \subpage partition_h_pg
121 */
122
123 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
124 /**
125 \page startup_s_pg Startup File startup_<device>.s
126
127 The \ref startup_s_pg contains:
128  - The reset handler which is executed after CPU reset and typically calls the \ref SystemInit function.
129  - The setup values for the Main Stack Pointer (MSP).
130  - Exception vectors of the Cortex-M Processor with weak functions that implement default routines.
131  - Interrupt vectors that are device specific with weak functions that implement default routines.
132
133 The file exists for each supported toolchain and is the only tool-chain specific CMSIS file.
134
135 To adapt the file to a new device only the interrupt vector table needs to be extended with
136 the device-specific interrupt handlers. The naming convention for the interrupt handler names are
137 &lt;interrupt_name&gt;_IRQHandler.  This table needs to be consistent with \ref IRQn_Type that defines all the
138 IRQ numbers for each interrupt.
139
140 \b Example:
141
142 The following example shows the extension of the interrupt vector table for the LPC1100 device family.
143
144 \code
145                 ; External Interrupts
146                 DCD     WAKEUP0_IRQHandler       ; 16+ 0: Wakeup PIO0.0
147                 DCD     WAKEUP1_IRQHandler       ; 16+ 1: Wakeup PIO0.1
148                 DCD     WAKEUP2_IRQHandler       ; 16+ 2: Wakeup PIO0.2
149                  :       :
150                  :       :
151                 DCD     EINT1_IRQHandler         ; 16+30: PIO INT1
152                 DCD     EINT0_IRQHandler         ; 16+31: PIO INT0
153          :
154          :
155                 EXPORT  WAKEUP0_IRQHandler       [WEAK]
156                 EXPORT  WAKEUP1_IRQHandler       [WEAK]
157                 EXPORT  WAKEUP2_IRQHandler       [WEAK]
158                  :       :
159                  :       :
160                 EXPORT  EINT1_IRQHandler         [WEAK]
161                 EXPORT  EINT0_IRQHandler         [WEAK]
162
163 WAKEUP0_IRQHandler
164 WAKEUP1_IRQHandler
165 WAKEUP1_IRQHandler
166       :
167       :
168 EINT1_IRQHandler
169 EINT0_IRQHandler
170                 B       .
171
172 \endcode
173
174 \section startup_s_sec startup_Device.s Template File
175
176 An ARM Compiler \ref startup_s_sec for an ARMv7-M processor like Cortex-M3 is shown below.
177 The files for other compiler vendors differ slightly in the syntax, but not in the overall structure.
178
179 \verbinclude "Source\ARM\startup_Device.s"
180 */
181
182 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
183 /**
184 \page system_c_pg System Configuration Files system_<device>.c and system_<device>.h
185
186 The \ref system_c_pg provides as a minimum the functions described under \ref system_init_gr.
187 These functions are device specific and need adaptations. In addition, the file might have
188 configuration settings for the device such as XTAL frequency or PLL prescaler settings.
189
190 For devices with external memory BUS the system_<device>.c also configures the BUS system.
191
192 The silicon vendor might expose other functions (i.e. for power configuration) in the system_<device>.c file.
193 In case of additional features the function prototypes need to be added to the system_<device>.h header file.
194
195 \section system_Device_sec system_Device.c Template File
196
197 The \ref system_Device_sec for the Cortex-M3 is shown below.
198
199 \verbinclude "Source\system_Device.c"
200
201 \section system_Device_h_sec system_Device.h Template File
202
203 The system_<device>.h header file contains prototypes to access the public functions in the system_<device>.c file.
204 The \ref system_Device_h_sec is shown below.
205
206 \verbinclude "Include\system_Device.h"
207
208 */
209
210 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
211 /**
212 \page device_h_pg Device Header File <device.h>
213
214 The \ref device_h_pg contains the following sections that are device specific:
215
216   - \ref interrupt_number_sec provides interrupt numbers (IRQn) for all exceptions and interrupts of the device.
217   - \ref core_config_sect reflect the features of the device.
218   - \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.
219   - <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.
220
221 <a href="Modules.html">\b Reference </a> describes the standard features and functions of the \ref device_h_pg in detail.
222
223 \section interrupt_number_sec Interrupt Number Definition
224
225 \ref device_h_pg contains the enumeration \ref IRQn_Type that defines all exceptions and interrupts of the device.
226   - Negative IRQn values represent processor core exceptions (internal interrupts).
227   - Positive IRQn values represent device-specific exceptions (external interrupts). The first device-specific interrupt has the IRQn value 0.
228     The IRQn values needs extension to reflect the device-specific interrupt vector table in the \ref startup_s_pg.
229
230 \b Example:
231
232 The following example shows the extension of the interrupt vector table for the LPC1100 device family.
233
234 \code
235 typedef enum IRQn
236 {
237 /******  Cortex-M0 Processor Exceptions Numbers ***************************************************/
238   NonMaskableInt_IRQn           = -14,      /*!< 2 Non Maskable Interrupt                         */
239   HardFault_IRQn                = -13,      /*!< 3 Cortex-M0 Hard Fault Interrupt                 */
240   SVCall_IRQn                   = -5,       /*!< 11 Cortex-M0 SV Call Interrupt                   */
241   PendSV_IRQn                   = -2,       /*!< 14 Cortex-M0 Pend SV Interrupt                   */
242   SysTick_IRQn                  = -1,       /*!< 15 Cortex-M0 System Tick Interrupt               */
243
244 /******  LPC11xx/LPC11Cxx Specific Interrupt Numbers **********************************************/
245   WAKEUP0_IRQn                  = 0,        /*!< All I/O pins can be used as wakeup source.       */
246   WAKEUP1_IRQn                  = 1,        /*!< There are 13 pins in total for LPC11xx           */
247   WAKEUP2_IRQn                  = 2,
248                  :       :
249                  :       :
250   EINT1_IRQn                    = 30,       /*!< External Interrupt 1 Interrupt                   */
251   EINT0_IRQn                    = 31,       /*!< External Interrupt 0 Interrupt                   */
252 } IRQn_Type;
253 \endcode
254
255 \section core_config_sect Configuration of the Processor and Core Peripherals
256
257 The \ref device_h_pg  configures the Cortex-M or SecurCore processor and the core peripherals with <i>\#defines</i>
258 that are set prior to including the file <b>core_<cpu>.h</b>.
259
260 The following tables list the <i>\#defines</i> along with the possible values for each processor core.
261 If these <i>\#defines</i> are missing default values are used.
262
263 \b core_cm0.h
264 <table class="cmtable">
265     <tr>
266       <th>\#define</th>
267       <th>Value Range</th>
268       <th>Default</th>
269       <th>Description</th>
270     </tr>
271     <tr>
272       <td>__CM0_REV</td>
273       <td>0x0000</td>
274       <td>0x0000</td>
275       <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
276     </tr>
277     <tr>
278       <td>__NVIC_PRIO_BITS</td>
279       <td>2</td>
280       <td>2</td>
281       <td>Number of priority bits implemented in the NVIC (device specific)</td>
282     </tr>
283     <tr>
284       <td>__Vendor_SysTickConfig</td>
285       <td>0 .. 1</td>
286       <td>0</td>
287       <td>If this define is set to 1, then the default <b>SysTick_Config</b> function
288                 is excluded. In this case, the file <i><b>device.h</b></i>
289                 must contain a vendor specific implementation of this function.</td>
290     </tr>
291 </table>
292
293 \b core_cm0plus.h
294 <table class="cmtable">
295     <tr>
296       <th>\#define</th>
297       <th>Value Range</th>
298       <th>Default</th>
299       <th>Description</th>
300     </tr>
301     <tr>
302       <td>__CM0PLUS_REV</td>
303       <td>0x0000</td>
304       <td>0x0000</td>
305       <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
306     </tr>
307     <tr>
308       <td>__NVIC_PRIO_BITS</td>
309       <td>2</td>
310       <td>2</td>
311       <td>Number of priority bits implemented in the NVIC (device specific)</td>
312     </tr>
313     <tr>
314       <td>__Vendor_SysTickConfig</td>
315       <td>0 .. 1</td>
316       <td>0</td>
317       <td>If this define is set to 1, then the default <b>SysTick_Config</b> function
318                 is excluded. In this case, the file <i><b>device.h</b></i>
319                 must contain a vendor specific implementation of this function.</td>
320     </tr>
321 </table>
322
323 \b core_cm3.h
324 <table class="cmtable">
325     <tr>
326       <th>\#define</th>
327       <th>Value Range</th>
328       <th>Default</th>
329       <th>Description</th>
330     </tr>
331     <tr>
332       <td>__CM3_REV</td>
333       <td>0x0101 | 0x0200</td>
334       <td>0x0200</td>
335       <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
336     </tr>
337     <tr>
338       <td>__NVIC_PRIO_BITS</td>
339       <td>2 .. 8</td>
340       <td>4</td>
341       <td>Number of priority bits implemented in the NVIC (device specific)</td>
342     </tr>
343     <tr>
344       <td>__MPU_PRESENT</td>
345       <td>0 .. 1</td>
346       <td>0</td>
347       <td>Defines if a MPU is present or not</td>
348     </tr>
349     <tr>
350       <td>__Vendor_SysTickConfig</td>
351       <td>0 .. 1</td>
352       <td>0</td>
353       <td>If this define is set to 1, then the default <b>SysTick_Config</b> function
354                 is excluded. In this case, the file <i><b>device.h</b></i>
355                 must contain a vendor specific implementation of this function.</td>
356     </tr>
357 </table>
358
359 \b core_cm4.h
360 <table class="cmtable">
361     <tr>
362       <th>\#define</th>
363       <th>Value Range</th>
364       <th>Default</th>
365       <th>Description</th>
366     </tr>
367     <tr>
368       <td>__CM4_REV</td>
369       <td>0x0000</td>
370       <td>0x0000</td>
371       <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
372     </tr>
373     <tr>
374       <td>__NVIC_PRIO_BITS</td>
375       <td>2 .. 8</td>
376       <td>4</td>
377       <td>Number of priority bits implemented in the NVIC (device specific)</td>
378     </tr>
379     <tr>
380       <td>__MPU_PRESENT</td>
381       <td>0 .. 1</td>
382       <td>0</td>
383       <td>Defines if a MPU is present or not</td>
384     </tr>
385     <tr>
386       <td>__FPU_PRESENT</td>
387       <td>0 .. 1</td>
388       <td>0</td>
389       <td>Defines if a FPU is present or not</td>
390     </tr>
391     <tr>
392       <td>__Vendor_SysTickConfig</td>
393       <td>0 .. 1</td>
394       <td>0</td>
395       <td>If this define is set to 1, then the default <b>SysTick_Config</b> function
396                 is excluded. In this case, the file <i><b>device.h</b></i>
397                 must contain a vendor specific implementation of this function.</td>
398     </tr>
399 </table>
400
401 \b core_cm7.h
402 <table class="cmtable" summary="">
403     <tr>
404       <th>\#define</th>
405       <th>Value Range</th>
406       <th>Default</th>
407       <th>Description</th>
408     </tr>
409     <tr>
410       <td>__CM7_REV</td>
411       <td>0x0000</td>
412       <td>0x0000</td>
413       <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
414     </tr>
415     <tr>
416       <td>__MPU_PRESENT</td>
417       <td>0 .. 1</td>
418       <td>0</td>
419       <td>Defines if a MPU is present or not</td>
420     </tr>
421     <tr>
422       <td>__NVIC_PRIO_BITS</td>
423       <td>2 .. 8</td>
424       <td>4</td>
425       <td>Number of priority bits implemented in the NVIC (device specific)</td>
426     </tr>
427     <tr>
428       <td>__Vendor_SysTickConfig</td>
429       <td>0 .. 1</td>
430       <td>0</td>
431       <td>If this define is set to 1, then the default <b>SysTick_Config</b> function
432                 is excluded. In this case, the file <i><b>device.h</b></i>
433                 must contain a vendor specific implementation of this function.</td>
434     </tr>
435     <tr>
436       <td>__FPU_PRESENT</td>
437       <td>0 .. 1</td>
438       <td>0</td>
439       <td>Defines if a FPU is present or not. See <b>__FPU_DP</b> description below.</td>
440     </tr>
441     <tr>
442       <td>__FPU_DP</td>
443       <td>0 .. 1</td>
444       <td>0</td>
445       <td>The combination of the defines <b>__FPU_PRESENT</b> and <b>__FPU_DP</b>
446          determine the whether the FPU is with single or double precision as shown in the table below.
447              \n\n
448              <table class="cmtable" summary="">
449                  <tr  bgcolor="cyan">
450            <td><b>__FPU_PRESENT</b></td>
451                    <td><b>__FPU_DP</b></td>
452                    <td><b>Description</b></td>
453                  </tr>
454                  <tr>
455                    <td align="center">0</td>
456                    <td align="center"><i>ignored</i></td>
457                    <td>Processor has no FPU. The value set for <b>__FPU_DP</b> has no influence. </td>
458                  </tr>
459                  <tr>
460                    <td align="center">1</td>
461                    <td align="center">0</td>
462                    <td>Processor with FPU with single precision. The file <b>ARMCM7_SP.h</b> has preconfigured settings for this combination.</td>
463                  </tr>
464                  <tr>
465                    <td align="center">1</td>
466                    <td align="center">1</td>
467            <td>Processor with FPU with double precision. The file <b>ARMCM7_DP.h</b> has preconfigured settings for this combination.</td>
468                  </tr>
469                  </table>
470           </td>
471     </tr>
472     <tr>
473       <td>__ICACHE_PRESENT</td>
474       <td>0 .. 1</td>
475       <td>1</td>
476       <td>Instruction Chache present or not</td>
477     </tr>
478     <tr>
479       <td>__DCACHE_PRESENT</td>
480       <td>0 .. 1</td>
481       <td>1</td>
482       <td>Data Chache present or not</td>
483     </tr>
484     <tr>
485       <td>__DTCM_PRESENT</td>
486       <td>0 .. 1</td>
487       <td>1</td>
488       <td>Data Tightly Coupled Memory is present or not</td>
489     </tr>
490 </table>
491
492 \b core_sc000.h
493 <table class="cmtable">
494     <tr>
495       <th>\#define</th>
496       <th>Value Range</th>
497       <th>Default</th>
498       <th>Description</th>
499     </tr>
500     <tr>
501       <td>__SC000_REV</td>
502       <td>0x0000</td>
503       <td>0x0000</td>
504       <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
505     </tr>
506     <tr>
507       <td>__NVIC_PRIO_BITS</td>
508       <td>2</td>
509       <td>2</td>
510       <td>Number of priority bits implemented in the NVIC (device specific)</td>
511     </tr>
512     <tr>
513       <td>__MPU_PRESENT</td>
514       <td>0 .. 1</td>
515       <td>0</td>
516       <td>Defines if a MPU is present or not</td>
517     </tr>
518     <tr>
519       <td>__Vendor_SysTickConfig</td>
520       <td>0 .. 1</td>
521       <td>0</td>
522       <td>If this define is set to 1, then the default <b>SysTick_Config</b> function
523                 is excluded. In this case, the file <i><b>device.h</b></i>
524                 must contain a vendor specific implementation of this function.</td>
525     </tr>
526 </table>
527
528 \b core_sc300.h
529 <table class="cmtable">
530     <tr>
531       <th>\#define</th>
532       <th>Value Range</th>
533       <th>Default</th>
534       <th>Description</th>
535     </tr>
536     <tr>
537       <td>__SC300_REV</td>
538       <td>0x0000</td>
539       <td>0x0000</td>
540       <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
541     </tr>
542     <tr>
543       <td>__NVIC_PRIO_BITS</td>
544       <td>2 .. 8</td>
545       <td>4</td>
546       <td>Number of priority bits implemented in the NVIC (device specific)</td>
547     </tr>
548     <tr>
549       <td>__MPU_PRESENT</td>
550       <td>0 .. 1</td>
551       <td>0</td>
552       <td>Defines if a MPU is present or not</td>
553     </tr>
554     <tr>
555       <td>__Vendor_SysTickConfig</td>
556       <td>0 .. 1</td>
557       <td>0</td>
558       <td>If this define is set to 1, then the default <b>SysTick_Config</b> function
559                 is excluded. In this case, the file <i><b>device.h</b></i>
560                 must contain a vendor specific implementation of this function.</td>
561     </tr>
562 </table>
563
564 \b core_ARMv8MBL.h
565 <table class="cmtable">
566     <tr>
567       <th>\#define</th>
568       <th>Value Range</th>
569       <th>Default</th>
570       <th>Description</th>
571     </tr>
572     <tr>
573       <td>__ARMv8MBL_REV</td>
574       <td>0x0000</td>
575       <td>0x0000</td>
576       <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
577     </tr>
578     <tr>
579       <td>__MPU_PRESENT</td>
580       <td>0 .. 1</td>
581       <td>0</td>
582       <td>Defines if a MPU is present or not</td>
583     </tr>
584     <tr>
585       <td>__SAUREGION_PRESENT</td>
586       <td>0 .. 1</td>
587       <td>0</td>
588       <td>Defines if SAU regions are present or not</td>
589     </tr>
590     <tr>
591       <td>__VTOR_PRESENT</td>
592       <td>0 .. 1</td>
593       <td>0</td>
594       <td>Defines if a VTOR register is present or not</td>
595     </tr>
596     <tr>
597       <td>__NVIC_PRIO_BITS</td>
598       <td>2</td>
599       <td>2</td>
600       <td>Number of priority bits implemented in the NVIC (device specific)</td>
601     </tr>
602     <tr>
603       <td>__Vendor_SysTickConfig</td>
604       <td>0 .. 1</td>
605       <td>0</td>
606       <td>If this define is set to 1, then the default <b>SysTick_Config</b> function
607                 is excluded. In this case, the file <i><b>device.h</b></i>
608                 must contain a vendor specific implementation of this function.</td>
609     </tr>
610 </table>
611
612 \b core_ARMv8MML.h
613 <table class="cmtable">
614     <tr>
615       <th>\#define</th>
616       <th>Value Range</th>
617       <th>Default</th>
618       <th>Description</th>
619     </tr>
620     <tr>
621       <td>__ARMv8MML_REV</td>
622       <td>0x0000</td>
623       <td>0x0000</td>
624       <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
625     </tr>
626     <tr>
627       <td>__MPU_PRESENT</td>
628       <td>0 .. 1</td>
629       <td>0</td>
630       <td>Defines if a MPU is present or not</td>
631     </tr>
632     <tr>
633       <td>__SAUREGION_PRESENT</td>
634       <td>0 .. 1</td>
635       <td>0</td>
636       <td>Defines if SAU regions are present or not</td>
637     </tr>
638     <tr>
639       <td>__FPU_PRESENT</td>
640       <td>0 .. 1</td>
641       <td>0</td>
642       <td>Defines if a FPU is present or not</td>
643     </tr>
644     <tr>
645       <td>__NVIC_PRIO_BITS</td>
646       <td>2 .. 8</td>
647       <td>3</td>
648       <td>Number of priority bits implemented in the NVIC (device specific)</td>
649     </tr>
650     <tr>
651       <td>__Vendor_SysTickConfig</td>
652       <td>0 .. 1</td>
653       <td>0</td>
654       <td>If this define is set to 1, then the default <b>SysTick_Config</b> function
655                 is excluded. In this case, the file <i><b>device.h</b></i>
656                 must contain a vendor specific implementation of this function.</td>
657     </tr>
658 </table>
659
660 \b Example
661
662 The following code exemplifies the configuration of the Cortex-M4 Processor and Core Peripherals.
663
664 \code
665 #define __CM4_REV                 0x0001    /* Core revision r0p1                                 */
666 #define __MPU_PRESENT             1         /* MPU present or not                                 */
667 #define __NVIC_PRIO_BITS          3         /* Number of Bits used for Priority Levels            */
668 #define __Vendor_SysTickConfig    0         /* Set to 1 if different SysTick Config is used       */
669 #define __FPU_PRESENT             1         /* FPU present or not                                 */
670 .
671 .
672 #include <core_cm4.h>                       /* Cortex-M4 processor and core peripherals           */
673 \endcode
674
675
676 \section core_version_sect   CMSIS Version and Processor Information
677
678 Defines in the core_<i>cpu</i>.h file identify the version of the CMSIS-CORE and the processor used.
679 The following shows the defines in the various core_<i>cpu</i>.h files that may be used in the \ref device_h_pg
680 to verify a minimum version or ensure that the right processor core is used.
681
682 \b core_cm0.h
683 \code
684 #define __CM0_CMSIS_VERSION_MAIN  (5U)                                 /* [31:16] CMSIS HAL main version */
685 #define __CM0_CMSIS_VERSION_SUB   (0U)                                 /* [15:0]  CMSIS HAL sub version */
686 #define __CM0_CMSIS_VERSION       ((__CM0_CMSIS_VERSION_MAIN << 16U) | \
687                                     __CM0_CMSIS_VERSION_SUB          ) /* CMSIS HAL version number */
688  
689 #define __CORTEX_M                (0U)                                 /* Cortex-M Core */
690 \endcode
691
692
693 \b core_cm0plus.h
694 \code
695 #define __CM0PLUS_CMSIS_VERSION_MAIN  (5U)                                  /* [31:16] CMSIS HAL main version */
696 #define __CM0PLUS_CMSIS_VERSION_SUB   (0U)                                  /* [15:0]  CMSIS HAL sub version */
697 #define __CM0PLUS_CMSIS_VERSION       ((__CM0P_CMSIS_VERSION_MAIN << 16U) | \
698                                         __CM0P_CMSIS_VERSION_SUB          ) /* CMSIS HAL version number */
699  
700 #define __CORTEX_M                    (0U)                                  /* Cortex-M Core */
701 \endcode
702
703
704 \b core_cm3.h
705 \code
706 #define __CM3_CMSIS_VERSION_MAIN  (5U)                                 /* [31:16] CMSIS HAL main version */
707 #define __CM3_CMSIS_VERSION_SUB   (0U)                                 /* [15:0]  CMSIS HAL sub version */
708 #define __CM3_CMSIS_VERSION       ((__CM3_CMSIS_VERSION_MAIN << 16U) | \
709                                     __CM3_CMSIS_VERSION_SUB          ) /* CMSIS HAL version number */
710  
711 #define __CORTEX_M                (3U)                                 /* Cortex-M Core */
712 \endcode
713
714 \b core_cm4.h
715 \code
716 #define __CM4_CMSIS_VERSION_MAIN  (5U)                                 /* [31:16] CMSIS HAL main version */
717 #define __CM4_CMSIS_VERSION_SUB   (0U)                                 /* [15:0]  CMSIS HAL sub version */
718 #define __CM4_CMSIS_VERSION       ((__CM4_CMSIS_VERSION_MAIN << 16U) | \
719                                     __CM4_CMSIS_VERSION_SUB          ) /* CMSIS HAL version number */
720  
721 #define __CORTEX_M                (4U)                                 /* Cortex-M Core */
722 \endcode
723
724 \b core_cm7.h
725 \code
726 #define __CM7_CMSIS_VERSION_MAIN  (5U)                                 /* [31:16] CMSIS HAL main version */
727 #define __CM7_CMSIS_VERSION_SUB   (0U)                                 /* [15:0]  CMSIS HAL sub version */
728 #define __CM7_CMSIS_VERSION       ((__CM7_CMSIS_VERSION_MAIN << 16U) | \
729                                     __CM7_CMSIS_VERSION_SUB          ) /* CMSIS HAL version number */
730  
731 #define __CORTEX_M                (7U)                                 /* Cortex-M Core */
732 \endcode
733
734 \b core_sc000.h
735 \code
736 #define __SC000_CMSIS_VERSION_MAIN  (5U)                                   /* [31:16] CMSIS HAL main version */
737 #define __SC000_CMSIS_VERSION_SUB   (0U)                                   /* [15:0]  CMSIS HAL sub version */
738 #define __SC000_CMSIS_VERSION       ((__SC000_CMSIS_VERSION_MAIN << 16U) | \
739                                       __SC000_CMSIS_VERSION_SUB          ) /* CMSIS HAL version number */
740  
741 #define __CORTEX_SC                 (0U)                                   /* Cortex secure core */
742 \endcode
743
744 \b core_sc300.h
745 \code
746 #define __SC300_CMSIS_VERSION_MAIN  (5U)                                   /* [31:16] CMSIS HAL main version */
747 #define __SC300_CMSIS_VERSION_SUB   (0U)                                   /* [15:0]  CMSIS HAL sub version */
748 #define __SC300_CMSIS_VERSION       ((__SC300_CMSIS_VERSION_MAIN << 16U) | \
749                                       __SC300_CMSIS_VERSION_SUB          ) /* CMSIS HAL version number */
750  
751 #define __CORTEX_SC                 (300U)                                 /* Cortex secure core */
752 \endcode
753
754 \b core_ARMv8MBL.h
755 \code
756 #define __ARMv8MBL_CMSIS_VERSION_MAIN  (5U)                                       /* [31:16] CMSIS HAL main version */
757 #define __ARMv8MBL_CMSIS_VERSION_SUB   (0U)                                       /* [15:0]  CMSIS HAL sub version */
758 #define __ARMv8MBL_CMSIS_VERSION       ((__ARMv8MBL_CMSIS_VERSION_MAIN << 16U) | \
759                                          __ARMv8MBL_CMSIS_VERSION_SUB           ) /* CMSIS HAL version number */
760  
761 #define __CORTEX_M                     (tbd)                                      /* Cortex secure core */
762 \endcode
763
764 \b core_ARMv8MML.h
765 \code
766 #define __ARMv8MML_CMSIS_VERSION_MAIN  (5U)                                       /* [31:16] CMSIS HAL main version */
767 #define __ARMv8MML_CMSIS_VERSION_SUB   (0U)                                       /* [15:0]  CMSIS HAL sub version */
768 #define __ARMv8MML_CMSIS_VERSION       ((__ARMv8MML_CMSIS_VERSION_MAIN << 16U) | \
769                                          __ARMv8MML_CMSIS_VERSION_SUB           ) /* CMSIS HAL version number */
770  
771 #define __CORTEX_M                     (tbd)                                      /* Cortex secure core */
772 \endcode
773
774
775 \section device_access Device Peripheral Access Layer
776
777 The \ref device_h_pg contains for each peripheral:
778  - Register Layout Typedef
779  - Base Address
780  - Access Definitions
781
782 The section \ref peripheral_gr shows examples for peripheral definitions.
783
784 \section device_h_sec Device.h Template File
785
786 The silicon vendor needs to extend the Device.h template file with the CMSIS features described above.
787 In addition the \ref device_h_pg may contain functions to access device-specific peripherals.
788 The \ref system_Device_h_sec which is provided as part of the CMSIS specification is shown below.
789
790 \verbinclude "Include\Device.h"
791
792 */
793
794
795
796 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
797 /**
798 \page partition_h_pg System Partition Header File partition_<device>.h
799
800 The \ref partition_h_pg contains the initial setup of the TrustZone hardware in an ARMv8-M system.
801 The function \ref TZ_SAU_Setup is call from \ref SystemInit and uses the settings in this file to 
802 initialize the Secure Attribute Unit (SAU) and define non-secure interrupts (register NVIC_INIT_ITNS).
803 The following initializations are performed:
804
805   - \ref sau_ctrlregister_sec provides settings for the SAU CTRL register.
806   - \ref sau_regions_sect provides configuration of the SAU Address Regions.
807   - \ref sau_sleepexception_sec provides device-specific deepsleep and exception settings.
808   - \ref sau_interrupttarget_sec provides device-specific interrupt target settings.
809
810 \section sau_ctrlregister_sec  SAU CTRL register settings
811 <table class="cmtable">
812     <tr>
813       <th>\#define</th>
814       <th>Value Range</th>
815       <th>Default</th>
816       <th>Description</th>
817     </tr>
818     <tr>
819       <td>SAU_INIT_CTRL</td>
820       <td>0 .. 1</td>
821       <td>0</td>
822       <td>Initialize SAU CTRL register or not
823            - 0: do not initialize SAU CTRL register
824            - 1: initialize SAU CTRL register</td>
825     </tr>
826     <tr>
827       <td>SAU_INIT_CTRL_ENABLE</td>
828       <td>0 .. 1</td>
829       <td>0</td>
830       <td>enable/disable the SAU
831            - 0: disable SAU
832            - 1: enable SAU</td>
833     </tr>
834     <tr>
835       <td>SAU_INIT_CTRL_ALLNS</td>
836       <td>0 .. 1</td>
837       <td>0</td>
838       <td>value for SAU_CTRL register bit ALLNS
839            - 0: all Memory is Secure
840            - 1: all Memory is Non-Secure</td>
841     </tr>
842 </table>
843
844 \section sau_regions_sect  Configuration of the SAU Address Regions
845 <table class="cmtable">
846     <tr>
847       <th>\#define</th>
848       <th>Value Range</th>
849       <th>Default</th>
850       <th>Description</th>
851     </tr>
852     <tr>
853       <td>SAU_REGIONS_MAX</td>
854       <td>0 .. tbd</td>
855       <td>8</td>
856       <td>maximum number of SAU regions</td>
857     </tr>
858     <tr>
859       <td>SAU_INIT_REGION<number></td>
860       <td>0 .. 1</td>
861       <td>0</td>
862       <td>initialize SAU region or not
863            - 0: do not initialize SAU region
864            - 1: initialize SAU region</td>
865     </tr>
866     <tr>
867       <td>SAU_INIT_START<number></td>
868       <td>0x00000000 .. 0xFFFFFFE0\n
869           [in steps of 32]</td>
870       <td>0x00000000</td>
871       <td>region start address</td>
872     </tr>
873     <tr>
874       <td>SAU_INIT_END<number></td>
875       <td>0x00000000 .. 0xFFFFFFE0\n
876           [in steps of 32]</td>
877       <td>0x00000000</td>
878       <td>region start address</td>
879     </tr>
880     <tr>
881       <td>SAU_INIT_NSC<number></td>
882       <td>0 .. 1</td>
883       <td>0</td>
884       <td>SAU region attribute
885            - 0: Non-Secure
886            - 1: Secure, Non-Secure callable</td>
887     </tr>
888 </table>
889
890 The range of \<number\> is from 0 .. SAU_REGIONS_MAX.
891 A set of these macros must exist for each \<number\>.
892
893 The following example shows a set of SAU region macros.
894
895 \code
896 #define SAU_REGIONS_MAX   8                 /* Max. number of SAU regions */
897  
898 #define SAU_INIT_REGION0    1
899 #define SAU_INIT_START0     0x00000000      /* start address of SAU region 0 */
900 #define SAU_INIT_END0       0x001FFFE0      /* end address of SAU region 0 */
901 #define SAU_INIT_NSC0       1
902  
903 #define SAU_INIT_REGION1    1
904 #define SAU_INIT_START1     0x00200000      /* start address of SAU region 1 */
905 #define SAU_INIT_END1       0x003FFFE0      /* end address of SAU region 1 */
906 #define SAU_INIT_NSC1       0
907  
908 #define SAU_INIT_REGION2    1
909 #define SAU_INIT_START2     0x20200000      /* start address of SAU region 2 */
910 #define SAU_INIT_END2       0x203FFFE0      /* end address of SAU region 2 */
911 #define SAU_INIT_NSC2       0
912  
913 #define SAU_INIT_REGION3    1
914 #define SAU_INIT_START3     0x40000000      /* start address of SAU region 3 */
915 #define SAU_INIT_END3       0x40040000      /* end address of SAU region 3 */
916 #define SAU_INIT_NSC3       0
917  
918 #define SAU_INIT_REGION4    0
919 #define SAU_INIT_START4     0x00000000      /* start address of SAU region 4 */
920 #define SAU_INIT_END4       0x00000000      /* end address of SAU region 4 */
921 #define SAU_INIT_NSC4       0
922  
923 #define SAU_INIT_REGION5    0
924 #define SAU_INIT_START5     0x00000000      /* start address of SAU region 5 */
925 #define SAU_INIT_END5       0x00000000      /* end address of SAU region 5 */
926 #define SAU_INIT_NSC5       0
927  
928 #define SAU_INIT_REGION6    0
929 #define SAU_INIT_START6     0x00000000      /* start address of SAU region 6 */
930 #define SAU_INIT_END6       0x00000000      /* end address of SAU region 6 */
931 #define SAU_INIT_NSC6       0
932  
933 #define SAU_INIT_REGION7    0
934 #define SAU_INIT_START7     0x00000000      /* start address of SAU region 7 */
935 #define SAU_INIT_END7       0x00000000      /* end address of SAU region 7 */
936 #define SAU_INIT_NSC7       0
937 \endcode
938
939
940 \section sau_sleepexception_sec  Configuration of Sleep and Exception behaviour
941 <table class="cmtable">
942     <tr>
943       <th>\#define</th>
944       <th>Value Range</th>
945       <th>Default</th>
946       <th>Description</th>
947     </tr>
948     <tr>
949       <td>CSR_INIT_DEEPSLEEPS</td>
950       <td>0 .. 1</td>
951       <td>0</td>
952       <td>value for SCB_CSR register bit DEEPSLEEPS
953            - 0: Deep Sleep can be enabled by Secure and Non-Secure state
954            - 1: Deep Sleep can be enabled by Secure state only</td>
955     </tr>
956     <tr>
957       <td>AIRCR_INIT_SYSRESETREQS</td>
958       <td>0 .. 1</td>
959       <td>0</td>
960       <td>value for SCB_AIRCR register bit SYSRESETREQS
961            - 0: System reset request accessible from Secure and Non-Secure state
962            - 1: System reset request accessible from Secure state only</td>
963     </tr>
964     <tr>
965       <td>AIRCR_INIT_PRIS</td>
966       <td>0 .. 1</td>
967       <td>0</td>
968       <td>value for SCB_AIRCR register bit PRIS
969            - 0: Priority of Non-Secure exceptions is Not altered
970            - 1: Priority of Non-Secure exceptions is Lowered to 0x80-0xFF</td>
971     </tr>
972     <tr>
973       <td>AIRCR_INIT_BFHFNMINS</td>
974       <td>0 .. 1</td>
975       <td>0</td>
976       <td>value for SCB_AIRCR register bit BFHFNMINS
977            - 0: BusFault, HardFault, and NMI target are Secure state
978            - 1: BusFault, HardFault, and NMI target are Non-Secure state</td>
979     </tr>
980 </table>
981
982 \section sau_interrupttarget_sec Configuration of Interrupt Target settings
983
984 Each interrupt has a configuration bit that defines the execution
985 in Secure or Non-secure state. The Non-Secure interrupts have a separate
986 vector table.  Refer to \ref Model_TrustZone for more information.
987
988 <table class="cmtable">
989     <tr>
990       <th>\#define</th>
991       <th>Value Range</th>
992       <th>Default</th>
993       <th>Description</th>
994     </tr>
995     <tr>
996       <td>NVIC_INIT_ITNS<number></td>
997       <td>0x00000000 .. 0xFFFFFFFF\n
998           [each bit represents an interrupt]</td>
999       <td>0x00000000</td>
1000       <td>Interrupt vector target
1001            - 0: Secure state
1002            - 1: Non-Secure state</td>
1003     </tr>
1004 </table>
1005
1006 The range of \<number\> is 0 .. (\<number of external interrupts\> + 31) / 32.
1007
1008 The following example shows the configuration for a maximum of 64 external interrupts.
1009
1010 \code
1011 #define NVIC_INIT_ITNS0      0x0000122B
1012 #define NVIC_INIT_ITNS1      0x0000003A
1013 \endcode
1014
1015
1016 */
1017
1018 */