annotate Common/Drivers/CMSIS_v210/core_cmInstr.h @ 96:6eec2db15cf8 kittz

Sorry. Now.
author Dmitry Romanov <kitt@bk.ru>
date Mon, 26 Nov 2018 13:45:14 +0300
parents 5f11787b4f42
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**************************************************************************//**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 * @file core_cmInstr.h
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @brief CMSIS Cortex-M Core Instruction Access Header File
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @version V2.10
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @date 19. July 2011
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @note
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 * Copyright (C) 2009-2011 ARM Limited. All rights reserved.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 * @par
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 * ARM Limited (ARM) is supplying this software for use with Cortex-M
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 * processor based microcontrollers. This file can be freely distributed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 * within development tools that are supporting such ARM based processors.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 * @par
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 ******************************************************************************/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 #ifndef __CORE_CMINSTR_H
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 #define __CORE_CMINSTR_H
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 /* ########################## Core Instruction Access ######################### */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 Access to dedicated instructions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 #if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 /* ARM armcc specific functions */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 #if (__ARMCC_VERSION < 400677)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 #error "Please use ARM Compiler Toolchain V4.0.677 or later!"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 /** \brief No Operation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44 No Operation does nothing. This instruction can be used for code alignment purposes.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 #define __NOP __nop
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 /** \brief Wait For Interrupt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 Wait For Interrupt is a hint instruction that suspends execution
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 until one of a number of events occurs.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 #define __WFI __wfi
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 /** \brief Wait For Event
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 Wait For Event is a hint instruction that permits the processor to enter
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 a low-power state until one of a number of events occurs.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 #define __WFE __wfe
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 /** \brief Send Event
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 Send Event is a hint instruction. It causes an event to be signaled to the CPU.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 #define __SEV __sev
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 /** \brief Instruction Synchronization Barrier
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 Instruction Synchronization Barrier flushes the pipeline in the processor,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 so that all instructions following the ISB are fetched from cache or
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 memory, after the instruction has been completed.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 #define __ISB() __isb(0xF)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 /** \brief Data Synchronization Barrier
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 This function acts as a special kind of Data Memory Barrier.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 It completes when all explicit memory accesses before this instruction complete.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 #define __DSB() __dsb(0xF)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89 /** \brief Data Memory Barrier
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 This function ensures the apparent order of the explicit memory operations before
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 and after the instruction, without ensuring their completion.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 #define __DMB() __dmb(0xF)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 /** \brief Reverse byte order (32 bit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 This function reverses the byte order in integer value.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 \param [in] value Value to reverse
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 \return Reversed value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 #define __REV __rev
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 /** \brief Reverse byte order (16 bit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 This function reverses the byte order in two unsigned short values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 \param [in] value Value to reverse
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112 \return Reversed value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 static __INLINE __ASM uint32_t __REV16(uint32_t value)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 rev16 r0, r0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117 bx lr
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 /** \brief Reverse byte order in signed short value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 This function reverses the byte order in a signed short value with sign extension to integer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 \param [in] value Value to reverse
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126 \return Reversed value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 static __INLINE __ASM int32_t __REVSH(int32_t value)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 revsh r0, r0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 bx lr
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 #if (__CORTEX_M >= 0x03)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 /** \brief Reverse bit order of value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 This function reverses the bit order of the given value.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 \param [in] value Value to reverse
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 \return Reversed value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 #define __RBIT __rbit
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 /** \brief LDR Exclusive (8 bit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 This function performs a exclusive LDR command for 8 bit value.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 \param [in] ptr Pointer to data
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 \return value of type uint8_t at (*ptr)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 /** \brief LDR Exclusive (16 bit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 This function performs a exclusive LDR command for 16 bit values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 \param [in] ptr Pointer to data
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162 \return value of type uint16_t at (*ptr)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 /** \brief LDR Exclusive (32 bit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 This function performs a exclusive LDR command for 32 bit values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 \param [in] ptr Pointer to data
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 \return value of type uint32_t at (*ptr)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 /** \brief STR Exclusive (8 bit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 This function performs a exclusive STR command for 8 bit values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 \param [in] value Value to store
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 \param [in] ptr Pointer to location
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 \return 0 Function succeeded
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 \return 1 Function failed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 #define __STREXB(value, ptr) __strex(value, ptr)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 /** \brief STR Exclusive (16 bit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 This function performs a exclusive STR command for 16 bit values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 \param [in] value Value to store
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 \param [in] ptr Pointer to location
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 \return 0 Function succeeded
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 \return 1 Function failed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 #define __STREXH(value, ptr) __strex(value, ptr)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 /** \brief STR Exclusive (32 bit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 This function performs a exclusive STR command for 32 bit values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 \param [in] value Value to store
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 \param [in] ptr Pointer to location
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 \return 0 Function succeeded
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 \return 1 Function failed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 #define __STREXW(value, ptr) __strex(value, ptr)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213 /** \brief Remove the exclusive lock
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 This function removes the exclusive lock which is created by LDREX.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 #define __CLREX __clrex
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221 /** \brief Signed Saturate
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 This function saturates a signed value.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 \param [in] value Value to be saturated
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 \param [in] sat Bit position to saturate to (1..32)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 \return Saturated value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 #define __SSAT __ssat
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 /** \brief Unsigned Saturate
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 This function saturates an unsigned value.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 \param [in] value Value to be saturated
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237 \param [in] sat Bit position to saturate to (0..31)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 \return Saturated value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 #define __USAT __usat
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 /** \brief Count leading zeros
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 This function counts the number of leading zeros of a data value.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 \param [in] value Value to count the leading zeros
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 \return number of leading zeros in value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 #define __CLZ __clz
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 #endif /* (__CORTEX_M >= 0x03) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 #elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 /* IAR iccarm specific functions */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 #include <cmsis_iar.h>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262 #elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 /* GNU gcc specific functions */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 /** \brief No Operation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 No Operation does nothing. This instruction can be used for code alignment purposes.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 __attribute__( ( always_inline ) ) static __INLINE void __NOP(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271 __ASM volatile ("nop");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 /** \brief Wait For Interrupt
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 Wait For Interrupt is a hint instruction that suspends execution
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 until one of a number of events occurs.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 __attribute__( ( always_inline ) ) static __INLINE void __WFI(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282 __ASM volatile ("wfi");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 /** \brief Wait For Event
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 Wait For Event is a hint instruction that permits the processor to enter
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 a low-power state until one of a number of events occurs.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 __attribute__( ( always_inline ) ) static __INLINE void __WFE(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 __ASM volatile ("wfe");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 /** \brief Send Event
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 Send Event is a hint instruction. It causes an event to be signaled to the CPU.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 __attribute__( ( always_inline ) ) static __INLINE void __SEV(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 __ASM volatile ("sev");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 /** \brief Instruction Synchronization Barrier
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 Instruction Synchronization Barrier flushes the pipeline in the processor,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 so that all instructions following the ISB are fetched from cache or
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 memory, after the instruction has been completed.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 __attribute__( ( always_inline ) ) static __INLINE void __ISB(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 __ASM volatile ("isb");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 /** \brief Data Synchronization Barrier
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 This function acts as a special kind of Data Memory Barrier.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 It completes when all explicit memory accesses before this instruction complete.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 __attribute__( ( always_inline ) ) static __INLINE void __DSB(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 __ASM volatile ("dsb");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 /** \brief Data Memory Barrier
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 This function ensures the apparent order of the explicit memory operations before
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 and after the instruction, without ensuring their completion.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 __attribute__( ( always_inline ) ) static __INLINE void __DMB(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 __ASM volatile ("dmb");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 /** \brief Reverse byte order (32 bit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 This function reverses the byte order in integer value.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 \param [in] value Value to reverse
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 \return Reversed value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 __attribute__( ( always_inline ) ) static __INLINE uint32_t __REV(uint32_t value)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350 uint32_t result;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 __ASM volatile ("rev %0, %1" : "=r" (result) : "r" (value) );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 return(result);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 /** \brief Reverse byte order (16 bit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 This function reverses the byte order in two unsigned short values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361 \param [in] value Value to reverse
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 \return Reversed value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 __attribute__( ( always_inline ) ) static __INLINE uint32_t __REV16(uint32_t value)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 uint32_t result;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 __ASM volatile ("rev16 %0, %1" : "=r" (result) : "r" (value) );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 return(result);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 /** \brief Reverse byte order in signed short value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 This function reverses the byte order in a signed short value with sign extension to integer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 \param [in] value Value to reverse
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 \return Reversed value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380 __attribute__( ( always_inline ) ) static __INLINE int32_t __REVSH(int32_t value)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 uint32_t result;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 __ASM volatile ("revsh %0, %1" : "=r" (result) : "r" (value) );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 return(result);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 #if (__CORTEX_M >= 0x03)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 /** \brief Reverse bit order of value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 This function reverses the bit order of the given value.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 \param [in] value Value to reverse
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 \return Reversed value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 __attribute__( ( always_inline ) ) static __INLINE uint32_t __RBIT(uint32_t value)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 uint32_t result;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 return(result);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 /** \brief LDR Exclusive (8 bit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 This function performs a exclusive LDR command for 8 bit value.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 \param [in] ptr Pointer to data
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 \return value of type uint8_t at (*ptr)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414 __attribute__( ( always_inline ) ) static __INLINE uint8_t __LDREXB(volatile uint8_t *addr)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416 uint8_t result;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418 __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 return(result);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 /** \brief LDR Exclusive (16 bit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425 This function performs a exclusive LDR command for 16 bit values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 \param [in] ptr Pointer to data
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428 \return value of type uint16_t at (*ptr)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 __attribute__( ( always_inline ) ) static __INLINE uint16_t __LDREXH(volatile uint16_t *addr)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432 uint16_t result;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434 __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435 return(result);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439 /** \brief LDR Exclusive (32 bit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441 This function performs a exclusive LDR command for 32 bit values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443 \param [in] ptr Pointer to data
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 \return value of type uint32_t at (*ptr)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446 __attribute__( ( always_inline ) ) static __INLINE uint32_t __LDREXW(volatile uint32_t *addr)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448 uint32_t result;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450 __ASM volatile ("ldrex %0, [%1]" : "=r" (result) : "r" (addr) );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451 return(result);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 /** \brief STR Exclusive (8 bit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 This function performs a exclusive STR command for 8 bit values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 \param [in] value Value to store
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460 \param [in] ptr Pointer to location
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 \return 0 Function succeeded
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462 \return 1 Function failed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464 __attribute__( ( always_inline ) ) static __INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 uint32_t result;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468 __ASM volatile ("strexb %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 return(result);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 /** \brief STR Exclusive (16 bit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 This function performs a exclusive STR command for 16 bit values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477 \param [in] value Value to store
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478 \param [in] ptr Pointer to location
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 \return 0 Function succeeded
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480 \return 1 Function failed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482 __attribute__( ( always_inline ) ) static __INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 uint32_t result;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486 __ASM volatile ("strexh %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 return(result);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491 /** \brief STR Exclusive (32 bit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493 This function performs a exclusive STR command for 32 bit values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495 \param [in] value Value to store
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496 \param [in] ptr Pointer to location
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497 \return 0 Function succeeded
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498 \return 1 Function failed
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500 __attribute__( ( always_inline ) ) static __INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502 uint32_t result;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504 __ASM volatile ("strex %0, %2, [%1]" : "=r" (result) : "r" (addr), "r" (value) );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505 return(result);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 /** \brief Remove the exclusive lock
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
511 This function removes the exclusive lock which is created by LDREX.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514 __attribute__( ( always_inline ) ) static __INLINE void __CLREX(void)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516 __ASM volatile ("clrex");
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520 /** \brief Signed Saturate
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
522 This function saturates a signed value.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524 \param [in] value Value to be saturated
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525 \param [in] sat Bit position to saturate to (1..32)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526 \return Saturated value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 #define __SSAT(ARG1,ARG2) \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529 ({ \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
530 uint32_t __RES, __ARG1 = (ARG1); \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
531 __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
532 __RES; \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533 })
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
536 /** \brief Unsigned Saturate
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 This function saturates an unsigned value.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
539
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540 \param [in] value Value to be saturated
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
541 \param [in] sat Bit position to saturate to (0..31)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
542 \return Saturated value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
543 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544 #define __USAT(ARG1,ARG2) \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545 ({ \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
546 uint32_t __RES, __ARG1 = (ARG1); \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
547 __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
548 __RES; \
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549 })
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
550
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
551
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552 /** \brief Count leading zeros
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554 This function counts the number of leading zeros of a data value.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556 \param [in] value Value to count the leading zeros
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557 \return number of leading zeros in value
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
558 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
559 __attribute__( ( always_inline ) ) static __INLINE uint8_t __CLZ(uint32_t value)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
560 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
561 uint8_t result;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
562
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
563 __ASM volatile ("clz %0, %1" : "=r" (result) : "r" (value) );
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
564 return(result);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
565 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
566
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
567 #endif /* (__CORTEX_M >= 0x03) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
568
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
569
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
570
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
571
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
572 #elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
573 /* TASKING carm specific functions */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
574
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
575 /*
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
576 * The CMSIS functions have been implemented as intrinsics in the compiler.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
577 * Please use "carm -?i" to get an up to date list of all intrinsics,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
578 * Including the CMSIS ones.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
579 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
580
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
581 #endif
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
582
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
583 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
584
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
585 #endif /* __CORE_CMINSTR_H */