1 /**************************************************************************//**
2 * @file cmsis_armcc.txt
3 * @brief CMSIS compiler specific macros, functions, instructions
6 ******************************************************************************/
7 /* CMSIS compiler control architecture macros */
9 \defgroup comp_cntrl_gr Compiler Control
10 \brief Compiler agnostic \#define symbols for generic C/C++ source code
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.
23 \brief Set to 1 when generating code for Armv7-A (Cortex-A7)
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.
30 \brief Pass information from the compiler to the assembler.
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).
37 // Reverse bit order of value
39 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
43 __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
51 \brief Recommend that function should be inlined by the compiler.
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.
59 const uint32_t led_mask[] = {1U << 4, 1U << 5, 1U << 6, 1U << 7};
61 //------------------------------------------------------------------------------
63 //------------------------------------------------------------------------------
64 __INLINE static void LED_On (uint32_t led) {
66 PTD->PCOR = led_mask[led];
73 \brief Define a static function should be inlined by the compiler.
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.
80 __STATIC_INLINE uint32_t GIC_GetPriority(IRQn_Type IRQn)
82 return((uint32_t)GICDistributor->D_IPRIORITYR[((uint32_t)(int32_t)IRQn)]);
89 \brief Inform the compiler that a function does not return.
91 Informs the compiler that the function does not return. The compiler can then perform optimizations by
92 removing code that is never reached.
96 // OS idle demon (running when no other thread is ready to run).
98 __NO_RETURN void os_idle_demon (void);
104 \brief Inform that a variable shall be retained in executable image.
106 Definitions tagged with \b __USED in the source code should be not removed by the linker when detected as unused.
108 <b> Code Example:</b>
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;
120 \brief Export a function or variable weakly to allow overwrites.
122 Functions defined with \b __WEAK export their symbols weakly. A function defined weak behaves like a normal defined
123 function unless a non-weak function with the same name is linked into the same image. If both a non-weak
124 function and a weak defined function exist in the same image, then all calls to the function resolve to the non-weak
127 Functions declared with \b __WEAK and then defined without \b __WEAK behave as non-weak functions.
129 <b> Code Example:</b>
131 __WEAK void SystemInit(void)
134 SystemCoreClockSetup();
141 \brief Minimum alignment for a variable.
143 Specifies a minimum alignment for a variable or structure field, measured in bytes.
145 <b> Code Example:</b>
147 uint32_t stack_space[0x100] __ALIGNED(8); // 8-byte alignment required
153 \brief Request smallest possible alignment.
155 Specifies that a type must have the smallest possible alignment.
157 <b> Code Example:</b>
161 uint32_t u32[2] __PACKED;
169 /* end group comp_cntrl_gr */
171 /* ########################## Core Instruction Access ######################### */
173 \defgroup CMSIS_Core_InstructionInterface Intrinsic Functions
174 \brief Functions that generate specific Cortex-A CPU Instructions
180 \details No Operation does nothing. This instruction can be used for code alignment purposes.
184 \details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
187 \details Wait For Event is a hint instruction that permits the processor to enter
190 \details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
193 \details Instruction Synchronization Barrier flushes the pipeline in the processor,
194 so that all instructions following the ISB are fetched from cache or memory,
195 after the instruction has been completed.
198 \details Acts as a special kind of Data Memory Barrier.
199 It completes when all explicit memory accesses before this instruction complete.
202 \details Ensures the apparent order of the explicit memory operations before
203 and after the instruction, without ensuring their completion.
206 \details Causes the processor to enter Debug state.
207 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
211 \brief Reverse byte order (32 bit)
212 \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
213 \param [in] value Value to reverse
214 \return Reversed value
216 uint32_t __REV(uint32_t value);
219 \brief Reverse byte order (16 bit)
220 \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
221 \param [in] value Value to reverse
222 \return Reversed value
224 uint16_t __REV16(uint16_t value);
227 \brief Reverse byte order (16 bit)
228 \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
229 \param [in] value Value to reverse
230 \return Reversed value
232 int32_t __REVSH(int32_t value);
235 \brief Rotate Right in unsigned value (32 bit)
236 \details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
237 \param [in] op1 Value to rotate
238 \param [in] op2 Number of Bits to rotate
239 \return Rotated value
241 uint32_t __ROR(uint32_t op1, uint32_t op2);
244 \brief Reverse bit order of value
245 \details Reverses the bit order of the given value.
246 \param [in] value Value to reverse
247 \return Reversed value
249 uint32_t __RBIT(uint32_t value);
252 \brief Count leading zeros.
253 \details Counts the number of leading zeros of a data value.
254 \param [in] value Value to count the leading zeros
255 \return number of leading zeros in value
257 uint8_t __CLZ(uint32_t value);
260 /* end of group CMSIS_Core_InstructionInterface */