meh

Fork of mbed by mbed official

Committer:
ricardobtez
Date:
Tue Apr 05 23:51:21 2016 +0000
Revision:
118:16969dd821af
Parent:
73:1efda918f0ba
Child:
110:165afa46840b
dgdgr

Who changed what in which revision?

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