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