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

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Fri May 26 12:30:20 2017 +0100
Revision:
143:86740a56073b
Parent:
110:165afa46840b
Release 143 of the mbed library.

Who changed what in which revision?

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