]> git.sur5r.net Git - freertos/blob - Demo/CORTEX_M4F_M0_LPC43xx_Keil/system/core_cmInstr.h
Added fast book files to project - although fast boot is not integrated yet.
[freertos] / Demo / CORTEX_M4F_M0_LPC43xx_Keil / system / core_cmInstr.h
1 /**************************************************************************//**\r
2  * @file     core_cmInstr.h\r
3  * @brief    CMSIS Cortex-M Core Instruction Access Header File\r
4  * @version  V2.01\r
5  * @date     06. December 2010\r
6  *\r
7  * @note\r
8  * Copyright (C) 2009-2010 ARM Limited. All rights reserved.\r
9  *\r
10  * @par\r
11  * ARM Limited (ARM) is supplying this software for use with Cortex-M \r
12  * processor based microcontrollers.  This file can be freely distributed \r
13  * within development tools that are supporting such ARM based processors. \r
14  *\r
15  * @par\r
16  * THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED\r
17  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF\r
18  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.\r
19  * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR\r
20  * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.\r
21  *\r
22  ******************************************************************************/\r
23 \r
24 #ifndef __CORE_CMINSTR_H__\r
25 #define __CORE_CMINSTR_H__\r
26 \r
27 \r
28 /* ##########################  Core Instruction Access  ######################### */\r
29 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface\r
30   Access to dedicated instructions\r
31   @{\r
32 */\r
33 \r
34 #if defined ( __CC_ARM   ) /*------------------ RealView Compiler ----------------*/\r
35 /* ARM armcc specific functions */\r
36 \r
37 /** \brief  No Operation\r
38 \r
39     No Operation does nothing. This instruction can be used for code alignment purposes.\r
40  */\r
41 #define __NOP                             __nop\r
42 \r
43 \r
44 /** \brief  Wait For Interrupt\r
45 \r
46     Wait For Interrupt is a hint instruction that suspends execution\r
47     until one of a number of events occurs.\r
48  */\r
49 #define __WFI                             __wfi\r
50 \r
51 \r
52 /** \brief  Wait For Event\r
53 \r
54     Wait For Event is a hint instruction that permits the processor to enter\r
55     a low-power state until one of a number of events occurs.\r
56  */\r
57 #define __WFE                             __wfe\r
58 \r
59 \r
60 /** \brief  Send Event\r
61 \r
62     Send Event is a hint instruction. It causes an event to be signaled to the CPU.\r
63  */\r
64 #define __SEV                             __sev\r
65 \r
66 \r
67 /** \brief  Instruction Synchronization Barrier\r
68 \r
69     Instruction Synchronization Barrier flushes the pipeline in the processor, \r
70     so that all instructions following the ISB are fetched from cache or \r
71     memory, after the instruction has been completed.\r
72  */\r
73 #define __ISB()                           __isb(0xF)\r
74 \r
75 \r
76 /** \brief  Data Synchronization Barrier\r
77 \r
78     This function acts as a special kind of Data Memory Barrier. \r
79     It completes when all explicit memory accesses before this instruction complete.\r
80  */\r
81 #define __DSB()                           __dsb(0xF)\r
82 \r
83 \r
84 /** \brief  Data Memory Barrier\r
85 \r
86     This function ensures the apparent order of the explicit memory operations before \r
87     and after the instruction, without ensuring their completion.\r
88  */\r
89 #define __DMB()                           __dmb(0xF)\r
90 \r
91 \r
92 /** \brief  Reverse byte order (32 bit)\r
93 \r
94     This function reverses the byte order in integer value.\r
95 \r
96     \param [in]    value  Value to reverse\r
97     \return               Reversed value\r
98  */\r
99 #define __REV                             __rev\r
100 \r
101 \r
102 /** \brief  Reverse byte order (16 bit)\r
103 \r
104     This function reverses the byte order in two unsigned short values.\r
105 \r
106     \param [in]    value  Value to reverse\r
107     \return               Reversed value\r
108  */\r
109 #if (__ARMCC_VERSION < 400677)\r
110 extern uint32_t __REV16(uint32_t value);\r
111 #else  /* (__ARMCC_VERSION >= 400677)  */\r
112 static __INLINE __ASM uint32_t __REV16(uint32_t value)\r
113 {\r
114   rev16 r0, r0\r
115   bx lr\r
116 }\r
117 #endif /* __ARMCC_VERSION  */ \r
118 \r
119 \r
120 /** \brief  Reverse byte order in signed short value\r
121 \r
122     This function reverses the byte order in a signed short value with sign extension to integer.\r
123 \r
124     \param [in]    value  Value to reverse\r
125     \return               Reversed value\r
126  */\r
127 #if (__ARMCC_VERSION < 400677)\r
128 extern int32_t __REVSH(int32_t value);\r
129 #else  /* (__ARMCC_VERSION >= 400677)  */\r
130 static __INLINE __ASM int32_t __REVSH(int32_t value)\r
131 {\r
132   revsh r0, r0\r
133   bx lr\r
134 }\r
135 #endif /* __ARMCC_VERSION  */ \r
136 \r
137 \r
138 #if       (__CORTEX_M >= 0x03)\r
139 \r
140 /** \brief  Reverse bit order of value\r
141 \r
142     This function reverses the bit order of the given value.\r
143 \r
144     \param [in]    value  Value to reverse\r
145     \return               Reversed value\r
146  */\r
147 #define __RBIT                            __rbit\r
148 \r
149 \r
150 /** \brief  LDR Exclusive (8 bit)\r
151 \r
152     This function performs a exclusive LDR command for 8 bit value.\r
153 \r
154     \param [in]    ptr  Pointer to data\r
155     \return             value of type uint8_t at (*ptr)\r
156  */\r
157 #define __LDREXB(ptr)                     ((uint8_t ) __ldrex(ptr))\r
158 \r
159 \r
160 /** \brief  LDR Exclusive (16 bit)\r
161 \r
162     This function performs a exclusive LDR command for 16 bit values.\r
163 \r
164     \param [in]    ptr  Pointer to data\r
165     \return        value of type uint16_t at (*ptr)\r
166  */\r
167 #define __LDREXH(ptr)                     ((uint16_t) __ldrex(ptr))\r
168 \r
169 \r
170 /** \brief  LDR Exclusive (32 bit)\r
171 \r
172     This function performs a exclusive LDR command for 32 bit values.\r
173 \r
174     \param [in]    ptr  Pointer to data\r
175     \return        value of type uint32_t at (*ptr)\r
176  */\r
177 #define __LDREXW(ptr)                     ((uint32_t ) __ldrex(ptr))\r
178 \r
179 \r
180 /** \brief  STR Exclusive (8 bit)\r
181 \r
182     This function performs a exclusive STR command for 8 bit values.\r
183 \r
184     \param [in]  value  Value to store\r
185     \param [in]    ptr  Pointer to location\r
186     \return          0  Function succeeded\r
187     \return          1  Function failed\r
188  */\r
189 #define __STREXB(value, ptr)              __strex(value, ptr)\r
190 \r
191 \r
192 /** \brief  STR Exclusive (16 bit)\r
193 \r
194     This function performs a exclusive STR command for 16 bit values.\r
195 \r
196     \param [in]  value  Value to store\r
197     \param [in]    ptr  Pointer to location\r
198     \return          0  Function succeeded\r
199     \return          1  Function failed\r
200  */\r
201 #define __STREXH(value, ptr)              __strex(value, ptr)\r
202 \r
203 \r
204 /** \brief  STR Exclusive (32 bit)\r
205 \r
206     This function performs a exclusive STR command for 32 bit values.\r
207 \r
208     \param [in]  value  Value to store\r
209     \param [in]    ptr  Pointer to location\r
210     \return          0  Function succeeded\r
211     \return          1  Function failed\r
212  */\r
213 #define __STREXW(value, ptr)              __strex(value, ptr)\r
214 \r
215 \r
216 /** \brief  Remove the exclusive lock\r
217 \r
218     This function removes the exclusive lock which is created by LDREX.\r
219 \r
220  */\r
221 #if (__ARMCC_VERSION < 400000)\r
222 extern void __CLREX(void);\r
223 #else  /* (__ARMCC_VERSION >= 400000)  */\r
224 #define __CLREX                           __clrex\r
225 #endif /* __ARMCC_VERSION  */ \r
226 \r
227 \r
228 /** \brief  Signed Saturate\r
229 \r
230     This function saturates a signed value.\r
231 \r
232     \param [in]  value  Value to be saturated\r
233     \param [in]    sat  Bit position to saturate to (1..32)\r
234     \return             Saturated value\r
235  */\r
236 #define __SSAT                            __ssat\r
237 \r
238 \r
239 /** \brief  Unsigned Saturate\r
240 \r
241     This function saturates an unsigned value.\r
242 \r
243     \param [in]  value  Value to be saturated\r
244     \param [in]    sat  Bit position to saturate to (0..31)\r
245     \return             Saturated value\r
246  */\r
247 #define __USAT                            __usat\r
248 \r
249 \r
250 /** \brief  Count leading zeros\r
251 \r
252     This function counts the number of leading zeros of a data value.\r
253 \r
254     \param [in]  value  Value to count the leading zeros\r
255     \return             number of leading zeros in value\r
256  */\r
257 #define __CLZ                             __clz \r
258 \r
259 #endif /* (__CORTEX_M >= 0x03) */\r
260 \r
261 \r
262 \r
263 #elif (defined (__ICCARM__)) /*---------------- ICC Compiler ---------------------*/\r
264 /* IAR iccarm specific functions */\r
265 \r
266 #include <intrinsics.h>                     /* IAR Intrinsics   */\r
267 \r
268 #pragma diag_suppress=Pe940\r
269 \r
270 /** \brief  No Operation\r
271 \r
272     No Operation does nothing. This instruction can be used for code alignment purposes.\r
273  */\r
274 #define __NOP                           __no_operation\r
275 \r
276 \r
277 /** \brief  Wait For Interrupt\r
278 \r
279     Wait For Interrupt is a hint instruction that suspends execution\r
280     until one of a number of events occurs.\r
281  */\r
282 static __INLINE  void __WFI(void)\r
283 {\r
284   __ASM ("wfi");\r
285 }\r
286 \r
287 \r
288 /** \brief  Wait For Event\r
289 \r
290     Wait For Event is a hint instruction that permits the processor to enter\r
291     a low-power state until one of a number of events occurs.\r
292  */\r
293 static __INLINE  void __WFE(void)\r
294 {\r
295   __ASM ("wfe");\r
296 }\r
297 \r
298 \r
299 /** \brief  Send Event\r
300 \r
301     Send Event is a hint instruction. It causes an event to be signaled to the CPU.\r
302  */\r
303 static __INLINE  void __SEV(void)\r
304 {\r
305   __ASM ("sev");\r
306 }\r
307 \r
308 \r
309 /* intrinsic     void __ISB(void)            (see intrinsics.h) */\r
310 /* intrinsic     void __DSB(void)            (see intrinsics.h) */\r
311 /* intrinsic     void __DMB(void)            (see intrinsics.h) */\r
312 /* intrinsic uint32_t __REV(uint32_t value)  (see intrinsics.h) */\r
313 /* intrinsic          __SSAT                 (see intrinsics.h) */\r
314 /* intrinsic          __USAT                 (see intrinsics.h) */\r
315 \r
316 \r
317 /** \brief  Reverse byte order (16 bit)\r
318 \r
319     This function reverses the byte order in two unsigned short values.\r
320 \r
321     \param [in]    value  Value to reverse\r
322     \return               Reversed value\r
323  */\r
324 static uint32_t __REV16(uint32_t value)\r
325 {\r
326   __ASM("rev16 r0, r0");\r
327 }\r
328 \r
329 \r
330 /* intrinsic uint32_t __REVSH(uint32_t value)  (see intrinsics.h */\r
331 \r
332 \r
333 #if       (__CORTEX_M >= 0x03)\r
334 \r
335 /** \brief  Reverse bit order of value\r
336 \r
337     This function reverses the bit order of the given value.\r
338 \r
339     \param [in]    value  Value to reverse\r
340     \return               Reversed value\r
341  */\r
342 static uint32_t __RBIT(uint32_t value)\r
343 {\r
344   __ASM("rbit r0, r0");\r
345 }\r
346 \r
347 \r
348 /** \brief  LDR Exclusive (8 bit)\r
349 \r
350     This function performs a exclusive LDR command for 8 bit value.\r
351 \r
352     \param [in]    ptr  Pointer to data\r
353     \return             value of type uint8_t at (*ptr)\r
354  */\r
355 static uint8_t __LDREXB(volatile uint8_t *addr)\r
356 {\r
357   __ASM("ldrexb r0, [r0]");\r
358 }\r
359 \r
360 \r
361 /** \brief  LDR Exclusive (16 bit)\r
362 \r
363     This function performs a exclusive LDR command for 16 bit values.\r
364 \r
365     \param [in]    ptr  Pointer to data\r
366     \return        value of type uint16_t at (*ptr)\r
367  */\r
368 static uint16_t __LDREXH(volatile uint16_t *addr)\r
369 {\r
370   __ASM("ldrexh r0, [r0]");\r
371 }\r
372 \r
373 \r
374 /** \brief  LDR Exclusive (32 bit)\r
375 \r
376     This function performs a exclusive LDR command for 32 bit values.\r
377 \r
378     \param [in]    ptr  Pointer to data\r
379     \return        value of type uint32_t at (*ptr)\r
380  */\r
381 /* intrinsic unsigned long __LDREX(unsigned long *)  (see intrinsics.h) */\r
382 static uint32_t __LDREXW(volatile uint32_t *addr)\r
383 {\r
384   __ASM("ldrex r0, [r0]");\r
385 }\r
386 \r
387 \r
388 /** \brief  STR Exclusive (8 bit)\r
389 \r
390     This function performs a exclusive STR command for 8 bit values.\r
391 \r
392     \param [in]  value  Value to store\r
393     \param [in]    ptr  Pointer to location\r
394     \return          0  Function succeeded\r
395     \return          1  Function failed\r
396  */\r
397 static uint32_t __STREXB(uint8_t value, volatile uint8_t *addr)\r
398 {\r
399   __ASM("strexb r0, r0, [r1]");\r
400 }\r
401 \r
402 \r
403 /** \brief  STR Exclusive (16 bit)\r
404 \r
405     This function performs a exclusive STR command for 16 bit values.\r
406 \r
407     \param [in]  value  Value to store\r
408     \param [in]    ptr  Pointer to location\r
409     \return          0  Function succeeded\r
410     \return          1  Function failed\r
411  */\r
412 static uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)\r
413 {\r
414   __ASM("strexh r0, r0, [r1]");\r
415 }\r
416 \r
417 \r
418 /** \brief  STR Exclusive (32 bit)\r
419 \r
420     This function performs a exclusive STR command for 32 bit values.\r
421 \r
422     \param [in]  value  Value to store\r
423     \param [in]    ptr  Pointer to location\r
424     \return          0  Function succeeded\r
425     \return          1  Function failed\r
426  */\r
427 /* intrinsic unsigned long __STREX(unsigned long, unsigned long)  (see intrinsics.h )*/\r
428 static uint32_t __STREXW(uint32_t value, volatile uint32_t *addr)\r
429 {\r
430   __ASM("strex r0, r0, [r1]");\r
431 }\r
432 \r
433 \r
434 /** \brief  Remove the exclusive lock\r
435 \r
436     This function removes the exclusive lock which is created by LDREX.\r
437 \r
438  */\r
439 static __INLINE void __CLREX(void)\r
440 {\r
441   __ASM ("clrex");\r
442 }\r
443 \r
444 /* intrinsic   unsigned char __CLZ( unsigned long )      (see intrinsics.h) */\r
445 \r
446 #endif /* (__CORTEX_M >= 0x03) */\r
447 \r
448 #pragma diag_default=Pe940\r
449 \r
450 \r
451 \r
452 #elif (defined (__GNUC__)) /*------------------ GNU Compiler ---------------------*/\r
453 /* GNU gcc specific functions */\r
454 \r
455 /** \brief  No Operation\r
456 \r
457     No Operation does nothing. This instruction can be used for code alignment purposes.\r
458  */\r
459 __attribute__( ( always_inline ) ) static __INLINE void __NOP(void)\r
460 {\r
461   __ASM volatile ("nop");\r
462 }\r
463 \r
464 \r
465 /** \brief  Wait For Interrupt\r
466 \r
467     Wait For Interrupt is a hint instruction that suspends execution\r
468     until one of a number of events occurs.\r
469  */\r
470 __attribute__( ( always_inline ) ) static __INLINE void __WFI(void)\r
471 {\r
472   __ASM volatile ("wfi");\r
473 }\r
474 \r
475 \r
476 /** \brief  Wait For Event\r
477 \r
478     Wait For Event is a hint instruction that permits the processor to enter\r
479     a low-power state until one of a number of events occurs.\r
480  */\r
481 __attribute__( ( always_inline ) ) static __INLINE void __WFE(void)\r
482 {\r
483   __ASM volatile ("wfe");\r
484 }\r
485 \r
486 \r
487 /** \brief  Send Event\r
488 \r
489     Send Event is a hint instruction. It causes an event to be signaled to the CPU.\r
490  */\r
491 __attribute__( ( always_inline ) ) static __INLINE void __SEV(void)\r
492 {\r
493   __ASM volatile ("sev");\r
494 }\r
495 \r
496 \r
497 /** \brief  Instruction Synchronization Barrier\r
498 \r
499     Instruction Synchronization Barrier flushes the pipeline in the processor, \r
500     so that all instructions following the ISB are fetched from cache or \r
501     memory, after the instruction has been completed.\r
502  */\r
503 __attribute__( ( always_inline ) ) static __INLINE void __ISB(void)\r
504 {\r
505   __ASM volatile ("isb");\r
506 }\r
507 \r
508 \r
509 /** \brief  Data Synchronization Barrier\r
510 \r
511     This function acts as a special kind of Data Memory Barrier. \r
512     It completes when all explicit memory accesses before this instruction complete.\r
513  */\r
514 __attribute__( ( always_inline ) ) static __INLINE void __DSB(void)\r
515 {\r
516   __ASM volatile ("dsb");\r
517 }\r
518 \r
519 \r
520 /** \brief  Data Memory Barrier\r
521 \r
522     This function ensures the apparent order of the explicit memory operations before \r
523     and after the instruction, without ensuring their completion.\r
524  */\r
525 __attribute__( ( always_inline ) ) static __INLINE void __DMB(void)\r
526 {\r
527   __ASM volatile ("dmb");\r
528 }\r
529 \r
530 \r
531 /** \brief  Reverse byte order (32 bit)\r
532 \r
533     This function reverses the byte order in integer value.\r
534 \r
535     \param [in]    value  Value to reverse\r
536     \return               Reversed value\r
537  */\r
538 __attribute__( ( always_inline ) ) static __INLINE uint32_t __REV(uint32_t value)\r
539 {\r
540   uint32_t result;\r
541   \r
542   __ASM volatile ("rev %0, %1" : "=r" (result) : "r" (value) );\r
543   return(result);\r
544 }\r
545 \r
546 \r
547 /** \brief  Reverse byte order (16 bit)\r
548 \r
549     This function reverses the byte order in two unsigned short values.\r
550 \r
551     \param [in]    value  Value to reverse\r
552     \return               Reversed value\r
553  */\r
554 __attribute__( ( always_inline ) ) static __INLINE uint32_t __REV16(uint32_t value)\r
555 {\r
556   uint32_t result;\r
557   \r
558   __ASM volatile ("rev16 %0, %1" : "=r" (result) : "r" (value) );\r
559   return(result);\r
560 }\r
561 \r
562 \r
563 /** \brief  Reverse byte order in signed short value\r
564 \r
565     This function reverses the byte order in a signed short value with sign extension to integer.\r
566 \r
567     \param [in]    value  Value to reverse\r
568     \return               Reversed value\r
569  */\r
570 __attribute__( ( always_inline ) ) static __INLINE int32_t __REVSH(int32_t value)\r
571 {\r
572   uint32_t result;\r
573   \r
574   __ASM volatile ("revsh %0, %1" : "=r" (result) : "r" (value) );\r
575   return(result);\r
576 }\r
577 \r
578 \r
579 #if       (__CORTEX_M >= 0x03)\r
580 \r
581 /** \brief  Reverse bit order of value\r
582 \r
583     This function reverses the bit order of the given value.\r
584 \r
585     \param [in]    value  Value to reverse\r
586     \return               Reversed value\r
587  */\r
588 __attribute__( ( always_inline ) ) static __INLINE uint32_t __RBIT(uint32_t value)\r
589 {\r
590   uint32_t result;\r
591   \r
592    __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );\r
593    return(result);\r
594 }\r
595 \r
596 \r
597 /** \brief  LDR Exclusive (8 bit)\r
598 \r
599     This function performs a exclusive LDR command for 8 bit value.\r
600 \r
601     \param [in]    ptr  Pointer to data\r
602     \return             value of type uint8_t at (*ptr)\r
603  */\r
604 __attribute__( ( always_inline ) ) static __INLINE uint8_t __LDREXB(volatile uint8_t *addr)\r
605 {\r
606     uint8_t result;\r
607   \r
608    __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) );\r
609    return(result);\r
610 }\r
611 \r
612 \r
613 /** \brief  LDR Exclusive (16 bit)\r
614 \r
615     This function performs a exclusive LDR command for 16 bit values.\r
616 \r
617     \param [in]    ptr  Pointer to data\r
618     \return        value of type uint16_t at (*ptr)\r
619  */\r
620 __attribute__( ( always_inline ) ) static __INLINE uint16_t __LDREXH(volatile uint16_t *addr)\r
621 {\r
622     uint16_t result;\r
623   \r
624    __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) );\r
625    return(result);\r
626 }\r
627 \r
628 \r
629 /** \brief  LDR Exclusive (32 bit)\r
630 \r
631     This function performs a exclusive LDR command for 32 bit values.\r
632 \r
633     \param [in]    ptr  Pointer to data\r
634     \return        value of type uint32_t at (*ptr)\r
635  */\r
636 __attribute__( ( always_inline ) ) static __INLINE uint32_t __LDREXW(volatile uint32_t *addr)\r
637 {\r
638     uint32_t result;\r
639   \r
640    __ASM volatile ("ldrex %0, [%1]" : "=r" (result) : "r" (addr) );\r
641    return(result);\r
642 }\r
643 \r
644 \r
645 /** \brief  STR Exclusive (8 bit)\r
646 \r
647     This function performs a exclusive STR command for 8 bit values.\r
648 \r
649     \param [in]  value  Value to store\r
650     \param [in]    ptr  Pointer to location\r
651     \return          0  Function succeeded\r
652     \return          1  Function failed\r
653  */\r
654 __attribute__( ( always_inline ) ) static __INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr)\r
655 {\r
656    uint32_t result;\r
657   \r
658    __ASM volatile ("strexb %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) );\r
659    return(result);\r
660 }\r
661 \r
662 \r
663 /** \brief  STR Exclusive (16 bit)\r
664 \r
665     This function performs a exclusive STR command for 16 bit values.\r
666 \r
667     \param [in]  value  Value to store\r
668     \param [in]    ptr  Pointer to location\r
669     \return          0  Function succeeded\r
670     \return          1  Function failed\r
671  */\r
672 __attribute__( ( always_inline ) ) static __INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)\r
673 {\r
674    uint32_t result;\r
675   \r
676    __ASM volatile ("strexh %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) );\r
677    return(result);\r
678 }\r
679 \r
680 \r
681 /** \brief  STR Exclusive (32 bit)\r
682 \r
683     This function performs a exclusive STR command for 32 bit values.\r
684 \r
685     \param [in]  value  Value to store\r
686     \param [in]    ptr  Pointer to location\r
687     \return          0  Function succeeded\r
688     \return          1  Function failed\r
689  */\r
690 __attribute__( ( always_inline ) ) static __INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr)\r
691 {\r
692    uint32_t result;\r
693   \r
694    __ASM volatile ("strex %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) );\r
695    return(result);\r
696 }\r
697 \r
698 \r
699 /** \brief  Remove the exclusive lock\r
700 \r
701     This function removes the exclusive lock which is created by LDREX.\r
702 \r
703  */\r
704 __attribute__( ( always_inline ) ) static __INLINE void __CLREX(void)\r
705 {\r
706   __ASM volatile ("clrex");\r
707 }\r
708 \r
709 \r
710 /** \brief  Signed Saturate\r
711 \r
712     This function saturates a signed value.\r
713 \r
714     \param [in]  value  Value to be saturated\r
715     \param [in]    sat  Bit position to saturate to (1..32)\r
716     \return             Saturated value\r
717  */\r
718 #define __SSAT(ARG1,ARG2) \\r
719 ({                          \\r
720   uint32_t __RES, __ARG1 = (ARG1); \\r
721   __ASM ("ssat %0, %1, %2" : "=r" (__RES) :  "I" (ARG2), "r" (__ARG1) ); \\r
722   __RES; \\r
723  })\r
724 \r
725 \r
726 /** \brief  Unsigned Saturate\r
727 \r
728     This function saturates an unsigned value.\r
729 \r
730     \param [in]  value  Value to be saturated\r
731     \param [in]    sat  Bit position to saturate to (0..31)\r
732     \return             Saturated value\r
733  */\r
734 #define __USAT(ARG1,ARG2) \\r
735 ({                          \\r
736   uint32_t __RES, __ARG1 = (ARG1); \\r
737   __ASM ("usat %0, %1, %2" : "=r" (__RES) :  "I" (ARG2), "r" (__ARG1) ); \\r
738   __RES; \\r
739  })\r
740 \r
741 \r
742 /** \brief  Count leading zeros\r
743 \r
744     This function counts the number of leading zeros of a data value.\r
745 \r
746     \param [in]  value  Value to count the leading zeros\r
747     \return             number of leading zeros in value\r
748  */\r
749 __attribute__( ( always_inline ) ) static __INLINE uint8_t __CLZ(uint32_t value)\r
750 {\r
751   uint8_t result;\r
752   \r
753   __ASM volatile ("clz %0, %1" : "=r" (result) : "r" (value) );\r
754   return(result);\r
755 }\r
756 \r
757 #endif /* (__CORTEX_M >= 0x03) */\r
758 \r
759 \r
760 \r
761 \r
762 #elif (defined (__TASKING__)) /*--------------- TASKING Compiler -----------------*/\r
763 /* TASKING carm specific functions */\r
764 \r
765 /*\r
766  * The CMSIS functions have been implemented as intrinsics in the compiler.\r
767  * Please use "carm -?i" to get an up to date list of all instrinsics,\r
768  * Including the CMSIS ones.\r
769  */\r
770 \r
771 #endif\r
772 \r
773 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */\r
774 \r
775 #endif /* __CORE_CMINSTR_H__ */\r