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

Fork of mbed by mbed official

Committer:
Mikchel
Date:
Sun May 03 16:04:42 2015 +0000
Revision:
99:7f6c6de930c0
Parent:
65:5798e58a58b1
12

Who changed what in which revision?

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