aboutsummaryrefslogtreecommitdiffstats
path: root/firmware/filter.h
blob: 127bfce0dccb5732326a8c9dbe621efa7ba3b4a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#ifndef FILTER_H_
#define FILTER_H_

#include "util.h"
#include "fixpt.h"


struct lp_filter_u16 {
	uint24_t filter_buf;
};

struct lp_filter_fixpt {
	fixpt_t filter_buf;
};


static inline void lp_filter_u16_set(struct lp_filter_u16 *lp,
				     uint16_t new_value)
{
	lp->filter_buf = new_value;
}

static inline void lp_filter_u16_reset(struct lp_filter_u16 *lp)
{
	lp_filter_u16_set(lp, 0u);
}

uint16_t lp_filter_u16_run(struct lp_filter_u16 *lp, uint16_t in,
			   uint8_t filter_shift);

static inline void lp_filter_fixpt_set(struct lp_filter_fixpt *lp,
				       fixpt_t new_value)
{
	lp->filter_buf = new_value;
}

static inline void lp_filter_fixpt_reset(struct lp_filter_fixpt *lp)
{
	lp_filter_fixpt_set(lp, int_to_fixpt(0));
}

fixpt_t lp_filter_fixpt_run(struct lp_filter_fixpt *lp, fixpt_t in,
			    fixpt_t div);

#endif /* FILTER_H_ */
bues.ch cgit interface