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