Library Functions.
More...
Library Functions.
#define TM_FFT_GetFFTSize 
( 

FFT  ) 
((FFT)>FFT_Size) 
Gets FFT size in units of samples length.
 Parameters

FFT  Pointer to TM_FFT_F32_t structure where FFT size will be checked 
 Return values

FFT  size 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

FFT  Pointer to TM_FFT_F32_t structure where FFT output sample will be returned 
index  Index in buffer where result will be returned. Valid input is between 0 and FFT_Size  1 
 Return values

 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

FFT  Pointer to TM_FFT_F32_t structure where max index at max value should be checked 
 Return values

 Note
 Defined as macro for faster execution
#define TM_FFT_GetMaxValue 
( 

FFT  ) 
((FFT)>MaxValue) 
Gets max value from already calculated FFT result.
 Parameters

FFT  Pointer to TM_FFT_F32_t structure where max value should be checked 
 Return values

 Note
 Defined as macro for faster execution
uint8_t TM_FFT_AddToBuffer 
( 
TM_FFT_F32_t * 
FFT, 


float32_t 
sampleValue 

) 
 
Adds new sample to input buffer in FFT array.
 Parameters

*FFT  Pointer to TM_FFT_F32_t structure where new sample will be added 
sampleValue  A new sample to be added to buffer, real part. Imaginary part will be set to 0 
 Return values

FFT  calculation 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

*FFT  Pointer to TM_FFT_F32_t structure where new sample will be added 
Real  A new sample to be added to buffer, real part. 
Imag  A new sample to be added to buffer, imaginary part. 
 Return values

FFT  calculation status:
 0: Input buffer is not full yet
 > 0: Input buffer is full and samples are ready to be calculated

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

*FFT  Pointer to TM_FFT_F32_t structure where buffers will be free 
 Return values

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

*FFT  Pointer to empty TM_FFT_F32_t structure for FFT 
FFT_Size  Number 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_malloc  Set 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

Initialization  status:
 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.

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

*FFT  Pointer to TM_FFT_F32_t where FFT calculation will happen 
 Return values

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

*FFT  Pointer to TM_FFT_F32_t structure where buffers will be set 
*InputBuffer  Pointer to buffer of type float32_t with FFT_Size * 2 length 
*OutputBuffer  Pointer to buffer of type float32_t with FFT_Size length 
 Return values
