]> begriffs open source - cmsis/blob - CMSIS/DoxyGen/Core_A/src/cmsis_armcc.txt
Updated Core_A documentation
[cmsis] / CMSIS / DoxyGen / Core_A / src / cmsis_armcc.txt
1 /**************************************************************************//**
2  * @file     cmsis_armcc.txt
3  * @brief    CMSIS compiler specific macros, functions, instructions
4  * @version  V1.00
5  * @date     22. Feb 2017
6  ******************************************************************************/
7 /* CMSIS compiler control architecture macros */
8 /**
9 \defgroup comp_cntrl_gr Compiler Control
10 \brief Compiler agnostic \#define symbols for generic C/C++ source code
11 \details
12 The CMSIS-Core provides the header file \b cmsis_compiler.h with consistent \#define symbols to generate C or C++ source files that should be compiler agnostic.
13 Each CMSIS compliant compiler should support the functionality described in this section.
14 @{
15 */
16
17 /**
18 \def __ARMCC_VERSION
19 */
20
21 /**
22 \def __ARM_ARCH_7A__    
23 \brief Set to 1 when generating code for ARMv7-A (Cortex-A7)
24 \details
25 The \b \#define __ARM_ARCH_7A__ is set to 1 when generating code for the ARMv7-A architecture. This architecture is for example used by the Cortex-A7 processor.
26 */
27
28 /**      
29 \def __ASM           
30 \brief Pass information from the compiler to the assembler.
31 \details
32 The \b __ASM keyword can declare or define an embedded assembly function or incorporate inline assembly into a function
33 (shown in the code example below).
34  
35 <b>Code Example:</b>
36 \code
37 // Reverse bit order of value
38  
39 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
40 {
41   uint32_t result;
42  
43    __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
44    return(result);
45 }
46 \endcode
47 */
48
49 /**        
50 \def __INLINE         
51 \brief Recommend that function should be inlined by the compiler.
52 \details
53 Inline functions offer a trade-off between code size and performance. By default, the compiler decides during optimization whether to
54 inline code or not. The \b __INLINE attribute gives the compiler an hint to inline this function. 
55 Still, the compiler may decide not to inline the function. As the function is global an callable function is also generated. 
56
57 <b> Code Example:</b>
58 \code
59 const uint32_t led_mask[] = {1U << 4, 1U << 5, 1U << 6, 1U << 7};
60  
61 //------------------------------------------------------------------------------
62 // Switch on LEDs
63 //------------------------------------------------------------------------------
64 __INLINE static void LED_On (uint32_t led) {
65  
66   PTD->PCOR   = led_mask[led];
67 }
68 \endcode
69 */
70
71 /**
72 \def __STATIC_INLINE  
73 \brief Define a static function should be inlined by the compiler.
74 \details
75 Defines a static function that may be inlined by the compiler. If the compiler generates inline code for 
76 all calls to this functions, no additional function implementation is generated which may further optimize space.
77
78 <b> Code Example:</b>
79 \todo add example
80 */
81
82 /**
83 \def __STATIC_ASM          
84 \todo Daniel: Need input to this
85 */
86
87 /**  
88 \def __NO_RETURN             
89 \brief Inform the compiler that a function does not return.
90 \details
91 Informs the compiler that the function does not return. The compiler can then perform optimizations by
92 removing code that is never reached.
93  
94 <b> Code Example:</b>
95 \code
96 // OS idle demon (running when no other thread is ready to run).
97  
98 __NO_RETURN void os_idle_demon (void);
99 \endcode
100 */
101
102 /**
103 \def __USED     
104 \brief Inform that a variable shall be retained in executable image.
105 \details
106 Definitions tagged with \b __USED in the source code should be not removed by the linker when detected as unused.
107  
108 <b> Code Example:</b>
109 \code
110 // Export following variables for debugging 
111 __USED uint32_t const CMSIS_RTOS_API_Version = osCMSIS;
112 __USED uint32_t const CMSIS_RTOS_RTX_Version = osCMSIS_RTX;
113 __USED uint32_t const os_clockrate = OS_TICK;
114 __USED uint32_t const os_timernum  = 0;
115 \endcode
116 \todo Daniel: verify example
117 **/
118
119 /**             
120 \def __WEAK                  
121 \brief Export a function or variable weakly to allow overwrites.
122 \details
123 Functions defined with \b __WEAK export their symbols weakly. A function defined weak behaves like a normal defined
124 function unless a non-weak function with the same name is linked into the same image. If both a non-weak
125 function and a weak defined function exist in the same image, then all calls to the function resolve to the non-weak
126 function.
127
128 Functions declared with \b __WEAK and then defined without \b __WEAK behave as non-weak functions.
129  
130 <b> Code Example:</b>
131 \code
132 __WEAK void SystemInit(void)
133 {
134   SystemCoreSetup();
135   SystemCoreClockSetup(); 
136 }
137 \endcode
138 */
139
140 /**
141 \def __UNALIGNED_UINT32(x)   
142 \brief Pointer for unaligned access of a uint32_t variable.
143 \details
144 Defines a pointer to a uint32_t from an address that does not need to be aligned. This can then be used in read/write
145 operations. The compiler will generate the appropriate access (aligned or non-aligned) depending on the underlying ARM
146 processor core and compiler settings.
147  
148 <b> Code Example:</b>
149 \code
150 uint32_t val32;
151  
152 void test (uint8_t *ptr) {
153   __UNALIGNED_UINT32(ptr) = val32;
154 }
155 \endcode
156 */
157
158 /**
159 \def __ALIGNED(x)  
160 \brief Minimum alignment for a variable.
161 \details
162 Specifies a minimum alignment for a variable or structure field, measured in bytes.
163  
164 <b> Code Example:</b>
165 \code
166 uint32_t stack_space[0x100] __ALIGNED(8);   // 8-byte alignment required
167 \endcode
168 */
169
170 /**
171 \def __PACKED   
172 \brief Request smallest possible alignment.
173 \details
174 Specifies that a type must have the smallest possible alignment.
175  
176 <b> Code Example:</b>
177 \code
178 struct foo {
179   uint8_t  u8;
180   uint32_t u32[2] __PACKED;
181 };
182 \endcode
183 */
184
185 /**
186 @}
187 */
188 /* end group comp_cntrl_gr */
189
190 /* ###########################  Core Function Access  ########################### */
191 /** 
192 \defgroup core_reg_func_gr Core Register Access
193 \brief Functions to access the Cortex-A core registers
194 @{
195 */
196
197 /**
198 \fn __STATIC_INLINE uint32_t __get_FPSCR(void)
199 \details 
200   Returns the current value of the Floating Point Status/Control register.
201
202 \fn __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
203 \details 
204   Assigns the given value to the Floating Point Status/Control register.
205
206 \fn __STATIC_INLINE uint32_t __get_CPSR(void)
207 \details
208         This function returns the content of the CPSR Register.
209
210 \fn __STATIC_INLINE void __set_SP(uint32_t stack)
211 \details
212   This function assigns the given value to the current stack pointer.
213
214 \fn __STATIC_ASM void __set_PSP(uint32_t topOfProcStack)
215 \details
216   This function assigns the given value to the USR/SYS Stack Pointer (PSP).
217
218 \fn __STATIC_ASM void __set_CPS_USR(void)
219 \details
220   This function changes the processor state to User Mode
221
222 \fn __STATIC_INLINE uint32_t __get_FPEXC(void)
223 \details
224   This function returns the current value of the Floating Point Exception Control register.
225
226 \fn __STATIC_INLINE void __set_FPEXC(uint32_t fpexc)
227 \details
228   This function assigns the given value to the Floating Point Exception Control register.
229
230 \fn __STATIC_INLINE uint32_t __get_CPACR(void)
231 \details
232   This function returns the current value of the Coprocessor Access Control register.
233
234 \fn __STATIC_INLINE void __set_CPACR(uint32_t cpacr)
235 \details
236   This function assigns the given value to the Coprocessor Access Control register.
237
238 \fn __STATIC_INLINE uint32_t __get_CBAR()
239 \details
240   This function returns the value of the Configuration Base Address register.
241
242 \fn __STATIC_INLINE uint32_t __get_TTBR0() 
243 \details
244   This function returns the value of the Translation Table Base Register 0.
245
246 \fn __STATIC_INLINE void __set_TTBR0(uint32_t ttbr0) 
247 \details
248   This function assigns the given value to the Translation Table Base Register 0.
249
250 \fn __STATIC_INLINE uint32_t __get_DACR() 
251 \details
252   This function returns the value of the Domain Access Control Register.
253
254 \fn __STATIC_INLINE void __set_DACR(uint32_t dacr) 
255 \details
256   This function assigns the given value to the Domain Access Control Register.
257
258 \fn __STATIC_INLINE void __set_SCTLR(uint32_t sctlr)
259 \details
260   This function assigns the given value to the System Control Register.
261
262 \fn __STATIC_INLINE uint32_t __get_SCTLR() 
263 \details
264   This function returns the value of the System Control Register.
265
266 \fn __STATIC_INLINE void __set_ACTRL(uint32_t actrl)
267 \details
268   This function assigns the given value to the Auxiliary Control Register.
269
270 \fn __STATIC_INLINE uint32_t __get_ACTRL(void)
271 \details
272   This function returns the value of the Auxiliary Control Register.
273
274 \fn __STATIC_INLINE uint32_t __get_MPIDR(void)
275 \details
276   This function returns the value of the Multiprocessor Affinity Register.
277
278 \fn __STATIC_INLINE uint32_t __get_VBAR(void)
279 \details
280   This function returns the value of the Vector Base Address Register.
281
282 \fn __STATIC_INLINE void __set_VBAR(uint32_t vbar)
283 \details
284   This function assigns the given value to the Vector Base Address Register.
285
286 \fn __STATIC_INLINE void __set_CNTP_TVAL(uint32_t value) 
287 \details
288   This function assigns the given value to PL1 Physical Timer Value Register (CNTP_TVAL).
289
290 \fn __STATIC_INLINE uint32_t __get_CNTP_TVAL() 
291 \details
292   This function returns the value of the PL1 Physical Timer Value Register (CNTP_TVAL).
293
294 \fn __STATIC_INLINE void __set_CNTP_CTL(uint32_t value) 
295 \details
296   This function assigns the given value to PL1 Physical Timer Control Register (CNTP_CTL).
297
298 \fn __STATIC_INLINE void __set_TLBIALL(uint32_t value) 
299 \details
300
301 \fn __STATIC_INLINE void __set_BPIALL(uint32_t value)   
302 \details
303   Branch Predictor Invalidate All
304
305 \fn __STATIC_INLINE void __set_ICIALLU(uint32_t value) 
306 \details
307   Instruction Cache Invalidate All
308
309 \fn __STATIC_INLINE void __set_DCCMVAC(uint32_t value) 
310 \details
311   Data cache clean
312
313 \fn __STATIC_INLINE void __set_DCIMVAC(uint32_t value) 
314 \details
315   Data cache invalidate
316
317 \fn __STATIC_INLINE void __set_DCCIMVAC(uint32_t value) 
318 \details
319   Data cache clean and invalidate
320 */
321 /**
322 @} 
323 */
324 /* end group core_reg_func_gr */
325
326 /* ##########################  Core Instruction Access  ######################### */
327 /** 
328 \defgroup CMSIS_Core_InstructionInterface Intrinsic Functions for CPU Instructions
329 \brief Functions that generate specific Cortex-A CPU Instructions
330 @{
331 */
332
333 /**
334 \def __NOP                         
335 \details No Operation does nothing. This instruction can be used for code alignment purposes.
336
337
338 \def __WFI                         
339 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
340
341 \def __WFE                         
342 \details Wait For Event is a hint instruction that permits the processor to enter
343
344 \def __SEV                         
345 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
346
347 \def __ISB()
348 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
349            so that all instructions following the ISB are fetched from cache or memory,
350            after the instruction has been completed.
351
352 \def __DSB()
353 \details Acts as a special kind of Data Memory Barrier.
354            It completes when all explicit memory accesses before this instruction complete.
355
356 \def __DMB()
357 \details Ensures the apparent order of the explicit memory operations before
358            and after the instruction, without ensuring their completion.
359
360
361 \def __REV                             
362 \details Reverses the byte order in integer value.
363 */
364
365 /**
366 \details Reverses the byte order in two unsigned short values.
367 */
368 /* leave definition here */ 
369 _STATIC_INLINE __ASM uint32_t __REV16(uint32_t value);
370
371 /**
372 \details Reverses the byte order in a signed short value with sign extension to integer.
373 */
374 /* leave definition here */ 
375 \fn __STATIC_INLINE __ASM int32_t __REVSH(int32_t value);
376
377 /**
378 \def __ROR         
379 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
380
381 \def __BKPT(value) 
382 \details Causes the processor to enter Debug state.
383            Debug tools can use this to investigate system state when the instruction at a particular address is reached.
384
385
386 \fn __STATIC_INLINE uint32_t __RBIT(uint32_t value)
387 \details 
388         Reverses the bit order of the given value.
389
390 \def __CLZ                            
391 \details 
392         Counts the number of leading zeros of a data value.
393 */
394
395 /** @}*/ 
396 /* end of group CMSIS_Core_InstructionInterface */
397
398