meh

Fork of mbed by mbed official

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

Who changed what in which revision?

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