Martin Werluschnig / Mbed 2 deprecated Diplomarbeit_MW_CW

Dependencies:   mbed

Committer:
martwerl
Date:
Thu Nov 15 17:59:08 2018 +0000
Revision:
1:ff38e3bad33a
Parent:
0:afeca64a6543
Diplomarbeit

Who changed what in which revision?

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