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