1*5fd0122aSMatthias Ringwald /* --COPYRIGHT--,BSD 2*5fd0122aSMatthias Ringwald * Copyright (c) 2017, Texas Instruments Incorporated 3*5fd0122aSMatthias Ringwald * All rights reserved. 4*5fd0122aSMatthias Ringwald * 5*5fd0122aSMatthias Ringwald * Redistribution and use in source and binary forms, with or without 6*5fd0122aSMatthias Ringwald * modification, are permitted provided that the following conditions 7*5fd0122aSMatthias Ringwald * are met: 8*5fd0122aSMatthias Ringwald * 9*5fd0122aSMatthias Ringwald * * Redistributions of source code must retain the above copyright 10*5fd0122aSMatthias Ringwald * notice, this list of conditions and the following disclaimer. 11*5fd0122aSMatthias Ringwald * 12*5fd0122aSMatthias Ringwald * * Redistributions in binary form must reproduce the above copyright 13*5fd0122aSMatthias Ringwald * notice, this list of conditions and the following disclaimer in the 14*5fd0122aSMatthias Ringwald * documentation and/or other materials provided with the distribution. 15*5fd0122aSMatthias Ringwald * 16*5fd0122aSMatthias Ringwald * * Neither the name of Texas Instruments Incorporated nor the names of 17*5fd0122aSMatthias Ringwald * its contributors may be used to endorse or promote products derived 18*5fd0122aSMatthias Ringwald * from this software without specific prior written permission. 19*5fd0122aSMatthias Ringwald * 20*5fd0122aSMatthias Ringwald * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21*5fd0122aSMatthias Ringwald * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 22*5fd0122aSMatthias Ringwald * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23*5fd0122aSMatthias Ringwald * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24*5fd0122aSMatthias Ringwald * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25*5fd0122aSMatthias Ringwald * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26*5fd0122aSMatthias Ringwald * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 27*5fd0122aSMatthias Ringwald * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 28*5fd0122aSMatthias Ringwald * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 29*5fd0122aSMatthias Ringwald * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 30*5fd0122aSMatthias Ringwald * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31*5fd0122aSMatthias Ringwald * --/COPYRIGHT--*/ 32*5fd0122aSMatthias Ringwald #ifndef __FPU_H__ 33*5fd0122aSMatthias Ringwald #define __FPU_H__ 34*5fd0122aSMatthias Ringwald 35*5fd0122aSMatthias Ringwald //***************************************************************************** 36*5fd0122aSMatthias Ringwald // 37*5fd0122aSMatthias Ringwald //! 38*5fd0122aSMatthias Ringwald //! \addtogroup fpu_api 39*5fd0122aSMatthias Ringwald //! @{ 40*5fd0122aSMatthias Ringwald // 41*5fd0122aSMatthias Ringwald //***************************************************************************** 42*5fd0122aSMatthias Ringwald 43*5fd0122aSMatthias Ringwald //***************************************************************************** 44*5fd0122aSMatthias Ringwald // 45*5fd0122aSMatthias Ringwald // If building with a C++ compiler, make all of the definitions in this header 46*5fd0122aSMatthias Ringwald // have a C binding. 47*5fd0122aSMatthias Ringwald // 48*5fd0122aSMatthias Ringwald //***************************************************************************** 49*5fd0122aSMatthias Ringwald #ifdef __cplusplus 50*5fd0122aSMatthias Ringwald extern "C" 51*5fd0122aSMatthias Ringwald { 52*5fd0122aSMatthias Ringwald #endif 53*5fd0122aSMatthias Ringwald 54*5fd0122aSMatthias Ringwald #include <stdint.h> 55*5fd0122aSMatthias Ringwald #include <ti/devices/msp432p4xx/inc/msp.h> 56*5fd0122aSMatthias Ringwald 57*5fd0122aSMatthias Ringwald //***************************************************************************** 58*5fd0122aSMatthias Ringwald // 59*5fd0122aSMatthias Ringwald // Values that can be passed to FPUHalfPrecisionSet as the mode parameter. 60*5fd0122aSMatthias Ringwald // 61*5fd0122aSMatthias Ringwald //***************************************************************************** 62*5fd0122aSMatthias Ringwald #define FPU_HALF_IEEE 0x00000000 63*5fd0122aSMatthias Ringwald #define FPU_HALF_ALTERNATE 0x04000000 64*5fd0122aSMatthias Ringwald 65*5fd0122aSMatthias Ringwald //***************************************************************************** 66*5fd0122aSMatthias Ringwald // 67*5fd0122aSMatthias Ringwald // Values that can be passed to FPU_setNaNMode as the mode parameter. 68*5fd0122aSMatthias Ringwald // 69*5fd0122aSMatthias Ringwald //***************************************************************************** 70*5fd0122aSMatthias Ringwald #define FPU_NAN_PROPAGATE 0x00000000 71*5fd0122aSMatthias Ringwald #define FPU_NAN_DEFAULT 0x02000000 72*5fd0122aSMatthias Ringwald 73*5fd0122aSMatthias Ringwald //***************************************************************************** 74*5fd0122aSMatthias Ringwald // 75*5fd0122aSMatthias Ringwald // Values that can be passed to FPU_setFlushToZeroMode as the mode parameter. 76*5fd0122aSMatthias Ringwald // 77*5fd0122aSMatthias Ringwald //***************************************************************************** 78*5fd0122aSMatthias Ringwald #define FPU_FLUSH_TO_ZERO_DIS 0x00000000 79*5fd0122aSMatthias Ringwald #define FPU_FLUSH_TO_ZERO_EN 0x01000000 80*5fd0122aSMatthias Ringwald 81*5fd0122aSMatthias Ringwald //***************************************************************************** 82*5fd0122aSMatthias Ringwald // 83*5fd0122aSMatthias Ringwald // Values that can be passed to FPU_setRoundingMode as the mode parameter. 84*5fd0122aSMatthias Ringwald // 85*5fd0122aSMatthias Ringwald //***************************************************************************** 86*5fd0122aSMatthias Ringwald #define FPU_ROUND_NEAREST 0x00000000 87*5fd0122aSMatthias Ringwald #define FPU_ROUND_POS_INF 0x00400000 88*5fd0122aSMatthias Ringwald #define FPU_ROUND_NEG_INF 0x00800000 89*5fd0122aSMatthias Ringwald #define FPU_ROUND_ZERO 0x00c00000 90*5fd0122aSMatthias Ringwald 91*5fd0122aSMatthias Ringwald //***************************************************************************** 92*5fd0122aSMatthias Ringwald // 93*5fd0122aSMatthias Ringwald //! Enables the floating-point unit. 94*5fd0122aSMatthias Ringwald //! 95*5fd0122aSMatthias Ringwald //! This function enables the floating-point unit, allowing the floating-point 96*5fd0122aSMatthias Ringwald //! instructions to be executed. This function must be called prior to 97*5fd0122aSMatthias Ringwald //! performing any hardware floating-point operations; failure to do so results 98*5fd0122aSMatthias Ringwald //! in a NOCP usage fault. 99*5fd0122aSMatthias Ringwald //! 100*5fd0122aSMatthias Ringwald //! \return None. 101*5fd0122aSMatthias Ringwald // 102*5fd0122aSMatthias Ringwald //***************************************************************************** 103*5fd0122aSMatthias Ringwald extern void FPU_enableModule(void); 104*5fd0122aSMatthias Ringwald 105*5fd0122aSMatthias Ringwald //***************************************************************************** 106*5fd0122aSMatthias Ringwald // 107*5fd0122aSMatthias Ringwald //! Disables the floating-point unit. 108*5fd0122aSMatthias Ringwald //! 109*5fd0122aSMatthias Ringwald //! This function disables the floating-point unit, preventing floating-point 110*5fd0122aSMatthias Ringwald //! instructions from executing (generating a NOCP usage fault instead). 111*5fd0122aSMatthias Ringwald //! 112*5fd0122aSMatthias Ringwald //! \return None. 113*5fd0122aSMatthias Ringwald // 114*5fd0122aSMatthias Ringwald //***************************************************************************** 115*5fd0122aSMatthias Ringwald extern void FPU_disableModule(void); 116*5fd0122aSMatthias Ringwald 117*5fd0122aSMatthias Ringwald //***************************************************************************** 118*5fd0122aSMatthias Ringwald // 119*5fd0122aSMatthias Ringwald //! Enables the stacking of floating-point registers. 120*5fd0122aSMatthias Ringwald //! 121*5fd0122aSMatthias Ringwald //! This function enables the stacking of floating-point registers s0-s15 when 122*5fd0122aSMatthias Ringwald //! an interrupt is handled. When enabled, space is reserved on the stack for 123*5fd0122aSMatthias Ringwald //! the floating-point context and the floating-point state is saved into this 124*5fd0122aSMatthias Ringwald //! stack space. Upon return from the interrupt, the floating-point context is 125*5fd0122aSMatthias Ringwald //! restored. 126*5fd0122aSMatthias Ringwald //! 127*5fd0122aSMatthias Ringwald //! If the floating-point registers are not stacked, floating-point 128*5fd0122aSMatthias Ringwald //! instructions cannot be safely executed in an interrupt handler because the 129*5fd0122aSMatthias Ringwald //! values of s0-s15 are not likely to be preserved for the interrupted code. 130*5fd0122aSMatthias Ringwald //! On the other hand, stacking the floating-point registers increases the 131*5fd0122aSMatthias Ringwald //! stacking operation from 8 words to 26 words, also increasing the interrupt 132*5fd0122aSMatthias Ringwald //! response latency. 133*5fd0122aSMatthias Ringwald //! 134*5fd0122aSMatthias Ringwald //! \return None. 135*5fd0122aSMatthias Ringwald // 136*5fd0122aSMatthias Ringwald //***************************************************************************** 137*5fd0122aSMatthias Ringwald extern void FPU_enableStacking(void); 138*5fd0122aSMatthias Ringwald 139*5fd0122aSMatthias Ringwald //***************************************************************************** 140*5fd0122aSMatthias Ringwald // 141*5fd0122aSMatthias Ringwald //! Enables the lazy stacking of floating-point registers. 142*5fd0122aSMatthias Ringwald //! 143*5fd0122aSMatthias Ringwald //! This function enables the lazy stacking of floating-point registers s0-s15 144*5fd0122aSMatthias Ringwald //! when an interrupt is handled. When lazy stacking is enabled, space is 145*5fd0122aSMatthias Ringwald //! reserved on the stack for the floating-point context, but the 146*5fd0122aSMatthias Ringwald //! floating-point state is not saved. If a floating-point instruction is 147*5fd0122aSMatthias Ringwald //! executed from within the interrupt context, the floating-point context is 148*5fd0122aSMatthias Ringwald //! first saved into the space reserved on the stack. On completion of the 149*5fd0122aSMatthias Ringwald //! interrupt handler, the floating-point context is only restored if it was 150*5fd0122aSMatthias Ringwald //! saved (as the result of executing a floating-point instruction). 151*5fd0122aSMatthias Ringwald //! 152*5fd0122aSMatthias Ringwald //! This method provides a compromise between fast interrupt response (because 153*5fd0122aSMatthias Ringwald //! the floating-point state is not saved on interrupt entry) and the ability 154*5fd0122aSMatthias Ringwald //! to use floating-point in interrupt handlers (because the floating-point 155*5fd0122aSMatthias Ringwald //! state is saved if floating-point instructions are used). 156*5fd0122aSMatthias Ringwald //! 157*5fd0122aSMatthias Ringwald //! \return None. 158*5fd0122aSMatthias Ringwald // 159*5fd0122aSMatthias Ringwald //***************************************************************************** 160*5fd0122aSMatthias Ringwald extern void FPU_enableLazyStacking(void); 161*5fd0122aSMatthias Ringwald 162*5fd0122aSMatthias Ringwald //***************************************************************************** 163*5fd0122aSMatthias Ringwald // 164*5fd0122aSMatthias Ringwald //! Disables the stacking of floating-point registers. 165*5fd0122aSMatthias Ringwald //! 166*5fd0122aSMatthias Ringwald //! This function disables the stacking of floating-point registers s0-s15 when 167*5fd0122aSMatthias Ringwald //! an interrupt is handled. When floating-point context stacking is disabled, 168*5fd0122aSMatthias Ringwald //! floating-point operations performed in an interrupt handler destroy the 169*5fd0122aSMatthias Ringwald //! floating-point context of the main thread of execution. 170*5fd0122aSMatthias Ringwald //! 171*5fd0122aSMatthias Ringwald //! \return None. 172*5fd0122aSMatthias Ringwald // 173*5fd0122aSMatthias Ringwald //***************************************************************************** 174*5fd0122aSMatthias Ringwald extern void FPU_disableStacking(void); 175*5fd0122aSMatthias Ringwald 176*5fd0122aSMatthias Ringwald //***************************************************************************** 177*5fd0122aSMatthias Ringwald // 178*5fd0122aSMatthias Ringwald //! Selects the format of half-precision floating-point values. 179*5fd0122aSMatthias Ringwald //! 180*5fd0122aSMatthias Ringwald //! \param mode is the format for half-precision floating-point value, which 181*5fd0122aSMatthias Ringwald //! is either \b FPU_HALF_IEEE or \b FPU_HALF_ALTERNATE. 182*5fd0122aSMatthias Ringwald //! 183*5fd0122aSMatthias Ringwald //! This function selects between the IEEE half-precision floating-point 184*5fd0122aSMatthias Ringwald //! representation and the Cortex-M processor alternative representation. The 185*5fd0122aSMatthias Ringwald //! alternative representation has a larger range but does not have a way to 186*5fd0122aSMatthias Ringwald //! encode infinity (positive or negative) or NaN (quiet or signalling). The 187*5fd0122aSMatthias Ringwald //! default setting is the IEEE format. 188*5fd0122aSMatthias Ringwald //! 189*5fd0122aSMatthias Ringwald //! \note Unless this function is called prior to executing any floating-point 190*5fd0122aSMatthias Ringwald //! instructions, the default mode is used. 191*5fd0122aSMatthias Ringwald //! 192*5fd0122aSMatthias Ringwald //! \return None. 193*5fd0122aSMatthias Ringwald // 194*5fd0122aSMatthias Ringwald //***************************************************************************** 195*5fd0122aSMatthias Ringwald extern void FPU_setHalfPrecisionMode(uint32_t mode); 196*5fd0122aSMatthias Ringwald 197*5fd0122aSMatthias Ringwald //***************************************************************************** 198*5fd0122aSMatthias Ringwald // 199*5fd0122aSMatthias Ringwald //! Selects the NaN mode. 200*5fd0122aSMatthias Ringwald //! 201*5fd0122aSMatthias Ringwald //! \param mode is the mode for NaN results; which is 202*5fd0122aSMatthias Ringwald //! either \b FPU_NAN_PROPAGATE or \b FPU_NAN_DEFAULT. 203*5fd0122aSMatthias Ringwald //! 204*5fd0122aSMatthias Ringwald //! This function selects the handling of NaN results during floating-point 205*5fd0122aSMatthias Ringwald //! computations. NaNs can either propagate (the default), or they can return 206*5fd0122aSMatthias Ringwald //! the default NaN. 207*5fd0122aSMatthias Ringwald //! 208*5fd0122aSMatthias Ringwald //! \note Unless this function is called prior to executing any floating-point 209*5fd0122aSMatthias Ringwald //! instructions, the default mode is used. 210*5fd0122aSMatthias Ringwald //! 211*5fd0122aSMatthias Ringwald //! \return None. 212*5fd0122aSMatthias Ringwald // 213*5fd0122aSMatthias Ringwald //***************************************************************************** 214*5fd0122aSMatthias Ringwald extern void FPU_setNaNMode(uint32_t mode); 215*5fd0122aSMatthias Ringwald 216*5fd0122aSMatthias Ringwald //***************************************************************************** 217*5fd0122aSMatthias Ringwald // 218*5fd0122aSMatthias Ringwald //! Selects the flush-to-zero mode. 219*5fd0122aSMatthias Ringwald //! 220*5fd0122aSMatthias Ringwald //! \param mode is the flush-to-zero mode; which is either 221*5fd0122aSMatthias Ringwald //! \b FPU_FLUSH_TO_ZERO_DIS or \b FPU_FLUSH_TO_ZERO_EN. 222*5fd0122aSMatthias Ringwald //! 223*5fd0122aSMatthias Ringwald //! This function enables or disables the flush-to-zero mode of the 224*5fd0122aSMatthias Ringwald //! floating-point unit. When disabled (the default), the floating-point unit 225*5fd0122aSMatthias Ringwald //! is fully IEEE compliant. When enabled, values close to zero are treated as 226*5fd0122aSMatthias Ringwald //! zero, greatly improving the execution speed at the expense of some accuracy 227*5fd0122aSMatthias Ringwald //! (as well as IEEE compliance). 228*5fd0122aSMatthias Ringwald //! 229*5fd0122aSMatthias Ringwald //! \note Unless this function is called prior to executing any floating-point 230*5fd0122aSMatthias Ringwald //! instructions, the default mode is used. 231*5fd0122aSMatthias Ringwald //! 232*5fd0122aSMatthias Ringwald //! \return None. 233*5fd0122aSMatthias Ringwald // 234*5fd0122aSMatthias Ringwald //***************************************************************************** 235*5fd0122aSMatthias Ringwald extern void FPU_setFlushToZeroMode(uint32_t mode); 236*5fd0122aSMatthias Ringwald 237*5fd0122aSMatthias Ringwald //***************************************************************************** 238*5fd0122aSMatthias Ringwald // 239*5fd0122aSMatthias Ringwald //! Selects the rounding mode for floating-point results. 240*5fd0122aSMatthias Ringwald //! 241*5fd0122aSMatthias Ringwald //! \param mode is the rounding mode. 242*5fd0122aSMatthias Ringwald //! 243*5fd0122aSMatthias Ringwald //! This function selects the rounding mode for floating-point results. After 244*5fd0122aSMatthias Ringwald //! a floating-point operation, the result is rounded toward the specified 245*5fd0122aSMatthias Ringwald //! value. The default mode is \b FPU_ROUND_NEAREST. 246*5fd0122aSMatthias Ringwald //! 247*5fd0122aSMatthias Ringwald //! The following rounding modes are available (as specified by \e mode): 248*5fd0122aSMatthias Ringwald //! 249*5fd0122aSMatthias Ringwald //! - \b FPU_ROUND_NEAREST - round toward the nearest value 250*5fd0122aSMatthias Ringwald //! - \b FPU_ROUND_POS_INF - round toward positive infinity 251*5fd0122aSMatthias Ringwald //! - \b FPU_ROUND_NEG_INF - round toward negative infinity 252*5fd0122aSMatthias Ringwald //! - \b FPU_ROUND_ZERO - round toward zero 253*5fd0122aSMatthias Ringwald //! 254*5fd0122aSMatthias Ringwald //! \note Unless this function is called prior to executing any floating-point 255*5fd0122aSMatthias Ringwald //! instructions, the default mode is used. 256*5fd0122aSMatthias Ringwald //! 257*5fd0122aSMatthias Ringwald //! \return None. 258*5fd0122aSMatthias Ringwald // 259*5fd0122aSMatthias Ringwald //***************************************************************************** 260*5fd0122aSMatthias Ringwald extern void FPU_setRoundingMode(uint32_t mode); 261*5fd0122aSMatthias Ringwald 262*5fd0122aSMatthias Ringwald //***************************************************************************** 263*5fd0122aSMatthias Ringwald // 264*5fd0122aSMatthias Ringwald // Mark the end of the C bindings section for C++ compilers. 265*5fd0122aSMatthias Ringwald // 266*5fd0122aSMatthias Ringwald //***************************************************************************** 267*5fd0122aSMatthias Ringwald #ifdef __cplusplus 268*5fd0122aSMatthias Ringwald } 269*5fd0122aSMatthias Ringwald #endif 270*5fd0122aSMatthias Ringwald 271*5fd0122aSMatthias Ringwald 272*5fd0122aSMatthias Ringwald //***************************************************************************** 273*5fd0122aSMatthias Ringwald // 274*5fd0122aSMatthias Ringwald // Close the Doxygen group. 275*5fd0122aSMatthias Ringwald //! @} 276*5fd0122aSMatthias Ringwald // 277*5fd0122aSMatthias Ringwald //***************************************************************************** 278*5fd0122aSMatthias Ringwald 279*5fd0122aSMatthias Ringwald 280*5fd0122aSMatthias Ringwald #endif // __FPU_H__ 281