The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
Kojto
Date:
Thu Oct 29 08:40:18 2015 +0000
Revision:
109:9296ab0bfc11
Child:
110:165afa46840b
Release 109  of the mbed library

Changes:
- new platforms - NUCLEO_F042K6, WIZNWIKI_W7500ECO
- MTS targets - bootloaders update to 0.1.1
- STM F7 - RTC enable fixes
- STM F4 - i2c pending stop before start fix
- STM all targets - analogout normalization fix

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 109:9296ab0bfc11 1 /**************************************************************************//**
Kojto 109:9296ab0bfc11 2 * @file core_cmInstr.h
Kojto 109:9296ab0bfc11 3 * @brief CMSIS Cortex-M Core Instruction Access Header File
Kojto 109:9296ab0bfc11 4 * @version V3.20
Kojto 109:9296ab0bfc11 5 * @date 05. March 2013
Kojto 109:9296ab0bfc11 6 *
Kojto 109:9296ab0bfc11 7 * @note
Kojto 109:9296ab0bfc11 8 *
Kojto 109:9296ab0bfc11 9 ******************************************************************************/
Kojto 109:9296ab0bfc11 10 /* Copyright (c) 2009 - 2013 ARM LIMITED
Kojto 109:9296ab0bfc11 11
Kojto 109:9296ab0bfc11 12 All rights reserved.
Kojto 109:9296ab0bfc11 13 Redistribution and use in source and binary forms, with or without
Kojto 109:9296ab0bfc11 14 modification, are permitted provided that the following conditions are met:
Kojto 109:9296ab0bfc11 15 - Redistributions of source code must retain the above copyright
Kojto 109:9296ab0bfc11 16 notice, this list of conditions and the following disclaimer.
Kojto 109:9296ab0bfc11 17 - Redistributions in binary form must reproduce the above copyright
Kojto 109:9296ab0bfc11 18 notice, this list of conditions and the following disclaimer in the
Kojto 109:9296ab0bfc11 19 documentation and/or other materials provided with the distribution.
Kojto 109:9296ab0bfc11 20 - Neither the name of ARM nor the names of its contributors may be used
Kojto 109:9296ab0bfc11 21 to endorse or promote products derived from this software without
Kojto 109:9296ab0bfc11 22 specific prior written permission.
Kojto 109:9296ab0bfc11 23 *
Kojto 109:9296ab0bfc11 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 109:9296ab0bfc11 25 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 109:9296ab0bfc11 26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Kojto 109:9296ab0bfc11 27 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
Kojto 109:9296ab0bfc11 28 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
Kojto 109:9296ab0bfc11 29 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
Kojto 109:9296ab0bfc11 30 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Kojto 109:9296ab0bfc11 31 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
Kojto 109:9296ab0bfc11 32 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
Kojto 109:9296ab0bfc11 33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
Kojto 109:9296ab0bfc11 34 POSSIBILITY OF SUCH DAMAGE.
Kojto 109:9296ab0bfc11 35 ---------------------------------------------------------------------------*/
Kojto 109:9296ab0bfc11 36
Kojto 109:9296ab0bfc11 37
Kojto 109:9296ab0bfc11 38 #ifndef __CORE_CMINSTR_H
Kojto 109:9296ab0bfc11 39 #define __CORE_CMINSTR_H
Kojto 109:9296ab0bfc11 40
Kojto 109:9296ab0bfc11 41
Kojto 109:9296ab0bfc11 42 /* ########################## Core Instruction Access ######################### */
Kojto 109:9296ab0bfc11 43 /** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
Kojto 109:9296ab0bfc11 44 Access to dedicated instructions
Kojto 109:9296ab0bfc11 45 @{
Kojto 109:9296ab0bfc11 46 */
Kojto 109:9296ab0bfc11 47
Kojto 109:9296ab0bfc11 48 #if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
Kojto 109:9296ab0bfc11 49 /* ARM armcc specific functions */
Kojto 109:9296ab0bfc11 50
Kojto 109:9296ab0bfc11 51 #if (__ARMCC_VERSION < 400677)
Kojto 109:9296ab0bfc11 52 #error "Please use ARM Compiler Toolchain V4.0.677 or later!"
Kojto 109:9296ab0bfc11 53 #endif
Kojto 109:9296ab0bfc11 54
Kojto 109:9296ab0bfc11 55
Kojto 109:9296ab0bfc11 56 /** \brief No Operation
Kojto 109:9296ab0bfc11 57
Kojto 109:9296ab0bfc11 58 No Operation does nothing. This instruction can be used for code alignment purposes.
Kojto 109:9296ab0bfc11 59 */
Kojto 109:9296ab0bfc11 60 #define __NOP __nop
Kojto 109:9296ab0bfc11 61
Kojto 109:9296ab0bfc11 62
Kojto 109:9296ab0bfc11 63 /** \brief Wait For Interrupt
Kojto 109:9296ab0bfc11 64
Kojto 109:9296ab0bfc11 65 Wait For Interrupt is a hint instruction that suspends execution
Kojto 109:9296ab0bfc11 66 until one of a number of events occurs.
Kojto 109:9296ab0bfc11 67 */
Kojto 109:9296ab0bfc11 68 #define __WFI __wfi
Kojto 109:9296ab0bfc11 69
Kojto 109:9296ab0bfc11 70
Kojto 109:9296ab0bfc11 71 /** \brief Wait For Event
Kojto 109:9296ab0bfc11 72
Kojto 109:9296ab0bfc11 73 Wait For Event is a hint instruction that permits the processor to enter
Kojto 109:9296ab0bfc11 74 a low-power state until one of a number of events occurs.
Kojto 109:9296ab0bfc11 75 */
Kojto 109:9296ab0bfc11 76 #define __WFE __wfe
Kojto 109:9296ab0bfc11 77
Kojto 109:9296ab0bfc11 78
Kojto 109:9296ab0bfc11 79 /** \brief Send Event
Kojto 109:9296ab0bfc11 80
Kojto 109:9296ab0bfc11 81 Send Event is a hint instruction. It causes an event to be signaled to the CPU.
Kojto 109:9296ab0bfc11 82 */
Kojto 109:9296ab0bfc11 83 #define __SEV __sev
Kojto 109:9296ab0bfc11 84
Kojto 109:9296ab0bfc11 85
Kojto 109:9296ab0bfc11 86 /** \brief Instruction Synchronization Barrier
Kojto 109:9296ab0bfc11 87
Kojto 109:9296ab0bfc11 88 Instruction Synchronization Barrier flushes the pipeline in the processor,
Kojto 109:9296ab0bfc11 89 so that all instructions following the ISB are fetched from cache or
Kojto 109:9296ab0bfc11 90 memory, after the instruction has been completed.
Kojto 109:9296ab0bfc11 91 */
Kojto 109:9296ab0bfc11 92 #define __ISB() __isb(0xF)
Kojto 109:9296ab0bfc11 93
Kojto 109:9296ab0bfc11 94
Kojto 109:9296ab0bfc11 95 /** \brief Data Synchronization Barrier
Kojto 109:9296ab0bfc11 96
Kojto 109:9296ab0bfc11 97 This function acts as a special kind of Data Memory Barrier.
Kojto 109:9296ab0bfc11 98 It completes when all explicit memory accesses before this instruction complete.
Kojto 109:9296ab0bfc11 99 */
Kojto 109:9296ab0bfc11 100 #define __DSB() __dsb(0xF)
Kojto 109:9296ab0bfc11 101
Kojto 109:9296ab0bfc11 102
Kojto 109:9296ab0bfc11 103 /** \brief Data Memory Barrier
Kojto 109:9296ab0bfc11 104
Kojto 109:9296ab0bfc11 105 This function ensures the apparent order of the explicit memory operations before
Kojto 109:9296ab0bfc11 106 and after the instruction, without ensuring their completion.
Kojto 109:9296ab0bfc11 107 */
Kojto 109:9296ab0bfc11 108 #define __DMB() __dmb(0xF)
Kojto 109:9296ab0bfc11 109
Kojto 109:9296ab0bfc11 110
Kojto 109:9296ab0bfc11 111 /** \brief Reverse byte order (32 bit)
Kojto 109:9296ab0bfc11 112
Kojto 109:9296ab0bfc11 113 This function reverses the byte order in integer value.
Kojto 109:9296ab0bfc11 114
Kojto 109:9296ab0bfc11 115 \param [in] value Value to reverse
Kojto 109:9296ab0bfc11 116 \return Reversed value
Kojto 109:9296ab0bfc11 117 */
Kojto 109:9296ab0bfc11 118 #define __REV __rev
Kojto 109:9296ab0bfc11 119
Kojto 109:9296ab0bfc11 120
Kojto 109:9296ab0bfc11 121 /** \brief Reverse byte order (16 bit)
Kojto 109:9296ab0bfc11 122
Kojto 109:9296ab0bfc11 123 This function reverses the byte order in two unsigned short values.
Kojto 109:9296ab0bfc11 124
Kojto 109:9296ab0bfc11 125 \param [in] value Value to reverse
Kojto 109:9296ab0bfc11 126 \return Reversed value
Kojto 109:9296ab0bfc11 127 */
Kojto 109:9296ab0bfc11 128 #ifndef __NO_EMBEDDED_ASM
Kojto 109:9296ab0bfc11 129 __attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
Kojto 109:9296ab0bfc11 130 {
Kojto 109:9296ab0bfc11 131 rev16 r0, r0
Kojto 109:9296ab0bfc11 132 bx lr
Kojto 109:9296ab0bfc11 133 }
Kojto 109:9296ab0bfc11 134 #endif
Kojto 109:9296ab0bfc11 135
Kojto 109:9296ab0bfc11 136 /** \brief Reverse byte order in signed short value
Kojto 109:9296ab0bfc11 137
Kojto 109:9296ab0bfc11 138 This function reverses the byte order in a signed short value with sign extension to integer.
Kojto 109:9296ab0bfc11 139
Kojto 109:9296ab0bfc11 140 \param [in] value Value to reverse
Kojto 109:9296ab0bfc11 141 \return Reversed value
Kojto 109:9296ab0bfc11 142 */
Kojto 109:9296ab0bfc11 143 #ifndef __NO_EMBEDDED_ASM
Kojto 109:9296ab0bfc11 144 __attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int32_t __REVSH(int32_t value)
Kojto 109:9296ab0bfc11 145 {
Kojto 109:9296ab0bfc11 146 revsh r0, r0
Kojto 109:9296ab0bfc11 147 bx lr
Kojto 109:9296ab0bfc11 148 }
Kojto 109:9296ab0bfc11 149 #endif
Kojto 109:9296ab0bfc11 150
Kojto 109:9296ab0bfc11 151
Kojto 109:9296ab0bfc11 152 /** \brief Rotate Right in unsigned value (32 bit)
Kojto 109:9296ab0bfc11 153
Kojto 109:9296ab0bfc11 154 This function Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
Kojto 109:9296ab0bfc11 155
Kojto 109:9296ab0bfc11 156 \param [in] value Value to rotate
Kojto 109:9296ab0bfc11 157 \param [in] value Number of Bits to rotate
Kojto 109:9296ab0bfc11 158 \return Rotated value
Kojto 109:9296ab0bfc11 159 */
Kojto 109:9296ab0bfc11 160 #define __ROR __ror
Kojto 109:9296ab0bfc11 161
Kojto 109:9296ab0bfc11 162
Kojto 109:9296ab0bfc11 163 /** \brief Breakpoint
Kojto 109:9296ab0bfc11 164
Kojto 109:9296ab0bfc11 165 This function causes the processor to enter Debug state.
Kojto 109:9296ab0bfc11 166 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
Kojto 109:9296ab0bfc11 167
Kojto 109:9296ab0bfc11 168 \param [in] value is ignored by the processor.
Kojto 109:9296ab0bfc11 169 If required, a debugger can use it to store additional information about the breakpoint.
Kojto 109:9296ab0bfc11 170 */
Kojto 109:9296ab0bfc11 171 #define __BKPT(value) __breakpoint(value)
Kojto 109:9296ab0bfc11 172
Kojto 109:9296ab0bfc11 173
Kojto 109:9296ab0bfc11 174 #if (__CORTEX_M >= 0x03)
Kojto 109:9296ab0bfc11 175
Kojto 109:9296ab0bfc11 176 /** \brief Reverse bit order of value
Kojto 109:9296ab0bfc11 177
Kojto 109:9296ab0bfc11 178 This function reverses the bit order of the given value.
Kojto 109:9296ab0bfc11 179
Kojto 109:9296ab0bfc11 180 \param [in] value Value to reverse
Kojto 109:9296ab0bfc11 181 \return Reversed value
Kojto 109:9296ab0bfc11 182 */
Kojto 109:9296ab0bfc11 183 #define __RBIT __rbit
Kojto 109:9296ab0bfc11 184
Kojto 109:9296ab0bfc11 185
Kojto 109:9296ab0bfc11 186 /** \brief LDR Exclusive (8 bit)
Kojto 109:9296ab0bfc11 187
Kojto 109:9296ab0bfc11 188 This function performs a exclusive LDR command for 8 bit value.
Kojto 109:9296ab0bfc11 189
Kojto 109:9296ab0bfc11 190 \param [in] ptr Pointer to data
Kojto 109:9296ab0bfc11 191 \return value of type uint8_t at (*ptr)
Kojto 109:9296ab0bfc11 192 */
Kojto 109:9296ab0bfc11 193 #define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
Kojto 109:9296ab0bfc11 194
Kojto 109:9296ab0bfc11 195
Kojto 109:9296ab0bfc11 196 /** \brief LDR Exclusive (16 bit)
Kojto 109:9296ab0bfc11 197
Kojto 109:9296ab0bfc11 198 This function performs a exclusive LDR command for 16 bit values.
Kojto 109:9296ab0bfc11 199
Kojto 109:9296ab0bfc11 200 \param [in] ptr Pointer to data
Kojto 109:9296ab0bfc11 201 \return value of type uint16_t at (*ptr)
Kojto 109:9296ab0bfc11 202 */
Kojto 109:9296ab0bfc11 203 #define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
Kojto 109:9296ab0bfc11 204
Kojto 109:9296ab0bfc11 205
Kojto 109:9296ab0bfc11 206 /** \brief LDR Exclusive (32 bit)
Kojto 109:9296ab0bfc11 207
Kojto 109:9296ab0bfc11 208 This function performs a exclusive LDR command for 32 bit values.
Kojto 109:9296ab0bfc11 209
Kojto 109:9296ab0bfc11 210 \param [in] ptr Pointer to data
Kojto 109:9296ab0bfc11 211 \return value of type uint32_t at (*ptr)
Kojto 109:9296ab0bfc11 212 */
Kojto 109:9296ab0bfc11 213 #define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
Kojto 109:9296ab0bfc11 214
Kojto 109:9296ab0bfc11 215
Kojto 109:9296ab0bfc11 216 /** \brief STR Exclusive (8 bit)
Kojto 109:9296ab0bfc11 217
Kojto 109:9296ab0bfc11 218 This function performs a exclusive STR command for 8 bit values.
Kojto 109:9296ab0bfc11 219
Kojto 109:9296ab0bfc11 220 \param [in] value Value to store
Kojto 109:9296ab0bfc11 221 \param [in] ptr Pointer to location
Kojto 109:9296ab0bfc11 222 \return 0 Function succeeded
Kojto 109:9296ab0bfc11 223 \return 1 Function failed
Kojto 109:9296ab0bfc11 224 */
Kojto 109:9296ab0bfc11 225 #define __STREXB(value, ptr) __strex(value, ptr)
Kojto 109:9296ab0bfc11 226
Kojto 109:9296ab0bfc11 227
Kojto 109:9296ab0bfc11 228 /** \brief STR Exclusive (16 bit)
Kojto 109:9296ab0bfc11 229
Kojto 109:9296ab0bfc11 230 This function performs a exclusive STR command for 16 bit values.
Kojto 109:9296ab0bfc11 231
Kojto 109:9296ab0bfc11 232 \param [in] value Value to store
Kojto 109:9296ab0bfc11 233 \param [in] ptr Pointer to location
Kojto 109:9296ab0bfc11 234 \return 0 Function succeeded
Kojto 109:9296ab0bfc11 235 \return 1 Function failed
Kojto 109:9296ab0bfc11 236 */
Kojto 109:9296ab0bfc11 237 #define __STREXH(value, ptr) __strex(value, ptr)
Kojto 109:9296ab0bfc11 238
Kojto 109:9296ab0bfc11 239
Kojto 109:9296ab0bfc11 240 /** \brief STR Exclusive (32 bit)
Kojto 109:9296ab0bfc11 241
Kojto 109:9296ab0bfc11 242 This function performs a exclusive STR command for 32 bit values.
Kojto 109:9296ab0bfc11 243
Kojto 109:9296ab0bfc11 244 \param [in] value Value to store
Kojto 109:9296ab0bfc11 245 \param [in] ptr Pointer to location
Kojto 109:9296ab0bfc11 246 \return 0 Function succeeded
Kojto 109:9296ab0bfc11 247 \return 1 Function failed
Kojto 109:9296ab0bfc11 248 */
Kojto 109:9296ab0bfc11 249 #define __STREXW(value, ptr) __strex(value, ptr)
Kojto 109:9296ab0bfc11 250
Kojto 109:9296ab0bfc11 251
Kojto 109:9296ab0bfc11 252 /** \brief Remove the exclusive lock
Kojto 109:9296ab0bfc11 253
Kojto 109:9296ab0bfc11 254 This function removes the exclusive lock which is created by LDREX.
Kojto 109:9296ab0bfc11 255
Kojto 109:9296ab0bfc11 256 */
Kojto 109:9296ab0bfc11 257 #define __CLREX __clrex
Kojto 109:9296ab0bfc11 258
Kojto 109:9296ab0bfc11 259
Kojto 109:9296ab0bfc11 260 /** \brief Signed Saturate
Kojto 109:9296ab0bfc11 261
Kojto 109:9296ab0bfc11 262 This function saturates a signed value.
Kojto 109:9296ab0bfc11 263
Kojto 109:9296ab0bfc11 264 \param [in] value Value to be saturated
Kojto 109:9296ab0bfc11 265 \param [in] sat Bit position to saturate to (1..32)
Kojto 109:9296ab0bfc11 266 \return Saturated value
Kojto 109:9296ab0bfc11 267 */
Kojto 109:9296ab0bfc11 268 #define __SSAT __ssat
Kojto 109:9296ab0bfc11 269
Kojto 109:9296ab0bfc11 270
Kojto 109:9296ab0bfc11 271 /** \brief Unsigned Saturate
Kojto 109:9296ab0bfc11 272
Kojto 109:9296ab0bfc11 273 This function saturates an unsigned value.
Kojto 109:9296ab0bfc11 274
Kojto 109:9296ab0bfc11 275 \param [in] value Value to be saturated
Kojto 109:9296ab0bfc11 276 \param [in] sat Bit position to saturate to (0..31)
Kojto 109:9296ab0bfc11 277 \return Saturated value
Kojto 109:9296ab0bfc11 278 */
Kojto 109:9296ab0bfc11 279 #define __USAT __usat
Kojto 109:9296ab0bfc11 280
Kojto 109:9296ab0bfc11 281
Kojto 109:9296ab0bfc11 282 /** \brief Count leading zeros
Kojto 109:9296ab0bfc11 283
Kojto 109:9296ab0bfc11 284 This function counts the number of leading zeros of a data value.
Kojto 109:9296ab0bfc11 285
Kojto 109:9296ab0bfc11 286 \param [in] value Value to count the leading zeros
Kojto 109:9296ab0bfc11 287 \return number of leading zeros in value
Kojto 109:9296ab0bfc11 288 */
Kojto 109:9296ab0bfc11 289 #define __CLZ __clz
Kojto 109:9296ab0bfc11 290
Kojto 109:9296ab0bfc11 291 #endif /* (__CORTEX_M >= 0x03) */
Kojto 109:9296ab0bfc11 292
Kojto 109:9296ab0bfc11 293
Kojto 109:9296ab0bfc11 294
Kojto 109:9296ab0bfc11 295 #elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
Kojto 109:9296ab0bfc11 296 /* IAR iccarm specific functions */
Kojto 109:9296ab0bfc11 297
Kojto 109:9296ab0bfc11 298 #include <cmsis_iar.h>
Kojto 109:9296ab0bfc11 299
Kojto 109:9296ab0bfc11 300
Kojto 109:9296ab0bfc11 301 #elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/
Kojto 109:9296ab0bfc11 302 /* TI CCS specific functions */
Kojto 109:9296ab0bfc11 303
Kojto 109:9296ab0bfc11 304 #include <cmsis_ccs.h>
Kojto 109:9296ab0bfc11 305
Kojto 109:9296ab0bfc11 306
Kojto 109:9296ab0bfc11 307 #elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
Kojto 109:9296ab0bfc11 308 /* GNU gcc specific functions */
Kojto 109:9296ab0bfc11 309
Kojto 109:9296ab0bfc11 310 /* Define macros for porting to both thumb1 and thumb2.
Kojto 109:9296ab0bfc11 311 * For thumb1, use low register (r0-r7), specified by constrant "l"
Kojto 109:9296ab0bfc11 312 * Otherwise, use general registers, specified by constrant "r" */
Kojto 109:9296ab0bfc11 313 #if defined (__thumb__) && !defined (__thumb2__)
Kojto 109:9296ab0bfc11 314 #define __CMSIS_GCC_OUT_REG(r) "=l" (r)
Kojto 109:9296ab0bfc11 315 #define __CMSIS_GCC_USE_REG(r) "l" (r)
Kojto 109:9296ab0bfc11 316 #else
Kojto 109:9296ab0bfc11 317 #define __CMSIS_GCC_OUT_REG(r) "=r" (r)
Kojto 109:9296ab0bfc11 318 #define __CMSIS_GCC_USE_REG(r) "r" (r)
Kojto 109:9296ab0bfc11 319 #endif
Kojto 109:9296ab0bfc11 320
Kojto 109:9296ab0bfc11 321 /** \brief No Operation
Kojto 109:9296ab0bfc11 322
Kojto 109:9296ab0bfc11 323 No Operation does nothing. This instruction can be used for code alignment purposes.
Kojto 109:9296ab0bfc11 324 */
Kojto 109:9296ab0bfc11 325 __attribute__( ( always_inline ) ) __STATIC_INLINE void __NOP(void)
Kojto 109:9296ab0bfc11 326 {
Kojto 109:9296ab0bfc11 327 __ASM volatile ("nop");
Kojto 109:9296ab0bfc11 328 }
Kojto 109:9296ab0bfc11 329
Kojto 109:9296ab0bfc11 330
Kojto 109:9296ab0bfc11 331 /** \brief Wait For Interrupt
Kojto 109:9296ab0bfc11 332
Kojto 109:9296ab0bfc11 333 Wait For Interrupt is a hint instruction that suspends execution
Kojto 109:9296ab0bfc11 334 until one of a number of events occurs.
Kojto 109:9296ab0bfc11 335 */
Kojto 109:9296ab0bfc11 336 __attribute__( ( always_inline ) ) __STATIC_INLINE void __WFI(void)
Kojto 109:9296ab0bfc11 337 {
Kojto 109:9296ab0bfc11 338 __ASM volatile ("wfi");
Kojto 109:9296ab0bfc11 339 }
Kojto 109:9296ab0bfc11 340
Kojto 109:9296ab0bfc11 341
Kojto 109:9296ab0bfc11 342 /** \brief Wait For Event
Kojto 109:9296ab0bfc11 343
Kojto 109:9296ab0bfc11 344 Wait For Event is a hint instruction that permits the processor to enter
Kojto 109:9296ab0bfc11 345 a low-power state until one of a number of events occurs.
Kojto 109:9296ab0bfc11 346 */
Kojto 109:9296ab0bfc11 347 __attribute__( ( always_inline ) ) __STATIC_INLINE void __WFE(void)
Kojto 109:9296ab0bfc11 348 {
Kojto 109:9296ab0bfc11 349 __ASM volatile ("wfe");
Kojto 109:9296ab0bfc11 350 }
Kojto 109:9296ab0bfc11 351
Kojto 109:9296ab0bfc11 352
Kojto 109:9296ab0bfc11 353 /** \brief Send Event
Kojto 109:9296ab0bfc11 354
Kojto 109:9296ab0bfc11 355 Send Event is a hint instruction. It causes an event to be signaled to the CPU.
Kojto 109:9296ab0bfc11 356 */
Kojto 109:9296ab0bfc11 357 __attribute__( ( always_inline ) ) __STATIC_INLINE void __SEV(void)
Kojto 109:9296ab0bfc11 358 {
Kojto 109:9296ab0bfc11 359 __ASM volatile ("sev");
Kojto 109:9296ab0bfc11 360 }
Kojto 109:9296ab0bfc11 361
Kojto 109:9296ab0bfc11 362
Kojto 109:9296ab0bfc11 363 /** \brief Instruction Synchronization Barrier
Kojto 109:9296ab0bfc11 364
Kojto 109:9296ab0bfc11 365 Instruction Synchronization Barrier flushes the pipeline in the processor,
Kojto 109:9296ab0bfc11 366 so that all instructions following the ISB are fetched from cache or
Kojto 109:9296ab0bfc11 367 memory, after the instruction has been completed.
Kojto 109:9296ab0bfc11 368 */
Kojto 109:9296ab0bfc11 369 __attribute__( ( always_inline ) ) __STATIC_INLINE void __ISB(void)
Kojto 109:9296ab0bfc11 370 {
Kojto 109:9296ab0bfc11 371 __ASM volatile ("isb");
Kojto 109:9296ab0bfc11 372 }
Kojto 109:9296ab0bfc11 373
Kojto 109:9296ab0bfc11 374
Kojto 109:9296ab0bfc11 375 /** \brief Data Synchronization Barrier
Kojto 109:9296ab0bfc11 376
Kojto 109:9296ab0bfc11 377 This function acts as a special kind of Data Memory Barrier.
Kojto 109:9296ab0bfc11 378 It completes when all explicit memory accesses before this instruction complete.
Kojto 109:9296ab0bfc11 379 */
Kojto 109:9296ab0bfc11 380 __attribute__( ( always_inline ) ) __STATIC_INLINE void __DSB(void)
Kojto 109:9296ab0bfc11 381 {
Kojto 109:9296ab0bfc11 382 __ASM volatile ("dsb");
Kojto 109:9296ab0bfc11 383 }
Kojto 109:9296ab0bfc11 384
Kojto 109:9296ab0bfc11 385
Kojto 109:9296ab0bfc11 386 /** \brief Data Memory Barrier
Kojto 109:9296ab0bfc11 387
Kojto 109:9296ab0bfc11 388 This function ensures the apparent order of the explicit memory operations before
Kojto 109:9296ab0bfc11 389 and after the instruction, without ensuring their completion.
Kojto 109:9296ab0bfc11 390 */
Kojto 109:9296ab0bfc11 391 __attribute__( ( always_inline ) ) __STATIC_INLINE void __DMB(void)
Kojto 109:9296ab0bfc11 392 {
Kojto 109:9296ab0bfc11 393 __ASM volatile ("dmb");
Kojto 109:9296ab0bfc11 394 }
Kojto 109:9296ab0bfc11 395
Kojto 109:9296ab0bfc11 396
Kojto 109:9296ab0bfc11 397 /** \brief Reverse byte order (32 bit)
Kojto 109:9296ab0bfc11 398
Kojto 109:9296ab0bfc11 399 This function reverses the byte order in integer value.
Kojto 109:9296ab0bfc11 400
Kojto 109:9296ab0bfc11 401 \param [in] value Value to reverse
Kojto 109:9296ab0bfc11 402 \return Reversed value
Kojto 109:9296ab0bfc11 403 */
Kojto 109:9296ab0bfc11 404 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __REV(uint32_t value)
Kojto 109:9296ab0bfc11 405 {
Kojto 109:9296ab0bfc11 406 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
Kojto 109:9296ab0bfc11 407 return __builtin_bswap32(value);
Kojto 109:9296ab0bfc11 408 #else
Kojto 109:9296ab0bfc11 409 uint32_t result;
Kojto 109:9296ab0bfc11 410
Kojto 109:9296ab0bfc11 411 __ASM volatile ("rev %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
Kojto 109:9296ab0bfc11 412 return(result);
Kojto 109:9296ab0bfc11 413 #endif
Kojto 109:9296ab0bfc11 414 }
Kojto 109:9296ab0bfc11 415
Kojto 109:9296ab0bfc11 416
Kojto 109:9296ab0bfc11 417 /** \brief Reverse byte order (16 bit)
Kojto 109:9296ab0bfc11 418
Kojto 109:9296ab0bfc11 419 This function reverses the byte order in two unsigned short values.
Kojto 109:9296ab0bfc11 420
Kojto 109:9296ab0bfc11 421 \param [in] value Value to reverse
Kojto 109:9296ab0bfc11 422 \return Reversed value
Kojto 109:9296ab0bfc11 423 */
Kojto 109:9296ab0bfc11 424 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __REV16(uint32_t value)
Kojto 109:9296ab0bfc11 425 {
Kojto 109:9296ab0bfc11 426 uint32_t result;
Kojto 109:9296ab0bfc11 427
Kojto 109:9296ab0bfc11 428 __ASM volatile ("rev16 %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
Kojto 109:9296ab0bfc11 429 return(result);
Kojto 109:9296ab0bfc11 430 }
Kojto 109:9296ab0bfc11 431
Kojto 109:9296ab0bfc11 432
Kojto 109:9296ab0bfc11 433 /** \brief Reverse byte order in signed short value
Kojto 109:9296ab0bfc11 434
Kojto 109:9296ab0bfc11 435 This function reverses the byte order in a signed short value with sign extension to integer.
Kojto 109:9296ab0bfc11 436
Kojto 109:9296ab0bfc11 437 \param [in] value Value to reverse
Kojto 109:9296ab0bfc11 438 \return Reversed value
Kojto 109:9296ab0bfc11 439 */
Kojto 109:9296ab0bfc11 440 __attribute__( ( always_inline ) ) __STATIC_INLINE int32_t __REVSH(int32_t value)
Kojto 109:9296ab0bfc11 441 {
Kojto 109:9296ab0bfc11 442 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
Kojto 109:9296ab0bfc11 443 return (short)__builtin_bswap16(value);
Kojto 109:9296ab0bfc11 444 #else
Kojto 109:9296ab0bfc11 445 uint32_t result;
Kojto 109:9296ab0bfc11 446
Kojto 109:9296ab0bfc11 447 __ASM volatile ("revsh %0, %1" : __CMSIS_GCC_OUT_REG (result) : __CMSIS_GCC_USE_REG (value) );
Kojto 109:9296ab0bfc11 448 return(result);
Kojto 109:9296ab0bfc11 449 #endif
Kojto 109:9296ab0bfc11 450 }
Kojto 109:9296ab0bfc11 451
Kojto 109:9296ab0bfc11 452
Kojto 109:9296ab0bfc11 453 /** \brief Rotate Right in unsigned value (32 bit)
Kojto 109:9296ab0bfc11 454
Kojto 109:9296ab0bfc11 455 This function Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
Kojto 109:9296ab0bfc11 456
Kojto 109:9296ab0bfc11 457 \param [in] value Value to rotate
Kojto 109:9296ab0bfc11 458 \param [in] value Number of Bits to rotate
Kojto 109:9296ab0bfc11 459 \return Rotated value
Kojto 109:9296ab0bfc11 460 */
Kojto 109:9296ab0bfc11 461 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __ROR(uint32_t op1, uint32_t op2)
Kojto 109:9296ab0bfc11 462 {
Kojto 109:9296ab0bfc11 463 return (op1 >> op2) | (op1 << (32 - op2));
Kojto 109:9296ab0bfc11 464 }
Kojto 109:9296ab0bfc11 465
Kojto 109:9296ab0bfc11 466
Kojto 109:9296ab0bfc11 467 /** \brief Breakpoint
Kojto 109:9296ab0bfc11 468
Kojto 109:9296ab0bfc11 469 This function causes the processor to enter Debug state.
Kojto 109:9296ab0bfc11 470 Debug tools can use this to investigate system state when the instruction at a particular address is reached.
Kojto 109:9296ab0bfc11 471
Kojto 109:9296ab0bfc11 472 \param [in] value is ignored by the processor.
Kojto 109:9296ab0bfc11 473 If required, a debugger can use it to store additional information about the breakpoint.
Kojto 109:9296ab0bfc11 474 */
Kojto 109:9296ab0bfc11 475 #define __BKPT(value) __ASM volatile ("bkpt "#value)
Kojto 109:9296ab0bfc11 476
Kojto 109:9296ab0bfc11 477
Kojto 109:9296ab0bfc11 478 #if (__CORTEX_M >= 0x03)
Kojto 109:9296ab0bfc11 479
Kojto 109:9296ab0bfc11 480 /** \brief Reverse bit order of value
Kojto 109:9296ab0bfc11 481
Kojto 109:9296ab0bfc11 482 This function reverses the bit order of the given value.
Kojto 109:9296ab0bfc11 483
Kojto 109:9296ab0bfc11 484 \param [in] value Value to reverse
Kojto 109:9296ab0bfc11 485 \return Reversed value
Kojto 109:9296ab0bfc11 486 */
Kojto 109:9296ab0bfc11 487 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
Kojto 109:9296ab0bfc11 488 {
Kojto 109:9296ab0bfc11 489 uint32_t result;
Kojto 109:9296ab0bfc11 490
Kojto 109:9296ab0bfc11 491 __ASM volatile ("rbit %0, %1" : "=r" (result) : "r" (value) );
Kojto 109:9296ab0bfc11 492 return(result);
Kojto 109:9296ab0bfc11 493 }
Kojto 109:9296ab0bfc11 494
Kojto 109:9296ab0bfc11 495
Kojto 109:9296ab0bfc11 496 /** \brief LDR Exclusive (8 bit)
Kojto 109:9296ab0bfc11 497
Kojto 109:9296ab0bfc11 498 This function performs a exclusive LDR command for 8 bit value.
Kojto 109:9296ab0bfc11 499
Kojto 109:9296ab0bfc11 500 \param [in] ptr Pointer to data
Kojto 109:9296ab0bfc11 501 \return value of type uint8_t at (*ptr)
Kojto 109:9296ab0bfc11 502 */
Kojto 109:9296ab0bfc11 503 __attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __LDREXB(volatile uint8_t *addr)
Kojto 109:9296ab0bfc11 504 {
Kojto 109:9296ab0bfc11 505 uint32_t result;
Kojto 109:9296ab0bfc11 506
Kojto 109:9296ab0bfc11 507 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
Kojto 109:9296ab0bfc11 508 __ASM volatile ("ldrexb %0, %1" : "=r" (result) : "Q" (*addr) );
Kojto 109:9296ab0bfc11 509 #else
Kojto 109:9296ab0bfc11 510 /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
Kojto 109:9296ab0bfc11 511 accepted by assembler. So has to use following less efficient pattern.
Kojto 109:9296ab0bfc11 512 */
Kojto 109:9296ab0bfc11 513 __ASM volatile ("ldrexb %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
Kojto 109:9296ab0bfc11 514 #endif
Kojto 109:9296ab0bfc11 515 return(result);
Kojto 109:9296ab0bfc11 516 }
Kojto 109:9296ab0bfc11 517
Kojto 109:9296ab0bfc11 518
Kojto 109:9296ab0bfc11 519 /** \brief LDR Exclusive (16 bit)
Kojto 109:9296ab0bfc11 520
Kojto 109:9296ab0bfc11 521 This function performs a exclusive LDR command for 16 bit values.
Kojto 109:9296ab0bfc11 522
Kojto 109:9296ab0bfc11 523 \param [in] ptr Pointer to data
Kojto 109:9296ab0bfc11 524 \return value of type uint16_t at (*ptr)
Kojto 109:9296ab0bfc11 525 */
Kojto 109:9296ab0bfc11 526 __attribute__( ( always_inline ) ) __STATIC_INLINE uint16_t __LDREXH(volatile uint16_t *addr)
Kojto 109:9296ab0bfc11 527 {
Kojto 109:9296ab0bfc11 528 uint32_t result;
Kojto 109:9296ab0bfc11 529
Kojto 109:9296ab0bfc11 530 #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)
Kojto 109:9296ab0bfc11 531 __ASM volatile ("ldrexh %0, %1" : "=r" (result) : "Q" (*addr) );
Kojto 109:9296ab0bfc11 532 #else
Kojto 109:9296ab0bfc11 533 /* Prior to GCC 4.8, "Q" will be expanded to [rx, #0] which is not
Kojto 109:9296ab0bfc11 534 accepted by assembler. So has to use following less efficient pattern.
Kojto 109:9296ab0bfc11 535 */
Kojto 109:9296ab0bfc11 536 __ASM volatile ("ldrexh %0, [%1]" : "=r" (result) : "r" (addr) : "memory" );
Kojto 109:9296ab0bfc11 537 #endif
Kojto 109:9296ab0bfc11 538 return(result);
Kojto 109:9296ab0bfc11 539 }
Kojto 109:9296ab0bfc11 540
Kojto 109:9296ab0bfc11 541
Kojto 109:9296ab0bfc11 542 /** \brief LDR Exclusive (32 bit)
Kojto 109:9296ab0bfc11 543
Kojto 109:9296ab0bfc11 544 This function performs a exclusive LDR command for 32 bit values.
Kojto 109:9296ab0bfc11 545
Kojto 109:9296ab0bfc11 546 \param [in] ptr Pointer to data
Kojto 109:9296ab0bfc11 547 \return value of type uint32_t at (*ptr)
Kojto 109:9296ab0bfc11 548 */
Kojto 109:9296ab0bfc11 549 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __LDREXW(volatile uint32_t *addr)
Kojto 109:9296ab0bfc11 550 {
Kojto 109:9296ab0bfc11 551 uint32_t result;
Kojto 109:9296ab0bfc11 552
Kojto 109:9296ab0bfc11 553 __ASM volatile ("ldrex %0, %1" : "=r" (result) : "Q" (*addr) );
Kojto 109:9296ab0bfc11 554 return(result);
Kojto 109:9296ab0bfc11 555 }
Kojto 109:9296ab0bfc11 556
Kojto 109:9296ab0bfc11 557
Kojto 109:9296ab0bfc11 558 /** \brief STR Exclusive (8 bit)
Kojto 109:9296ab0bfc11 559
Kojto 109:9296ab0bfc11 560 This function performs a exclusive STR command for 8 bit values.
Kojto 109:9296ab0bfc11 561
Kojto 109:9296ab0bfc11 562 \param [in] value Value to store
Kojto 109:9296ab0bfc11 563 \param [in] ptr Pointer to location
Kojto 109:9296ab0bfc11 564 \return 0 Function succeeded
Kojto 109:9296ab0bfc11 565 \return 1 Function failed
Kojto 109:9296ab0bfc11 566 */
Kojto 109:9296ab0bfc11 567 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXB(uint8_t value, volatile uint8_t *addr)
Kojto 109:9296ab0bfc11 568 {
Kojto 109:9296ab0bfc11 569 uint32_t result;
Kojto 109:9296ab0bfc11 570
Kojto 109:9296ab0bfc11 571 __ASM volatile ("strexb %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
Kojto 109:9296ab0bfc11 572 return(result);
Kojto 109:9296ab0bfc11 573 }
Kojto 109:9296ab0bfc11 574
Kojto 109:9296ab0bfc11 575
Kojto 109:9296ab0bfc11 576 /** \brief STR Exclusive (16 bit)
Kojto 109:9296ab0bfc11 577
Kojto 109:9296ab0bfc11 578 This function performs a exclusive STR command for 16 bit values.
Kojto 109:9296ab0bfc11 579
Kojto 109:9296ab0bfc11 580 \param [in] value Value to store
Kojto 109:9296ab0bfc11 581 \param [in] ptr Pointer to location
Kojto 109:9296ab0bfc11 582 \return 0 Function succeeded
Kojto 109:9296ab0bfc11 583 \return 1 Function failed
Kojto 109:9296ab0bfc11 584 */
Kojto 109:9296ab0bfc11 585 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXH(uint16_t value, volatile uint16_t *addr)
Kojto 109:9296ab0bfc11 586 {
Kojto 109:9296ab0bfc11 587 uint32_t result;
Kojto 109:9296ab0bfc11 588
Kojto 109:9296ab0bfc11 589 __ASM volatile ("strexh %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
Kojto 109:9296ab0bfc11 590 return(result);
Kojto 109:9296ab0bfc11 591 }
Kojto 109:9296ab0bfc11 592
Kojto 109:9296ab0bfc11 593
Kojto 109:9296ab0bfc11 594 /** \brief STR Exclusive (32 bit)
Kojto 109:9296ab0bfc11 595
Kojto 109:9296ab0bfc11 596 This function performs a exclusive STR command for 32 bit values.
Kojto 109:9296ab0bfc11 597
Kojto 109:9296ab0bfc11 598 \param [in] value Value to store
Kojto 109:9296ab0bfc11 599 \param [in] ptr Pointer to location
Kojto 109:9296ab0bfc11 600 \return 0 Function succeeded
Kojto 109:9296ab0bfc11 601 \return 1 Function failed
Kojto 109:9296ab0bfc11 602 */
Kojto 109:9296ab0bfc11 603 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __STREXW(uint32_t value, volatile uint32_t *addr)
Kojto 109:9296ab0bfc11 604 {
Kojto 109:9296ab0bfc11 605 uint32_t result;
Kojto 109:9296ab0bfc11 606
Kojto 109:9296ab0bfc11 607 __ASM volatile ("strex %0, %2, %1" : "=&r" (result), "=Q" (*addr) : "r" (value) );
Kojto 109:9296ab0bfc11 608 return(result);
Kojto 109:9296ab0bfc11 609 }
Kojto 109:9296ab0bfc11 610
Kojto 109:9296ab0bfc11 611
Kojto 109:9296ab0bfc11 612 /** \brief Remove the exclusive lock
Kojto 109:9296ab0bfc11 613
Kojto 109:9296ab0bfc11 614 This function removes the exclusive lock which is created by LDREX.
Kojto 109:9296ab0bfc11 615
Kojto 109:9296ab0bfc11 616 */
Kojto 109:9296ab0bfc11 617 __attribute__( ( always_inline ) ) __STATIC_INLINE void __CLREX(void)
Kojto 109:9296ab0bfc11 618 {
Kojto 109:9296ab0bfc11 619 __ASM volatile ("clrex" ::: "memory");
Kojto 109:9296ab0bfc11 620 }
Kojto 109:9296ab0bfc11 621
Kojto 109:9296ab0bfc11 622
Kojto 109:9296ab0bfc11 623 /** \brief Signed Saturate
Kojto 109:9296ab0bfc11 624
Kojto 109:9296ab0bfc11 625 This function saturates a signed value.
Kojto 109:9296ab0bfc11 626
Kojto 109:9296ab0bfc11 627 \param [in] value Value to be saturated
Kojto 109:9296ab0bfc11 628 \param [in] sat Bit position to saturate to (1..32)
Kojto 109:9296ab0bfc11 629 \return Saturated value
Kojto 109:9296ab0bfc11 630 */
Kojto 109:9296ab0bfc11 631 #define __SSAT(ARG1,ARG2) \
Kojto 109:9296ab0bfc11 632 ({ \
Kojto 109:9296ab0bfc11 633 uint32_t __RES, __ARG1 = (ARG1); \
Kojto 109:9296ab0bfc11 634 __ASM ("ssat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
Kojto 109:9296ab0bfc11 635 __RES; \
Kojto 109:9296ab0bfc11 636 })
Kojto 109:9296ab0bfc11 637
Kojto 109:9296ab0bfc11 638
Kojto 109:9296ab0bfc11 639 /** \brief Unsigned Saturate
Kojto 109:9296ab0bfc11 640
Kojto 109:9296ab0bfc11 641 This function saturates an unsigned value.
Kojto 109:9296ab0bfc11 642
Kojto 109:9296ab0bfc11 643 \param [in] value Value to be saturated
Kojto 109:9296ab0bfc11 644 \param [in] sat Bit position to saturate to (0..31)
Kojto 109:9296ab0bfc11 645 \return Saturated value
Kojto 109:9296ab0bfc11 646 */
Kojto 109:9296ab0bfc11 647 #define __USAT(ARG1,ARG2) \
Kojto 109:9296ab0bfc11 648 ({ \
Kojto 109:9296ab0bfc11 649 uint32_t __RES, __ARG1 = (ARG1); \
Kojto 109:9296ab0bfc11 650 __ASM ("usat %0, %1, %2" : "=r" (__RES) : "I" (ARG2), "r" (__ARG1) ); \
Kojto 109:9296ab0bfc11 651 __RES; \
Kojto 109:9296ab0bfc11 652 })
Kojto 109:9296ab0bfc11 653
Kojto 109:9296ab0bfc11 654
Kojto 109:9296ab0bfc11 655 /** \brief Count leading zeros
Kojto 109:9296ab0bfc11 656
Kojto 109:9296ab0bfc11 657 This function counts the number of leading zeros of a data value.
Kojto 109:9296ab0bfc11 658
Kojto 109:9296ab0bfc11 659 \param [in] value Value to count the leading zeros
Kojto 109:9296ab0bfc11 660 \return number of leading zeros in value
Kojto 109:9296ab0bfc11 661 */
Kojto 109:9296ab0bfc11 662 __attribute__( ( always_inline ) ) __STATIC_INLINE uint8_t __CLZ(uint32_t value)
Kojto 109:9296ab0bfc11 663 {
Kojto 109:9296ab0bfc11 664 uint32_t result;
Kojto 109:9296ab0bfc11 665
Kojto 109:9296ab0bfc11 666 __ASM volatile ("clz %0, %1" : "=r" (result) : "r" (value) );
Kojto 109:9296ab0bfc11 667 return(result);
Kojto 109:9296ab0bfc11 668 }
Kojto 109:9296ab0bfc11 669
Kojto 109:9296ab0bfc11 670 #endif /* (__CORTEX_M >= 0x03) */
Kojto 109:9296ab0bfc11 671
Kojto 109:9296ab0bfc11 672
Kojto 109:9296ab0bfc11 673
Kojto 109:9296ab0bfc11 674
Kojto 109:9296ab0bfc11 675 #elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/
Kojto 109:9296ab0bfc11 676 /* TASKING carm specific functions */
Kojto 109:9296ab0bfc11 677
Kojto 109:9296ab0bfc11 678 /*
Kojto 109:9296ab0bfc11 679 * The CMSIS functions have been implemented as intrinsics in the compiler.
Kojto 109:9296ab0bfc11 680 * Please use "carm -?i" to get an up to date list of all intrinsics,
Kojto 109:9296ab0bfc11 681 * Including the CMSIS ones.
Kojto 109:9296ab0bfc11 682 */
Kojto 109:9296ab0bfc11 683
Kojto 109:9296ab0bfc11 684 #endif
Kojto 109:9296ab0bfc11 685
Kojto 109:9296ab0bfc11 686 /*@}*/ /* end of group CMSIS_Core_InstructionInterface */
Kojto 109:9296ab0bfc11 687
Kojto 109:9296ab0bfc11 688 #endif /* __CORE_CMINSTR_H */