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:
Tue Mar 14 16:20:51 2017 +0000
Revision:
138:093f2bd7b9eb
Parent:
110:165afa46840b
Release 138 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

3716: fix for issue #3715: correction in startup files for ARM and IAR, alignment of system_stm32f429xx.c files https://github.com/ARMmbed/mbed-os/pull/3716
3741: STM32 remove warning in hal_tick_32b.c file https://github.com/ARMmbed/mbed-os/pull/3741
3780: STM32L4 : Fix GPIO G port compatibility https://github.com/ARMmbed/mbed-os/pull/3780
3831: NCS36510: SPISLAVE enabled (Conflict resolved) https://github.com/ARMmbed/mbed-os/pull/3831
3836: Allow to redefine nRF's PSTORAGE_NUM_OF_PAGES outside of the mbed-os https://github.com/ARMmbed/mbed-os/pull/3836
3840: STM32: gpio SPEED - always set High Speed by default https://github.com/ARMmbed/mbed-os/pull/3840
3844: STM32 GPIO: Typo correction. Update comment (GPIO_IP_WITHOUT_BRR) https://github.com/ARMmbed/mbed-os/pull/3844
3850: STM32: change spi error to debug warning https://github.com/ARMmbed/mbed-os/pull/3850
3860: Define GPIO_IP_WITHOUT_BRR for xDot platform https://github.com/ARMmbed/mbed-os/pull/3860
3880: DISCO_F469NI: allow the use of CAN2 instance when CAN1 is not activated https://github.com/ARMmbed/mbed-os/pull/3880
3795: Fix pwm period calc https://github.com/ARMmbed/mbed-os/pull/3795
3828: STM32 CAN API: correct format and type https://github.com/ARMmbed/mbed-os/pull/3828
3842: TARGET_NRF: corrected spi_init() to properly handle re-initialization https://github.com/ARMmbed/mbed-os/pull/3842
3843: STM32L476xG: set APB2 clock to 80MHz (instead of 40MHz) https://github.com/ARMmbed/mbed-os/pull/3843
3879: NUCLEO_F446ZE: Add missing AnalogIn pins on PF_3, PF_5 and PF_10. https://github.com/ARMmbed/mbed-os/pull/3879
3902: Fix heap and stack size for NUCLEO_F746ZG https://github.com/ARMmbed/mbed-os/pull/3902
3829: can_write(): return error code when no tx mailboxes are available https://github.com/ARMmbed/mbed-os/pull/3829

Who changed what in which revision?

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