]> begriffs open source - cmsis/blob - CMSIS/DoxyGen/Core/src/Ref_cmInstr.txt
Enhanced Core(M) documentation with CMSIS version control defines.
[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 /** \brief  Reverse byte order (32 bit)
103 \details
104 This function reverses the byte order in integer value.
105
106 \param [in]    value  Value to reverse
107 \return               Reversed value
108  */
109 uint32_t __REV(uint32_t value);
110
111
112 /**************************************************************************************************/
113 /** \brief  Reverse byte order (16 bit)
114
115 \details
116 This function reverses the byte order in two unsigned short values.
117
118 \param [in]    value  Value to reverse
119 \return               Reversed value
120 */
121 uint32_t __REV16(uint32_t value);
122
123
124 /**************************************************************************************************/
125 /** \brief  Reverse byte order in signed short value
126
127 \details
128 This function reverses the byte order in a signed short value with sign extension to integer.
129
130 \param [in]    value  Value to reverse
131 \return               Reversed value
132  */
133 int32_t __REVSH(int32_t value);
134
135
136 /**************************************************************************************************/
137 /** \brief  Reverse bit order of value [not for Cortex-M0, Cortex-M0+, or SC000]
138
139     This function reverses the bit order of the given value [not for Cortex-M0, Cortex-M0+, or SC000].
140
141     \param [in]    value  Value to reverse
142     \return               Reversed value
143  */
144 uint32_t __RBIT(uint32_t value);
145
146
147 /**************************************************************************************************/
148 /** \brief  Rotate a value right by a number of bits
149
150     This function rotates a value right by a specified number of bits.
151
152     \param [in]    value  Value to be shifted right
153     \param [in]    shift  Number of bits in the range [1..31]
154     \return               Rotated value
155         
156  */
157 uint32_t __ROR(uint32_t value, uint32_t shift);
158
159
160 /**************************************************************************************************/
161 /** \brief  LDR Exclusive (8 bit) [not for Cortex-M0, Cortex-M0+, or SC000]
162
163     This function executed an exclusive LDR command for 8 bit value [not for Cortex-M0, Cortex-M0+, or SC000].
164
165     \param [in]    *addr  Pointer to data
166     \return             value of type uint8_t at (*addr)
167  */
168 uint8_t __LDREXB(volatile uint8_t *addr);
169
170
171 /**************************************************************************************************/
172 /** \brief  LDR Exclusive (16 bit) [not for Cortex-M0, Cortex-M0+, or SC000]
173
174     This function executed an exclusive LDR command for 16 bit values [not for Cortex-M0, Cortex-M0+, or SC000].
175
176     \param [in]    *addr  Pointer to data
177     \return        value of type uint16_t at (*addr)
178  */
179 uint16_t __LDREXH(volatile uint16_t *addr);
180
181
182 /**************************************************************************************************/
183 /** \brief  LDR Exclusive (32 bit) [not for Cortex-M0, Cortex-M0+, or SC000]
184
185     This function executed an exclusive LDR command for 32 bit values [not for Cortex-M0, Cortex-M0+, or SC000].
186
187     \param [in]    *addr  Pointer to data
188     \return        value of type uint32_t at (*addr)
189  */
190 uint32_t __LDREXW(volatile uint32_t *addr);
191
192
193 /**************************************************************************************************/
194 /** \brief  STR Exclusive (8 bit) [not for Cortex-M0, Cortex-M0+, or SC000]
195
196     This function executed an exclusive STR command for 8 bit values [not for Cortex-M0, Cortex-M0+, or SC000].
197
198     \param [in]  value  Value to store
199     \param [in]  *addr  Pointer to location
200     \return          0  Function succeeded
201     \return          1  Function failed
202  */
203 uint32_t __STREXB(uint8_t value, volatile uint8_t *addr);
204
205
206 /**************************************************************************************************/
207 /** \brief  STR Exclusive (16 bit) [not for Cortex-M0, Cortex-M0+, or SC000]
208
209     This function executed an exclusive STR command for 16 bit values [not for Cortex-M0, Cortex-M0+, or SC000].
210
211     \param [in]  value  Value to store
212     \param [in]  *addr  Pointer to location
213     \return          0  Function succeeded
214     \return          1  Function failed
215  */
216 uint32_t __STREXH(uint16_t value, volatile uint16_t *addr);
217
218
219 /**************************************************************************************************/
220 /** \brief  STR Exclusive (32 bit)  [not for Cortex-M0, Cortex-M0+, or SC000]
221
222     This function executed an exclusive STR command for 32 bit values [not for Cortex-M0, Cortex-M0+, or SC000].
223
224     \param [in]  value  Value to store
225     \param [in]  *addr  Pointer to location
226     \return          0  Function succeeded
227     \return          1  Function failed
228  */
229 uint32_t __STREXW(uint32_t value, volatile uint32_t *addr);
230
231
232 /**************************************************************************************************/
233 /** \brief  Remove the exclusive lock [not for Cortex-M0, Cortex-M0+, or SC000]
234
235     This function removes the exclusive lock which is created by LDREX [not for Cortex-M0, Cortex-M0+, or SC000].
236
237  */
238 void __CLREX(void);
239
240
241 /**************************************************************************************************/
242 /** \brief  Signed Saturate [not for Cortex-M0, Cortex-M0+, or SC000]
243
244     This function saturates a signed value [not for Cortex-M0, Cortex-M0+, or SC000].
245
246     \param [in]  value  Value to be saturated
247     \param [in]    sat  Bit position to saturate to [1..32]
248     \return             Saturated value
249  */
250 uint32_t __SSAT(unint32_t value, uint32_t sat);
251
252
253 /**************************************************************************************************/
254 /** \brief  Unsigned Saturate [not for Cortex-M0, Cortex-M0+, or SC000]
255
256     This function saturates an unsigned value [not for Cortex-M0, Cortex-M0+, or SC000].
257
258     \param [in]  value  Value to be saturated
259     \param [in]    sat  Bit position to saturate to [0..31]
260     \return             Saturated value
261  */
262 uint32_t __USAT(uint32_t value, uint32_t sat);
263
264
265 /**************************************************************************************************/
266 /** \brief  Count leading zeros [not for Cortex-M0, Cortex-M0+, or SC000]
267
268     This function counts the number of leading zeros of a data value [not for Cortex-M0, Cortex-M0+, or SC000].
269
270     \param [in]  value  Value to count the leading zeros
271     \return             number of leading zeros in value
272  */
273 uint8_t __CLZ(uint32_t value);
274
275
276 /**************************************************************************************************/
277 /** \brief  Rotate Right with Extend (32 bit)
278
279     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.
280
281     \param [in]    value  Value to rotate
282     \return               Rotated value
283  */
284 uint32_t __RRX(uint32_t value);
285
286
287 /**************************************************************************************************/
288 /** \brief  LDRT Unprivileged (8 bit)
289
290     This function executed an Unprivileged LDRT command for 8 bit value.
291
292     \param [in]    ptr  Pointer to data
293     \return             value of type uint8_t at (*ptr)
294  */
295 uint8_t  __LDRBT(uint8_t ptr);
296
297
298 /**************************************************************************************************/
299 /** \brief  LDRT Unprivileged (16 bit)
300
301     This function executed an Unprivileged LDRT command for 16 bit values.
302
303     \param [in]    ptr  Pointer to data
304     \return        value of type uint16_t at (*ptr)
305  */
306 uint16_t  __LDRHT(uint16_t ptr);
307
308
309 /**************************************************************************************************/
310 /** \brief  LDRT Unprivileged (32 bit)
311
312     This function executed an Unprivileged LDRT command for 32 bit values.
313
314     \param [in]    ptr  Pointer to data
315     \return        value of type uint32_t at (*ptr)
316  */
317 uint32_t  __LDRT(uint32_t ptr);
318
319
320 /**************************************************************************************************/
321 /** \brief  STRT Unprivileged (8 bit)
322
323     This function executed an Unprivileged STRT command for 8 bit values.
324
325     \param [in]  value  Value to store
326     \param [in]    ptr  Pointer to location
327  */
328 void __STRBT(uint8_t value, uint8_t ptr);
329
330
331 /**************************************************************************************************/
332 /** \brief  STRT Unprivileged (16 bit)
333
334     This function executed an Unprivileged STRT command for 16 bit values.
335
336     \param [in]  value  Value to store
337     \param [in]    ptr  Pointer to location
338  */
339 void __STRHT(uint16_t value, uint16_t ptr);
340
341
342 /**************************************************************************************************/
343 /** \brief  STRT Unprivileged (32 bit)
344
345     This function executed an Unprivileged STRT command for 32 bit values.
346
347     \param [in]  value  Value to store
348     \param [in]    ptr  Pointer to location
349  */
350 void __STRT(uint32_t value, uint32_t ptr);
351
352
353
354 /**
355   \brief   Load-Acquire (8 bit)
356   \details Executes a LDAB instruction for 8 bit value.
357   \param [in]    ptr  Pointer to data
358   \return             value of type uint8_t at (*ptr)
359   \note    Only availabe for ARMv8-M Architecture. 
360  */
361 uint8_t __LDAB(volatile uint8_t *ptr);
362
363 /**
364   \brief   Load-Acquire (16 bit)
365   \details Executes a LDAH instruction for 16 bit values.
366   \param [in]    ptr  Pointer to data
367   \return        value of type uint16_t at (*ptr)
368   \note    Only availabe for ARMv8-M Architecture. 
369  */
370 uint16_t __LDAH(volatile uint16_t *ptr);
371
372 /**
373   \brief   Load-Acquire (32 bit)
374   \details Executes a LDA instruction for 32 bit values.
375   \param [in]    ptr  Pointer to data
376   \return        value of type uint32_t at (*ptr)
377   \note    Only availabe for ARMv8-M Architecture. 
378  */
379 uint32_t __LDA(volatile uint32_t *ptr);
380
381 /**
382   \brief   Store-Release (8 bit)
383   \details Executes a STLB instruction for 8 bit values.
384   \param [in]  value  Value to store
385   \param [in]    ptr  Pointer to location
386   \note    Only availabe for ARMv8-M Architecture. 
387  */
388 void __STLB(uint8_t value, volatile uint8_t *ptr);
389
390 /**
391   \brief   Store-Release (16 bit)
392   \details Executes a STLH instruction for 16 bit values.
393   \param [in]  value  Value to store
394   \param [in]    ptr  Pointer to location
395   \note    Only availabe for ARMv8-M Architecture. 
396  */
397 void __STLH(uint16_t value, volatile uint16_t *ptr);
398
399 /**
400   \brief   Store-Release (32 bit)
401   \details Executes a STL instruction for 32 bit values.
402   \param [in]  value  Value to store
403   \param [in]    ptr  Pointer to location
404   \note    Only availabe for ARMv8-M Architecture. 
405  */
406 void __STL(uint32_t value, volatile uint32_t *ptr);
407
408 /**
409   \brief   Load-Acquire Exclusive (8 bit)
410   \details Executes a LDAB exclusive instruction for 8 bit value.
411   \param [in]    ptr  Pointer to data
412   \return             value of type uint8_t at (*ptr)
413   \note    Only availabe for ARMv8-M Architecture. 
414  */
415 uint8_t __LDAEXB(volatile uint32_t *ptr);
416
417 /**
418   \brief   Load-Acquire Exclusive (16 bit)
419   \details Executes a LDAH exclusive instruction for 16 bit values.
420   \param [in]    ptr  Pointer to data
421   \return        value of type uint16_t at (*ptr)
422   \note    Only availabe for ARMv8-M Architecture. 
423  */
424 uint16_t __LDAEXH(volatile uint32_t *ptr);
425
426 /**
427   \brief   Load-Acquire Exclusive (32 bit)
428   \details Executes a LDA exclusive instruction for 32 bit values.
429   \param [in]    ptr  Pointer to data
430   \return        value of type uint32_t at (*ptr)
431   \note    Only availabe for ARMv8-M Architecture. 
432  */
433 uint32_t __LDAEX(volatile uint32_t *ptr);
434
435 /**
436   \brief   Store-Release Exclusive (8 bit)
437   \details Executes a STLB exclusive instruction for 8 bit values.
438   \param [in]  value  Value to store
439   \param [in]    ptr  Pointer to location
440   \return          0  Function succeeded
441   \return          1  Function failed
442   \note    Only availabe for ARMv8-M Architecture. 
443  */
444 uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr);
445
446 /**
447   \brief   Store-Release Exclusive (16 bit)
448   \details Executes a STLH exclusive instruction for 16 bit values.
449   \param [in]  value  Value to store
450   \param [in]    ptr  Pointer to location
451   \return          0  Function succeeded
452   \return          1  Function failed
453   \note    Only availabe for ARMv8-M Architecture. 
454  */
455 uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr);
456
457 /**
458   \brief   Store-Release Exclusive (32 bit)
459   \details Executes a STL exclusive instruction for 32 bit values.
460   \param [in]  value  Value to store
461   \param [in]    ptr  Pointer to location
462   \return          0  Function succeeded
463   \return          1  Function failed
464   \note    Only availabe for ARMv8-M Architecture. 
465  */
466 uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr);
467
468
469 /*@}*/ /* end of group Intrisic_CPU */
470
471