meh

Fork of mbed by mbed official

Committer:
Kojto
Date:
Wed Nov 25 13:21:40 2015 +0000
Revision:
110:165afa46840b
Parent:
89:552587b429a1
Release 110  of the mbed library

Changes:
- new platforms - STM32F410R, DISCO_F429ZI, DISCO_F469NI
- Nucleo L476 - gcc and uvision template
- k22,k64f targets - ADC channels A addition
- EFM32 - bugfixes in sleep, serial and spi
- Delta DFCM NNN40 - pinnames update

Who changed what in which revision?

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