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:
AnnaBridge
Date:
Fri May 26 12:30:20 2017 +0100
Revision:
143:86740a56073b
Parent:
110:165afa46840b
Release 143 of the mbed library.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 98:8ab26030e058 1 /**************************************************************************//**
Kojto 98:8ab26030e058 2 * @file core_cmFunc.h
Kojto 98:8ab26030e058 3 * @brief CMSIS Cortex-M Core Function Access Header File
Kojto 110:165afa46840b 4 * @version V4.10
Kojto 110:165afa46840b 5 * @date 18. March 2015
Kojto 98:8ab26030e058 6 *
Kojto 98:8ab26030e058 7 * @note
Kojto 98:8ab26030e058 8 *
Kojto 98:8ab26030e058 9 ******************************************************************************/
Kojto 110:165afa46840b 10 /* Copyright (c) 2009 - 2015 ARM LIMITED
Kojto 98:8ab26030e058 11
Kojto 98:8ab26030e058 12 All rights reserved.
Kojto 98:8ab26030e058 13 Redistribution and use in source and binary forms, with or without
Kojto 98:8ab26030e058 14 modification, are permitted provided that the following conditions are met:
Kojto 98:8ab26030e058 15 - Redistributions of source code must retain the above copyright
Kojto 98:8ab26030e058 16 notice, this list of conditions and the following disclaimer.
Kojto 98:8ab26030e058 17 - Redistributions in binary form must reproduce the above copyright
Kojto 98:8ab26030e058 18 notice, this list of conditions and the following disclaimer in the
Kojto 98:8ab26030e058 19 documentation and/or other materials provided with the distribution.
Kojto 98:8ab26030e058 20 - Neither the name of ARM nor the names of its contributors may be used
Kojto 98:8ab26030e058 21 to endorse or promote products derived from this software without
Kojto 98:8ab26030e058 22 specific prior written permission.
Kojto 98:8ab26030e058 23 *
Kojto 98:8ab26030e058 24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 98:8ab26030e058 25 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 98:8ab26030e058 26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Kojto 98:8ab26030e058 27 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
Kojto 98:8ab26030e058 28 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
Kojto 98:8ab26030e058 29 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
Kojto 98:8ab26030e058 30 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
Kojto 98:8ab26030e058 31 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
Kojto 98:8ab26030e058 32 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
Kojto 98:8ab26030e058 33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
Kojto 98:8ab26030e058 34 POSSIBILITY OF SUCH DAMAGE.
Kojto 98:8ab26030e058 35 ---------------------------------------------------------------------------*/
Kojto 98:8ab26030e058 36
Kojto 98:8ab26030e058 37
Kojto 98:8ab26030e058 38 #ifndef __CORE_CMFUNC_H
Kojto 98:8ab26030e058 39 #define __CORE_CMFUNC_H
Kojto 98:8ab26030e058 40
Kojto 98:8ab26030e058 41
Kojto 98:8ab26030e058 42 /* ########################### Core Function Access ########################### */
Kojto 98:8ab26030e058 43 /** \ingroup CMSIS_Core_FunctionInterface
Kojto 98:8ab26030e058 44 \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
Kojto 98:8ab26030e058 45 @{
Kojto 98:8ab26030e058 46 */
Kojto 98:8ab26030e058 47
Kojto 98:8ab26030e058 48 #if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/
Kojto 98:8ab26030e058 49 /* ARM armcc specific functions */
Kojto 98:8ab26030e058 50
Kojto 98:8ab26030e058 51 #if (__ARMCC_VERSION < 400677)
Kojto 98:8ab26030e058 52 #error "Please use ARM Compiler Toolchain V4.0.677 or later!"
Kojto 98:8ab26030e058 53 #endif
Kojto 98:8ab26030e058 54
Kojto 98:8ab26030e058 55 /* intrinsic void __enable_irq(); */
Kojto 98:8ab26030e058 56 /* intrinsic void __disable_irq(); */
Kojto 98:8ab26030e058 57
Kojto 98:8ab26030e058 58 /** \brief Get Control Register
Kojto 98:8ab26030e058 59
Kojto 98:8ab26030e058 60 This function returns the content of the Control Register.
Kojto 98:8ab26030e058 61
Kojto 98:8ab26030e058 62 \return Control Register value
Kojto 98:8ab26030e058 63 */
Kojto 98:8ab26030e058 64 __STATIC_INLINE uint32_t __get_CONTROL(void)
Kojto 98:8ab26030e058 65 {
Kojto 98:8ab26030e058 66 register uint32_t __regControl __ASM("control");
Kojto 98:8ab26030e058 67 return(__regControl);
Kojto 98:8ab26030e058 68 }
Kojto 98:8ab26030e058 69
Kojto 98:8ab26030e058 70
Kojto 98:8ab26030e058 71 /** \brief Set Control Register
Kojto 98:8ab26030e058 72
Kojto 98:8ab26030e058 73 This function writes the given value to the Control Register.
Kojto 98:8ab26030e058 74
Kojto 98:8ab26030e058 75 \param [in] control Control Register value to set
Kojto 98:8ab26030e058 76 */
Kojto 98:8ab26030e058 77 __STATIC_INLINE void __set_CONTROL(uint32_t control)
Kojto 98:8ab26030e058 78 {
Kojto 98:8ab26030e058 79 register uint32_t __regControl __ASM("control");
Kojto 98:8ab26030e058 80 __regControl = control;
Kojto 98:8ab26030e058 81 }
Kojto 98:8ab26030e058 82
Kojto 98:8ab26030e058 83
Kojto 98:8ab26030e058 84 /** \brief Get IPSR Register
Kojto 98:8ab26030e058 85
Kojto 98:8ab26030e058 86 This function returns the content of the IPSR Register.
Kojto 98:8ab26030e058 87
Kojto 98:8ab26030e058 88 \return IPSR Register value
Kojto 98:8ab26030e058 89 */
Kojto 98:8ab26030e058 90 __STATIC_INLINE uint32_t __get_IPSR(void)
Kojto 98:8ab26030e058 91 {
Kojto 98:8ab26030e058 92 register uint32_t __regIPSR __ASM("ipsr");
Kojto 98:8ab26030e058 93 return(__regIPSR);
Kojto 98:8ab26030e058 94 }
Kojto 98:8ab26030e058 95
Kojto 98:8ab26030e058 96
Kojto 98:8ab26030e058 97 /** \brief Get APSR Register
Kojto 98:8ab26030e058 98
Kojto 98:8ab26030e058 99 This function returns the content of the APSR Register.
Kojto 98:8ab26030e058 100
Kojto 98:8ab26030e058 101 \return APSR Register value
Kojto 98:8ab26030e058 102 */
Kojto 98:8ab26030e058 103 __STATIC_INLINE uint32_t __get_APSR(void)
Kojto 98:8ab26030e058 104 {
Kojto 98:8ab26030e058 105 register uint32_t __regAPSR __ASM("apsr");
Kojto 98:8ab26030e058 106 return(__regAPSR);
Kojto 98:8ab26030e058 107 }
Kojto 98:8ab26030e058 108
Kojto 98:8ab26030e058 109
Kojto 98:8ab26030e058 110 /** \brief Get xPSR Register
Kojto 98:8ab26030e058 111
Kojto 98:8ab26030e058 112 This function returns the content of the xPSR Register.
Kojto 98:8ab26030e058 113
Kojto 98:8ab26030e058 114 \return xPSR Register value
Kojto 98:8ab26030e058 115 */
Kojto 98:8ab26030e058 116 __STATIC_INLINE uint32_t __get_xPSR(void)
Kojto 98:8ab26030e058 117 {
Kojto 98:8ab26030e058 118 register uint32_t __regXPSR __ASM("xpsr");
Kojto 98:8ab26030e058 119 return(__regXPSR);
Kojto 98:8ab26030e058 120 }
Kojto 98:8ab26030e058 121
Kojto 98:8ab26030e058 122
Kojto 98:8ab26030e058 123 /** \brief Get Process Stack Pointer
Kojto 98:8ab26030e058 124
Kojto 98:8ab26030e058 125 This function returns the current value of the Process Stack Pointer (PSP).
Kojto 98:8ab26030e058 126
Kojto 98:8ab26030e058 127 \return PSP Register value
Kojto 98:8ab26030e058 128 */
Kojto 98:8ab26030e058 129 __STATIC_INLINE uint32_t __get_PSP(void)
Kojto 98:8ab26030e058 130 {
Kojto 98:8ab26030e058 131 register uint32_t __regProcessStackPointer __ASM("psp");
Kojto 98:8ab26030e058 132 return(__regProcessStackPointer);
Kojto 98:8ab26030e058 133 }
Kojto 98:8ab26030e058 134
Kojto 98:8ab26030e058 135
Kojto 98:8ab26030e058 136 /** \brief Set Process Stack Pointer
Kojto 98:8ab26030e058 137
Kojto 98:8ab26030e058 138 This function assigns the given value to the Process Stack Pointer (PSP).
Kojto 98:8ab26030e058 139
Kojto 98:8ab26030e058 140 \param [in] topOfProcStack Process Stack Pointer value to set
Kojto 98:8ab26030e058 141 */
Kojto 98:8ab26030e058 142 __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
Kojto 98:8ab26030e058 143 {
Kojto 98:8ab26030e058 144 register uint32_t __regProcessStackPointer __ASM("psp");
Kojto 98:8ab26030e058 145 __regProcessStackPointer = topOfProcStack;
Kojto 98:8ab26030e058 146 }
Kojto 98:8ab26030e058 147
Kojto 98:8ab26030e058 148
Kojto 98:8ab26030e058 149 /** \brief Get Main Stack Pointer
Kojto 98:8ab26030e058 150
Kojto 98:8ab26030e058 151 This function returns the current value of the Main Stack Pointer (MSP).
Kojto 98:8ab26030e058 152
Kojto 98:8ab26030e058 153 \return MSP Register value
Kojto 98:8ab26030e058 154 */
Kojto 98:8ab26030e058 155 __STATIC_INLINE uint32_t __get_MSP(void)
Kojto 98:8ab26030e058 156 {
Kojto 98:8ab26030e058 157 register uint32_t __regMainStackPointer __ASM("msp");
Kojto 98:8ab26030e058 158 return(__regMainStackPointer);
Kojto 98:8ab26030e058 159 }
Kojto 98:8ab26030e058 160
Kojto 98:8ab26030e058 161
Kojto 98:8ab26030e058 162 /** \brief Set Main Stack Pointer
Kojto 98:8ab26030e058 163
Kojto 98:8ab26030e058 164 This function assigns the given value to the Main Stack Pointer (MSP).
Kojto 98:8ab26030e058 165
Kojto 98:8ab26030e058 166 \param [in] topOfMainStack Main Stack Pointer value to set
Kojto 98:8ab26030e058 167 */
Kojto 98:8ab26030e058 168 __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
Kojto 98:8ab26030e058 169 {
Kojto 98:8ab26030e058 170 register uint32_t __regMainStackPointer __ASM("msp");
Kojto 98:8ab26030e058 171 __regMainStackPointer = topOfMainStack;
Kojto 98:8ab26030e058 172 }
Kojto 98:8ab26030e058 173
Kojto 98:8ab26030e058 174
Kojto 98:8ab26030e058 175 /** \brief Get Priority Mask
Kojto 98:8ab26030e058 176
Kojto 98:8ab26030e058 177 This function returns the current state of the priority mask bit from the Priority Mask Register.
Kojto 98:8ab26030e058 178
Kojto 98:8ab26030e058 179 \return Priority Mask value
Kojto 98:8ab26030e058 180 */
Kojto 98:8ab26030e058 181 __STATIC_INLINE uint32_t __get_PRIMASK(void)
Kojto 98:8ab26030e058 182 {
Kojto 98:8ab26030e058 183 register uint32_t __regPriMask __ASM("primask");
Kojto 98:8ab26030e058 184 return(__regPriMask);
Kojto 98:8ab26030e058 185 }
Kojto 98:8ab26030e058 186
Kojto 98:8ab26030e058 187
Kojto 98:8ab26030e058 188 /** \brief Set Priority Mask
Kojto 98:8ab26030e058 189
Kojto 98:8ab26030e058 190 This function assigns the given value to the Priority Mask Register.
Kojto 98:8ab26030e058 191
Kojto 98:8ab26030e058 192 \param [in] priMask Priority Mask
Kojto 98:8ab26030e058 193 */
Kojto 98:8ab26030e058 194 __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
Kojto 98:8ab26030e058 195 {
Kojto 98:8ab26030e058 196 register uint32_t __regPriMask __ASM("primask");
Kojto 98:8ab26030e058 197 __regPriMask = (priMask);
Kojto 98:8ab26030e058 198 }
Kojto 98:8ab26030e058 199
Kojto 98:8ab26030e058 200
Kojto 110:165afa46840b 201 #if (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300)
Kojto 98:8ab26030e058 202
Kojto 98:8ab26030e058 203 /** \brief Enable FIQ
Kojto 98:8ab26030e058 204
Kojto 98:8ab26030e058 205 This function enables FIQ interrupts by clearing the F-bit in the CPSR.
Kojto 98:8ab26030e058 206 Can only be executed in Privileged modes.
Kojto 98:8ab26030e058 207 */
Kojto 98:8ab26030e058 208 #define __enable_fault_irq __enable_fiq
Kojto 98:8ab26030e058 209
Kojto 98:8ab26030e058 210
Kojto 98:8ab26030e058 211 /** \brief Disable FIQ
Kojto 98:8ab26030e058 212
Kojto 98:8ab26030e058 213 This function disables FIQ interrupts by setting the F-bit in the CPSR.
Kojto 98:8ab26030e058 214 Can only be executed in Privileged modes.
Kojto 98:8ab26030e058 215 */
Kojto 98:8ab26030e058 216 #define __disable_fault_irq __disable_fiq
Kojto 98:8ab26030e058 217
Kojto 98:8ab26030e058 218
Kojto 98:8ab26030e058 219 /** \brief Get Base Priority
Kojto 98:8ab26030e058 220
Kojto 98:8ab26030e058 221 This function returns the current value of the Base Priority register.
Kojto 98:8ab26030e058 222
Kojto 98:8ab26030e058 223 \return Base Priority register value
Kojto 98:8ab26030e058 224 */
Kojto 98:8ab26030e058 225 __STATIC_INLINE uint32_t __get_BASEPRI(void)
Kojto 98:8ab26030e058 226 {
Kojto 98:8ab26030e058 227 register uint32_t __regBasePri __ASM("basepri");
Kojto 98:8ab26030e058 228 return(__regBasePri);
Kojto 98:8ab26030e058 229 }
Kojto 98:8ab26030e058 230
Kojto 98:8ab26030e058 231
Kojto 98:8ab26030e058 232 /** \brief Set Base Priority
Kojto 98:8ab26030e058 233
Kojto 98:8ab26030e058 234 This function assigns the given value to the Base Priority register.
Kojto 98:8ab26030e058 235
Kojto 98:8ab26030e058 236 \param [in] basePri Base Priority value to set
Kojto 98:8ab26030e058 237 */
Kojto 98:8ab26030e058 238 __STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
Kojto 98:8ab26030e058 239 {
Kojto 98:8ab26030e058 240 register uint32_t __regBasePri __ASM("basepri");
Kojto 98:8ab26030e058 241 __regBasePri = (basePri & 0xff);
Kojto 98:8ab26030e058 242 }
Kojto 98:8ab26030e058 243
Kojto 98:8ab26030e058 244
Kojto 110:165afa46840b 245 /** \brief Set Base Priority with condition
Kojto 110:165afa46840b 246
Kojto 110:165afa46840b 247 This function assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
Kojto 110:165afa46840b 248 or the new value increases the BASEPRI priority level.
Kojto 110:165afa46840b 249
Kojto 110:165afa46840b 250 \param [in] basePri Base Priority value to set
Kojto 110:165afa46840b 251 */
Kojto 110:165afa46840b 252 __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
Kojto 110:165afa46840b 253 {
Kojto 110:165afa46840b 254 register uint32_t __regBasePriMax __ASM("basepri_max");
Kojto 110:165afa46840b 255 __regBasePriMax = (basePri & 0xff);
Kojto 110:165afa46840b 256 }
Kojto 110:165afa46840b 257
Kojto 110:165afa46840b 258
Kojto 98:8ab26030e058 259 /** \brief Get Fault Mask
Kojto 98:8ab26030e058 260
Kojto 98:8ab26030e058 261 This function returns the current value of the Fault Mask register.
Kojto 98:8ab26030e058 262
Kojto 98:8ab26030e058 263 \return Fault Mask register value
Kojto 98:8ab26030e058 264 */
Kojto 98:8ab26030e058 265 __STATIC_INLINE uint32_t __get_FAULTMASK(void)
Kojto 98:8ab26030e058 266 {
Kojto 98:8ab26030e058 267 register uint32_t __regFaultMask __ASM("faultmask");
Kojto 98:8ab26030e058 268 return(__regFaultMask);
Kojto 98:8ab26030e058 269 }
Kojto 98:8ab26030e058 270
Kojto 98:8ab26030e058 271
Kojto 98:8ab26030e058 272 /** \brief Set Fault Mask
Kojto 98:8ab26030e058 273
Kojto 98:8ab26030e058 274 This function assigns the given value to the Fault Mask register.
Kojto 98:8ab26030e058 275
Kojto 98:8ab26030e058 276 \param [in] faultMask Fault Mask value to set
Kojto 98:8ab26030e058 277 */
Kojto 98:8ab26030e058 278 __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
Kojto 98:8ab26030e058 279 {
Kojto 98:8ab26030e058 280 register uint32_t __regFaultMask __ASM("faultmask");
Kojto 98:8ab26030e058 281 __regFaultMask = (faultMask & (uint32_t)1);
Kojto 98:8ab26030e058 282 }
Kojto 98:8ab26030e058 283
Kojto 110:165afa46840b 284 #endif /* (__CORTEX_M >= 0x03) || (__CORTEX_SC >= 300) */
Kojto 98:8ab26030e058 285
Kojto 98:8ab26030e058 286
Kojto 110:165afa46840b 287 #if (__CORTEX_M == 0x04) || (__CORTEX_M == 0x07)
Kojto 98:8ab26030e058 288
Kojto 98:8ab26030e058 289 /** \brief Get FPSCR
Kojto 98:8ab26030e058 290
Kojto 98:8ab26030e058 291 This function returns the current value of the Floating Point Status/Control register.
Kojto 98:8ab26030e058 292
Kojto 98:8ab26030e058 293 \return Floating Point Status/Control register value
Kojto 98:8ab26030e058 294 */
Kojto 98:8ab26030e058 295 __STATIC_INLINE uint32_t __get_FPSCR(void)
Kojto 98:8ab26030e058 296 {
Kojto 98:8ab26030e058 297 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
Kojto 98:8ab26030e058 298 register uint32_t __regfpscr __ASM("fpscr");
Kojto 98:8ab26030e058 299 return(__regfpscr);
Kojto 98:8ab26030e058 300 #else
Kojto 98:8ab26030e058 301 return(0);
Kojto 98:8ab26030e058 302 #endif
Kojto 98:8ab26030e058 303 }
Kojto 98:8ab26030e058 304
Kojto 98:8ab26030e058 305
Kojto 98:8ab26030e058 306 /** \brief Set FPSCR
Kojto 98:8ab26030e058 307
Kojto 98:8ab26030e058 308 This function assigns the given value to the Floating Point Status/Control register.
Kojto 98:8ab26030e058 309
Kojto 98:8ab26030e058 310 \param [in] fpscr Floating Point Status/Control value to set
Kojto 98:8ab26030e058 311 */
Kojto 98:8ab26030e058 312 __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
Kojto 98:8ab26030e058 313 {
Kojto 98:8ab26030e058 314 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
Kojto 98:8ab26030e058 315 register uint32_t __regfpscr __ASM("fpscr");
Kojto 98:8ab26030e058 316 __regfpscr = (fpscr);
Kojto 98:8ab26030e058 317 #endif
Kojto 98:8ab26030e058 318 }
Kojto 98:8ab26030e058 319
Kojto 110:165afa46840b 320 #endif /* (__CORTEX_M == 0x04) || (__CORTEX_M == 0x07) */
Kojto 98:8ab26030e058 321
Kojto 98:8ab26030e058 322
Kojto 98:8ab26030e058 323 #elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
Kojto 98:8ab26030e058 324 /* GNU gcc specific functions */
Kojto 98:8ab26030e058 325
Kojto 98:8ab26030e058 326 /** \brief Enable IRQ Interrupts
Kojto 98:8ab26030e058 327
Kojto 98:8ab26030e058 328 This function enables IRQ interrupts by clearing the I-bit in the CPSR.
Kojto 98:8ab26030e058 329 Can only be executed in Privileged modes.
Kojto 98:8ab26030e058 330 */
Kojto 98:8ab26030e058 331 __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void)
Kojto 98:8ab26030e058 332 {
Kojto 98:8ab26030e058 333 __ASM volatile ("cpsie i" : : : "memory");
Kojto 98:8ab26030e058 334 }
Kojto 98:8ab26030e058 335
Kojto 98:8ab26030e058 336
Kojto 98:8ab26030e058 337 /** \brief Disable IRQ Interrupts
Kojto 98:8ab26030e058 338
Kojto 98:8ab26030e058 339 This function disables IRQ interrupts by setting the I-bit in the CPSR.
Kojto 98:8ab26030e058 340 Can only be executed in Privileged modes.
Kojto 98:8ab26030e058 341 */
Kojto 98:8ab26030e058 342 __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void)
Kojto 98:8ab26030e058 343 {
Kojto 98:8ab26030e058 344 __ASM volatile ("cpsid i" : : : "memory");
Kojto 98:8ab26030e058 345 }
Kojto 98:8ab26030e058 346
Kojto 98:8ab26030e058 347
Kojto 98:8ab26030e058 348 /** \brief Get Control Register
Kojto 98:8ab26030e058 349
Kojto 98:8ab26030e058 350 This function returns the content of the Control Register.
Kojto 98:8ab26030e058 351
Kojto 98:8ab26030e058 352 \return Control Register value
Kojto 98:8ab26030e058 353 */
Kojto 98:8ab26030e058 354 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void)
Kojto 98:8ab26030e058 355 {
Kojto 98:8ab26030e058 356 uint32_t result;
Kojto 98:8ab26030e058 357
Kojto 98:8ab26030e058 358 __ASM volatile ("MRS %0, control" : "=r" (result) );
Kojto 98:8ab26030e058 359 return(result);
Kojto 98:8ab26030e058 360 }
Kojto 98:8ab26030e058 361
Kojto 98:8ab26030e058 362
Kojto 98:8ab26030e058 363 /** \brief Set Control Register
Kojto 98:8ab26030e058 364
Kojto 98:8ab26030e058 365 This function writes the given value to the Control Register.
Kojto 98:8ab26030e058 366
Kojto 98:8ab26030e058 367 \param [in] control Control Register value to set
Kojto 98:8ab26030e058 368 */
Kojto 98:8ab26030e058 369 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_CONTROL(uint32_t control)
Kojto 98:8ab26030e058 370 {
Kojto 98:8ab26030e058 371 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
Kojto 98:8ab26030e058 372 }
Kojto 98:8ab26030e058 373
Kojto 98:8ab26030e058 374
Kojto 98:8ab26030e058 375 /** \brief Get IPSR Register
Kojto 98:8ab26030e058 376
Kojto 98:8ab26030e058 377 This function returns the content of the IPSR Register.
Kojto 98:8ab26030e058 378
Kojto 98:8ab26030e058 379 \return IPSR Register value
Kojto 98:8ab26030e058 380 */
Kojto 98:8ab26030e058 381 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_IPSR(void)
Kojto 98:8ab26030e058 382 {
Kojto 98:8ab26030e058 383 uint32_t result;
Kojto 98:8ab26030e058 384
Kojto 98:8ab26030e058 385 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
Kojto 98:8ab26030e058 386 return(result);
Kojto 98:8ab26030e058 387 }
Kojto 98:8ab26030e058 388
Kojto 98:8ab26030e058 389
Kojto 98:8ab26030e058 390 /** \brief Get APSR Register
Kojto 98:8ab26030e058 391
Kojto 98:8ab26030e058 392 This function returns the content of the APSR Register.
Kojto 98:8ab26030e058 393
Kojto 98:8ab26030e058 394 \return APSR Register value
Kojto 98:8ab26030e058 395 */
Kojto 98:8ab26030e058 396 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_APSR(void)
Kojto 98:8ab26030e058 397 {
Kojto 98:8ab26030e058 398 uint32_t result;
Kojto 98:8ab26030e058 399
Kojto 98:8ab26030e058 400 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
Kojto 98:8ab26030e058 401 return(result);
Kojto 98:8ab26030e058 402 }
Kojto 98:8ab26030e058 403
Kojto 98:8ab26030e058 404
Kojto 98:8ab26030e058 405 /** \brief Get xPSR Register
Kojto 98:8ab26030e058 406
Kojto 98:8ab26030e058 407 This function returns the content of the xPSR Register.
Kojto 98:8ab26030e058 408
Kojto 98:8ab26030e058 409 \return xPSR Register value
Kojto 98:8ab26030e058 410 */
Kojto 98:8ab26030e058 411 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_xPSR(void)
Kojto 98:8ab26030e058 412 {
Kojto 98:8ab26030e058 413 uint32_t result;
Kojto 98:8ab26030e058 414
Kojto 98:8ab26030e058 415 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
Kojto 98:8ab26030e058 416 return(result);
Kojto 98:8ab26030e058 417 }
Kojto 98:8ab26030e058 418
Kojto 98:8ab26030e058 419
Kojto 98:8ab26030e058 420 /** \brief Get Process Stack Pointer
Kojto 98:8ab26030e058 421
Kojto 98:8ab26030e058 422 This function returns the current value of the Process Stack Pointer (PSP).
Kojto 98:8ab26030e058 423
Kojto 98:8ab26030e058 424 \return PSP Register value
Kojto 98:8ab26030e058 425 */
Kojto 98:8ab26030e058 426 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(void)
Kojto 98:8ab26030e058 427 {
Kojto 98:8ab26030e058 428 register uint32_t result;
Kojto 98:8ab26030e058 429
Kojto 98:8ab26030e058 430 __ASM volatile ("MRS %0, psp\n" : "=r" (result) );
Kojto 98:8ab26030e058 431 return(result);
Kojto 98:8ab26030e058 432 }
Kojto 98:8ab26030e058 433
Kojto 98:8ab26030e058 434
Kojto 98:8ab26030e058 435 /** \brief Set Process Stack Pointer
Kojto 98:8ab26030e058 436
Kojto 98:8ab26030e058 437 This function assigns the given value to the Process Stack Pointer (PSP).
Kojto 98:8ab26030e058 438
Kojto 98:8ab26030e058 439 \param [in] topOfProcStack Process Stack Pointer value to set
Kojto 98:8ab26030e058 440 */
Kojto 98:8ab26030e058 441 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
Kojto 98:8ab26030e058 442 {
Kojto 98:8ab26030e058 443 __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) : "sp");
Kojto 98:8ab26030e058 444 }
Kojto 98:8ab26030e058 445
Kojto 98:8ab26030e058 446
Kojto 98:8ab26030e058 447 /** \brief Get Main Stack Pointer
Kojto 98:8ab26030e058 448
Kojto 98:8ab26030e058 449 This function returns the current value of the Main Stack Pointer (MSP).
Kojto 98:8ab26030e058 450
Kojto 98:8ab26030e058 451 \return MSP Register value
Kojto 98:8ab26030e058 452 */
Kojto 98:8ab26030e058 453 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(void)
Kojto 98:8ab26030e058 454 {
Kojto 98:8ab26030e058 455 register uint32_t result;
Kojto 98:8ab26030e058 456
Kojto 98:8ab26030e058 457 __ASM volatile ("MRS %0, msp\n" : "=r" (result) );
Kojto 98:8ab26030e058 458 return(result);
Kojto 98:8ab26030e058 459 }
Kojto 98:8ab26030e058 460
Kojto 98:8ab26030e058 461
Kojto 98:8ab26030e058 462 /** \brief Set Main Stack Pointer
Kojto 98:8ab26030e058 463
Kojto 98:8ab26030e058 464 This function assigns the given value to the Main Stack Pointer (MSP).
Kojto 98:8ab26030e058 465
Kojto 98:8ab26030e058 466 \param [in] topOfMainStack Main Stack Pointer value to set
Kojto 98:8ab26030e058 467 */
Kojto 98:8ab26030e058 468 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
Kojto 98:8ab26030e058 469 {
Kojto 98:8ab26030e058 470 __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : "sp");
Kojto 98:8ab26030e058 471 }
Kojto 98:8ab26030e058 472
Kojto 98:8ab26030e058 473
Kojto 98:8ab26030e058 474 /** \brief Get Priority Mask
Kojto 98:8ab26030e058 475
Kojto 98:8ab26030e058 476 This function returns the current state of the priority mask bit from the Priority Mask Register.
Kojto 98:8ab26030e058 477
Kojto 98:8ab26030e058 478 \return Priority Mask value
Kojto 98:8ab26030e058 479 */
Kojto 98:8ab26030e058 480 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PRIMASK(void)
Kojto 98:8ab26030e058 481 {
Kojto 98:8ab26030e058 482 uint32_t result;
Kojto 98:8ab26030e058 483
Kojto 98:8ab26030e058 484 __ASM volatile ("MRS %0, primask" : "=r" (result) );
Kojto 98:8ab26030e058 485 return(result);
Kojto 98:8ab26030e058 486 }
Kojto 98:8ab26030e058 487
Kojto 98:8ab26030e058 488
Kojto 98:8ab26030e058 489 /** \brief Set Priority Mask
Kojto 98:8ab26030e058 490
Kojto 98:8ab26030e058 491 This function assigns the given value to the Priority Mask Register.
Kojto 98:8ab26030e058 492
Kojto 98:8ab26030e058 493 \param [in] priMask Priority Mask
Kojto 98:8ab26030e058 494 */
Kojto 98:8ab26030e058 495 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
Kojto 98:8ab26030e058 496 {
Kojto 98:8ab26030e058 497 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
Kojto 98:8ab26030e058 498 }
Kojto 98:8ab26030e058 499
Kojto 98:8ab26030e058 500
Kojto 98:8ab26030e058 501 #if (__CORTEX_M >= 0x03)
Kojto 98:8ab26030e058 502
Kojto 98:8ab26030e058 503 /** \brief Enable FIQ
Kojto 98:8ab26030e058 504
Kojto 98:8ab26030e058 505 This function enables FIQ interrupts by clearing the F-bit in the CPSR.
Kojto 98:8ab26030e058 506 Can only be executed in Privileged modes.
Kojto 98:8ab26030e058 507 */
Kojto 98:8ab26030e058 508 __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_fault_irq(void)
Kojto 98:8ab26030e058 509 {
Kojto 98:8ab26030e058 510 __ASM volatile ("cpsie f" : : : "memory");
Kojto 98:8ab26030e058 511 }
Kojto 98:8ab26030e058 512
Kojto 98:8ab26030e058 513
Kojto 98:8ab26030e058 514 /** \brief Disable FIQ
Kojto 98:8ab26030e058 515
Kojto 98:8ab26030e058 516 This function disables FIQ interrupts by setting the F-bit in the CPSR.
Kojto 98:8ab26030e058 517 Can only be executed in Privileged modes.
Kojto 98:8ab26030e058 518 */
Kojto 98:8ab26030e058 519 __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_fault_irq(void)
Kojto 98:8ab26030e058 520 {
Kojto 98:8ab26030e058 521 __ASM volatile ("cpsid f" : : : "memory");
Kojto 98:8ab26030e058 522 }
Kojto 98:8ab26030e058 523
Kojto 98:8ab26030e058 524
Kojto 98:8ab26030e058 525 /** \brief Get Base Priority
Kojto 98:8ab26030e058 526
Kojto 98:8ab26030e058 527 This function returns the current value of the Base Priority register.
Kojto 98:8ab26030e058 528
Kojto 98:8ab26030e058 529 \return Base Priority register value
Kojto 98:8ab26030e058 530 */
Kojto 98:8ab26030e058 531 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(void)
Kojto 98:8ab26030e058 532 {
Kojto 98:8ab26030e058 533 uint32_t result;
Kojto 98:8ab26030e058 534
Kojto 110:165afa46840b 535 __ASM volatile ("MRS %0, basepri" : "=r" (result) );
Kojto 98:8ab26030e058 536 return(result);
Kojto 98:8ab26030e058 537 }
Kojto 98:8ab26030e058 538
Kojto 98:8ab26030e058 539
Kojto 98:8ab26030e058 540 /** \brief Set Base Priority
Kojto 98:8ab26030e058 541
Kojto 98:8ab26030e058 542 This function assigns the given value to the Base Priority register.
Kojto 98:8ab26030e058 543
Kojto 98:8ab26030e058 544 \param [in] basePri Base Priority value to set
Kojto 98:8ab26030e058 545 */
Kojto 98:8ab26030e058 546 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI(uint32_t value)
Kojto 98:8ab26030e058 547 {
Kojto 98:8ab26030e058 548 __ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory");
Kojto 98:8ab26030e058 549 }
Kojto 98:8ab26030e058 550
Kojto 98:8ab26030e058 551
Kojto 110:165afa46840b 552 /** \brief Set Base Priority with condition
Kojto 110:165afa46840b 553
Kojto 110:165afa46840b 554 This function assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
Kojto 110:165afa46840b 555 or the new value increases the BASEPRI priority level.
Kojto 110:165afa46840b 556
Kojto 110:165afa46840b 557 \param [in] basePri Base Priority value to set
Kojto 110:165afa46840b 558 */
Kojto 110:165afa46840b 559 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI_MAX(uint32_t value)
Kojto 110:165afa46840b 560 {
Kojto 110:165afa46840b 561 __ASM volatile ("MSR basepri_max, %0" : : "r" (value) : "memory");
Kojto 110:165afa46840b 562 }
Kojto 110:165afa46840b 563
Kojto 110:165afa46840b 564
Kojto 98:8ab26030e058 565 /** \brief Get Fault Mask
Kojto 98:8ab26030e058 566
Kojto 98:8ab26030e058 567 This function returns the current value of the Fault Mask register.
Kojto 98:8ab26030e058 568
Kojto 98:8ab26030e058 569 \return Fault Mask register value
Kojto 98:8ab26030e058 570 */
Kojto 98:8ab26030e058 571 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
Kojto 98:8ab26030e058 572 {
Kojto 98:8ab26030e058 573 uint32_t result;
Kojto 98:8ab26030e058 574
Kojto 98:8ab26030e058 575 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
Kojto 98:8ab26030e058 576 return(result);
Kojto 98:8ab26030e058 577 }
Kojto 98:8ab26030e058 578
Kojto 98:8ab26030e058 579
Kojto 98:8ab26030e058 580 /** \brief Set Fault Mask
Kojto 98:8ab26030e058 581
Kojto 98:8ab26030e058 582 This function assigns the given value to the Fault Mask register.
Kojto 98:8ab26030e058 583
Kojto 98:8ab26030e058 584 \param [in] faultMask Fault Mask value to set
Kojto 98:8ab26030e058 585 */
Kojto 98:8ab26030e058 586 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
Kojto 98:8ab26030e058 587 {
Kojto 98:8ab26030e058 588 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
Kojto 98:8ab26030e058 589 }
Kojto 98:8ab26030e058 590
Kojto 98:8ab26030e058 591 #endif /* (__CORTEX_M >= 0x03) */
Kojto 98:8ab26030e058 592
Kojto 98:8ab26030e058 593
Kojto 110:165afa46840b 594 #if (__CORTEX_M == 0x04) || (__CORTEX_M == 0x07)
Kojto 98:8ab26030e058 595
Kojto 98:8ab26030e058 596 /** \brief Get FPSCR
Kojto 98:8ab26030e058 597
Kojto 98:8ab26030e058 598 This function returns the current value of the Floating Point Status/Control register.
Kojto 98:8ab26030e058 599
Kojto 98:8ab26030e058 600 \return Floating Point Status/Control register value
Kojto 98:8ab26030e058 601 */
Kojto 98:8ab26030e058 602 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void)
Kojto 98:8ab26030e058 603 {
Kojto 98:8ab26030e058 604 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
Kojto 98:8ab26030e058 605 uint32_t result;
Kojto 98:8ab26030e058 606
Kojto 98:8ab26030e058 607 /* Empty asm statement works as a scheduling barrier */
Kojto 98:8ab26030e058 608 __ASM volatile ("");
Kojto 98:8ab26030e058 609 __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
Kojto 98:8ab26030e058 610 __ASM volatile ("");
Kojto 98:8ab26030e058 611 return(result);
Kojto 98:8ab26030e058 612 #else
Kojto 98:8ab26030e058 613 return(0);
Kojto 98:8ab26030e058 614 #endif
Kojto 98:8ab26030e058 615 }
Kojto 98:8ab26030e058 616
Kojto 98:8ab26030e058 617
Kojto 98:8ab26030e058 618 /** \brief Set FPSCR
Kojto 98:8ab26030e058 619
Kojto 98:8ab26030e058 620 This function assigns the given value to the Floating Point Status/Control register.
Kojto 98:8ab26030e058 621
Kojto 98:8ab26030e058 622 \param [in] fpscr Floating Point Status/Control value to set
Kojto 98:8ab26030e058 623 */
Kojto 98:8ab26030e058 624 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
Kojto 98:8ab26030e058 625 {
Kojto 98:8ab26030e058 626 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
Kojto 98:8ab26030e058 627 /* Empty asm statement works as a scheduling barrier */
Kojto 98:8ab26030e058 628 __ASM volatile ("");
Kojto 98:8ab26030e058 629 __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc");
Kojto 98:8ab26030e058 630 __ASM volatile ("");
Kojto 98:8ab26030e058 631 #endif
Kojto 98:8ab26030e058 632 }
Kojto 98:8ab26030e058 633
Kojto 110:165afa46840b 634 #endif /* (__CORTEX_M == 0x04) || (__CORTEX_M == 0x07) */
Kojto 110:165afa46840b 635
Kojto 110:165afa46840b 636
Kojto 110:165afa46840b 637 #elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
Kojto 110:165afa46840b 638 /* IAR iccarm specific functions */
Kojto 110:165afa46840b 639 #include <cmsis_iar.h>
Kojto 110:165afa46840b 640
Kojto 110:165afa46840b 641
Kojto 110:165afa46840b 642 #elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/
Kojto 110:165afa46840b 643 /* TI CCS specific functions */
Kojto 110:165afa46840b 644 #include <cmsis_ccs.h>
Kojto 98:8ab26030e058 645
Kojto 98:8ab26030e058 646
Kojto 98:8ab26030e058 647 #elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/
Kojto 98:8ab26030e058 648 /* TASKING carm specific functions */
Kojto 98:8ab26030e058 649 /*
Kojto 98:8ab26030e058 650 * The CMSIS functions have been implemented as intrinsics in the compiler.
Kojto 110:165afa46840b 651 * Please use "carm -?i" to get an up to date list of all intrinsics,
Kojto 98:8ab26030e058 652 * Including the CMSIS ones.
Kojto 98:8ab26030e058 653 */
Kojto 98:8ab26030e058 654
Kojto 110:165afa46840b 655
Kojto 110:165afa46840b 656 #elif defined ( __CSMC__ ) /*------------------ COSMIC Compiler -------------------*/
Kojto 110:165afa46840b 657 /* Cosmic specific functions */
Kojto 110:165afa46840b 658 #include <cmsis_csm.h>
Kojto 110:165afa46840b 659
Kojto 98:8ab26030e058 660 #endif
Kojto 98:8ab26030e058 661
Kojto 98:8ab26030e058 662 /*@} end of CMSIS_Core_RegAccFunctions */
Kojto 98:8ab26030e058 663
Kojto 98:8ab26030e058 664 #endif /* __CORE_CMFUNC_H */