TM STM32Fxxx HAL Libraries  v1.0.0
Libraries for STM32Fxxx (F0, F4 and F7 series) devices based on HAL drivers from ST from Tilen Majerle

Library Functions. More...

Macros

#define TM_FFT_GetMaxValue(FFT)    ((FFT)->MaxValue)
 Gets max value from already calculated FFT result. More...
 
#define TM_FFT_GetMaxIndex(FFT)    ((FFT)->MaxIndex)
 Gets index value where max value happens from already calculated FFT result. More...
 
#define TM_FFT_GetFFTSize(FFT)    ((FFT)->FFT_Size)
 Gets FFT size in units of samples length. More...
 
#define TM_FFT_GetFromBuffer(FFT, index)    ((FFT)->Output[(uint16_t)(index)])
 Gets FFT result value from output buffer at given index. More...
 

Functions

uint8_t TM_FFT_Init_F32 (TM_FFT_F32_t *FFT, uint16_t FFT_Size, uint8_t use_malloc)
 Initializes and prepares FFT structure for signal operations. More...
 
void TM_FFT_SetBuffers_F32 (TM_FFT_F32_t *FFT, float32_t *InputBuffer, float32_t *OutputBuffer)
 Sets input and output buffers for FFT calculations. More...
 
uint8_t TM_FFT_AddToBuffer (TM_FFT_F32_t *FFT, float32_t sampleValue)
 Adds new sample to input buffer in FFT array. More...
 
uint8_t TM_FFT_AddToBufferWithImag (TM_FFT_F32_t *FFT, float32_t Real, float32_t Imag)
 Adds new sample (real and imaginary part if needed) to input buffer in FFT array. More...
 
void TM_FFT_Process_F32 (TM_FFT_F32_t *FFT)
 Processes and calculates FFT from InputBuffer and saves data to Output buffer. More...
 
void TM_FFT_Free_F32 (TM_FFT_F32_t *FFT)
 Free input and output buffers. More...
 

Detailed Description

Library Functions.

Macro Definition Documentation

#define TM_FFT_GetFFTSize (   FFT)    ((FFT)->FFT_Size)

Gets FFT size in units of samples length.

Parameters
FFTPointer to TM_FFT_F32_t structure where FFT size will be checked
Return values
FFTsize in units of elements for calculation
Note
Defined as macro for faster execution
#define TM_FFT_GetFromBuffer (   FFT,
  index 
)    ((FFT)->Output[(uint16_t)(index)])

Gets FFT result value from output buffer at given index.

Parameters
FFTPointer to TM_FFT_F32_t structure where FFT output sample will be returned
indexIndex in buffer where result will be returned. Valid input is between 0 and FFT_Size - 1
Return values
Valueat given index
Note
Defined as macro for faster execution
#define TM_FFT_GetMaxIndex (   FFT)    ((FFT)->MaxIndex)

Gets index value where max value happens from already calculated FFT result.

Parameters
FFTPointer to TM_FFT_F32_t structure where max index at max value should be checked
Return values
None
Note
Defined as macro for faster execution
#define TM_FFT_GetMaxValue (   FFT)    ((FFT)->MaxValue)

Gets max value from already calculated FFT result.

Parameters
FFTPointer to TM_FFT_F32_t structure where max value should be checked
Return values
None
Note
Defined as macro for faster execution

Function Documentation

uint8_t TM_FFT_AddToBuffer ( TM_FFT_F32_t FFT,
float32_t  sampleValue 
)

Adds new sample to input buffer in FFT array.

Parameters
*FFTPointer to TM_FFT_F32_t structure where new sample will be added
sampleValueA new sample to be added to buffer, real part. Imaginary part will be set to 0
Return values
FFTcalculation status:
  • 0: Input buffer is not full yet
  • > 0: Input buffer is full and samples are ready to be calculated
uint8_t TM_FFT_AddToBufferWithImag ( TM_FFT_F32_t FFT,
float32_t  Real,
float32_t  Imag 
)

Adds new sample (real and imaginary part if needed) to input buffer in FFT array.

Parameters
*FFTPointer to TM_FFT_F32_t structure where new sample will be added
RealA new sample to be added to buffer, real part.
ImagA new sample to be added to buffer, imaginary part.
Return values
FFTcalculation status:
  • 0: Input buffer is not full yet
  • > 0: Input buffer is full and samples are ready to be calculated
void TM_FFT_Free_F32 ( TM_FFT_F32_t FFT)

Free input and output buffers.

Note
This function has sense only, if you used malloc for memory allocation when you called TM_FFT_Init_F32 function
Parameters
*FFTPointer to TM_FFT_F32_t structure where buffers will be free
Return values
None
uint8_t TM_FFT_Init_F32 ( TM_FFT_F32_t FFT,
uint16_t  FFT_Size,
uint8_t  use_malloc 
)

Initializes and prepares FFT structure for signal operations.

Parameters
*FFTPointer to empty TM_FFT_F32_t structure for FFT
FFT_SizeNumber of samples to be used for FFT calculation This parameter can be a value of 2^n where n is between 4 and 12, so any power of 2 between 16 and 4096
use_mallocSet parameter to 1, if you want to use HEAP memory and malloc to allocate input and output buffers
Note
It is recommended to use malloc for allocation, because FFT input and output buffers differs in length
Return values
Initializationstatus:
  • 0: Initialized OK, ready to use
  • 1: Input FFT SIZE is not valid
  • 2: Malloc failed with allocating input data buffer
  • 3: Malloc failed with allocating output data buffer. If input data buffer is allocated, it will be free if this is returned.
void TM_FFT_Process_F32 ( TM_FFT_F32_t FFT)

Processes and calculates FFT from InputBuffer and saves data to Output buffer.

Note
This function also calculates max value and max index in array where max value happens
Parameters
*FFTPointer to TM_FFT_F32_t where FFT calculation will happen
Return values
None
void TM_FFT_SetBuffers_F32 ( TM_FFT_F32_t FFT,
float32_t *  InputBuffer,
float32_t *  OutputBuffer 
)

Sets input and output buffers for FFT calculations.

Note
Use this function only if you set
Parameters
*FFTPointer to TM_FFT_F32_t structure where buffers will be set
*InputBufferPointer to buffer of type float32_t with FFT_Size * 2 length
*OutputBufferPointer to buffer of type float32_t with FFT_Size length
Return values
None