Soundharrajan

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Mon Nov 18 22:09:31 2013 +0200
Revision:
70:673126e12c73
Release 70 of the mbed library

This release is a bugfix release for release 69, it adds proper target
support for LPC4088_EA.

Who changed what in which revision?

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