TM STM32F4xx Libraries  v1.0.0
Libraries for STM32F4xx devices from Tilen Majerle
tm_stm32f4_fft.h
1 
30 #ifndef TM_FFT_H
31 #define TM_FFT_H 100
32 
33 /* C++ detection */
34 #ifdef __cplusplus
35 extern C {
36 #endif
37 
69 #include "stm32f4xx.h"
70 #include "defines.h"
71 
72 #include "arm_math.h"
73 #include "arm_const_structs.h"
74 
81 /* Memory allocation function */
82 #ifndef LIB_ALLOC_FUNC
83 #define LIB_ALLOC_FUNC malloc
84 #endif
85 
86 /* Memory free function */
87 #ifndef LIB_FREE_FUNC
88 #define LIB_FREE_FUNC free
89 #endif
90 
104 typedef struct {
105  float32_t* Input;
106  float32_t* Output;
107  uint16_t FFT_Size;
108  uint8_t UseMalloc;
109  uint16_t Count;
110  const arm_cfft_instance_f32* S;
111  float32_t MaxValue;
112  uint32_t MaxIndex;
113 } TM_FFT_F32_t;
114 
138 uint8_t TM_FFT_Init_F32(TM_FFT_F32_t* FFT, uint16_t FFT_Size, uint8_t use_malloc);
139 
148 void TM_FFT_SetBuffers_F32(TM_FFT_F32_t* FFT, float32_t* InputBuffer, float32_t* OutputBuffer);
149 
158 uint8_t TM_FFT_AddToBuffer(TM_FFT_F32_t* FFT, float32_t sampleValue);
159 
167 
174 void TM_FFT_Free_F32(TM_FFT_F32_t* FFT);
175 
182 #define TM_FFT_GetMaxValue(FFT) ((FFT)->MaxValue)
183 
190 #define TM_FFT_GetMaxIndex(FFT) ((FFT)->MaxIndex)
191 
198 #define TM_FFT_GetFFTSize(FFT) ((FFT)->FFT_Size)
199 
207 #define TM_FFT_GetFromBuffer(FFT, index) ((FFT)->Output[(uint16_t)(index)])
208 
221 /* C++ detection */
222 #ifdef __cplusplus
223 }
224 #endif
225 
226 #endif
const arm_cfft_instance_f32 * S
Definition: tm_stm32f4_fft.h:110
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_stm32f4_fft.h:107
void TM_FFT_Free_F32(TM_FFT_F32_t *FFT)
Free input and output buffers.
FFT main structure for 32-bit float.
Definition: tm_stm32f4_fft.h:104
uint8_t UseMalloc
Definition: tm_stm32f4_fft.h:108
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_stm32f4_fft.h:105
float32_t * Output
Definition: tm_stm32f4_fft.h:106
uint32_t MaxIndex
Definition: tm_stm32f4_fft.h:112
float32_t MaxValue
Definition: tm_stm32f4_fft.h:111
uint8_t TM_FFT_AddToBuffer(TM_FFT_F32_t *FFT, float32_t sampleValue)
Adds new sample 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_stm32f4_fft.h:109