]> begriffs open source - cmsis/blob - CMSIS/DoxyGen/Core/src/Ref_cmInstr.txt
Pack/Doxygen: Updated versions and changelogs of Core(M) and Core(A).
[cmsis] / CMSIS / DoxyGen / Core / src / Ref_cmInstr.txt
1 /**
2 \defgroup intrinsic_CPU_gr Intrinsic Functions for CPU Instructions
3 @{
4 \brief Functions that generate specific Cortex-M CPU Instructions.
5 \details
6 The following functions generate specific Cortex-M instructions that cannot be directly accessed by the C/C++ Compiler.
7 Refer to the \ref ref_man_sec for detailed information about these Cortex-M instructions.
8
9 \note
10 When using the Arm Compiler Toolchain the following \ref intrinsic_CPU_gr are implemented using the Embedded Assembler: \ref __RRX, <Bruno: add more...>.
11 The usage of the Embedded Assembler can be disabled by with <b><i>define __NO_EMBEDDED_ASM</i></b>. This avoids potential side effects of the Embedded Assembler.
12 Refer to <b>Compiler User Guide - Using the Inline and Embedded Assemblers of the Arm Compiler</b> for more information. 
13
14 */
15 /**************************************************************************************************/
16 /** \brief  No Operation
17
18     This function does nothing. This instruction can be used for code alignment purposes.
19  */
20 void __NOP(void);
21
22
23 /**************************************************************************************************/
24 /** \brief  Wait For Interrupt
25
26     WFI is a hint instruction that suspends execution until one of the following events occurs:
27     - A non-masked interrupt occurs and is taken.
28     - An interrupt masked by PRIMASK becomes pending.
29     - A Debug Entry request.
30  */
31 void __WFI(void);
32
33
34 /**************************************************************************************************/
35 /** \brief  Wait For Event
36
37     Wait For Event is a hint instruction that permits the processor to enter
38     a low-power state until an events occurs:
39     \li If the <b>event register is 0</b>, then WFE suspends execution until one of the following events occurs:
40     - An exception, unless masked by the exception mask registers or the current priority level.
41     - An exception enters the Pending state, if SEVONPEND in the System Control Register is set.
42     - A Debug Entry request, if Debug is enabled.
43     - An event signaled by a peripheral or another processor in a multiprocessor system using
44     the SEV instruction.
45     
46     \li If the <b>event register is 1</b>, then WFE clears it to 0 and returns immediately.
47     
48  */
49 void __WFE(void);
50
51
52 /**************************************************************************************************/
53 /** \brief  Send Event
54
55     Send Event is a hint instruction. It causes an event to be signaled to the CPU.
56  */
57 void __SEV(void);
58
59
60 /**************************************************************************************************/
61 /** \brief  Set Breakpoint
62
63 This function causes the processor to enter Debug state.
64 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
65
66 \param [in]    value  is ignored by the processor. If required, a debugger can use it to obtain additional information about the breakpoint.
67 */
68 void __BKPT(uint8_t value);
69
70
71 /**************************************************************************************************/
72 /** \brief  Instruction Synchronization Barrier
73
74     Instruction Synchronization Barrier flushes the pipeline in the processor, 
75     so that all instructions following the ISB are fetched from cache or 
76     memory, after the instruction has been completed.
77  */
78 void __ISB(void);
79
80
81 /**************************************************************************************************/
82 /** \brief  Data Synchronization Barrier
83
84 \details
85 This function acts as a special kind of Data Memory Barrier. 
86 It completes when all explicit memory accesses before this instruction complete.
87  */
88 void __DSB(void);
89
90
91 /**************************************************************************************************/
92 /** \brief  Data Memory Barrier
93
94 \details
95 This function ensures the apparent order of the explicit memory operations before 
96 and after the instruction, without ensuring their completion.
97  */
98 void __DMB(void);
99
100
101 /**************************************************************************************************/
102 /**
103   \brief   Reverse byte order (32 bit)
104   \details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
105   \param [in]    value  Value to reverse
106   \return               Reversed value
107  */
108 uint32_t __REV(uint32_t value);
109
110
111 /**************************************************************************************************/
112 /**
113   \brief   Reverse byte order (16 bit)
114   \details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
115   \param [in]    value  Value to reverse
116   \return               Reversed value
117  */
118 uint32_t __REV16(uint32_t value);
119
120
121 /**************************************************************************************************/
122 /**
123   \brief   Reverse byte order (16 bit)
124   \details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
125   \param [in]    value  Value to reverse
126   \return               Reversed value
127  */
128 int32_t __REVSH(int32_t value);
129
130
131 /**************************************************************************************************/
132 /**
133   \brief   Reverse bit order of value
134   \param [in]    value  Value to reverse
135   \return               Reversed value
136  */
137 uint32_t __RBIT(uint32_t value);
138
139
140 /**************************************************************************************************/
141 /** \brief  Rotate a value right by a number of bits
142
143     This function rotates a value right by a specified number of bits.
144
145     \param [in]    value  Value to be shifted right
146     \param [in]    shift  Number of bits in the range [1..31]
147     \return               Rotated value
148         
149  */
150 uint32_t __ROR(uint32_t value, uint32_t shift);
151
152
153 /**************************************************************************************************/
154 /** \brief  LDR Exclusive (8 bit) [not for Cortex-M0, Cortex-M0+, or SC000]
155
156     This function executed an exclusive LDR command for 8 bit value [not for Cortex-M0, Cortex-M0+, or SC000].
157
158     \param [in]    *addr  Pointer to data
159     \return             value of type uint8_t at (*addr)
160  */
161 uint8_t __LDREXB(volatile uint8_t *addr);
162
163
164 /**************************************************************************************************/
165 /** \brief  LDR Exclusive (16 bit) [not for Cortex-M0, Cortex-M0+, or SC000]
166
167     This function executed an exclusive LDR command for 16 bit values [not for Cortex-M0, Cortex-M0+, or SC000].
168
169     \param [in]    *addr  Pointer to data
170     \return        value of type uint16_t at (*addr)
171  */
172 uint16_t __LDREXH(volatile uint16_t *addr);
173
174
175 /**************************************************************************************************/
176 /** \brief  LDR Exclusive (32 bit) [not for Cortex-M0, Cortex-M0+, or SC000]
177
178     This function executed an exclusive LDR command for 32 bit values [not for Cortex-M0, Cortex-M0+, or SC000].
179
180     \param [in]    *addr  Pointer to data
181     \return        value of type uint32_t at (*addr)
182  */
183 uint32_t __LDREXW(volatile uint32_t *addr);
184
185
186 /**************************************************************************************************/
187 /** \brief  STR Exclusive (8 bit) [not for Cortex-M0, Cortex-M0+, or SC000]
188
189     This function executed an exclusive STR command for 8 bit values [not for Cortex-M0, Cortex-M0+, or SC000].
190
191     \param [in]  value  Value to store
192     \param [in]  *addr  Pointer to location
193     \return          0  Function succeeded
194     \return          1  Function failed
195  */
196 uint32_t __STREXB(uint8_t value, volatile uint8_t *addr);
197
198
199 /**************************************************************************************************/
200 /** \brief  STR Exclusive (16 bit) [not for Cortex-M0, Cortex-M0+, or SC000]
201
202     This function executed an exclusive STR command for 16 bit values [not for Cortex-M0, Cortex-M0+, or SC000].
203
204     \param [in]  value  Value to store
205     \param [in]  *addr  Pointer to location
206     \return          0  Function succeeded
207     \return          1  Function failed
208  */
209 uint32_t __STREXH(uint16_t value, volatile uint16_t *addr);
210
211
212 /**************************************************************************************************/
213 /** \brief  STR Exclusive (32 bit)  [not for Cortex-M0, Cortex-M0+, or SC000]
214
215     This function executed an exclusive STR command for 32 bit values [not for Cortex-M0, Cortex-M0+, or SC000].
216
217     \param [in]  value  Value to store
218     \param [in]  *addr  Pointer to location
219     \return          0  Function succeeded
220     \return          1  Function failed
221  */
222 uint32_t __STREXW(uint32_t value, volatile uint32_t *addr);
223
224
225 /**************************************************************************************************/
226 /** \brief  Remove the exclusive lock [not for Cortex-M0, Cortex-M0+, or SC000]
227
228     This function removes the exclusive lock which is created by LDREX [not for Cortex-M0, Cortex-M0+, or SC000].
229
230  */
231 void __CLREX(void);
232
233
234 /**************************************************************************************************/
235 /** \brief  Signed Saturate [not for Cortex-M0, Cortex-M0+, or SC000]
236
237     This function saturates a signed value [not for Cortex-M0, Cortex-M0+, or SC000].
238
239     \param [in]  value  Value to be saturated
240     \param [in]    sat  Bit position to saturate to [1..32]
241     \return             Saturated value
242  */
243 int32_t __SSAT(int32_t value, uint32_t sat);
244
245
246 /**************************************************************************************************/
247 /** \brief  Unsigned Saturate [not for Cortex-M0, Cortex-M0+, or SC000]
248
249     This function saturates an unsigned value [not for Cortex-M0, Cortex-M0+, or SC000].
250
251     \param [in]  value  Value to be saturated
252     \param [in]    sat  Bit position to saturate to [0..31]
253     \return             Saturated value
254  */
255 uint32_t __USAT(uint32_t value, uint32_t sat);
256
257
258 /**************************************************************************************************/
259 /** \brief  Count leading zeros
260
261     This function counts the number of leading zeros of a data value.
262     
263     On Armv6-M (Cortex-M0, Cortex-M0+, and SC000) this function is not available as a core instruction
264     instruction and thus __CLZ is implemented in software.
265
266     \param [in]  value  Value to count the leading zeros
267     \return             number of leading zeros in value
268  */
269 uint8_t __CLZ(uint32_t value);
270
271
272 /**************************************************************************************************/
273 /** \brief  Rotate Right with Extend (32 bit)
274
275     This function moves each bit of a bitstring right by one bit. The carry input is shifted in at the left end of the bitstring.
276
277     \param [in]    value  Value to rotate
278     \return               Rotated value
279  */
280 uint32_t __RRX(uint32_t value);
281
282
283 /**************************************************************************************************/
284 /** \brief  LDRT Unprivileged (8 bit)
285
286     This function executed an Unprivileged LDRT command for 8 bit value.
287
288     \param [in]    ptr  Pointer to data
289     \return             value of type uint8_t at (*ptr)
290  */
291 uint8_t  __LDRBT(uint8_t ptr);
292
293
294 /**************************************************************************************************/
295 /** \brief  LDRT Unprivileged (16 bit)
296
297     This function executed an Unprivileged LDRT command for 16 bit values.
298
299     \param [in]    ptr  Pointer to data
300     \return        value of type uint16_t at (*ptr)
301  */
302 uint16_t  __LDRHT(uint16_t ptr);
303
304
305 /**************************************************************************************************/
306 /** \brief  LDRT Unprivileged (32 bit)
307
308     This function executed an Unprivileged LDRT command for 32 bit values.
309
310     \param [in]    ptr  Pointer to data
311     \return        value of type uint32_t at (*ptr)
312  */
313 uint32_t  __LDRT(uint32_t ptr);
314
315
316 /**************************************************************************************************/
317 /** \brief  STRT Unprivileged (8 bit)
318
319     This function executed an Unprivileged STRT command for 8 bit values.
320
321     \param [in]  value  Value to store
322     \param [in]    ptr  Pointer to location
323  */
324 void __STRBT(uint8_t value, uint8_t ptr);
325
326
327 /**************************************************************************************************/
328 /** \brief  STRT Unprivileged (16 bit)
329
330     This function executed an Unprivileged STRT command for 16 bit values.
331
332     \param [in]  value  Value to store
333     \param [in]    ptr  Pointer to location
334  */
335 void __STRHT(uint16_t value, uint16_t ptr);
336
337
338 /**************************************************************************************************/
339 /** \brief  STRT Unprivileged (32 bit)
340
341     This function executed an Unprivileged STRT command for 32 bit values.
342
343     \param [in]  value  Value to store
344     \param [in]    ptr  Pointer to location
345  */
346 void __STRT(uint32_t value, uint32_t ptr);
347
348
349
350 /**
351   \brief   Load-Acquire (8 bit)
352   \details Executes a LDAB instruction for 8 bit value.
353   \param [in]    ptr  Pointer to data
354   \return             value of type uint8_t at (*ptr)
355   \note    Only availabe for Armv8-M Architecture. 
356  */
357 uint8_t __LDAB(volatile uint8_t *ptr);
358
359 /**
360   \brief   Load-Acquire (16 bit)
361   \details Executes a LDAH instruction for 16 bit values.
362   \param [in]    ptr  Pointer to data
363   \return        value of type uint16_t at (*ptr)
364   \note    Only availabe for Armv8-M Architecture. 
365  */
366 uint16_t __LDAH(volatile uint16_t *ptr);
367
368 /**
369   \brief   Load-Acquire (32 bit)
370   \details Executes a LDA instruction for 32 bit values.
371   \param [in]    ptr  Pointer to data
372   \return        value of type uint32_t at (*ptr)
373   \note    Only availabe for Armv8-M Architecture. 
374  */
375 uint32_t __LDA(volatile uint32_t *ptr);
376
377 /**
378   \brief   Store-Release (8 bit)
379   \details Executes a STLB instruction for 8 bit values.
380   \param [in]  value  Value to store
381   \param [in]    ptr  Pointer to location
382   \note    Only availabe for Armv8-M Architecture. 
383  */
384 void __STLB(uint8_t value, volatile uint8_t *ptr);
385
386 /**
387   \brief   Store-Release (16 bit)
388   \details Executes a STLH instruction for 16 bit values.
389   \param [in]  value  Value to store
390   \param [in]    ptr  Pointer to location
391   \note    Only availabe for Armv8-M Architecture. 
392  */
393 void __STLH(uint16_t value, volatile uint16_t *ptr);
394
395 /**
396   \brief   Store-Release (32 bit)
397   \details Executes a STL instruction for 32 bit values.
398   \param [in]  value  Value to store
399   \param [in]    ptr  Pointer to location
400   \note    Only availabe for Armv8-M Architecture. 
401  */
402 void __STL(uint32_t value, volatile uint32_t *ptr);
403
404 /**
405   \brief   Load-Acquire Exclusive (8 bit)
406   \details Executes a LDAB exclusive instruction for 8 bit value.
407   \param [in]    ptr  Pointer to data
408   \return             value of type uint8_t at (*ptr)
409   \note    Only availabe for Armv8-M Architecture. 
410  */
411 uint8_t __LDAEXB(volatile uint32_t *ptr);
412
413 /**
414   \brief   Load-Acquire Exclusive (16 bit)
415   \details Executes a LDAH exclusive instruction for 16 bit values.
416   \param [in]    ptr  Pointer to data
417   \return        value of type uint16_t at (*ptr)
418   \note    Only availabe for Armv8-M Architecture. 
419  */
420 uint16_t __LDAEXH(volatile uint32_t *ptr);
421
422 /**
423   \brief   Load-Acquire Exclusive (32 bit)
424   \details Executes a LDA exclusive instruction for 32 bit values.
425   \param [in]    ptr  Pointer to data
426   \return        value of type uint32_t at (*ptr)
427   \note    Only availabe for Armv8-M Architecture. 
428  */
429 uint32_t __LDAEX(volatile uint32_t *ptr);
430
431 /**
432   \brief   Store-Release Exclusive (8 bit)
433   \details Executes a STLB exclusive instruction for 8 bit values.
434   \param [in]  value  Value to store
435   \param [in]    ptr  Pointer to location
436   \return          0  Function succeeded
437   \return          1  Function failed
438   \note    Only availabe for Armv8-M Architecture. 
439  */
440 uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr);
441
442 /**
443   \brief   Store-Release Exclusive (16 bit)
444   \details Executes a STLH exclusive instruction for 16 bit values.
445   \param [in]  value  Value to store
446   \param [in]    ptr  Pointer to location
447   \return          0  Function succeeded
448   \return          1  Function failed
449   \note    Only availabe for Armv8-M Architecture. 
450  */
451 uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr);
452
453 /**
454   \brief   Store-Release Exclusive (32 bit)
455   \details Executes a STL exclusive instruction for 32 bit values.
456   \param [in]  value  Value to store
457   \param [in]    ptr  Pointer to location
458   \return          0  Function succeeded
459   \return          1  Function failed
460   \note    Only availabe for Armv8-M Architecture. 
461  */
462 uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr);
463
464
465 /*@}*/ /* end of group Intrisic_CPU */
466
467