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

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Mon Apr 07 18:28:36 2014 +0100
Revision:
82:6473597d706e
Release 82 of the mbed library

Main changes:

- support for K64F
- Revisited Nordic code structure
- Test infrastructure improvements
- various bug fixes

Who changed what in which revision?

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