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