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:
93:e188a91d3eaa
12

Who changed what in which revision?

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