2 \page templates_pg CMSIS-Core Device Templates
6 Arm supplies CMSIS-Core device template files for the all supported Cortex-A processors and various compiler vendors.
7 Refer to the list of \ref tested_tools_sec for compliance.
9 These CMSIS-Core device template files include the following:
10 - Register names of the Core Peripherals and names of the Core Exception Vectors.
11 - Functions to access core peripherals, cache, MMU and special CPU instructions
12 - Generic startup code and system configuration code.
14 The detailed file structure of the CMSIS-Core device templates is shown in the following picture.
16 <!-- \image html "CMSIS_CORE_Files.png" "CMSIS-Core File Structure" -->
18 \section CMSIS_Processor_files CMSIS-Core Processor Files
20 The CMSIS-Core processor files provided by Arm are in the directory .\\CMSIS\\Core_A\\Include. These header files define all processor specific attributes do not need any modifications.
21 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-A processor:
23 Header File | Processor
24 :----------------|:------------------------------
25 core_ca.h | generics for all supportet Cortex-A processors
27 \section device_examples Device Examples
29 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
30 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>:
32 Family | Device | Description
33 :------------------|:------------------|:---------------------------------
34 ARM Cortex-A5 | ARMCA5 | Cortex-A5 based device
35 ARM Cortex-A7 | ARMCA7 | Cortex-A7 based device
36 ARM Cortex-A9 | ARMCA9 | Cortex-A9 based device
40 \section template_files_sec Template Files
42 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.
43 Silicon vendors add to these template files the following information:
44 - <b>Device Peripheral Access Layer</b> that provides definitions for device-specific peripherals.
45 - <b>Access Functions for Peripherals</b> (optional) that provides additional helper functions to access device-specific peripherals.
46 - <b>Interrupt vectors</b> in the startup file that are device specific.
48 <table class="cmtable">
50 <th>Template File</th>
54 <td>.\\Device\\\_Template_Vendor\\Vendor\\Device_A\\Source\\ARM\\startup_Device.c</td>
55 <td>Startup file template for Arm C/C++ Compiler.</td>
58 <td>.\\Device\\\_Template_Vendor\\Vendor\\Device_A\\Source\\ARM\\Device.sct</td>
59 <td>Linker scatter file template for Arm C/C++ Compiler.</td>
62 <td>.\\Device\\\_Template_Vendor\\Vendor\\Device_A\\Source\\system_Device.c</td>
63 <td>Generic system_Device.c file for system configuration (i.e. processor clock and memory bus system).</td>
66 <td>.\\Device\\\_Template_Vendor\\Vendor\\Device_A\\Source\\mmu_Device.c</td>
67 <td>Sample mmu_Device.c file with memory map description for Memory Management Unit (MMU) configuration.</td>
70 <td>.\\Device\\\_Template_Vendor\\Vendor\\Device_A\\Include\\Device.h</td>
71 <td>Generic device header file. Needs to be extended with the device-specific peripheral registers. Optionally functions that access the peripherals
72 can be part of that file.</td>
75 <td>.\\Device\\\_Template_Vendor\\Vendor\\Device_A\\Include\\system_Device.h</td>
76 <td>Generic system device configuration include file.</td>
79 <td>.\\Device\\\_Template_Vendor\\Vendor\\Device_A\\Include\\mem_Device.h</td>
80 <td>Generic memory base address and size definitions used in scatter file. Settable via Configuration Wizard.</td>
85 <b>Adapt Template Files to a Device</b>
87 The following steps describe how to adopt the template files to a specific device or device family.
88 Copy the complete all files in the template directory and replace:
89 - directory name 'Vendor' with the abbreviation for the device vendor e.g.: NXP.
90 - directory name 'Device' with the specific device name e.g.: LPC17xx.
91 - in the file names 'Device' with the specific device name e.g.: LPC17xx.
93 Each template file contains comments that start with \b ToDo: that describe a required modification.
94 The template files contain place holders:
96 <table class="cmtable">
99 <th>Replaced with</th>
102 <td><Device></td>
103 <td>the specific device name or device family name; i.e. LPC17xx.</td>
106 <td><DeviceInterrupt></td>
107 <td>a specific interrupt name of the device; i.e. TIM1 for Timer 1.</td>
109 <td><DeviceAbbreviation></td>
110 <td>short name or abbreviation of the device family; i.e. LPC.</td>
114 <td>the specific Cortex-M processor name; i.e. Cortex-M3.</td>
119 The device configuration of the template files is described in detail on the following pages:
120 - \subpage startup_c_pg
121 - \subpage system_c_pg
122 - \subpage device_h_pg
127 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
129 \page startup_c_pg Startup File startup_<device>.c
131 The \ref startup_c_pg contains:
132 - Exception vectors of the Cortex-A Processor with weak functions that implement default routines.
133 - The reset handler which is executed after CPU reset and typically calls the \ref SystemInit function.
134 - The setup values for the various stack pointers, i.e. per exceptional mode and main stack.
136 The file exists for each supported toolchain and is the only tool-chain specific CMSIS file.
138 \section startup_c_sec startup_Device.c Template File
140 An Arm Compiler specific startup file for an Armv7-A processor like Cortex-A9 is shown below.
141 The files for other compiler vendors differ slightly in the syntax, but not in the overall structure.
143 \verbinclude "Source\ARM\startup_Device.c"
146 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
148 \page system_c_pg System Configuration Files system_<device>.c and system_<device>.h
150 The \ref system_c_pg provides as a minimum the functions described under \ref system_init_gr.
151 These functions are device specific and need adaptations. In addition, the file might have
152 configuration settings for the device such as XTAL frequency or PLL prescaler settings.
154 For devices with external memory BUS the system_<device>.c also configures the BUS system.
156 The silicon vendor might expose other functions (i.e. for power configuration) in the system_<device>.c file.
157 In case of additional features the function prototypes need to be added to the system_<device>.h header file.
159 \section system_Device_sec system_Device.c Template File
161 The \ref system_Device_sec for the Cortex-M3 is shown below.
163 \verbinclude "Source\system_Device.c"
165 \section system_Device_h_sec system_Device.h Template File
167 The system_<device>.h header file contains prototypes to access the public functions in the system_<device>.c file.
168 The \ref system_Device_h_sec is shown below.
170 \verbinclude "Include\system_Device.h"
174 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
176 \page device_h_pg Device Header File \<device.h>
178 The \ref device_h_pg contains the following sections that are device specific:
179 - \ref irqn_defs provides interrupt numbers (IRQn) for all exceptions and interrupts of the device.
180 - \ref config_perifs reflect the features of the device.
181 - \ref access_perifs definitions for the \ref peripheral_gr to all device peripherals. It contains all data structures and the address mapping for device-specific peripherals.
182 - <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.
184 <a href="Modules.html">\b Reference </a> describes the standard features and functions of the \ref device_h_pg in detail.
186 \section interrupt_number_sec Interrupt Number Definition
188 \ref device_h_pg contains the enumeration \ref IRQn_Type that defines all exceptions and interrupts of the device.
189 For devices implementing an Arm GIC these are defined as:
190 - IRQn 0-15 represents software generated interrupts (SGI), local to each processor core.
191 - IRQn 16-31 represents private peripheral interrupts (PPI), local to each processor core.
192 - IRQn 32-1019 represents shared peripheral interrupts (SPI), routable to all processor cores.
193 - IRQn 1020-1023 represents special interrupts, refer to the GIC Architecture Specification.
197 The following example shows the extension of the interrupt vector table for Cortex-A9 class device.
202 /****** SGI Interrupts Numbers ****************************************/
209 /****** Cortex-A9 Processor Exceptions Numbers ****************************************/
210 GlobalTimer_IRQn = 27, /*!< Global Timer Interrupt */
211 PrivTimer_IRQn = 29, /*!< Private Timer Interrupt */
212 PrivWatchdog_IRQn = 30, /*!< Private Watchdog Interrupt */
214 /****** Platform Exceptions Numbers ***************************************************/
215 Watchdog_IRQn = 32, /*!< SP805 Interrupt */
216 Timer0_IRQn = 34, /*!< SP804 Interrupt */
217 Timer1_IRQn = 35, /*!< SP804 Interrupt */
218 RTClock_IRQn = 36, /*!< PL031 Interrupt */
219 UART0_IRQn = 37, /*!< PL011 Interrupt */
225 \section core_config_sect Configuration of the Processor and Core Peripherals
227 The \ref device_h_pg configures the Cortex-A processor and the core peripherals with <i>\#defines</i>
228 that are set prior to including the file <b>core_<cpu>.h</b>.
230 The following tables list the <i>\#defines</i> along with the possible values for each processor core.
231 If these <i>\#defines</i> are missing default values are used.
233 <table class="cmtable">
244 <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
250 <td>Core type number</td>
253 <td>__FPU_PRESENT</td>
256 <td>Defines if an FPU is present or not</td>
259 <td>__GIC_PRESENT</td>
261 <td>Defines if an GIC is present or not</td>
262 <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
265 <td>__TIM_PRESENT</td>
268 <td>Defines if a private timer is present or not</td>
271 <td>__L2C_PRESENT</td>
274 <td>Defines if a level 2 cache controller is present or not</td>
280 The following code exemplifies the configuration of the Cortex-A9 Processor and Core Peripherals.
283 #define __CA_REV 0x0000U /*!< Core revision r0p0 */
284 #define __CORTEX_A 9U /*!< Cortex-A9 Core */
285 #define __FPU_PRESENT 1U /*!< FPU present */
286 #define __GIC_PRESENT 1U /*!< GIC present */
287 #define __TIM_PRESENT 0U /*!< TIM not present */
288 #define __L2C_PRESENT 0U /*!< L2C not present */
291 #include "core_ca.h" /* Cortex-A processor and core peripherals */
295 \section core_version_sect CMSIS Version and Processor Information
297 Defines in the core_<i>cpu</i>.h file identify the version of the CMSIS-Core-A and the processor used.
298 The following shows the defines in the various core_<i>cpu</i>.h files that may be used in the \ref device_h_pg
299 to verify a minimum version or ensure that the right processor core is used.
302 #define __CA_CMSIS_VERSION_MAIN (5U) /* [31:16] CMSIS Core main version */
303 #define __CA_CMSIS_VERSION_SUB (0U) /* [15:0] CMSIS Core sub version */
304 #define __CA_CMSIS_VERSION ((__CA_CMSIS_VERSION_MAIN << 16U) | \
305 __CA_CMSIS_VERSION_SUB ) /* CMSIS Core version number */
308 \section device_access Device Peripheral Access Layer
310 The \ref device_h_pg contains for each peripheral:
311 - Register Layout Typedef
315 The section \ref peripheral_gr shows examples for peripheral definitions.
317 \section device_h_sec Device.h Template File
319 The silicon vendor needs to extend the Device.h template file with the CMSIS features described above.
320 In addition the \ref device_h_pg may contain functions to access device-specific peripherals.
321 The \ref system_Device_h_sec which is provided as part of the CMSIS specification is shown below.
323 \verbinclude "Include\Device.h"
327 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
329 \page mem_h_pg Memory Configuration Files mem_<device>.h
331 \verbinclude "Include\mem_Device.h"
335 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
337 \page mmu_c_pg Memory Management Unit Files mmu_<device>.c
339 \verbinclude "Source\mmu_Device.c"