EE445M RTOS
Taken at the University of Texas Spring 2015
fpu.c
Go to the documentation of this file.
1 //*****************************************************************************
2 //
3 // fpu.c - Routines for manipulating the floating-point unit in the Cortex-M
4 // processor.
5 //
6 // Copyright (c) 2011-2014 Texas Instruments Incorporated. All rights reserved.
7 // Software License Agreement
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions
11 // are met:
12 //
13 // Redistributions of source code must retain the above copyright
14 // notice, this list of conditions and the following disclaimer.
15 //
16 // Redistributions in binary form must reproduce the above copyright
17 // notice, this list of conditions and the following disclaimer in the
18 // documentation and/or other materials provided with the
19 // 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
26 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 //
37 // This is part of revision 2.1.0.12573 of the Tiva Peripheral Driver Library.
38 //
39 //*****************************************************************************
40 
41 //*****************************************************************************
42 //
45 //
46 //*****************************************************************************
47 
48 #include <stdint.h>
49 #include "inc/hw_nvic.h"
50 #include "inc/hw_types.h"
51 #include "driverlib/fpu.h"
52 
53 //*****************************************************************************
54 //
63 //
64 //*****************************************************************************
65 void
66 FPUEnable(void)
67 {
68  //
69  // Enable the coprocessors used by the floating-point unit.
70  //
74 }
75 
76 //*****************************************************************************
77 //
84 //
85 //*****************************************************************************
86 void
88 {
89  //
90  // Disable the coprocessors used by the floating-point unit.
91  //
95 }
96 
97 //*****************************************************************************
98 //
115 //
116 //*****************************************************************************
117 void
119 {
120  //
121  // Enable automatic state preservation for the floating-point unit, and
122  // disable lazy state preservation (meaning that the floating-point state
123  // is always stacked when floating-point instructions are used).
124  //
126 }
127 
128 //*****************************************************************************
129 //
147 //
148 //*****************************************************************************
149 void
151 {
152  //
153  // Enable automatic and lazy state preservation for the floating-point
154  // unit.
155  //
157 }
158 
159 //*****************************************************************************
160 //
169 //
170 //*****************************************************************************
171 void
173 {
174  //
175  // Disable automatic and lazy state preservation for the floating-point
176  // unit.
177  //
179 }
180 
181 //*****************************************************************************
182 //
198 //
199 //*****************************************************************************
200 void
201 FPUHalfPrecisionModeSet(uint32_t ui32Mode)
202 {
203  //
204  // Set the half-precision floating-point format.
205  //
206  HWREG(NVIC_FPDSC) = (HWREG(NVIC_FPDSC) & ~(NVIC_FPDSC_AHP)) | ui32Mode;
207 }
208 
209 //*****************************************************************************
210 //
224 //
225 //*****************************************************************************
226 void
227 FPUNaNModeSet(uint32_t ui32Mode)
228 {
229  //
230  // Set the NaN mode.
231  //
232  HWREG(NVIC_FPDSC) = (HWREG(NVIC_FPDSC) & ~(NVIC_FPDSC_DN)) | ui32Mode;
233 }
234 
235 //*****************************************************************************
236 //
252 //
253 //*****************************************************************************
254 void
255 FPUFlushToZeroModeSet(uint32_t ui32Mode)
256 {
257  //
258  // Set the flush-to-zero mode.
259  //
260  HWREG(NVIC_FPDSC) = (HWREG(NVIC_FPDSC) & ~(NVIC_FPDSC_FZ)) | ui32Mode;
261 }
262 
263 //*****************************************************************************
264 //
284 //
285 //*****************************************************************************
286 void
287 FPURoundingModeSet(uint32_t ui32Mode)
288 {
289  //
290  // Set the rounding mode.
291  //
292  HWREG(NVIC_FPDSC) = (HWREG(NVIC_FPDSC) & ~(NVIC_FPDSC_RMODE_M)) | ui32Mode;
293 }
294 
295 //*****************************************************************************
296 //
297 // Close the Doxygen group.
299 //
300 //*****************************************************************************
#define NVIC_FPDSC_RMODE_M
Definition: hw_nvic.h:1406
#define NVIC_CPAC
Definition: hw_nvic.h:129
#define NVIC_CPAC_CP10_FULL
Definition: hw_nvic.h:1103
#define NVIC_FPCC_LSPEN
Definition: hw_nvic.h:1381
#define HWREG(x)
Definition: hw_types.h:48
void FPUStackingDisable(void)
Definition: fpu.c:172
#define NVIC_FPDSC_DN
Definition: hw_nvic.h:1404
void FPUEnable(void)
Definition: fpu.c:66
void FPUHalfPrecisionModeSet(uint32_t ui32Mode)
Definition: fpu.c:201
#define NVIC_CPAC_CP11_FULL
Definition: hw_nvic.h:1098
void FPUNaNModeSet(uint32_t ui32Mode)
Definition: fpu.c:227
#define NVIC_CPAC_CP10_DIS
Definition: hw_nvic.h:1101
#define NVIC_FPDSC_FZ
Definition: hw_nvic.h:1405
#define NVIC_FPCC
Definition: hw_nvic.h:149
#define NVIC_CPAC_CP11_M
Definition: hw_nvic.h:1094
#define NVIC_CPAC_CP11_DIS
Definition: hw_nvic.h:1096
#define NVIC_FPCC_ASPEN
Definition: hw_nvic.h:1379
void FPURoundingModeSet(uint32_t ui32Mode)
Definition: fpu.c:287
#define NVIC_FPDSC
Definition: hw_nvic.h:151
void FPUDisable(void)
Definition: fpu.c:87
void FPUStackingEnable(void)
Definition: fpu.c:118
void FPUFlushToZeroModeSet(uint32_t ui32Mode)
Definition: fpu.c:255
void FPULazyStackingEnable(void)
Definition: fpu.c:150
#define NVIC_CPAC_CP10_M
Definition: hw_nvic.h:1099
#define NVIC_FPDSC_AHP
Definition: hw_nvic.h:1403