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:
<>
Date:
Mon Jan 16 12:05:23 2017 +0000
Revision:
134:ad3be0349dc5
Parent:
110:165afa46840b
Release 134 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

3488: Dev stm i2c v2 unitary functions https://github.com/ARMmbed/mbed-os/pull/3488
3492: Fix #3463 CAN read() return value https://github.com/ARMmbed/mbed-os/pull/3492
3503: [LPC15xx] Ensure that PWM=1 is resolved correctly https://github.com/ARMmbed/mbed-os/pull/3503
3504: [LPC15xx] CAN implementation improvements https://github.com/ARMmbed/mbed-os/pull/3504
3539: NUCLEO_F412ZG - Add support of TRNG peripheral https://github.com/ARMmbed/mbed-os/pull/3539
3540: STM: SPI: Initialize Rx in spi_master_write https://github.com/ARMmbed/mbed-os/pull/3540
3438: K64F: Add support for SERIAL ASYNCH API https://github.com/ARMmbed/mbed-os/pull/3438
3519: MCUXpresso: Fix ENET driver to enable interrupts after interrupt handler is set https://github.com/ARMmbed/mbed-os/pull/3519
3544: STM32L4 deepsleep improvement https://github.com/ARMmbed/mbed-os/pull/3544
3546: NUCLEO-F412ZG - Add CAN peripheral https://github.com/ARMmbed/mbed-os/pull/3546
3551: Fix I2C driver for RZ/A1H https://github.com/ARMmbed/mbed-os/pull/3551
3558: K64F UART Asynch API: Fix synchronization issue https://github.com/ARMmbed/mbed-os/pull/3558
3563: LPC4088 - Fix vector checksum https://github.com/ARMmbed/mbed-os/pull/3563
3567: Dev stm32 F0 v1.7.0 https://github.com/ARMmbed/mbed-os/pull/3567
3577: Fixes linking errors when building with debug profile https://github.com/ARMmbed/mbed-os/pull/3577

Who changed what in which revision?

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