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