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
tm_stm32_fft.h
1 
37 #ifndef TM_FFT_H
38 #define TM_FFT_H 100
39 
40 /* C++ detection */
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44 
126 #include "stm32fxxx_hal.h"
127 #include "defines.h"
128 
129 #include "arm_math.h"
130 #include "arm_const_structs.h"
131 
138 /* Memory allocation function */
139 #ifndef LIB_ALLOC_FUNC
140 #define LIB_ALLOC_FUNC malloc
141 #endif
142 
143 /* Memory free function */
144 #ifndef LIB_FREE_FUNC
145 #define LIB_FREE_FUNC free
146 #endif
147 
161 typedef struct {
162  float32_t* Input;
163  float32_t* Output;
164  uint16_t FFT_Size;
165  uint8_t UseMalloc;
166  uint16_t Count;
167  const arm_cfft_instance_f32* S;
168  float32_t MaxValue;
169  uint32_t MaxIndex;
170 } TM_FFT_F32_t;
171 
195 uint8_t TM_FFT_Init_F32(TM_FFT_F32_t* FFT, uint16_t FFT_Size, uint8_t use_malloc);
196 
205 void TM_FFT_SetBuffers_F32(TM_FFT_F32_t* FFT, float32_t* InputBuffer, float32_t* OutputBuffer);
206 
215 uint8_t TM_FFT_AddToBuffer(TM_FFT_F32_t* FFT, float32_t sampleValue);
216 
226 uint8_t TM_FFT_AddToBufferWithImag(TM_FFT_F32_t* FFT, float32_t Real, float32_t Imag);
227 
235 
242 void TM_FFT_Free_F32(TM_FFT_F32_t* FFT);
243 
250 #define TM_FFT_GetMaxValue(FFT) ((FFT)->MaxValue)
251 
258 #define TM_FFT_GetMaxIndex(FFT) ((FFT)->MaxIndex)
259 
266 #define TM_FFT_GetFFTSize(FFT) ((FFT)->FFT_Size)
267 
275 #define TM_FFT_GetFromBuffer(FFT, index) ((FFT)->Output[(uint16_t)(index)])
276 
289 /* C++ detection */
290 #ifdef __cplusplus
291 }
292 #endif
293 
294 #endif
const arm_cfft_instance_f32 * S
Definition: tm_stm32_fft.h:167
void TM_FFT_SetBuffers_F32(TM_FFT_F32_t *FFT, float32_t *InputBuffer, float32_t *OutputBuffer)
Sets input and output buffers for FFT calculations.
uint16_t FFT_Size
Definition: tm_stm32_fft.h:164
void TM_FFT_Free_F32(TM_FFT_F32_t *FFT)
Free input and output buffers.
FFT main structure for 32-bit float.
Definition: tm_stm32_fft.h:161
uint8_t UseMalloc
Definition: tm_stm32_fft.h:165
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.
float32_t * Input
Definition: tm_stm32_fft.h:162
float32_t * Output
Definition: tm_stm32_fft.h:163
uint32_t MaxIndex
Definition: tm_stm32_fft.h:169
float32_t MaxValue
Definition: tm_stm32_fft.h:168
uint8_t TM_FFT_AddToBuffer(TM_FFT_F32_t *FFT, float32_t sampleValue)
Adds new sample to input buffer in FFT array.
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. ...
void TM_FFT_Process_F32(TM_FFT_F32_t *FFT)
Processes and calculates FFT from InputBuffer and saves data to Output buffer.
uint16_t Count
Definition: tm_stm32_fft.h:166