Lab 1 Program C

Dependents:   Lab1C

Fork of mbed by -deleted-

Committer:
emilmont
Date:
Tue Jun 12 18:23:44 2012 +0100
Revision:
40:976df7c37ad5
First build for the new build system

Who changed what in which revision?

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