my fork

Dependents:   Nucleo_blueNRG

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Fri Jul 25 09:46:51 2014 +0100
Revision:
87:6213f644d804
Release 87 of the mbed library

Main changes:

- error.h renamed to mbed_error.h to avoid name clashes
- upgraded to V7 of the nRF51822 soft-device 110
- New targets: HRM107
- Improved test infrastructure
- Bug fixes on various targets

Who changed what in which revision?

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