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