From d9b26d16c063aec32b70287ff861a1f23642a9f2 Mon Sep 17 00:00:00 2001 From: jaseg Date: Wed, 4 Mar 2020 17:10:31 +0100 Subject: Fix frequency measurement simulation --- controller/fw/src/freq_meas.c | 69 +++++++++++++++++++++++++++++++++--------- controller/fw/src/freq_meas.h | 2 +- controller/fw/src/simulation.h | 14 +++++++++ 3 files changed, 70 insertions(+), 15 deletions(-) create mode 100644 controller/fw/src/simulation.h (limited to 'controller/fw/src') diff --git a/controller/fw/src/freq_meas.c b/controller/fw/src/freq_meas.c index 627af34..ba7801e 100644 --- a/controller/fw/src/freq_meas.c +++ b/controller/fw/src/freq_meas.c @@ -7,6 +7,7 @@ #include "freq_meas.h" #include "sr_global.h" +#include "simulation.h" /* FTT window lookup table defined in generated/fmeas_fft_window.c */ @@ -29,17 +30,33 @@ extern arm_status arm_rfft_4096_fast_init_f32(arm_rfft_fast_instance_f32 * S); void func_gauss_grad(float *out, float *params, int x, void *userdata); float func_gauss(float *params, int x, void *userdata); -int adc_buf_measure_freq(uint16_t adc_buf[FMEAS_FFT_LEN], float *out) { +int adc_buf_measure_freq(int16_t adc_buf[FMEAS_FFT_LEN], float *out) { int rc; float in_buf[FMEAS_FFT_LEN]; float out_buf[FMEAS_FFT_LEN]; + /* + DEBUG_PRINTN(" [emulated adc buf] "); + for (size_t i=0; i +#define DEBUG_PRINTN(...) fprintf(stderr, __VA_ARGS__) +#define DEBUG_PRINTNF(fmt, ...) DEBUG_PRINTN("%s:%d: " fmt, __FILE__, __LINE__, ##__VA_ARGS__) +#define DEBUG_PRINT(fmt, ...) DEBUG_PRINTNF(fmt "\n", ##__VA_ARGS__) +#else +#define DEBUG_PRINT(...) ((void)0) +#define DEBUG_PRINTN(...) ((void)0) +#endif + +#endif /* __SIMULATION_H__ */ -- cgit