Functions
Fpu_api

Functions

void FPUEnable (void)
 
void FPUDisable (void)
 
void FPUStackingEnable (void)
 
void FPULazyStackingEnable (void)
 
void FPUStackingDisable (void)
 
void FPUHalfPrecisionModeSet (uint32_t ui32Mode)
 
void FPUNaNModeSet (uint32_t ui32Mode)
 
void FPUFlushToZeroModeSet (uint32_t ui32Mode)
 
void FPURoundingModeSet (uint32_t ui32Mode)
 

Detailed Description

Function Documentation

§ FPUEnable()

void FPUEnable ( void  )

Enables the floating-point unit.

This function enables the floating-point unit, allowing the floating-point instructions to be executed. This function must be called prior to performing any hardware floating-point operations; failure to do so results in a NOCP usage fault.

Returns
None.

References HWREG, NVIC_CPAC, NVIC_CPAC_CP10_FULL, NVIC_CPAC_CP10_M, NVIC_CPAC_CP11_FULL, and NVIC_CPAC_CP11_M.

§ FPUDisable()

void FPUDisable ( void  )

Disables the floating-point unit.

This function disables the floating-point unit, preventing floating-point instructions from executing (generating a NOCP usage fault instead).

Returns
None.

References HWREG, NVIC_CPAC, NVIC_CPAC_CP10_DIS, NVIC_CPAC_CP10_M, NVIC_CPAC_CP11_DIS, and NVIC_CPAC_CP11_M.

§ FPUStackingEnable()

void FPUStackingEnable ( void  )

Enables the stacking of floating-point registers.

This function enables the stacking of floating-point registers s0-s15 when an interrupt is handled. When enabled, space is reserved on the stack for the floating-point context and the floating-point state is saved into this stack space. Upon return from the interrupt, the floating-point context is restored.

If the floating-point registers are not stacked, floating-point instructions cannot be safely executed in an interrupt handler because the values of s0-s15 are not likely to be preserved for the interrupted code. On the other hand, stacking the floating-point registers increases the stacking operation from 8 words to 26 words, also increasing the interrupt response latency.

Returns
None.

References HWREG, NVIC_FPCC, NVIC_FPCC_ASPEN, and NVIC_FPCC_LSPEN.

§ FPULazyStackingEnable()

void FPULazyStackingEnable ( void  )

Enables the lazy stacking of floating-point registers.

This function enables the lazy stacking of floating-point registers s0-s15 when an interrupt is handled. When lazy stacking is enabled, space is reserved on the stack for the floating-point context, but the floating-point state is not saved. If a floating-point instruction is executed from within the interrupt context, the floating-point context is first saved into the space reserved on the stack. On completion of the interrupt handler, the floating-point context is only restored if it was saved (as the result of executing a floating-point instruction).

This method provides a compromise between fast interrupt response (because the floating-point state is not saved on interrupt entry) and the ability to use floating-point in interrupt handlers (because the floating-point state is saved if floating-point instructions are used).

Returns
None.

References HWREG, NVIC_FPCC, NVIC_FPCC_ASPEN, and NVIC_FPCC_LSPEN.

§ FPUStackingDisable()

void FPUStackingDisable ( void  )

Disables the stacking of floating-point registers.

This function disables the stacking of floating-point registers s0-s15 when an interrupt is handled. When floating-point context stacking is disabled, floating-point operations performed in an interrupt handler destroy the floating-point context of the main thread of execution.

Returns
None.

References HWREG, NVIC_FPCC, NVIC_FPCC_ASPEN, and NVIC_FPCC_LSPEN.

§ FPUHalfPrecisionModeSet()

void FPUHalfPrecisionModeSet ( uint32_t  ui32Mode)

Selects the format of half-precision floating-point values.

Parameters
ui32Modeis the format for half-precision floating-point value, which is either FPU_HALF_IEEE or FPU_HALF_ALTERNATE.

This function selects between the IEEE half-precision floating-point representation and the Cortex-M processor alternative representation. The alternative representation has a larger range but does not have a way to encode infinity (positive or negative) or NaN (quiet or signaling). The default setting is the IEEE format.

Note
Unless this function is called prior to executing any floating-point instructions, the default mode is used.
Returns
None.

References HWREG, NVIC_FPDSC, and NVIC_FPDSC_AHP.

§ FPUNaNModeSet()

void FPUNaNModeSet ( uint32_t  ui32Mode)

Selects the NaN mode.

Parameters
ui32Modeis the mode for NaN results; which is either FPU_NAN_PROPAGATE or FPU_NAN_DEFAULT.

This function selects the handling of NaN results during floating-point computations. NaNs can either propagate (the default), or they can return the default NaN.

Note
Unless this function is called prior to executing any floating-point instructions, the default mode is used.
Returns
None.

References HWREG, NVIC_FPDSC, and NVIC_FPDSC_DN.

§ FPUFlushToZeroModeSet()

void FPUFlushToZeroModeSet ( uint32_t  ui32Mode)

Selects the flush-to-zero mode.

Parameters
ui32Modeis the flush-to-zero mode; which is either FPU_FLUSH_TO_ZERO_DIS or FPU_FLUSH_TO_ZERO_EN.

This function enables or disables the flush-to-zero mode of the floating-point unit. When disabled (the default), the floating-point unit is fully IEEE compliant. When enabled, values close to zero are treated as zero, greatly improving the execution speed at the expense of some accuracy (as well as IEEE compliance).

Note
Unless this function is called prior to executing any floating-point instructions, the default mode is used.
Returns
None.

References HWREG, NVIC_FPDSC, and NVIC_FPDSC_FZ.

§ FPURoundingModeSet()

void FPURoundingModeSet ( uint32_t  ui32Mode)

Selects the rounding mode for floating-point results.

Parameters
ui32Modeis the rounding mode.

This function selects the rounding mode for floating-point results. After a floating-point operation, the result is rounded toward the specified value. The default mode is FPU_ROUND_NEAREST.

The following rounding modes are available (as specified by ui32Mode):

  • FPU_ROUND_NEAREST - round toward the nearest value
  • FPU_ROUND_POS_INF - round toward positive infinity
  • FPU_ROUND_NEG_INF - round toward negative infinity
  • FPU_ROUND_ZERO - round toward zero
Note
Unless this function is called prior to executing any floating-point instructions, the default mode is used.
Returns
None.

References HWREG, NVIC_FPDSC, and NVIC_FPDSC_RMODE_M.

Copyright 2017, Texas Instruments Incorporated