mouvement AX12 petit robot version 2
Fork of command_AX12_petit_robot_v2 by
mbed/LPC1768/core_cmFunc.h@2:99b1cb0d9f5e, 2017-04-18 (annotated)
- Committer:
- SquirrelGod
- Date:
- Tue Apr 18 16:02:40 2017 +0000
- Revision:
- 2:99b1cb0d9f5e
AX12_control
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
SquirrelGod | 2:99b1cb0d9f5e | 1 | /**************************************************************************//** |
SquirrelGod | 2:99b1cb0d9f5e | 2 | * @file core_cmFunc.h |
SquirrelGod | 2:99b1cb0d9f5e | 3 | * @brief CMSIS Cortex-M Core Function Access Header File |
SquirrelGod | 2:99b1cb0d9f5e | 4 | * @version V3.00 |
SquirrelGod | 2:99b1cb0d9f5e | 5 | * @date 09. December 2011 |
SquirrelGod | 2:99b1cb0d9f5e | 6 | * |
SquirrelGod | 2:99b1cb0d9f5e | 7 | * @note |
SquirrelGod | 2:99b1cb0d9f5e | 8 | * Copyright (C) 2009-2011 ARM Limited. All rights reserved. |
SquirrelGod | 2:99b1cb0d9f5e | 9 | * |
SquirrelGod | 2:99b1cb0d9f5e | 10 | * @par |
SquirrelGod | 2:99b1cb0d9f5e | 11 | * ARM Limited (ARM) is supplying this software for use with Cortex-M |
SquirrelGod | 2:99b1cb0d9f5e | 12 | * processor based microcontrollers. This file can be freely distributed |
SquirrelGod | 2:99b1cb0d9f5e | 13 | * within development tools that are supporting such ARM based processors. |
SquirrelGod | 2:99b1cb0d9f5e | 14 | * |
SquirrelGod | 2:99b1cb0d9f5e | 15 | * @par |
SquirrelGod | 2:99b1cb0d9f5e | 16 | * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED |
SquirrelGod | 2:99b1cb0d9f5e | 17 | * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF |
SquirrelGod | 2:99b1cb0d9f5e | 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. |
SquirrelGod | 2:99b1cb0d9f5e | 19 | * ARM SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR |
SquirrelGod | 2:99b1cb0d9f5e | 20 | * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER. |
SquirrelGod | 2:99b1cb0d9f5e | 21 | * |
SquirrelGod | 2:99b1cb0d9f5e | 22 | ******************************************************************************/ |
SquirrelGod | 2:99b1cb0d9f5e | 23 | |
SquirrelGod | 2:99b1cb0d9f5e | 24 | #ifndef __CORE_CMFUNC_H |
SquirrelGod | 2:99b1cb0d9f5e | 25 | #define __CORE_CMFUNC_H |
SquirrelGod | 2:99b1cb0d9f5e | 26 | |
SquirrelGod | 2:99b1cb0d9f5e | 27 | |
SquirrelGod | 2:99b1cb0d9f5e | 28 | /* ########################### Core Function Access ########################### */ |
SquirrelGod | 2:99b1cb0d9f5e | 29 | /** \ingroup CMSIS_Core_FunctionInterface |
SquirrelGod | 2:99b1cb0d9f5e | 30 | \defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions |
SquirrelGod | 2:99b1cb0d9f5e | 31 | @{ |
SquirrelGod | 2:99b1cb0d9f5e | 32 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 33 | |
SquirrelGod | 2:99b1cb0d9f5e | 34 | #if defined ( __CC_ARM ) /*------------------RealView Compiler -----------------*/ |
SquirrelGod | 2:99b1cb0d9f5e | 35 | /* ARM armcc specific functions */ |
SquirrelGod | 2:99b1cb0d9f5e | 36 | |
SquirrelGod | 2:99b1cb0d9f5e | 37 | #if (__ARMCC_VERSION < 400677) |
SquirrelGod | 2:99b1cb0d9f5e | 38 | #error "Please use ARM Compiler Toolchain V4.0.677 or later!" |
SquirrelGod | 2:99b1cb0d9f5e | 39 | #endif |
SquirrelGod | 2:99b1cb0d9f5e | 40 | |
SquirrelGod | 2:99b1cb0d9f5e | 41 | /* intrinsic void __enable_irq(); */ |
SquirrelGod | 2:99b1cb0d9f5e | 42 | /* intrinsic void __disable_irq(); */ |
SquirrelGod | 2:99b1cb0d9f5e | 43 | |
SquirrelGod | 2:99b1cb0d9f5e | 44 | /** \brief Get Control Register |
SquirrelGod | 2:99b1cb0d9f5e | 45 | |
SquirrelGod | 2:99b1cb0d9f5e | 46 | This function returns the content of the Control Register. |
SquirrelGod | 2:99b1cb0d9f5e | 47 | |
SquirrelGod | 2:99b1cb0d9f5e | 48 | \return Control Register value |
SquirrelGod | 2:99b1cb0d9f5e | 49 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 50 | static __INLINE uint32_t __get_CONTROL(void) |
SquirrelGod | 2:99b1cb0d9f5e | 51 | { |
SquirrelGod | 2:99b1cb0d9f5e | 52 | register uint32_t __regControl __ASM("control"); |
SquirrelGod | 2:99b1cb0d9f5e | 53 | return(__regControl); |
SquirrelGod | 2:99b1cb0d9f5e | 54 | } |
SquirrelGod | 2:99b1cb0d9f5e | 55 | |
SquirrelGod | 2:99b1cb0d9f5e | 56 | |
SquirrelGod | 2:99b1cb0d9f5e | 57 | /** \brief Set Control Register |
SquirrelGod | 2:99b1cb0d9f5e | 58 | |
SquirrelGod | 2:99b1cb0d9f5e | 59 | This function writes the given value to the Control Register. |
SquirrelGod | 2:99b1cb0d9f5e | 60 | |
SquirrelGod | 2:99b1cb0d9f5e | 61 | \param [in] control Control Register value to set |
SquirrelGod | 2:99b1cb0d9f5e | 62 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 63 | static __INLINE void __set_CONTROL(uint32_t control) |
SquirrelGod | 2:99b1cb0d9f5e | 64 | { |
SquirrelGod | 2:99b1cb0d9f5e | 65 | register uint32_t __regControl __ASM("control"); |
SquirrelGod | 2:99b1cb0d9f5e | 66 | __regControl = control; |
SquirrelGod | 2:99b1cb0d9f5e | 67 | } |
SquirrelGod | 2:99b1cb0d9f5e | 68 | |
SquirrelGod | 2:99b1cb0d9f5e | 69 | |
SquirrelGod | 2:99b1cb0d9f5e | 70 | /** \brief Get IPSR Register |
SquirrelGod | 2:99b1cb0d9f5e | 71 | |
SquirrelGod | 2:99b1cb0d9f5e | 72 | This function returns the content of the IPSR Register. |
SquirrelGod | 2:99b1cb0d9f5e | 73 | |
SquirrelGod | 2:99b1cb0d9f5e | 74 | \return IPSR Register value |
SquirrelGod | 2:99b1cb0d9f5e | 75 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 76 | static __INLINE uint32_t __get_IPSR(void) |
SquirrelGod | 2:99b1cb0d9f5e | 77 | { |
SquirrelGod | 2:99b1cb0d9f5e | 78 | register uint32_t __regIPSR __ASM("ipsr"); |
SquirrelGod | 2:99b1cb0d9f5e | 79 | return(__regIPSR); |
SquirrelGod | 2:99b1cb0d9f5e | 80 | } |
SquirrelGod | 2:99b1cb0d9f5e | 81 | |
SquirrelGod | 2:99b1cb0d9f5e | 82 | |
SquirrelGod | 2:99b1cb0d9f5e | 83 | /** \brief Get APSR Register |
SquirrelGod | 2:99b1cb0d9f5e | 84 | |
SquirrelGod | 2:99b1cb0d9f5e | 85 | This function returns the content of the APSR Register. |
SquirrelGod | 2:99b1cb0d9f5e | 86 | |
SquirrelGod | 2:99b1cb0d9f5e | 87 | \return APSR Register value |
SquirrelGod | 2:99b1cb0d9f5e | 88 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 89 | static __INLINE uint32_t __get_APSR(void) |
SquirrelGod | 2:99b1cb0d9f5e | 90 | { |
SquirrelGod | 2:99b1cb0d9f5e | 91 | register uint32_t __regAPSR __ASM("apsr"); |
SquirrelGod | 2:99b1cb0d9f5e | 92 | return(__regAPSR); |
SquirrelGod | 2:99b1cb0d9f5e | 93 | } |
SquirrelGod | 2:99b1cb0d9f5e | 94 | |
SquirrelGod | 2:99b1cb0d9f5e | 95 | |
SquirrelGod | 2:99b1cb0d9f5e | 96 | /** \brief Get xPSR Register |
SquirrelGod | 2:99b1cb0d9f5e | 97 | |
SquirrelGod | 2:99b1cb0d9f5e | 98 | This function returns the content of the xPSR Register. |
SquirrelGod | 2:99b1cb0d9f5e | 99 | |
SquirrelGod | 2:99b1cb0d9f5e | 100 | \return xPSR Register value |
SquirrelGod | 2:99b1cb0d9f5e | 101 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 102 | static __INLINE uint32_t __get_xPSR(void) |
SquirrelGod | 2:99b1cb0d9f5e | 103 | { |
SquirrelGod | 2:99b1cb0d9f5e | 104 | register uint32_t __regXPSR __ASM("xpsr"); |
SquirrelGod | 2:99b1cb0d9f5e | 105 | return(__regXPSR); |
SquirrelGod | 2:99b1cb0d9f5e | 106 | } |
SquirrelGod | 2:99b1cb0d9f5e | 107 | |
SquirrelGod | 2:99b1cb0d9f5e | 108 | |
SquirrelGod | 2:99b1cb0d9f5e | 109 | /** \brief Get Process Stack Pointer |
SquirrelGod | 2:99b1cb0d9f5e | 110 | |
SquirrelGod | 2:99b1cb0d9f5e | 111 | This function returns the current value of the Process Stack Pointer (PSP). |
SquirrelGod | 2:99b1cb0d9f5e | 112 | |
SquirrelGod | 2:99b1cb0d9f5e | 113 | \return PSP Register value |
SquirrelGod | 2:99b1cb0d9f5e | 114 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 115 | static __INLINE uint32_t __get_PSP(void) |
SquirrelGod | 2:99b1cb0d9f5e | 116 | { |
SquirrelGod | 2:99b1cb0d9f5e | 117 | register uint32_t __regProcessStackPointer __ASM("psp"); |
SquirrelGod | 2:99b1cb0d9f5e | 118 | return(__regProcessStackPointer); |
SquirrelGod | 2:99b1cb0d9f5e | 119 | } |
SquirrelGod | 2:99b1cb0d9f5e | 120 | |
SquirrelGod | 2:99b1cb0d9f5e | 121 | |
SquirrelGod | 2:99b1cb0d9f5e | 122 | /** \brief Set Process Stack Pointer |
SquirrelGod | 2:99b1cb0d9f5e | 123 | |
SquirrelGod | 2:99b1cb0d9f5e | 124 | This function assigns the given value to the Process Stack Pointer (PSP). |
SquirrelGod | 2:99b1cb0d9f5e | 125 | |
SquirrelGod | 2:99b1cb0d9f5e | 126 | \param [in] topOfProcStack Process Stack Pointer value to set |
SquirrelGod | 2:99b1cb0d9f5e | 127 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 128 | static __INLINE void __set_PSP(uint32_t topOfProcStack) |
SquirrelGod | 2:99b1cb0d9f5e | 129 | { |
SquirrelGod | 2:99b1cb0d9f5e | 130 | register uint32_t __regProcessStackPointer __ASM("psp"); |
SquirrelGod | 2:99b1cb0d9f5e | 131 | __regProcessStackPointer = topOfProcStack; |
SquirrelGod | 2:99b1cb0d9f5e | 132 | } |
SquirrelGod | 2:99b1cb0d9f5e | 133 | |
SquirrelGod | 2:99b1cb0d9f5e | 134 | |
SquirrelGod | 2:99b1cb0d9f5e | 135 | /** \brief Get Main Stack Pointer |
SquirrelGod | 2:99b1cb0d9f5e | 136 | |
SquirrelGod | 2:99b1cb0d9f5e | 137 | This function returns the current value of the Main Stack Pointer (MSP). |
SquirrelGod | 2:99b1cb0d9f5e | 138 | |
SquirrelGod | 2:99b1cb0d9f5e | 139 | \return MSP Register value |
SquirrelGod | 2:99b1cb0d9f5e | 140 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 141 | static __INLINE uint32_t __get_MSP(void) |
SquirrelGod | 2:99b1cb0d9f5e | 142 | { |
SquirrelGod | 2:99b1cb0d9f5e | 143 | register uint32_t __regMainStackPointer __ASM("msp"); |
SquirrelGod | 2:99b1cb0d9f5e | 144 | return(__regMainStackPointer); |
SquirrelGod | 2:99b1cb0d9f5e | 145 | } |
SquirrelGod | 2:99b1cb0d9f5e | 146 | |
SquirrelGod | 2:99b1cb0d9f5e | 147 | |
SquirrelGod | 2:99b1cb0d9f5e | 148 | /** \brief Set Main Stack Pointer |
SquirrelGod | 2:99b1cb0d9f5e | 149 | |
SquirrelGod | 2:99b1cb0d9f5e | 150 | This function assigns the given value to the Main Stack Pointer (MSP). |
SquirrelGod | 2:99b1cb0d9f5e | 151 | |
SquirrelGod | 2:99b1cb0d9f5e | 152 | \param [in] topOfMainStack Main Stack Pointer value to set |
SquirrelGod | 2:99b1cb0d9f5e | 153 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 154 | static __INLINE void __set_MSP(uint32_t topOfMainStack) |
SquirrelGod | 2:99b1cb0d9f5e | 155 | { |
SquirrelGod | 2:99b1cb0d9f5e | 156 | register uint32_t __regMainStackPointer __ASM("msp"); |
SquirrelGod | 2:99b1cb0d9f5e | 157 | __regMainStackPointer = topOfMainStack; |
SquirrelGod | 2:99b1cb0d9f5e | 158 | } |
SquirrelGod | 2:99b1cb0d9f5e | 159 | |
SquirrelGod | 2:99b1cb0d9f5e | 160 | |
SquirrelGod | 2:99b1cb0d9f5e | 161 | /** \brief Get Priority Mask |
SquirrelGod | 2:99b1cb0d9f5e | 162 | |
SquirrelGod | 2:99b1cb0d9f5e | 163 | This function returns the current state of the priority mask bit from the Priority Mask Register. |
SquirrelGod | 2:99b1cb0d9f5e | 164 | |
SquirrelGod | 2:99b1cb0d9f5e | 165 | \return Priority Mask value |
SquirrelGod | 2:99b1cb0d9f5e | 166 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 167 | static __INLINE uint32_t __get_PRIMASK(void) |
SquirrelGod | 2:99b1cb0d9f5e | 168 | { |
SquirrelGod | 2:99b1cb0d9f5e | 169 | register uint32_t __regPriMask __ASM("primask"); |
SquirrelGod | 2:99b1cb0d9f5e | 170 | return(__regPriMask); |
SquirrelGod | 2:99b1cb0d9f5e | 171 | } |
SquirrelGod | 2:99b1cb0d9f5e | 172 | |
SquirrelGod | 2:99b1cb0d9f5e | 173 | |
SquirrelGod | 2:99b1cb0d9f5e | 174 | /** \brief Set Priority Mask |
SquirrelGod | 2:99b1cb0d9f5e | 175 | |
SquirrelGod | 2:99b1cb0d9f5e | 176 | This function assigns the given value to the Priority Mask Register. |
SquirrelGod | 2:99b1cb0d9f5e | 177 | |
SquirrelGod | 2:99b1cb0d9f5e | 178 | \param [in] priMask Priority Mask |
SquirrelGod | 2:99b1cb0d9f5e | 179 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 180 | static __INLINE void __set_PRIMASK(uint32_t priMask) |
SquirrelGod | 2:99b1cb0d9f5e | 181 | { |
SquirrelGod | 2:99b1cb0d9f5e | 182 | register uint32_t __regPriMask __ASM("primask"); |
SquirrelGod | 2:99b1cb0d9f5e | 183 | __regPriMask = (priMask); |
SquirrelGod | 2:99b1cb0d9f5e | 184 | } |
SquirrelGod | 2:99b1cb0d9f5e | 185 | |
SquirrelGod | 2:99b1cb0d9f5e | 186 | |
SquirrelGod | 2:99b1cb0d9f5e | 187 | #if (__CORTEX_M >= 0x03) |
SquirrelGod | 2:99b1cb0d9f5e | 188 | |
SquirrelGod | 2:99b1cb0d9f5e | 189 | /** \brief Enable FIQ |
SquirrelGod | 2:99b1cb0d9f5e | 190 | |
SquirrelGod | 2:99b1cb0d9f5e | 191 | This function enables FIQ interrupts by clearing the F-bit in the CPSR. |
SquirrelGod | 2:99b1cb0d9f5e | 192 | Can only be executed in Privileged modes. |
SquirrelGod | 2:99b1cb0d9f5e | 193 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 194 | #define __enable_fault_irq __enable_fiq |
SquirrelGod | 2:99b1cb0d9f5e | 195 | |
SquirrelGod | 2:99b1cb0d9f5e | 196 | |
SquirrelGod | 2:99b1cb0d9f5e | 197 | /** \brief Disable FIQ |
SquirrelGod | 2:99b1cb0d9f5e | 198 | |
SquirrelGod | 2:99b1cb0d9f5e | 199 | This function disables FIQ interrupts by setting the F-bit in the CPSR. |
SquirrelGod | 2:99b1cb0d9f5e | 200 | Can only be executed in Privileged modes. |
SquirrelGod | 2:99b1cb0d9f5e | 201 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 202 | #define __disable_fault_irq __disable_fiq |
SquirrelGod | 2:99b1cb0d9f5e | 203 | |
SquirrelGod | 2:99b1cb0d9f5e | 204 | |
SquirrelGod | 2:99b1cb0d9f5e | 205 | /** \brief Get Base Priority |
SquirrelGod | 2:99b1cb0d9f5e | 206 | |
SquirrelGod | 2:99b1cb0d9f5e | 207 | This function returns the current value of the Base Priority register. |
SquirrelGod | 2:99b1cb0d9f5e | 208 | |
SquirrelGod | 2:99b1cb0d9f5e | 209 | \return Base Priority register value |
SquirrelGod | 2:99b1cb0d9f5e | 210 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 211 | static __INLINE uint32_t __get_BASEPRI(void) |
SquirrelGod | 2:99b1cb0d9f5e | 212 | { |
SquirrelGod | 2:99b1cb0d9f5e | 213 | register uint32_t __regBasePri __ASM("basepri"); |
SquirrelGod | 2:99b1cb0d9f5e | 214 | return(__regBasePri); |
SquirrelGod | 2:99b1cb0d9f5e | 215 | } |
SquirrelGod | 2:99b1cb0d9f5e | 216 | |
SquirrelGod | 2:99b1cb0d9f5e | 217 | |
SquirrelGod | 2:99b1cb0d9f5e | 218 | /** \brief Set Base Priority |
SquirrelGod | 2:99b1cb0d9f5e | 219 | |
SquirrelGod | 2:99b1cb0d9f5e | 220 | This function assigns the given value to the Base Priority register. |
SquirrelGod | 2:99b1cb0d9f5e | 221 | |
SquirrelGod | 2:99b1cb0d9f5e | 222 | \param [in] basePri Base Priority value to set |
SquirrelGod | 2:99b1cb0d9f5e | 223 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 224 | static __INLINE void __set_BASEPRI(uint32_t basePri) |
SquirrelGod | 2:99b1cb0d9f5e | 225 | { |
SquirrelGod | 2:99b1cb0d9f5e | 226 | register uint32_t __regBasePri __ASM("basepri"); |
SquirrelGod | 2:99b1cb0d9f5e | 227 | __regBasePri = (basePri & 0xff); |
SquirrelGod | 2:99b1cb0d9f5e | 228 | } |
SquirrelGod | 2:99b1cb0d9f5e | 229 | |
SquirrelGod | 2:99b1cb0d9f5e | 230 | |
SquirrelGod | 2:99b1cb0d9f5e | 231 | /** \brief Get Fault Mask |
SquirrelGod | 2:99b1cb0d9f5e | 232 | |
SquirrelGod | 2:99b1cb0d9f5e | 233 | This function returns the current value of the Fault Mask register. |
SquirrelGod | 2:99b1cb0d9f5e | 234 | |
SquirrelGod | 2:99b1cb0d9f5e | 235 | \return Fault Mask register value |
SquirrelGod | 2:99b1cb0d9f5e | 236 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 237 | static __INLINE uint32_t __get_FAULTMASK(void) |
SquirrelGod | 2:99b1cb0d9f5e | 238 | { |
SquirrelGod | 2:99b1cb0d9f5e | 239 | register uint32_t __regFaultMask __ASM("faultmask"); |
SquirrelGod | 2:99b1cb0d9f5e | 240 | return(__regFaultMask); |
SquirrelGod | 2:99b1cb0d9f5e | 241 | } |
SquirrelGod | 2:99b1cb0d9f5e | 242 | |
SquirrelGod | 2:99b1cb0d9f5e | 243 | |
SquirrelGod | 2:99b1cb0d9f5e | 244 | /** \brief Set Fault Mask |
SquirrelGod | 2:99b1cb0d9f5e | 245 | |
SquirrelGod | 2:99b1cb0d9f5e | 246 | This function assigns the given value to the Fault Mask register. |
SquirrelGod | 2:99b1cb0d9f5e | 247 | |
SquirrelGod | 2:99b1cb0d9f5e | 248 | \param [in] faultMask Fault Mask value to set |
SquirrelGod | 2:99b1cb0d9f5e | 249 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 250 | static __INLINE void __set_FAULTMASK(uint32_t faultMask) |
SquirrelGod | 2:99b1cb0d9f5e | 251 | { |
SquirrelGod | 2:99b1cb0d9f5e | 252 | register uint32_t __regFaultMask __ASM("faultmask"); |
SquirrelGod | 2:99b1cb0d9f5e | 253 | __regFaultMask = (faultMask & (uint32_t)1); |
SquirrelGod | 2:99b1cb0d9f5e | 254 | } |
SquirrelGod | 2:99b1cb0d9f5e | 255 | |
SquirrelGod | 2:99b1cb0d9f5e | 256 | #endif /* (__CORTEX_M >= 0x03) */ |
SquirrelGod | 2:99b1cb0d9f5e | 257 | |
SquirrelGod | 2:99b1cb0d9f5e | 258 | |
SquirrelGod | 2:99b1cb0d9f5e | 259 | #if (__CORTEX_M == 0x04) |
SquirrelGod | 2:99b1cb0d9f5e | 260 | |
SquirrelGod | 2:99b1cb0d9f5e | 261 | /** \brief Get FPSCR |
SquirrelGod | 2:99b1cb0d9f5e | 262 | |
SquirrelGod | 2:99b1cb0d9f5e | 263 | This function returns the current value of the Floating Point Status/Control register. |
SquirrelGod | 2:99b1cb0d9f5e | 264 | |
SquirrelGod | 2:99b1cb0d9f5e | 265 | \return Floating Point Status/Control register value |
SquirrelGod | 2:99b1cb0d9f5e | 266 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 267 | static __INLINE uint32_t __get_FPSCR(void) |
SquirrelGod | 2:99b1cb0d9f5e | 268 | { |
SquirrelGod | 2:99b1cb0d9f5e | 269 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) |
SquirrelGod | 2:99b1cb0d9f5e | 270 | register uint32_t __regfpscr __ASM("fpscr"); |
SquirrelGod | 2:99b1cb0d9f5e | 271 | return(__regfpscr); |
SquirrelGod | 2:99b1cb0d9f5e | 272 | #else |
SquirrelGod | 2:99b1cb0d9f5e | 273 | return(0); |
SquirrelGod | 2:99b1cb0d9f5e | 274 | #endif |
SquirrelGod | 2:99b1cb0d9f5e | 275 | } |
SquirrelGod | 2:99b1cb0d9f5e | 276 | |
SquirrelGod | 2:99b1cb0d9f5e | 277 | |
SquirrelGod | 2:99b1cb0d9f5e | 278 | /** \brief Set FPSCR |
SquirrelGod | 2:99b1cb0d9f5e | 279 | |
SquirrelGod | 2:99b1cb0d9f5e | 280 | This function assigns the given value to the Floating Point Status/Control register. |
SquirrelGod | 2:99b1cb0d9f5e | 281 | |
SquirrelGod | 2:99b1cb0d9f5e | 282 | \param [in] fpscr Floating Point Status/Control value to set |
SquirrelGod | 2:99b1cb0d9f5e | 283 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 284 | static __INLINE void __set_FPSCR(uint32_t fpscr) |
SquirrelGod | 2:99b1cb0d9f5e | 285 | { |
SquirrelGod | 2:99b1cb0d9f5e | 286 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) |
SquirrelGod | 2:99b1cb0d9f5e | 287 | register uint32_t __regfpscr __ASM("fpscr"); |
SquirrelGod | 2:99b1cb0d9f5e | 288 | __regfpscr = (fpscr); |
SquirrelGod | 2:99b1cb0d9f5e | 289 | #endif |
SquirrelGod | 2:99b1cb0d9f5e | 290 | } |
SquirrelGod | 2:99b1cb0d9f5e | 291 | |
SquirrelGod | 2:99b1cb0d9f5e | 292 | #endif /* (__CORTEX_M == 0x04) */ |
SquirrelGod | 2:99b1cb0d9f5e | 293 | |
SquirrelGod | 2:99b1cb0d9f5e | 294 | |
SquirrelGod | 2:99b1cb0d9f5e | 295 | #elif defined ( __ICCARM__ ) /*------------------ ICC Compiler -------------------*/ |
SquirrelGod | 2:99b1cb0d9f5e | 296 | /* IAR iccarm specific functions */ |
SquirrelGod | 2:99b1cb0d9f5e | 297 | |
SquirrelGod | 2:99b1cb0d9f5e | 298 | #include <cmsis_iar.h> |
SquirrelGod | 2:99b1cb0d9f5e | 299 | |
SquirrelGod | 2:99b1cb0d9f5e | 300 | #elif defined ( __GNUC__ ) /*------------------ GNU Compiler ---------------------*/ |
SquirrelGod | 2:99b1cb0d9f5e | 301 | /* GNU gcc specific functions */ |
SquirrelGod | 2:99b1cb0d9f5e | 302 | |
SquirrelGod | 2:99b1cb0d9f5e | 303 | /** \brief Enable IRQ Interrupts |
SquirrelGod | 2:99b1cb0d9f5e | 304 | |
SquirrelGod | 2:99b1cb0d9f5e | 305 | This function enables IRQ interrupts by clearing the I-bit in the CPSR. |
SquirrelGod | 2:99b1cb0d9f5e | 306 | Can only be executed in Privileged modes. |
SquirrelGod | 2:99b1cb0d9f5e | 307 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 308 | __attribute__( ( always_inline ) ) static __INLINE void __enable_irq(void) |
SquirrelGod | 2:99b1cb0d9f5e | 309 | { |
SquirrelGod | 2:99b1cb0d9f5e | 310 | __ASM volatile ("cpsie i"); |
SquirrelGod | 2:99b1cb0d9f5e | 311 | } |
SquirrelGod | 2:99b1cb0d9f5e | 312 | |
SquirrelGod | 2:99b1cb0d9f5e | 313 | |
SquirrelGod | 2:99b1cb0d9f5e | 314 | /** \brief Disable IRQ Interrupts |
SquirrelGod | 2:99b1cb0d9f5e | 315 | |
SquirrelGod | 2:99b1cb0d9f5e | 316 | This function disables IRQ interrupts by setting the I-bit in the CPSR. |
SquirrelGod | 2:99b1cb0d9f5e | 317 | Can only be executed in Privileged modes. |
SquirrelGod | 2:99b1cb0d9f5e | 318 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 319 | __attribute__( ( always_inline ) ) static __INLINE void __disable_irq(void) |
SquirrelGod | 2:99b1cb0d9f5e | 320 | { |
SquirrelGod | 2:99b1cb0d9f5e | 321 | __ASM volatile ("cpsid i"); |
SquirrelGod | 2:99b1cb0d9f5e | 322 | } |
SquirrelGod | 2:99b1cb0d9f5e | 323 | |
SquirrelGod | 2:99b1cb0d9f5e | 324 | |
SquirrelGod | 2:99b1cb0d9f5e | 325 | /** \brief Get Control Register |
SquirrelGod | 2:99b1cb0d9f5e | 326 | |
SquirrelGod | 2:99b1cb0d9f5e | 327 | This function returns the content of the Control Register. |
SquirrelGod | 2:99b1cb0d9f5e | 328 | |
SquirrelGod | 2:99b1cb0d9f5e | 329 | \return Control Register value |
SquirrelGod | 2:99b1cb0d9f5e | 330 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 331 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_CONTROL(void) |
SquirrelGod | 2:99b1cb0d9f5e | 332 | { |
SquirrelGod | 2:99b1cb0d9f5e | 333 | uint32_t result; |
SquirrelGod | 2:99b1cb0d9f5e | 334 | |
SquirrelGod | 2:99b1cb0d9f5e | 335 | __ASM volatile ("MRS %0, control" : "=r" (result) ); |
SquirrelGod | 2:99b1cb0d9f5e | 336 | return(result); |
SquirrelGod | 2:99b1cb0d9f5e | 337 | } |
SquirrelGod | 2:99b1cb0d9f5e | 338 | |
SquirrelGod | 2:99b1cb0d9f5e | 339 | |
SquirrelGod | 2:99b1cb0d9f5e | 340 | /** \brief Set Control Register |
SquirrelGod | 2:99b1cb0d9f5e | 341 | |
SquirrelGod | 2:99b1cb0d9f5e | 342 | This function writes the given value to the Control Register. |
SquirrelGod | 2:99b1cb0d9f5e | 343 | |
SquirrelGod | 2:99b1cb0d9f5e | 344 | \param [in] control Control Register value to set |
SquirrelGod | 2:99b1cb0d9f5e | 345 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 346 | __attribute__( ( always_inline ) ) static __INLINE void __set_CONTROL(uint32_t control) |
SquirrelGod | 2:99b1cb0d9f5e | 347 | { |
SquirrelGod | 2:99b1cb0d9f5e | 348 | __ASM volatile ("MSR control, %0" : : "r" (control) ); |
SquirrelGod | 2:99b1cb0d9f5e | 349 | } |
SquirrelGod | 2:99b1cb0d9f5e | 350 | |
SquirrelGod | 2:99b1cb0d9f5e | 351 | |
SquirrelGod | 2:99b1cb0d9f5e | 352 | /** \brief Get IPSR Register |
SquirrelGod | 2:99b1cb0d9f5e | 353 | |
SquirrelGod | 2:99b1cb0d9f5e | 354 | This function returns the content of the IPSR Register. |
SquirrelGod | 2:99b1cb0d9f5e | 355 | |
SquirrelGod | 2:99b1cb0d9f5e | 356 | \return IPSR Register value |
SquirrelGod | 2:99b1cb0d9f5e | 357 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 358 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_IPSR(void) |
SquirrelGod | 2:99b1cb0d9f5e | 359 | { |
SquirrelGod | 2:99b1cb0d9f5e | 360 | uint32_t result; |
SquirrelGod | 2:99b1cb0d9f5e | 361 | |
SquirrelGod | 2:99b1cb0d9f5e | 362 | __ASM volatile ("MRS %0, ipsr" : "=r" (result) ); |
SquirrelGod | 2:99b1cb0d9f5e | 363 | return(result); |
SquirrelGod | 2:99b1cb0d9f5e | 364 | } |
SquirrelGod | 2:99b1cb0d9f5e | 365 | |
SquirrelGod | 2:99b1cb0d9f5e | 366 | |
SquirrelGod | 2:99b1cb0d9f5e | 367 | /** \brief Get APSR Register |
SquirrelGod | 2:99b1cb0d9f5e | 368 | |
SquirrelGod | 2:99b1cb0d9f5e | 369 | This function returns the content of the APSR Register. |
SquirrelGod | 2:99b1cb0d9f5e | 370 | |
SquirrelGod | 2:99b1cb0d9f5e | 371 | \return APSR Register value |
SquirrelGod | 2:99b1cb0d9f5e | 372 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 373 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_APSR(void) |
SquirrelGod | 2:99b1cb0d9f5e | 374 | { |
SquirrelGod | 2:99b1cb0d9f5e | 375 | uint32_t result; |
SquirrelGod | 2:99b1cb0d9f5e | 376 | |
SquirrelGod | 2:99b1cb0d9f5e | 377 | __ASM volatile ("MRS %0, apsr" : "=r" (result) ); |
SquirrelGod | 2:99b1cb0d9f5e | 378 | return(result); |
SquirrelGod | 2:99b1cb0d9f5e | 379 | } |
SquirrelGod | 2:99b1cb0d9f5e | 380 | |
SquirrelGod | 2:99b1cb0d9f5e | 381 | |
SquirrelGod | 2:99b1cb0d9f5e | 382 | /** \brief Get xPSR Register |
SquirrelGod | 2:99b1cb0d9f5e | 383 | |
SquirrelGod | 2:99b1cb0d9f5e | 384 | This function returns the content of the xPSR Register. |
SquirrelGod | 2:99b1cb0d9f5e | 385 | |
SquirrelGod | 2:99b1cb0d9f5e | 386 | \return xPSR Register value |
SquirrelGod | 2:99b1cb0d9f5e | 387 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 388 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_xPSR(void) |
SquirrelGod | 2:99b1cb0d9f5e | 389 | { |
SquirrelGod | 2:99b1cb0d9f5e | 390 | uint32_t result; |
SquirrelGod | 2:99b1cb0d9f5e | 391 | |
SquirrelGod | 2:99b1cb0d9f5e | 392 | __ASM volatile ("MRS %0, xpsr" : "=r" (result) ); |
SquirrelGod | 2:99b1cb0d9f5e | 393 | return(result); |
SquirrelGod | 2:99b1cb0d9f5e | 394 | } |
SquirrelGod | 2:99b1cb0d9f5e | 395 | |
SquirrelGod | 2:99b1cb0d9f5e | 396 | |
SquirrelGod | 2:99b1cb0d9f5e | 397 | /** \brief Get Process Stack Pointer |
SquirrelGod | 2:99b1cb0d9f5e | 398 | |
SquirrelGod | 2:99b1cb0d9f5e | 399 | This function returns the current value of the Process Stack Pointer (PSP). |
SquirrelGod | 2:99b1cb0d9f5e | 400 | |
SquirrelGod | 2:99b1cb0d9f5e | 401 | \return PSP Register value |
SquirrelGod | 2:99b1cb0d9f5e | 402 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 403 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_PSP(void) |
SquirrelGod | 2:99b1cb0d9f5e | 404 | { |
SquirrelGod | 2:99b1cb0d9f5e | 405 | register uint32_t result; |
SquirrelGod | 2:99b1cb0d9f5e | 406 | |
SquirrelGod | 2:99b1cb0d9f5e | 407 | __ASM volatile ("MRS %0, psp\n" : "=r" (result) ); |
SquirrelGod | 2:99b1cb0d9f5e | 408 | return(result); |
SquirrelGod | 2:99b1cb0d9f5e | 409 | } |
SquirrelGod | 2:99b1cb0d9f5e | 410 | |
SquirrelGod | 2:99b1cb0d9f5e | 411 | |
SquirrelGod | 2:99b1cb0d9f5e | 412 | /** \brief Set Process Stack Pointer |
SquirrelGod | 2:99b1cb0d9f5e | 413 | |
SquirrelGod | 2:99b1cb0d9f5e | 414 | This function assigns the given value to the Process Stack Pointer (PSP). |
SquirrelGod | 2:99b1cb0d9f5e | 415 | |
SquirrelGod | 2:99b1cb0d9f5e | 416 | \param [in] topOfProcStack Process Stack Pointer value to set |
SquirrelGod | 2:99b1cb0d9f5e | 417 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 418 | __attribute__( ( always_inline ) ) static __INLINE void __set_PSP(uint32_t topOfProcStack) |
SquirrelGod | 2:99b1cb0d9f5e | 419 | { |
SquirrelGod | 2:99b1cb0d9f5e | 420 | __ASM volatile ("MSR psp, %0\n" : : "r" (topOfProcStack) ); |
SquirrelGod | 2:99b1cb0d9f5e | 421 | } |
SquirrelGod | 2:99b1cb0d9f5e | 422 | |
SquirrelGod | 2:99b1cb0d9f5e | 423 | |
SquirrelGod | 2:99b1cb0d9f5e | 424 | /** \brief Get Main Stack Pointer |
SquirrelGod | 2:99b1cb0d9f5e | 425 | |
SquirrelGod | 2:99b1cb0d9f5e | 426 | This function returns the current value of the Main Stack Pointer (MSP). |
SquirrelGod | 2:99b1cb0d9f5e | 427 | |
SquirrelGod | 2:99b1cb0d9f5e | 428 | \return MSP Register value |
SquirrelGod | 2:99b1cb0d9f5e | 429 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 430 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_MSP(void) |
SquirrelGod | 2:99b1cb0d9f5e | 431 | { |
SquirrelGod | 2:99b1cb0d9f5e | 432 | register uint32_t result; |
SquirrelGod | 2:99b1cb0d9f5e | 433 | |
SquirrelGod | 2:99b1cb0d9f5e | 434 | __ASM volatile ("MRS %0, msp\n" : "=r" (result) ); |
SquirrelGod | 2:99b1cb0d9f5e | 435 | return(result); |
SquirrelGod | 2:99b1cb0d9f5e | 436 | } |
SquirrelGod | 2:99b1cb0d9f5e | 437 | |
SquirrelGod | 2:99b1cb0d9f5e | 438 | |
SquirrelGod | 2:99b1cb0d9f5e | 439 | /** \brief Set Main Stack Pointer |
SquirrelGod | 2:99b1cb0d9f5e | 440 | |
SquirrelGod | 2:99b1cb0d9f5e | 441 | This function assigns the given value to the Main Stack Pointer (MSP). |
SquirrelGod | 2:99b1cb0d9f5e | 442 | |
SquirrelGod | 2:99b1cb0d9f5e | 443 | \param [in] topOfMainStack Main Stack Pointer value to set |
SquirrelGod | 2:99b1cb0d9f5e | 444 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 445 | __attribute__( ( always_inline ) ) static __INLINE void __set_MSP(uint32_t topOfMainStack) |
SquirrelGod | 2:99b1cb0d9f5e | 446 | { |
SquirrelGod | 2:99b1cb0d9f5e | 447 | __ASM volatile ("MSR msp, %0\n" : : "r" (topOfMainStack) ); |
SquirrelGod | 2:99b1cb0d9f5e | 448 | } |
SquirrelGod | 2:99b1cb0d9f5e | 449 | |
SquirrelGod | 2:99b1cb0d9f5e | 450 | |
SquirrelGod | 2:99b1cb0d9f5e | 451 | /** \brief Get Priority Mask |
SquirrelGod | 2:99b1cb0d9f5e | 452 | |
SquirrelGod | 2:99b1cb0d9f5e | 453 | This function returns the current state of the priority mask bit from the Priority Mask Register. |
SquirrelGod | 2:99b1cb0d9f5e | 454 | |
SquirrelGod | 2:99b1cb0d9f5e | 455 | \return Priority Mask value |
SquirrelGod | 2:99b1cb0d9f5e | 456 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 457 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_PRIMASK(void) |
SquirrelGod | 2:99b1cb0d9f5e | 458 | { |
SquirrelGod | 2:99b1cb0d9f5e | 459 | uint32_t result; |
SquirrelGod | 2:99b1cb0d9f5e | 460 | |
SquirrelGod | 2:99b1cb0d9f5e | 461 | __ASM volatile ("MRS %0, primask" : "=r" (result) ); |
SquirrelGod | 2:99b1cb0d9f5e | 462 | return(result); |
SquirrelGod | 2:99b1cb0d9f5e | 463 | } |
SquirrelGod | 2:99b1cb0d9f5e | 464 | |
SquirrelGod | 2:99b1cb0d9f5e | 465 | |
SquirrelGod | 2:99b1cb0d9f5e | 466 | /** \brief Set Priority Mask |
SquirrelGod | 2:99b1cb0d9f5e | 467 | |
SquirrelGod | 2:99b1cb0d9f5e | 468 | This function assigns the given value to the Priority Mask Register. |
SquirrelGod | 2:99b1cb0d9f5e | 469 | |
SquirrelGod | 2:99b1cb0d9f5e | 470 | \param [in] priMask Priority Mask |
SquirrelGod | 2:99b1cb0d9f5e | 471 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 472 | __attribute__( ( always_inline ) ) static __INLINE void __set_PRIMASK(uint32_t priMask) |
SquirrelGod | 2:99b1cb0d9f5e | 473 | { |
SquirrelGod | 2:99b1cb0d9f5e | 474 | __ASM volatile ("MSR primask, %0" : : "r" (priMask) ); |
SquirrelGod | 2:99b1cb0d9f5e | 475 | } |
SquirrelGod | 2:99b1cb0d9f5e | 476 | |
SquirrelGod | 2:99b1cb0d9f5e | 477 | |
SquirrelGod | 2:99b1cb0d9f5e | 478 | #if (__CORTEX_M >= 0x03) |
SquirrelGod | 2:99b1cb0d9f5e | 479 | |
SquirrelGod | 2:99b1cb0d9f5e | 480 | /** \brief Enable FIQ |
SquirrelGod | 2:99b1cb0d9f5e | 481 | |
SquirrelGod | 2:99b1cb0d9f5e | 482 | This function enables FIQ interrupts by clearing the F-bit in the CPSR. |
SquirrelGod | 2:99b1cb0d9f5e | 483 | Can only be executed in Privileged modes. |
SquirrelGod | 2:99b1cb0d9f5e | 484 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 485 | __attribute__( ( always_inline ) ) static __INLINE void __enable_fault_irq(void) |
SquirrelGod | 2:99b1cb0d9f5e | 486 | { |
SquirrelGod | 2:99b1cb0d9f5e | 487 | __ASM volatile ("cpsie f"); |
SquirrelGod | 2:99b1cb0d9f5e | 488 | } |
SquirrelGod | 2:99b1cb0d9f5e | 489 | |
SquirrelGod | 2:99b1cb0d9f5e | 490 | |
SquirrelGod | 2:99b1cb0d9f5e | 491 | /** \brief Disable FIQ |
SquirrelGod | 2:99b1cb0d9f5e | 492 | |
SquirrelGod | 2:99b1cb0d9f5e | 493 | This function disables FIQ interrupts by setting the F-bit in the CPSR. |
SquirrelGod | 2:99b1cb0d9f5e | 494 | Can only be executed in Privileged modes. |
SquirrelGod | 2:99b1cb0d9f5e | 495 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 496 | __attribute__( ( always_inline ) ) static __INLINE void __disable_fault_irq(void) |
SquirrelGod | 2:99b1cb0d9f5e | 497 | { |
SquirrelGod | 2:99b1cb0d9f5e | 498 | __ASM volatile ("cpsid f"); |
SquirrelGod | 2:99b1cb0d9f5e | 499 | } |
SquirrelGod | 2:99b1cb0d9f5e | 500 | |
SquirrelGod | 2:99b1cb0d9f5e | 501 | |
SquirrelGod | 2:99b1cb0d9f5e | 502 | /** \brief Get Base Priority |
SquirrelGod | 2:99b1cb0d9f5e | 503 | |
SquirrelGod | 2:99b1cb0d9f5e | 504 | This function returns the current value of the Base Priority register. |
SquirrelGod | 2:99b1cb0d9f5e | 505 | |
SquirrelGod | 2:99b1cb0d9f5e | 506 | \return Base Priority register value |
SquirrelGod | 2:99b1cb0d9f5e | 507 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 508 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_BASEPRI(void) |
SquirrelGod | 2:99b1cb0d9f5e | 509 | { |
SquirrelGod | 2:99b1cb0d9f5e | 510 | uint32_t result; |
SquirrelGod | 2:99b1cb0d9f5e | 511 | |
SquirrelGod | 2:99b1cb0d9f5e | 512 | __ASM volatile ("MRS %0, basepri_max" : "=r" (result) ); |
SquirrelGod | 2:99b1cb0d9f5e | 513 | return(result); |
SquirrelGod | 2:99b1cb0d9f5e | 514 | } |
SquirrelGod | 2:99b1cb0d9f5e | 515 | |
SquirrelGod | 2:99b1cb0d9f5e | 516 | |
SquirrelGod | 2:99b1cb0d9f5e | 517 | /** \brief Set Base Priority |
SquirrelGod | 2:99b1cb0d9f5e | 518 | |
SquirrelGod | 2:99b1cb0d9f5e | 519 | This function assigns the given value to the Base Priority register. |
SquirrelGod | 2:99b1cb0d9f5e | 520 | |
SquirrelGod | 2:99b1cb0d9f5e | 521 | \param [in] basePri Base Priority value to set |
SquirrelGod | 2:99b1cb0d9f5e | 522 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 523 | __attribute__( ( always_inline ) ) static __INLINE void __set_BASEPRI(uint32_t value) |
SquirrelGod | 2:99b1cb0d9f5e | 524 | { |
SquirrelGod | 2:99b1cb0d9f5e | 525 | __ASM volatile ("MSR basepri, %0" : : "r" (value) ); |
SquirrelGod | 2:99b1cb0d9f5e | 526 | } |
SquirrelGod | 2:99b1cb0d9f5e | 527 | |
SquirrelGod | 2:99b1cb0d9f5e | 528 | |
SquirrelGod | 2:99b1cb0d9f5e | 529 | /** \brief Get Fault Mask |
SquirrelGod | 2:99b1cb0d9f5e | 530 | |
SquirrelGod | 2:99b1cb0d9f5e | 531 | This function returns the current value of the Fault Mask register. |
SquirrelGod | 2:99b1cb0d9f5e | 532 | |
SquirrelGod | 2:99b1cb0d9f5e | 533 | \return Fault Mask register value |
SquirrelGod | 2:99b1cb0d9f5e | 534 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 535 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_FAULTMASK(void) |
SquirrelGod | 2:99b1cb0d9f5e | 536 | { |
SquirrelGod | 2:99b1cb0d9f5e | 537 | uint32_t result; |
SquirrelGod | 2:99b1cb0d9f5e | 538 | |
SquirrelGod | 2:99b1cb0d9f5e | 539 | __ASM volatile ("MRS %0, faultmask" : "=r" (result) ); |
SquirrelGod | 2:99b1cb0d9f5e | 540 | return(result); |
SquirrelGod | 2:99b1cb0d9f5e | 541 | } |
SquirrelGod | 2:99b1cb0d9f5e | 542 | |
SquirrelGod | 2:99b1cb0d9f5e | 543 | |
SquirrelGod | 2:99b1cb0d9f5e | 544 | /** \brief Set Fault Mask |
SquirrelGod | 2:99b1cb0d9f5e | 545 | |
SquirrelGod | 2:99b1cb0d9f5e | 546 | This function assigns the given value to the Fault Mask register. |
SquirrelGod | 2:99b1cb0d9f5e | 547 | |
SquirrelGod | 2:99b1cb0d9f5e | 548 | \param [in] faultMask Fault Mask value to set |
SquirrelGod | 2:99b1cb0d9f5e | 549 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 550 | __attribute__( ( always_inline ) ) static __INLINE void __set_FAULTMASK(uint32_t faultMask) |
SquirrelGod | 2:99b1cb0d9f5e | 551 | { |
SquirrelGod | 2:99b1cb0d9f5e | 552 | __ASM volatile ("MSR faultmask, %0" : : "r" (faultMask) ); |
SquirrelGod | 2:99b1cb0d9f5e | 553 | } |
SquirrelGod | 2:99b1cb0d9f5e | 554 | |
SquirrelGod | 2:99b1cb0d9f5e | 555 | #endif /* (__CORTEX_M >= 0x03) */ |
SquirrelGod | 2:99b1cb0d9f5e | 556 | |
SquirrelGod | 2:99b1cb0d9f5e | 557 | |
SquirrelGod | 2:99b1cb0d9f5e | 558 | #if (__CORTEX_M == 0x04) |
SquirrelGod | 2:99b1cb0d9f5e | 559 | |
SquirrelGod | 2:99b1cb0d9f5e | 560 | /** \brief Get FPSCR |
SquirrelGod | 2:99b1cb0d9f5e | 561 | |
SquirrelGod | 2:99b1cb0d9f5e | 562 | This function returns the current value of the Floating Point Status/Control register. |
SquirrelGod | 2:99b1cb0d9f5e | 563 | |
SquirrelGod | 2:99b1cb0d9f5e | 564 | \return Floating Point Status/Control register value |
SquirrelGod | 2:99b1cb0d9f5e | 565 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 566 | __attribute__( ( always_inline ) ) static __INLINE uint32_t __get_FPSCR(void) |
SquirrelGod | 2:99b1cb0d9f5e | 567 | { |
SquirrelGod | 2:99b1cb0d9f5e | 568 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) |
SquirrelGod | 2:99b1cb0d9f5e | 569 | uint32_t result; |
SquirrelGod | 2:99b1cb0d9f5e | 570 | |
SquirrelGod | 2:99b1cb0d9f5e | 571 | __ASM volatile ("VMRS %0, fpscr" : "=r" (result) ); |
SquirrelGod | 2:99b1cb0d9f5e | 572 | return(result); |
SquirrelGod | 2:99b1cb0d9f5e | 573 | #else |
SquirrelGod | 2:99b1cb0d9f5e | 574 | return(0); |
SquirrelGod | 2:99b1cb0d9f5e | 575 | #endif |
SquirrelGod | 2:99b1cb0d9f5e | 576 | } |
SquirrelGod | 2:99b1cb0d9f5e | 577 | |
SquirrelGod | 2:99b1cb0d9f5e | 578 | |
SquirrelGod | 2:99b1cb0d9f5e | 579 | /** \brief Set FPSCR |
SquirrelGod | 2:99b1cb0d9f5e | 580 | |
SquirrelGod | 2:99b1cb0d9f5e | 581 | This function assigns the given value to the Floating Point Status/Control register. |
SquirrelGod | 2:99b1cb0d9f5e | 582 | |
SquirrelGod | 2:99b1cb0d9f5e | 583 | \param [in] fpscr Floating Point Status/Control value to set |
SquirrelGod | 2:99b1cb0d9f5e | 584 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 585 | __attribute__( ( always_inline ) ) static __INLINE void __set_FPSCR(uint32_t fpscr) |
SquirrelGod | 2:99b1cb0d9f5e | 586 | { |
SquirrelGod | 2:99b1cb0d9f5e | 587 | #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) |
SquirrelGod | 2:99b1cb0d9f5e | 588 | __ASM volatile ("VMSR fpscr, %0" : : "r" (fpscr) ); |
SquirrelGod | 2:99b1cb0d9f5e | 589 | #endif |
SquirrelGod | 2:99b1cb0d9f5e | 590 | } |
SquirrelGod | 2:99b1cb0d9f5e | 591 | |
SquirrelGod | 2:99b1cb0d9f5e | 592 | #endif /* (__CORTEX_M == 0x04) */ |
SquirrelGod | 2:99b1cb0d9f5e | 593 | |
SquirrelGod | 2:99b1cb0d9f5e | 594 | |
SquirrelGod | 2:99b1cb0d9f5e | 595 | #elif defined ( __TASKING__ ) /*------------------ TASKING Compiler --------------*/ |
SquirrelGod | 2:99b1cb0d9f5e | 596 | /* TASKING carm specific functions */ |
SquirrelGod | 2:99b1cb0d9f5e | 597 | |
SquirrelGod | 2:99b1cb0d9f5e | 598 | /* |
SquirrelGod | 2:99b1cb0d9f5e | 599 | * The CMSIS functions have been implemented as intrinsics in the compiler. |
SquirrelGod | 2:99b1cb0d9f5e | 600 | * Please use "carm -?i" to get an up to date list of all instrinsics, |
SquirrelGod | 2:99b1cb0d9f5e | 601 | * Including the CMSIS ones. |
SquirrelGod | 2:99b1cb0d9f5e | 602 | */ |
SquirrelGod | 2:99b1cb0d9f5e | 603 | |
SquirrelGod | 2:99b1cb0d9f5e | 604 | #endif |
SquirrelGod | 2:99b1cb0d9f5e | 605 | |
SquirrelGod | 2:99b1cb0d9f5e | 606 | /*@} end of CMSIS_Core_RegAccFunctions */ |
SquirrelGod | 2:99b1cb0d9f5e | 607 | |
SquirrelGod | 2:99b1cb0d9f5e | 608 | |
SquirrelGod | 2:99b1cb0d9f5e | 609 | #endif /* __CORE_CMFUNC_H */ |