#ifndef __FILTER_H__
#define __FILTER_H__

#ifdef __cplusplus
 extern "C" {
#endif

#include "stm32f4xx.h"

struct list_s {
    struct list_s *prev;
    struct list_s *next;
    uint32_t data;
};

struct data_filter_s {
    float raw_f;
    uint32_t raw_u;

    uint16_t median_len;
    uint16_t median_idx;
    struct list_s head;
    struct list_s *median_buff;
    uint32_t median_output;

    uint16_t window_len;
    uint16_t window_idx;
    uint32_t *window_buff;
    uint32_t window_sum;
    uint32_t window_output;
};

extern uint32_t system_tick_cnt;

extern void filter_init(void);
extern void filter_quadratic_process(void);
extern void filter_median_process(void);
extern void filter_window_process(void);
extern void filter_output_process(void);
extern void filter_loop(void);

#ifdef __cplusplus
}
#endif

#endif /* __FILTER_H__ */
