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

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

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

Committer:
Kojto
Date:
Wed Apr 29 10:16:23 2015 +0100
Revision:
98:8ab26030e058
Child:
110:165afa46840b
Release 98 of the mbed library

Changes:
- Silabs new targets (Giant, Zero, Happy, Leopard, Wonder Geckos)
- Asynchronous SPI, I2C, Serial
- LowPower classes
- Nordic - nordic SDK v8.0 update
- Teensy - gcc arm fix for startup
- Nucleo F411 - usb freq fix

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 98:8ab26030e058 4 * @version V3.20
Kojto 98:8ab26030e058 5 * @date 25. February 2013
Kojto 98:8ab26030e058 6 *
Kojto 98:8ab26030e058 7 * @note
Kojto 98:8ab26030e058 8 *
Kojto 98:8ab26030e058 9 ******************************************************************************/
Kojto 98:8ab26030e058 10 /* Copyright (c) 2009 - 2013 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 98:8ab26030e058 201 #if (__CORTEX_M >= 0x03)
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 98:8ab26030e058 245 /** \brief Get Fault Mask
Kojto 98:8ab26030e058 246
Kojto 98:8ab26030e058 247 This function returns the current value of the Fault Mask register.
Kojto 98:8ab26030e058 248
Kojto 98:8ab26030e058 249 \return Fault Mask register value
Kojto 98:8ab26030e058 250 */
Kojto 98:8ab26030e058 251 __STATIC_INLINE uint32_t __get_FAULTMASK(void)
Kojto 98:8ab26030e058 252 {
Kojto 98:8ab26030e058 253 register uint32_t __regFaultMask __ASM("faultmask");
Kojto 98:8ab26030e058 254 return(__regFaultMask);
Kojto 98:8ab26030e058 255 }
Kojto 98:8ab26030e058 256
Kojto 98:8ab26030e058 257
Kojto 98:8ab26030e058 258 /** \brief Set Fault Mask
Kojto 98:8ab26030e058 259
Kojto 98:8ab26030e058 260 This function assigns the given value to the Fault Mask register.
Kojto 98:8ab26030e058 261
Kojto 98:8ab26030e058 262 \param [in] faultMask Fault Mask value to set
Kojto 98:8ab26030e058 263 */
Kojto 98:8ab26030e058 264 __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
Kojto 98:8ab26030e058 265 {
Kojto 98:8ab26030e058 266 register uint32_t __regFaultMask __ASM("faultmask");
Kojto 98:8ab26030e058 267 __regFaultMask = (faultMask & (uint32_t)1);
Kojto 98:8ab26030e058 268 }
Kojto 98:8ab26030e058 269
Kojto 98:8ab26030e058 270 #endif /* (__CORTEX_M >= 0x03) */
Kojto 98:8ab26030e058 271
Kojto 98:8ab26030e058 272
Kojto 98:8ab26030e058 273 #if (__CORTEX_M == 0x04)
Kojto 98:8ab26030e058 274
Kojto 98:8ab26030e058 275 /** \brief Get FPSCR
Kojto 98:8ab26030e058 276
Kojto 98:8ab26030e058 277 This function returns the current value of the Floating Point Status/Control register.
Kojto 98:8ab26030e058 278
Kojto 98:8ab26030e058 279 \return Floating Point Status/Control register value
Kojto 98:8ab26030e058 280 */
Kojto 98:8ab26030e058 281 __STATIC_INLINE uint32_t __get_FPSCR(void)
Kojto 98:8ab26030e058 282 {
Kojto 98:8ab26030e058 283 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
Kojto 98:8ab26030e058 284 register uint32_t __regfpscr __ASM("fpscr");
Kojto 98:8ab26030e058 285 return(__regfpscr);
Kojto 98:8ab26030e058 286 #else
Kojto 98:8ab26030e058 287 return(0);
Kojto 98:8ab26030e058 288 #endif
Kojto 98:8ab26030e058 289 }
Kojto 98:8ab26030e058 290
Kojto 98:8ab26030e058 291
Kojto 98:8ab26030e058 292 /** \brief Set FPSCR
Kojto 98:8ab26030e058 293
Kojto 98:8ab26030e058 294 This function assigns the given value to the Floating Point Status/Control register.
Kojto 98:8ab26030e058 295
Kojto 98:8ab26030e058 296 \param [in] fpscr Floating Point Status/Control value to set
Kojto 98:8ab26030e058 297 */
Kojto 98:8ab26030e058 298 __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
Kojto 98:8ab26030e058 299 {
Kojto 98:8ab26030e058 300 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
Kojto 98:8ab26030e058 301 register uint32_t __regfpscr __ASM("fpscr");
Kojto 98:8ab26030e058 302 __regfpscr = (fpscr);
Kojto 98:8ab26030e058 303 #endif
Kojto 98:8ab26030e058 304 }
Kojto 98:8ab26030e058 305
Kojto 98:8ab26030e058 306 #endif /* (__CORTEX_M == 0x04) */
Kojto 98:8ab26030e058 307
Kojto 98:8ab26030e058 308
Kojto 98:8ab26030e058 309 #elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/
Kojto 98:8ab26030e058 310 /* IAR iccarm specific functions */
Kojto 98:8ab26030e058 311
Kojto 98:8ab26030e058 312 #include <cmsis_iar.h>
Kojto 98:8ab26030e058 313
Kojto 98:8ab26030e058 314
Kojto 98:8ab26030e058 315 #elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/
Kojto 98:8ab26030e058 316 /* TI CCS specific functions */
Kojto 98:8ab26030e058 317
Kojto 98:8ab26030e058 318 #include <cmsis_ccs.h>
Kojto 98:8ab26030e058 319
Kojto 98:8ab26030e058 320
Kojto 98:8ab26030e058 321 #elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/
Kojto 98:8ab26030e058 322 /* GNU gcc specific functions */
Kojto 98:8ab26030e058 323
Kojto 98:8ab26030e058 324 /** \brief Enable IRQ Interrupts
Kojto 98:8ab26030e058 325
Kojto 98:8ab26030e058 326 This function enables IRQ interrupts by clearing the I-bit in the CPSR.
Kojto 98:8ab26030e058 327 Can only be executed in Privileged modes.
Kojto 98:8ab26030e058 328 */
Kojto 98:8ab26030e058 329 __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void)
Kojto 98:8ab26030e058 330 {
Kojto 98:8ab26030e058 331 __ASM volatile ("cpsie i" : : : "memory");
Kojto 98:8ab26030e058 332 }
Kojto 98:8ab26030e058 333
Kojto 98:8ab26030e058 334
Kojto 98:8ab26030e058 335 /** \brief Disable IRQ Interrupts
Kojto 98:8ab26030e058 336
Kojto 98:8ab26030e058 337 This function disables IRQ interrupts by setting the I-bit in the CPSR.
Kojto 98:8ab26030e058 338 Can only be executed in Privileged modes.
Kojto 98:8ab26030e058 339 */
Kojto 98:8ab26030e058 340 __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void)
Kojto 98:8ab26030e058 341 {
Kojto 98:8ab26030e058 342 __ASM volatile ("cpsid i" : : : "memory");
Kojto 98:8ab26030e058 343 }
Kojto 98:8ab26030e058 344
Kojto 98:8ab26030e058 345
Kojto 98:8ab26030e058 346 /** \brief Get Control Register
Kojto 98:8ab26030e058 347
Kojto 98:8ab26030e058 348 This function returns the content of the Control Register.
Kojto 98:8ab26030e058 349
Kojto 98:8ab26030e058 350 \return Control Register value
Kojto 98:8ab26030e058 351 */
Kojto 98:8ab26030e058 352 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void)
Kojto 98:8ab26030e058 353 {
Kojto 98:8ab26030e058 354 uint32_t result;
Kojto 98:8ab26030e058 355
Kojto 98:8ab26030e058 356 __ASM volatile ("MRS %0, control" : "=r" (result) );
Kojto 98:8ab26030e058 357 return(result);
Kojto 98:8ab26030e058 358 }
Kojto 98:8ab26030e058 359
Kojto 98:8ab26030e058 360
Kojto 98:8ab26030e058 361 /** \brief Set Control Register
Kojto 98:8ab26030e058 362
Kojto 98:8ab26030e058 363 This function writes the given value to the Control Register.
Kojto 98:8ab26030e058 364
Kojto 98:8ab26030e058 365 \param [in] control Control Register value to set
Kojto 98:8ab26030e058 366 */
Kojto 98:8ab26030e058 367 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_CONTROL(uint32_t control)
Kojto 98:8ab26030e058 368 {
Kojto 98:8ab26030e058 369 __ASM volatile ("MSR control, %0" : : "r" (control) : "memory");
Kojto 98:8ab26030e058 370 }
Kojto 98:8ab26030e058 371
Kojto 98:8ab26030e058 372
Kojto 98:8ab26030e058 373 /** \brief Get IPSR Register
Kojto 98:8ab26030e058 374
Kojto 98:8ab26030e058 375 This function returns the content of the IPSR Register.
Kojto 98:8ab26030e058 376
Kojto 98:8ab26030e058 377 \return IPSR Register value
Kojto 98:8ab26030e058 378 */
Kojto 98:8ab26030e058 379 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_IPSR(void)
Kojto 98:8ab26030e058 380 {
Kojto 98:8ab26030e058 381 uint32_t result;
Kojto 98:8ab26030e058 382
Kojto 98:8ab26030e058 383 __ASM volatile ("MRS %0, ipsr" : "=r" (result) );
Kojto 98:8ab26030e058 384 return(result);
Kojto 98:8ab26030e058 385 }
Kojto 98:8ab26030e058 386
Kojto 98:8ab26030e058 387
Kojto 98:8ab26030e058 388 /** \brief Get APSR Register
Kojto 98:8ab26030e058 389
Kojto 98:8ab26030e058 390 This function returns the content of the APSR Register.
Kojto 98:8ab26030e058 391
Kojto 98:8ab26030e058 392 \return APSR Register value
Kojto 98:8ab26030e058 393 */
Kojto 98:8ab26030e058 394 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_APSR(void)
Kojto 98:8ab26030e058 395 {
Kojto 98:8ab26030e058 396 uint32_t result;
Kojto 98:8ab26030e058 397
Kojto 98:8ab26030e058 398 __ASM volatile ("MRS %0, apsr" : "=r" (result) );
Kojto 98:8ab26030e058 399 return(result);
Kojto 98:8ab26030e058 400 }
Kojto 98:8ab26030e058 401
Kojto 98:8ab26030e058 402
Kojto 98:8ab26030e058 403 /** \brief Get xPSR Register
Kojto 98:8ab26030e058 404
Kojto 98:8ab26030e058 405 This function returns the content of the xPSR Register.
Kojto 98:8ab26030e058 406
Kojto 98:8ab26030e058 407 \return xPSR Register value
Kojto 98:8ab26030e058 408 */
Kojto 98:8ab26030e058 409 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_xPSR(void)
Kojto 98:8ab26030e058 410 {
Kojto 98:8ab26030e058 411 uint32_t result;
Kojto 98:8ab26030e058 412
Kojto 98:8ab26030e058 413 __ASM volatile ("MRS %0, xpsr" : "=r" (result) );
Kojto 98:8ab26030e058 414 return(result);
Kojto 98:8ab26030e058 415 }
Kojto 98:8ab26030e058 416
Kojto 98:8ab26030e058 417
Kojto 98:8ab26030e058 418 /** \brief Get Process Stack Pointer
Kojto 98:8ab26030e058 419
Kojto 98:8ab26030e058 420 This function returns the current value of the Process Stack Pointer (PSP).
Kojto 98:8ab26030e058 421
Kojto 98:8ab26030e058 422 \return PSP Register value
Kojto 98:8ab26030e058 423 */
Kojto 98:8ab26030e058 424 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(void)
Kojto 98:8ab26030e058 425 {
Kojto 98:8ab26030e058 426 register uint32_t result;
Kojto 98:8ab26030e058 427
Kojto 98:8ab26030e058 428 __ASM volatile ("MRS %0, psp\n" : "=r" (result) );
Kojto 98:8ab26030e058 429 return(result);
Kojto 98:8ab26030e058 430 }
Kojto 98:8ab26030e058 431
Kojto 98:8ab26030e058 432
Kojto 98:8ab26030e058 433 /** \brief Set Process Stack Pointer
Kojto 98:8ab26030e058 434
Kojto 98:8ab26030e058 435 This function assigns the given value to the Process Stack Pointer (PSP).
Kojto 98:8ab26030e058 436
Kojto 98:8ab26030e058 437 \param [in] topOfProcStack Process Stack Pointer value to set
Kojto 98:8ab26030e058 438 */
Kojto 98:8ab26030e058 439 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
Kojto 98:8ab26030e058 440 {
Kojto 98:8ab26030e058 441 __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) : "sp");
Kojto 98:8ab26030e058 442 }
Kojto 98:8ab26030e058 443
Kojto 98:8ab26030e058 444
Kojto 98:8ab26030e058 445 /** \brief Get Main Stack Pointer
Kojto 98:8ab26030e058 446
Kojto 98:8ab26030e058 447 This function returns the current value of the Main Stack Pointer (MSP).
Kojto 98:8ab26030e058 448
Kojto 98:8ab26030e058 449 \return MSP Register value
Kojto 98:8ab26030e058 450 */
Kojto 98:8ab26030e058 451 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(void)
Kojto 98:8ab26030e058 452 {
Kojto 98:8ab26030e058 453 register uint32_t result;
Kojto 98:8ab26030e058 454
Kojto 98:8ab26030e058 455 __ASM volatile ("MRS %0, msp\n" : "=r" (result) );
Kojto 98:8ab26030e058 456 return(result);
Kojto 98:8ab26030e058 457 }
Kojto 98:8ab26030e058 458
Kojto 98:8ab26030e058 459
Kojto 98:8ab26030e058 460 /** \brief Set Main Stack Pointer
Kojto 98:8ab26030e058 461
Kojto 98:8ab26030e058 462 This function assigns the given value to the Main Stack Pointer (MSP).
Kojto 98:8ab26030e058 463
Kojto 98:8ab26030e058 464 \param [in] topOfMainStack Main Stack Pointer value to set
Kojto 98:8ab26030e058 465 */
Kojto 98:8ab26030e058 466 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
Kojto 98:8ab26030e058 467 {
Kojto 98:8ab26030e058 468 __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : "sp");
Kojto 98:8ab26030e058 469 }
Kojto 98:8ab26030e058 470
Kojto 98:8ab26030e058 471
Kojto 98:8ab26030e058 472 /** \brief Get Priority Mask
Kojto 98:8ab26030e058 473
Kojto 98:8ab26030e058 474 This function returns the current state of the priority mask bit from the Priority Mask Register.
Kojto 98:8ab26030e058 475
Kojto 98:8ab26030e058 476 \return Priority Mask value
Kojto 98:8ab26030e058 477 */
Kojto 98:8ab26030e058 478 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PRIMASK(void)
Kojto 98:8ab26030e058 479 {
Kojto 98:8ab26030e058 480 uint32_t result;
Kojto 98:8ab26030e058 481
Kojto 98:8ab26030e058 482 __ASM volatile ("MRS %0, primask" : "=r" (result) );
Kojto 98:8ab26030e058 483 return(result);
Kojto 98:8ab26030e058 484 }
Kojto 98:8ab26030e058 485
Kojto 98:8ab26030e058 486
Kojto 98:8ab26030e058 487 /** \brief Set Priority Mask
Kojto 98:8ab26030e058 488
Kojto 98:8ab26030e058 489 This function assigns the given value to the Priority Mask Register.
Kojto 98:8ab26030e058 490
Kojto 98:8ab26030e058 491 \param [in] priMask Priority Mask
Kojto 98:8ab26030e058 492 */
Kojto 98:8ab26030e058 493 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
Kojto 98:8ab26030e058 494 {
Kojto 98:8ab26030e058 495 __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory");
Kojto 98:8ab26030e058 496 }
Kojto 98:8ab26030e058 497
Kojto 98:8ab26030e058 498
Kojto 98:8ab26030e058 499 #if (__CORTEX_M >= 0x03)
Kojto 98:8ab26030e058 500
Kojto 98:8ab26030e058 501 /** \brief Enable FIQ
Kojto 98:8ab26030e058 502
Kojto 98:8ab26030e058 503 This function enables FIQ interrupts by clearing the F-bit in the CPSR.
Kojto 98:8ab26030e058 504 Can only be executed in Privileged modes.
Kojto 98:8ab26030e058 505 */
Kojto 98:8ab26030e058 506 __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_fault_irq(void)
Kojto 98:8ab26030e058 507 {
Kojto 98:8ab26030e058 508 __ASM volatile ("cpsie f" : : : "memory");
Kojto 98:8ab26030e058 509 }
Kojto 98:8ab26030e058 510
Kojto 98:8ab26030e058 511
Kojto 98:8ab26030e058 512 /** \brief Disable FIQ
Kojto 98:8ab26030e058 513
Kojto 98:8ab26030e058 514 This function disables FIQ interrupts by setting the F-bit in the CPSR.
Kojto 98:8ab26030e058 515 Can only be executed in Privileged modes.
Kojto 98:8ab26030e058 516 */
Kojto 98:8ab26030e058 517 __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_fault_irq(void)
Kojto 98:8ab26030e058 518 {
Kojto 98:8ab26030e058 519 __ASM volatile ("cpsid f" : : : "memory");
Kojto 98:8ab26030e058 520 }
Kojto 98:8ab26030e058 521
Kojto 98:8ab26030e058 522
Kojto 98:8ab26030e058 523 /** \brief Get Base Priority
Kojto 98:8ab26030e058 524
Kojto 98:8ab26030e058 525 This function returns the current value of the Base Priority register.
Kojto 98:8ab26030e058 526
Kojto 98:8ab26030e058 527 \return Base Priority register value
Kojto 98:8ab26030e058 528 */
Kojto 98:8ab26030e058 529 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(void)
Kojto 98:8ab26030e058 530 {
Kojto 98:8ab26030e058 531 uint32_t result;
Kojto 98:8ab26030e058 532
Kojto 98:8ab26030e058 533 __ASM volatile ("MRS %0, basepri_max" : "=r" (result) );
Kojto 98:8ab26030e058 534 return(result);
Kojto 98:8ab26030e058 535 }
Kojto 98:8ab26030e058 536
Kojto 98:8ab26030e058 537
Kojto 98:8ab26030e058 538 /** \brief Set Base Priority
Kojto 98:8ab26030e058 539
Kojto 98:8ab26030e058 540 This function assigns the given value to the Base Priority register.
Kojto 98:8ab26030e058 541
Kojto 98:8ab26030e058 542 \param [in] basePri Base Priority value to set
Kojto 98:8ab26030e058 543 */
Kojto 98:8ab26030e058 544 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI(uint32_t value)
Kojto 98:8ab26030e058 545 {
Kojto 98:8ab26030e058 546 __ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory");
Kojto 98:8ab26030e058 547 }
Kojto 98:8ab26030e058 548
Kojto 98:8ab26030e058 549
Kojto 98:8ab26030e058 550 /** \brief Get Fault Mask
Kojto 98:8ab26030e058 551
Kojto 98:8ab26030e058 552 This function returns the current value of the Fault Mask register.
Kojto 98:8ab26030e058 553
Kojto 98:8ab26030e058 554 \return Fault Mask register value
Kojto 98:8ab26030e058 555 */
Kojto 98:8ab26030e058 556 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FAULTMASK(void)
Kojto 98:8ab26030e058 557 {
Kojto 98:8ab26030e058 558 uint32_t result;
Kojto 98:8ab26030e058 559
Kojto 98:8ab26030e058 560 __ASM volatile ("MRS %0, faultmask" : "=r" (result) );
Kojto 98:8ab26030e058 561 return(result);
Kojto 98:8ab26030e058 562 }
Kojto 98:8ab26030e058 563
Kojto 98:8ab26030e058 564
Kojto 98:8ab26030e058 565 /** \brief Set Fault Mask
Kojto 98:8ab26030e058 566
Kojto 98:8ab26030e058 567 This function assigns the given value to the Fault Mask register.
Kojto 98:8ab26030e058 568
Kojto 98:8ab26030e058 569 \param [in] faultMask Fault Mask value to set
Kojto 98:8ab26030e058 570 */
Kojto 98:8ab26030e058 571 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
Kojto 98:8ab26030e058 572 {
Kojto 98:8ab26030e058 573 __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory");
Kojto 98:8ab26030e058 574 }
Kojto 98:8ab26030e058 575
Kojto 98:8ab26030e058 576 #endif /* (__CORTEX_M >= 0x03) */
Kojto 98:8ab26030e058 577
Kojto 98:8ab26030e058 578
Kojto 98:8ab26030e058 579 #if (__CORTEX_M == 0x04)
Kojto 98:8ab26030e058 580
Kojto 98:8ab26030e058 581 /** \brief Get FPSCR
Kojto 98:8ab26030e058 582
Kojto 98:8ab26030e058 583 This function returns the current value of the Floating Point Status/Control register.
Kojto 98:8ab26030e058 584
Kojto 98:8ab26030e058 585 \return Floating Point Status/Control register value
Kojto 98:8ab26030e058 586 */
Kojto 98:8ab26030e058 587 __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void)
Kojto 98:8ab26030e058 588 {
Kojto 98:8ab26030e058 589 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
Kojto 98:8ab26030e058 590 uint32_t result;
Kojto 98:8ab26030e058 591
Kojto 98:8ab26030e058 592 /* Empty asm statement works as a scheduling barrier */
Kojto 98:8ab26030e058 593 __ASM volatile ("");
Kojto 98:8ab26030e058 594 __ASM volatile ("VMRS %0, fpscr" : "=r" (result) );
Kojto 98:8ab26030e058 595 __ASM volatile ("");
Kojto 98:8ab26030e058 596 return(result);
Kojto 98:8ab26030e058 597 #else
Kojto 98:8ab26030e058 598 return(0);
Kojto 98:8ab26030e058 599 #endif
Kojto 98:8ab26030e058 600 }
Kojto 98:8ab26030e058 601
Kojto 98:8ab26030e058 602
Kojto 98:8ab26030e058 603 /** \brief Set FPSCR
Kojto 98:8ab26030e058 604
Kojto 98:8ab26030e058 605 This function assigns the given value to the Floating Point Status/Control register.
Kojto 98:8ab26030e058 606
Kojto 98:8ab26030e058 607 \param [in] fpscr Floating Point Status/Control value to set
Kojto 98:8ab26030e058 608 */
Kojto 98:8ab26030e058 609 __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
Kojto 98:8ab26030e058 610 {
Kojto 98:8ab26030e058 611 #if (__FPU_PRESENT == 1) && (__FPU_USED == 1)
Kojto 98:8ab26030e058 612 /* Empty asm statement works as a scheduling barrier */
Kojto 98:8ab26030e058 613 __ASM volatile ("");
Kojto 98:8ab26030e058 614 __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc");
Kojto 98:8ab26030e058 615 __ASM volatile ("");
Kojto 98:8ab26030e058 616 #endif
Kojto 98:8ab26030e058 617 }
Kojto 98:8ab26030e058 618
Kojto 98:8ab26030e058 619 #endif /* (__CORTEX_M == 0x04) */
Kojto 98:8ab26030e058 620
Kojto 98:8ab26030e058 621
Kojto 98:8ab26030e058 622 #elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/
Kojto 98:8ab26030e058 623 /* TASKING carm specific functions */
Kojto 98:8ab26030e058 624
Kojto 98:8ab26030e058 625 /*
Kojto 98:8ab26030e058 626 * The CMSIS functions have been implemented as intrinsics in the compiler.
Kojto 98:8ab26030e058 627 * Please use "carm -?i" to get an up to date list of all instrinsics,
Kojto 98:8ab26030e058 628 * Including the CMSIS ones.
Kojto 98:8ab26030e058 629 */
Kojto 98:8ab26030e058 630
Kojto 98:8ab26030e058 631 #endif
Kojto 98:8ab26030e058 632
Kojto 98:8ab26030e058 633 /*@} end of CMSIS_Core_RegAccFunctions */
Kojto 98:8ab26030e058 634
Kojto 98:8ab26030e058 635
Kojto 98:8ab26030e058 636 #endif /* __CORE_CMFUNC_H */