my fork
Fork of mbed by
TARGET_LPC1768/core_cmFunc.h@97:4298809c7c9e, 2015-04-08 (annotated)
- Committer:
- filartrix
- Date:
- Wed Apr 08 14:12:53 2015 +0000
- Revision:
- 97:4298809c7c9e
- Parent:
- 64:e3affc9e7238
First reale BlueNRG module for nucleo 401 board
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 |
bogdanm | 64:e3affc9e7238 | 4 | * @version V3.20 |
bogdanm | 64:e3affc9e7238 | 5 | * @date 25. February 2013 |
bogdanm | 64:e3affc9e7238 | 6 | * |
bogdanm | 64:e3affc9e7238 | 7 | * @note |
bogdanm | 64:e3affc9e7238 | 8 | * |
bogdanm | 64:e3affc9e7238 | 9 | ******************************************************************************/ |
bogdanm | 64:e3affc9e7238 | 10 | /* Copyright (c) 2009 - 2013 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 | |
bogdanm | 64:e3affc9e7238 | 201 | #if (__CORTEX_M >= 0x03) |
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 | |
bogdanm | 64:e3affc9e7238 | 245 | /** \brief Get Fault Mask |
bogdanm | 64:e3affc9e7238 | 246 | |
bogdanm | 64:e3affc9e7238 | 247 | This function returns the current value of the Fault Mask register. |
bogdanm | 64:e3affc9e7238 | 248 | |
bogdanm | 64:e3affc9e7238 | 249 | \return Fault Mask register value |
bogdanm | 64:e3affc9e7238 | 250 | */ |
bogdanm | 64:e3affc9e7238 | 251 | __STATIC_INLINE uint32_t __get_FAULTMASK(void) |
bogdanm | 64:e3affc9e7238 | 252 | { |
bogdanm | 64:e3affc9e7238 | 253 | register uint32_t __regFaultMask __ASM("faultmask"); |
bogdanm | 64:e3affc9e7238 | 254 | return(__regFaultMask); |
bogdanm | 64:e3affc9e7238 | 255 | } |
bogdanm | 64:e3affc9e7238 | 256 | |
bogdanm | 64:e3affc9e7238 | 257 | |
bogdanm | 64:e3affc9e7238 | 258 | /** \brief Set Fault Mask |
bogdanm | 64:e3affc9e7238 | 259 | |
bogdanm | 64:e3affc9e7238 | 260 | This function assigns the given value to the Fault Mask register. |
bogdanm | 64:e3affc9e7238 | 261 | |
bogdanm | 64:e3affc9e7238 | 262 | \param [in] faultMask Fault Mask value to set |
bogdanm | 64:e3affc9e7238 | 263 | */ |
bogdanm | 64:e3affc9e7238 | 264 | __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) |
bogdanm | 64:e3affc9e7238 | 265 | { |
bogdanm | 64:e3affc9e7238 | 266 | register uint32_t __regFaultMask __ASM("faultmask"); |
bogdanm | 64:e3affc9e7238 | 267 | __regFaultMask = (faultMask & (uint32_t)1); |
bogdanm | 64:e3affc9e7238 | 268 | } |
bogdanm | 64:e3affc9e7238 | 269 | |
bogdanm | 64:e3affc9e7238 | 270 | #endif /* (__CORTEX_M >= 0x03) */ |
bogdanm | 64:e3affc9e7238 | 271 | |
bogdanm | 64:e3affc9e7238 | 272 | |
bogdanm | 64:e3affc9e7238 | 273 | #if (__CORTEX_M == 0x04) |
bogdanm | 64:e3affc9e7238 | 274 | |
bogdanm | 64:e3affc9e7238 | 275 | /** \brief Get FPSCR |
bogdanm | 64:e3affc9e7238 | 276 | |
bogdanm | 64:e3affc9e7238 | 277 | This function returns the current value of the Floating Point Status/Control register. |
bogdanm | 64:e3affc9e7238 | 278 | |
bogdanm | 64:e3affc9e7238 | 279 | \return Floating Point Status/Control register value |
bogdanm | 64:e3affc9e7238 | 280 | */ |
bogdanm | 64:e3affc9e7238 | 281 | __STATIC_INLINE uint32_t __get_FPSCR(void) |
bogdanm | 64:e3affc9e7238 | 282 | { |
bogdanm | 64:e3affc9e7238 | 283 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) |
bogdanm | 64:e3affc9e7238 | 284 | register uint32_t __regfpscr __ASM("fpscr"); |
bogdanm | 64:e3affc9e7238 | 285 | return(__regfpscr); |
bogdanm | 64:e3affc9e7238 | 286 | #else |
bogdanm | 64:e3affc9e7238 | 287 | return(0); |
bogdanm | 64:e3affc9e7238 | 288 | #endif |
bogdanm | 64:e3affc9e7238 | 289 | } |
bogdanm | 64:e3affc9e7238 | 290 | |
bogdanm | 64:e3affc9e7238 | 291 | |
bogdanm | 64:e3affc9e7238 | 292 | /** \brief Set FPSCR |
bogdanm | 64:e3affc9e7238 | 293 | |
bogdanm | 64:e3affc9e7238 | 294 | This function assigns the given value to the Floating Point Status/Control register. |
bogdanm | 64:e3affc9e7238 | 295 | |
bogdanm | 64:e3affc9e7238 | 296 | \param [in] fpscr Floating Point Status/Control value to set |
bogdanm | 64:e3affc9e7238 | 297 | */ |
bogdanm | 64:e3affc9e7238 | 298 | __STATIC_INLINE void __set_FPSCR(uint32_t fpscr) |
bogdanm | 64:e3affc9e7238 | 299 | { |
bogdanm | 64:e3affc9e7238 | 300 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) |
bogdanm | 64:e3affc9e7238 | 301 | register uint32_t __regfpscr __ASM("fpscr"); |
bogdanm | 64:e3affc9e7238 | 302 | __regfpscr = (fpscr); |
bogdanm | 64:e3affc9e7238 | 303 | #endif |
bogdanm | 64:e3affc9e7238 | 304 | } |
bogdanm | 64:e3affc9e7238 | 305 | |
bogdanm | 64:e3affc9e7238 | 306 | #endif /* (__CORTEX_M == 0x04) */ |
bogdanm | 64:e3affc9e7238 | 307 | |
bogdanm | 64:e3affc9e7238 | 308 | |
bogdanm | 64:e3affc9e7238 | 309 | #elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/ |
bogdanm | 64:e3affc9e7238 | 310 | /* IAR iccarm specific functions */ |
bogdanm | 64:e3affc9e7238 | 311 | |
bogdanm | 64:e3affc9e7238 | 312 | #include <cmsis_iar.h> |
bogdanm | 64:e3affc9e7238 | 313 | |
bogdanm | 64:e3affc9e7238 | 314 | |
bogdanm | 64:e3affc9e7238 | 315 | #elif defined ( __TMS470__ ) /*---------------- TI CCS Compiler ------------------*/ |
bogdanm | 64:e3affc9e7238 | 316 | /* TI CCS specific functions */ |
bogdanm | 64:e3affc9e7238 | 317 | |
bogdanm | 64:e3affc9e7238 | 318 | #include <cmsis_ccs.h> |
bogdanm | 64:e3affc9e7238 | 319 | |
bogdanm | 64:e3affc9e7238 | 320 | |
bogdanm | 64:e3affc9e7238 | 321 | #elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/ |
bogdanm | 64:e3affc9e7238 | 322 | /* GNU gcc specific functions */ |
bogdanm | 64:e3affc9e7238 | 323 | |
bogdanm | 64:e3affc9e7238 | 324 | /** \brief Enable IRQ Interrupts |
bogdanm | 64:e3affc9e7238 | 325 | |
bogdanm | 64:e3affc9e7238 | 326 | This function enables IRQ interrupts by clearing the I-bit in the CPSR. |
bogdanm | 64:e3affc9e7238 | 327 | Can only be executed in Privileged modes. |
bogdanm | 64:e3affc9e7238 | 328 | */ |
bogdanm | 64:e3affc9e7238 | 329 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_irq(void) |
bogdanm | 64:e3affc9e7238 | 330 | { |
bogdanm | 64:e3affc9e7238 | 331 | __ASM volatile ("cpsie i" : : : "memory"); |
bogdanm | 64:e3affc9e7238 | 332 | } |
bogdanm | 64:e3affc9e7238 | 333 | |
bogdanm | 64:e3affc9e7238 | 334 | |
bogdanm | 64:e3affc9e7238 | 335 | /** \brief Disable IRQ Interrupts |
bogdanm | 64:e3affc9e7238 | 336 | |
bogdanm | 64:e3affc9e7238 | 337 | This function disables IRQ interrupts by setting the I-bit in the CPSR. |
bogdanm | 64:e3affc9e7238 | 338 | Can only be executed in Privileged modes. |
bogdanm | 64:e3affc9e7238 | 339 | */ |
bogdanm | 64:e3affc9e7238 | 340 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_irq(void) |
bogdanm | 64:e3affc9e7238 | 341 | { |
bogdanm | 64:e3affc9e7238 | 342 | __ASM volatile ("cpsid i" : : : "memory"); |
bogdanm | 64:e3affc9e7238 | 343 | } |
bogdanm | 64:e3affc9e7238 | 344 | |
bogdanm | 64:e3affc9e7238 | 345 | |
bogdanm | 64:e3affc9e7238 | 346 | /** \brief Get Control Register |
bogdanm | 64:e3affc9e7238 | 347 | |
bogdanm | 64:e3affc9e7238 | 348 | This function returns the content of the Control Register. |
bogdanm | 64:e3affc9e7238 | 349 | |
bogdanm | 64:e3affc9e7238 | 350 | \return Control Register value |
bogdanm | 64:e3affc9e7238 | 351 | */ |
bogdanm | 64:e3affc9e7238 | 352 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_CONTROL(void) |
bogdanm | 64:e3affc9e7238 | 353 | { |
bogdanm | 64:e3affc9e7238 | 354 | uint32_t result; |
bogdanm | 64:e3affc9e7238 | 355 | |
bogdanm | 64:e3affc9e7238 | 356 | __ASM volatile ("MRS %0, control" : "=r" (result) ); |
bogdanm | 64:e3affc9e7238 | 357 | return(result); |
bogdanm | 64:e3affc9e7238 | 358 | } |
bogdanm | 64:e3affc9e7238 | 359 | |
bogdanm | 64:e3affc9e7238 | 360 | |
bogdanm | 64:e3affc9e7238 | 361 | /** \brief Set Control Register |
bogdanm | 64:e3affc9e7238 | 362 | |
bogdanm | 64:e3affc9e7238 | 363 | This function writes the given value to the Control Register. |
bogdanm | 64:e3affc9e7238 | 364 | |
bogdanm | 64:e3affc9e7238 | 365 | \param [in] control Control Register value to set |
bogdanm | 64:e3affc9e7238 | 366 | */ |
bogdanm | 64:e3affc9e7238 | 367 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_CONTROL(uint32_t control) |
bogdanm | 64:e3affc9e7238 | 368 | { |
bogdanm | 64:e3affc9e7238 | 369 | __ASM volatile ("MSR control, %0" : : "r" (control) : "memory"); |
bogdanm | 64:e3affc9e7238 | 370 | } |
bogdanm | 64:e3affc9e7238 | 371 | |
bogdanm | 64:e3affc9e7238 | 372 | |
bogdanm | 64:e3affc9e7238 | 373 | /** \brief Get IPSR Register |
bogdanm | 64:e3affc9e7238 | 374 | |
bogdanm | 64:e3affc9e7238 | 375 | This function returns the content of the IPSR Register. |
bogdanm | 64:e3affc9e7238 | 376 | |
bogdanm | 64:e3affc9e7238 | 377 | \return IPSR Register value |
bogdanm | 64:e3affc9e7238 | 378 | */ |
bogdanm | 64:e3affc9e7238 | 379 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_IPSR(void) |
bogdanm | 64:e3affc9e7238 | 380 | { |
bogdanm | 64:e3affc9e7238 | 381 | uint32_t result; |
bogdanm | 64:e3affc9e7238 | 382 | |
bogdanm | 64:e3affc9e7238 | 383 | __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); |
bogdanm | 64:e3affc9e7238 | 384 | return(result); |
bogdanm | 64:e3affc9e7238 | 385 | } |
bogdanm | 64:e3affc9e7238 | 386 | |
bogdanm | 64:e3affc9e7238 | 387 | |
bogdanm | 64:e3affc9e7238 | 388 | /** \brief Get APSR Register |
bogdanm | 64:e3affc9e7238 | 389 | |
bogdanm | 64:e3affc9e7238 | 390 | This function returns the content of the APSR Register. |
bogdanm | 64:e3affc9e7238 | 391 | |
bogdanm | 64:e3affc9e7238 | 392 | \return APSR Register value |
bogdanm | 64:e3affc9e7238 | 393 | */ |
bogdanm | 64:e3affc9e7238 | 394 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_APSR(void) |
bogdanm | 64:e3affc9e7238 | 395 | { |
bogdanm | 64:e3affc9e7238 | 396 | uint32_t result; |
bogdanm | 64:e3affc9e7238 | 397 | |
bogdanm | 64:e3affc9e7238 | 398 | __ASM volatile ("MRS %0, apsr" : "=r" (result) ); |
bogdanm | 64:e3affc9e7238 | 399 | return(result); |
bogdanm | 64:e3affc9e7238 | 400 | } |
bogdanm | 64:e3affc9e7238 | 401 | |
bogdanm | 64:e3affc9e7238 | 402 | |
bogdanm | 64:e3affc9e7238 | 403 | /** \brief Get xPSR Register |
bogdanm | 64:e3affc9e7238 | 404 | |
bogdanm | 64:e3affc9e7238 | 405 | This function returns the content of the xPSR Register. |
bogdanm | 64:e3affc9e7238 | 406 | |
bogdanm | 64:e3affc9e7238 | 407 | \return xPSR Register value |
bogdanm | 64:e3affc9e7238 | 408 | */ |
bogdanm | 64:e3affc9e7238 | 409 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_xPSR(void) |
bogdanm | 64:e3affc9e7238 | 410 | { |
bogdanm | 64:e3affc9e7238 | 411 | uint32_t result; |
bogdanm | 64:e3affc9e7238 | 412 | |
bogdanm | 64:e3affc9e7238 | 413 | __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); |
bogdanm | 64:e3affc9e7238 | 414 | return(result); |
bogdanm | 64:e3affc9e7238 | 415 | } |
bogdanm | 64:e3affc9e7238 | 416 | |
bogdanm | 64:e3affc9e7238 | 417 | |
bogdanm | 64:e3affc9e7238 | 418 | /** \brief Get Process Stack Pointer |
bogdanm | 64:e3affc9e7238 | 419 | |
bogdanm | 64:e3affc9e7238 | 420 | This function returns the current value of the Process Stack Pointer (PSP). |
bogdanm | 64:e3affc9e7238 | 421 | |
bogdanm | 64:e3affc9e7238 | 422 | \return PSP Register value |
bogdanm | 64:e3affc9e7238 | 423 | */ |
bogdanm | 64:e3affc9e7238 | 424 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PSP(void) |
bogdanm | 64:e3affc9e7238 | 425 | { |
bogdanm | 64:e3affc9e7238 | 426 | register uint32_t result; |
bogdanm | 64:e3affc9e7238 | 427 | |
bogdanm | 64:e3affc9e7238 | 428 | __ASM volatile ("MRS %0, psp\n" : "=r" (result) ); |
bogdanm | 64:e3affc9e7238 | 429 | return(result); |
bogdanm | 64:e3affc9e7238 | 430 | } |
bogdanm | 64:e3affc9e7238 | 431 | |
bogdanm | 64:e3affc9e7238 | 432 | |
bogdanm | 64:e3affc9e7238 | 433 | /** \brief Set Process Stack Pointer |
bogdanm | 64:e3affc9e7238 | 434 | |
bogdanm | 64:e3affc9e7238 | 435 | This function assigns the given value to the Process Stack Pointer (PSP). |
bogdanm | 64:e3affc9e7238 | 436 | |
bogdanm | 64:e3affc9e7238 | 437 | \param [in] topOfProcStack Process Stack Pointer value to set |
bogdanm | 64:e3affc9e7238 | 438 | */ |
bogdanm | 64:e3affc9e7238 | 439 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PSP(uint32_t topOfProcStack) |
bogdanm | 64:e3affc9e7238 | 440 | { |
bogdanm | 64:e3affc9e7238 | 441 | __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) : "sp"); |
bogdanm | 64:e3affc9e7238 | 442 | } |
bogdanm | 64:e3affc9e7238 | 443 | |
bogdanm | 64:e3affc9e7238 | 444 | |
bogdanm | 64:e3affc9e7238 | 445 | /** \brief Get Main Stack Pointer |
bogdanm | 64:e3affc9e7238 | 446 | |
bogdanm | 64:e3affc9e7238 | 447 | This function returns the current value of the Main Stack Pointer (MSP). |
bogdanm | 64:e3affc9e7238 | 448 | |
bogdanm | 64:e3affc9e7238 | 449 | \return MSP Register value |
bogdanm | 64:e3affc9e7238 | 450 | */ |
bogdanm | 64:e3affc9e7238 | 451 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_MSP(void) |
bogdanm | 64:e3affc9e7238 | 452 | { |
bogdanm | 64:e3affc9e7238 | 453 | register uint32_t result; |
bogdanm | 64:e3affc9e7238 | 454 | |
bogdanm | 64:e3affc9e7238 | 455 | __ASM volatile ("MRS %0, msp\n" : "=r" (result) ); |
bogdanm | 64:e3affc9e7238 | 456 | return(result); |
bogdanm | 64:e3affc9e7238 | 457 | } |
bogdanm | 64:e3affc9e7238 | 458 | |
bogdanm | 64:e3affc9e7238 | 459 | |
bogdanm | 64:e3affc9e7238 | 460 | /** \brief Set Main Stack Pointer |
bogdanm | 64:e3affc9e7238 | 461 | |
bogdanm | 64:e3affc9e7238 | 462 | This function assigns the given value to the Main Stack Pointer (MSP). |
bogdanm | 64:e3affc9e7238 | 463 | |
bogdanm | 64:e3affc9e7238 | 464 | \param [in] topOfMainStack Main Stack Pointer value to set |
bogdanm | 64:e3affc9e7238 | 465 | */ |
bogdanm | 64:e3affc9e7238 | 466 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_MSP(uint32_t topOfMainStack) |
bogdanm | 64:e3affc9e7238 | 467 | { |
bogdanm | 64:e3affc9e7238 | 468 | __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) : "sp"); |
bogdanm | 64:e3affc9e7238 | 469 | } |
bogdanm | 64:e3affc9e7238 | 470 | |
bogdanm | 64:e3affc9e7238 | 471 | |
bogdanm | 64:e3affc9e7238 | 472 | /** \brief Get Priority Mask |
bogdanm | 64:e3affc9e7238 | 473 | |
bogdanm | 64:e3affc9e7238 | 474 | This function returns the current state of the priority mask bit from the Priority Mask Register. |
bogdanm | 64:e3affc9e7238 | 475 | |
bogdanm | 64:e3affc9e7238 | 476 | \return Priority Mask value |
bogdanm | 64:e3affc9e7238 | 477 | */ |
bogdanm | 64:e3affc9e7238 | 478 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_PRIMASK(void) |
bogdanm | 64:e3affc9e7238 | 479 | { |
bogdanm | 64:e3affc9e7238 | 480 | uint32_t result; |
bogdanm | 64:e3affc9e7238 | 481 | |
bogdanm | 64:e3affc9e7238 | 482 | __ASM volatile ("MRS %0, primask" : "=r" (result) ); |
bogdanm | 64:e3affc9e7238 | 483 | return(result); |
bogdanm | 64:e3affc9e7238 | 484 | } |
bogdanm | 64:e3affc9e7238 | 485 | |
bogdanm | 64:e3affc9e7238 | 486 | |
bogdanm | 64:e3affc9e7238 | 487 | /** \brief Set Priority Mask |
bogdanm | 64:e3affc9e7238 | 488 | |
bogdanm | 64:e3affc9e7238 | 489 | This function assigns the given value to the Priority Mask Register. |
bogdanm | 64:e3affc9e7238 | 490 | |
bogdanm | 64:e3affc9e7238 | 491 | \param [in] priMask Priority Mask |
bogdanm | 64:e3affc9e7238 | 492 | */ |
bogdanm | 64:e3affc9e7238 | 493 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_PRIMASK(uint32_t priMask) |
bogdanm | 64:e3affc9e7238 | 494 | { |
bogdanm | 64:e3affc9e7238 | 495 | __ASM volatile ("MSR primask, %0" : : "r" (priMask) : "memory"); |
bogdanm | 64:e3affc9e7238 | 496 | } |
bogdanm | 64:e3affc9e7238 | 497 | |
bogdanm | 64:e3affc9e7238 | 498 | |
bogdanm | 64:e3affc9e7238 | 499 | #if (__CORTEX_M >= 0x03) |
bogdanm | 64:e3affc9e7238 | 500 | |
bogdanm | 64:e3affc9e7238 | 501 | /** \brief Enable FIQ |
bogdanm | 64:e3affc9e7238 | 502 | |
bogdanm | 64:e3affc9e7238 | 503 | This function enables FIQ interrupts by clearing the F-bit in the CPSR. |
bogdanm | 64:e3affc9e7238 | 504 | Can only be executed in Privileged modes. |
bogdanm | 64:e3affc9e7238 | 505 | */ |
bogdanm | 64:e3affc9e7238 | 506 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __enable_fault_irq(void) |
bogdanm | 64:e3affc9e7238 | 507 | { |
bogdanm | 64:e3affc9e7238 | 508 | __ASM volatile ("cpsie f" : : : "memory"); |
bogdanm | 64:e3affc9e7238 | 509 | } |
bogdanm | 64:e3affc9e7238 | 510 | |
bogdanm | 64:e3affc9e7238 | 511 | |
bogdanm | 64:e3affc9e7238 | 512 | /** \brief Disable FIQ |
bogdanm | 64:e3affc9e7238 | 513 | |
bogdanm | 64:e3affc9e7238 | 514 | This function disables FIQ interrupts by setting the F-bit in the CPSR. |
bogdanm | 64:e3affc9e7238 | 515 | Can only be executed in Privileged modes. |
bogdanm | 64:e3affc9e7238 | 516 | */ |
bogdanm | 64:e3affc9e7238 | 517 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __disable_fault_irq(void) |
bogdanm | 64:e3affc9e7238 | 518 | { |
bogdanm | 64:e3affc9e7238 | 519 | __ASM volatile ("cpsid f" : : : "memory"); |
bogdanm | 64:e3affc9e7238 | 520 | } |
bogdanm | 64:e3affc9e7238 | 521 | |
bogdanm | 64:e3affc9e7238 | 522 | |
bogdanm | 64:e3affc9e7238 | 523 | /** \brief Get Base Priority |
bogdanm | 64:e3affc9e7238 | 524 | |
bogdanm | 64:e3affc9e7238 | 525 | This function returns the current value of the Base Priority register. |
bogdanm | 64:e3affc9e7238 | 526 | |
bogdanm | 64:e3affc9e7238 | 527 | \return Base Priority register value |
bogdanm | 64:e3affc9e7238 | 528 | */ |
bogdanm | 64:e3affc9e7238 | 529 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_BASEPRI(void) |
bogdanm | 64:e3affc9e7238 | 530 | { |
bogdanm | 64:e3affc9e7238 | 531 | uint32_t result; |
bogdanm | 64:e3affc9e7238 | 532 | |
bogdanm | 64:e3affc9e7238 | 533 | __ASM volatile ("MRS %0, basepri_max" : "=r" (result) ); |
bogdanm | 64:e3affc9e7238 | 534 | return(result); |
bogdanm | 64:e3affc9e7238 | 535 | } |
bogdanm | 64:e3affc9e7238 | 536 | |
bogdanm | 64:e3affc9e7238 | 537 | |
bogdanm | 64:e3affc9e7238 | 538 | /** \brief Set Base Priority |
bogdanm | 64:e3affc9e7238 | 539 | |
bogdanm | 64:e3affc9e7238 | 540 | This function assigns the given value to the Base Priority register. |
bogdanm | 64:e3affc9e7238 | 541 | |
bogdanm | 64:e3affc9e7238 | 542 | \param [in] basePri Base Priority value to set |
bogdanm | 64:e3affc9e7238 | 543 | */ |
bogdanm | 64:e3affc9e7238 | 544 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_BASEPRI(uint32_t value) |
bogdanm | 64:e3affc9e7238 | 545 | { |
bogdanm | 64:e3affc9e7238 | 546 | __ASM volatile ("MSR basepri, %0" : : "r" (value) : "memory"); |
bogdanm | 64:e3affc9e7238 | 547 | } |
bogdanm | 64:e3affc9e7238 | 548 | |
bogdanm | 64:e3affc9e7238 | 549 | |
bogdanm | 64:e3affc9e7238 | 550 | /** \brief Get Fault Mask |
bogdanm | 64:e3affc9e7238 | 551 | |
bogdanm | 64:e3affc9e7238 | 552 | This function returns the current value of the Fault Mask register. |
bogdanm | 64:e3affc9e7238 | 553 | |
bogdanm | 64:e3affc9e7238 | 554 | \return Fault Mask register value |
bogdanm | 64:e3affc9e7238 | 555 | */ |
bogdanm | 64:e3affc9e7238 | 556 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FAULTMASK(void) |
bogdanm | 64:e3affc9e7238 | 557 | { |
bogdanm | 64:e3affc9e7238 | 558 | uint32_t result; |
bogdanm | 64:e3affc9e7238 | 559 | |
bogdanm | 64:e3affc9e7238 | 560 | __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); |
bogdanm | 64:e3affc9e7238 | 561 | return(result); |
bogdanm | 64:e3affc9e7238 | 562 | } |
bogdanm | 64:e3affc9e7238 | 563 | |
bogdanm | 64:e3affc9e7238 | 564 | |
bogdanm | 64:e3affc9e7238 | 565 | /** \brief Set Fault Mask |
bogdanm | 64:e3affc9e7238 | 566 | |
bogdanm | 64:e3affc9e7238 | 567 | This function assigns the given value to the Fault Mask register. |
bogdanm | 64:e3affc9e7238 | 568 | |
bogdanm | 64:e3affc9e7238 | 569 | \param [in] faultMask Fault Mask value to set |
bogdanm | 64:e3affc9e7238 | 570 | */ |
bogdanm | 64:e3affc9e7238 | 571 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask) |
bogdanm | 64:e3affc9e7238 | 572 | { |
bogdanm | 64:e3affc9e7238 | 573 | __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) : "memory"); |
bogdanm | 64:e3affc9e7238 | 574 | } |
bogdanm | 64:e3affc9e7238 | 575 | |
bogdanm | 64:e3affc9e7238 | 576 | #endif /* (__CORTEX_M >= 0x03) */ |
bogdanm | 64:e3affc9e7238 | 577 | |
bogdanm | 64:e3affc9e7238 | 578 | |
bogdanm | 64:e3affc9e7238 | 579 | #if (__CORTEX_M == 0x04) |
bogdanm | 64:e3affc9e7238 | 580 | |
bogdanm | 64:e3affc9e7238 | 581 | /** \brief Get FPSCR |
bogdanm | 64:e3affc9e7238 | 582 | |
bogdanm | 64:e3affc9e7238 | 583 | This function returns the current value of the Floating Point Status/Control register. |
bogdanm | 64:e3affc9e7238 | 584 | |
bogdanm | 64:e3affc9e7238 | 585 | \return Floating Point Status/Control register value |
bogdanm | 64:e3affc9e7238 | 586 | */ |
bogdanm | 64:e3affc9e7238 | 587 | __attribute__( ( always_inline ) ) __STATIC_INLINE uint32_t __get_FPSCR(void) |
bogdanm | 64:e3affc9e7238 | 588 | { |
bogdanm | 64:e3affc9e7238 | 589 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) |
bogdanm | 64:e3affc9e7238 | 590 | uint32_t result; |
bogdanm | 64:e3affc9e7238 | 591 | |
bogdanm | 64:e3affc9e7238 | 592 | /* Empty asm statement works as a scheduling barrier */ |
bogdanm | 64:e3affc9e7238 | 593 | __ASM volatile (""); |
bogdanm | 64:e3affc9e7238 | 594 | __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); |
bogdanm | 64:e3affc9e7238 | 595 | __ASM volatile (""); |
bogdanm | 64:e3affc9e7238 | 596 | return(result); |
bogdanm | 64:e3affc9e7238 | 597 | #else |
bogdanm | 64:e3affc9e7238 | 598 | return(0); |
bogdanm | 64:e3affc9e7238 | 599 | #endif |
bogdanm | 64:e3affc9e7238 | 600 | } |
bogdanm | 64:e3affc9e7238 | 601 | |
bogdanm | 64:e3affc9e7238 | 602 | |
bogdanm | 64:e3affc9e7238 | 603 | /** \brief Set FPSCR |
bogdanm | 64:e3affc9e7238 | 604 | |
bogdanm | 64:e3affc9e7238 | 605 | This function assigns the given value to the Floating Point Status/Control register. |
bogdanm | 64:e3affc9e7238 | 606 | |
bogdanm | 64:e3affc9e7238 | 607 | \param [in] fpscr Floating Point Status/Control value to set |
bogdanm | 64:e3affc9e7238 | 608 | */ |
bogdanm | 64:e3affc9e7238 | 609 | __attribute__( ( always_inline ) ) __STATIC_INLINE void __set_FPSCR(uint32_t fpscr) |
bogdanm | 64:e3affc9e7238 | 610 | { |
bogdanm | 64:e3affc9e7238 | 611 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) |
bogdanm | 64:e3affc9e7238 | 612 | /* Empty asm statement works as a scheduling barrier */ |
bogdanm | 64:e3affc9e7238 | 613 | __ASM volatile (""); |
bogdanm | 64:e3affc9e7238 | 614 | __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) : "vfpcc"); |
bogdanm | 64:e3affc9e7238 | 615 | __ASM volatile (""); |
bogdanm | 64:e3affc9e7238 | 616 | #endif |
bogdanm | 64:e3affc9e7238 | 617 | } |
bogdanm | 64:e3affc9e7238 | 618 | |
bogdanm | 64:e3affc9e7238 | 619 | #endif /* (__CORTEX_M == 0x04) */ |
bogdanm | 64:e3affc9e7238 | 620 | |
bogdanm | 64:e3affc9e7238 | 621 | |
bogdanm | 64:e3affc9e7238 | 622 | #elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/ |
bogdanm | 64:e3affc9e7238 | 623 | /* TASKING carm specific functions */ |
bogdanm | 64:e3affc9e7238 | 624 | |
bogdanm | 64:e3affc9e7238 | 625 | /* |
bogdanm | 64:e3affc9e7238 | 626 | * The CMSIS functions have been implemented as intrinsics in the compiler. |
bogdanm | 64:e3affc9e7238 | 627 | * Please use "carm -?i" to get an up to date list of all instrinsics, |
bogdanm | 64:e3affc9e7238 | 628 | * Including the CMSIS ones. |
bogdanm | 64:e3affc9e7238 | 629 | */ |
bogdanm | 64:e3affc9e7238 | 630 | |
bogdanm | 64:e3affc9e7238 | 631 | #endif |
bogdanm | 64:e3affc9e7238 | 632 | |
bogdanm | 64:e3affc9e7238 | 633 | /*@} end of CMSIS_Core_RegAccFunctions */ |
bogdanm | 64:e3affc9e7238 | 634 | |
bogdanm | 64:e3affc9e7238 | 635 | |
bogdanm | 64:e3affc9e7238 | 636 | #endif /* __CORE_CMFUNC_H */ |