]> begriffs open source - cmsis/blob - CMSIS/DoxyGen/Core_A/src/Template.txt
Release preparation: Aligned version information and updated change histories.
[cmsis] / CMSIS / DoxyGen / Core_A / src / Template.txt
1 /**
2 \page templates_pg CMSIS-Core Device Templates
3
4 \details
5
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.
8
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.
13
14 The detailed file structure of the CMSIS-Core device templates is shown in the following picture.
15
16 <!-- \image html "CMSIS_CORE_Files.png" "CMSIS-Core File Structure" -->
17
18 \section CMSIS_Processor_files CMSIS-Core Processor Files 
19
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_&lt;cpu&gt;.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:
22
23 Header File      | Processor
24 :----------------|:------------------------------
25 core_ca.h        | generics for all supportet Cortex-A processors
26
27 \section device_examples Device Examples
28
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>:
31
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
37
38
39
40 \section template_files_sec Template Files
41
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.
47
48 <table class="cmtable">
49     <tr>
50       <th>Template File</th>
51       <th>Description</th>
52     </tr>
53     <tr>
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>
56     </tr>   
57     <tr>
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>
60     </tr>
61     <tr>
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>
64     </tr>
65     <tr>
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>
68     </tr>
69     <tr>
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>
73     </tr>
74     <tr>
75       <td>.\\Device\\\_Template_Vendor\\Vendor\\Device_A\\Include\\system_Device.h</td>
76       <td>Generic system device configuration include file.</td>
77     </tr>
78     <tr>
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>
81     </tr>
82 </table>
83
84
85 <b>Adapt Template Files to a Device</b>
86
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.
92
93 Each template file contains comments that start with \b ToDo: that describe a required modification.
94 The template files contain place holders:
95
96 <table class="cmtable">
97     <tr>
98       <th>Placeholder</th>
99       <th>Replaced with</th>
100     </tr>
101     <tr>
102       <td>&lt;Device&gt;</td>
103       <td>the specific device name or device family name; i.e. LPC17xx.</td>
104     </tr>
105     <tr>
106       <td>&lt;DeviceInterrupt&gt;</td>
107       <td>a specific interrupt name of the device; i.e. TIM1 for Timer 1.</td>
108     <tr>
109       <td>&lt;DeviceAbbreviation&gt;</td>
110       <td>short name or abbreviation of the device family; i.e. LPC.</td>
111     </tr>
112     <tr>
113       <td>Cortex-M#</td>
114       <td>the specific Cortex-M processor name; i.e. Cortex-M3.</td>
115     </tr>
116 </table>
117
118
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
123   - \subpage mem_h_pg
124   - \subpage mmu_c_pg
125 */
126
127 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
128 /**
129 \page startup_c_pg Startup File startup_<device>.c
130
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.
135
136 The file exists for each supported toolchain and is the only tool-chain specific CMSIS file.
137
138 \section startup_c_sec startup_Device.c Template File
139
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.
142
143 \verbinclude "Source\ARM\startup_Device.c"
144 */
145
146 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
147 /**
148 \page system_c_pg System Configuration Files system_<device>.c and system_<device>.h
149
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.
153
154 For devices with external memory BUS the system_<device>.c also configures the BUS system.
155
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.
158
159 \section system_Device_sec system_Device.c Template File
160
161 The \ref system_Device_sec for the Cortex-M3 is shown below.
162
163 \verbinclude "Source\system_Device.c"
164
165 \section system_Device_h_sec system_Device.h Template File
166
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.
169
170 \verbinclude "Include\system_Device.h"
171
172 */
173
174 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
175 /**
176 \page device_h_pg Device Header File \<device.h>
177
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.
183
184 <a href="Modules.html">\b Reference </a> describes the standard features and functions of the \ref device_h_pg in detail.
185
186 \section interrupt_number_sec Interrupt Number Definition
187
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 interrups (SPI), routeable to all processor cores.
193   - IRQn 1020-1023 represents special interrupts, refer to the GIC Architecture Specification.
194   
195 \b Example:
196
197 The following example shows the extension of the interrupt vector table for Cortex-A9 class device.
198
199 \code
200 typedef enum IRQn
201 {
202 /******  SGI Interrupts Numbers                 ****************************************/
203   SGI0_IRQn            =  0,      
204   SGI1_IRQn            =  1,
205   SGI2_IRQn            =  2,
206        :                  :
207   SGI15_IRQn           = 15,
208
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                    */
213
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        */
220        :                  :
221        :                  :
222 } IRQn_Type;
223 \endcode
224
225 \section core_config_sect Configuration of the Processor and Core Peripherals
226
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>.
229
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.
232
233 <table class="cmtable">
234     <tr>
235       <th>\#define</th>
236       <th>Value Range</th>
237       <th>Default</th>
238       <th>Description</th>
239     </tr>
240     <tr>
241       <td>__CM0_REV</td>
242       <td>0x0000</td>
243       <td>0x0000</td>
244       <td>Core revision number ([15:8] revision number, [7:0] patch number)</td>
245     </tr>
246     <tr>
247       <td>__CORTEX_A</td>
248       <td>5, 7, 9</td>
249       <td>(n/a)</td>
250       <td>Core type number</td>
251     </tr>
252     <tr>
253       <td>__FPU_PRESENT</td>
254       <td>0 .. 1</td>
255       <td>0</td>
256       <td>Defines if an FPU is present or not</td>
257     </tr>
258     <tr>
259       <td>__GIC_PRESENT</td>
260       <td>0 ..1 </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>
263     </tr>
264     <tr>
265       <td>__TIM_PRESENT</td>
266       <td>0 .. 1</td>
267       <td>0</td>
268       <td>Defines if a private timer is present or not</td>
269     </tr>
270     <tr>
271       <td>__L2C_PRESENT</td>
272       <td>0 .. 1</td>
273       <td>0</td>
274       <td>Defines if a level 2 cache controller is present or not</td>
275     </tr>
276 </table>
277
278 \b Example
279
280 The following code exemplifies the configuration of the Cortex-A9 Processor and Core Peripherals.
281
282 \code
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                             */
289 :
290 :
291 #include "core_ca.h"               /* Cortex-A processor and core peripherals       */
292 \endcode
293
294
295 \section core_version_sect   CMSIS Version and Processor Information
296
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.
300
301 \code
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 */
306 \endcode
307
308 \section device_access Device Peripheral Access Layer
309
310 The \ref device_h_pg contains for each peripheral:
311  - Register Layout Typedef
312  - Base Address
313  - Access Definitions
314
315 The section \ref peripheral_gr shows examples for peripheral definitions.
316
317 \section device_h_sec Device.h Template File
318
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.
322
323 \verbinclude "Include\Device.h"
324
325 */
326
327 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
328 /**
329 \page mem_h_pg Memory Configuration Files mem_<device>.h
330
331 \verbinclude "Include\mem_Device.h"
332
333 */
334
335 /*=======0=========1=========2=========3=========4=========5=========6=========7=========8=========9=========0=========1====*/
336 /**
337 \page mmu_c_pg Memory Management Unit Files mmu_<device>.c
338
339 \verbinclude "Source\mmu_Device.c"
340
341 */
342