[layer1] Adding neighbour cell measurement code to layer1.
[osmocom-bb.git] / src / target / firmware / include / layer1 / avg.h
1 #ifndef _L1_AVG_H
2 #define _L1_AVG_H
3
4 struct running_avg {
5         /* configuration */
6         uint16_t        period;                 /* over how many samples to average */
7         uint16_t        min_valid;
8
9         int32_t         acc_val;
10         uint16_t        num_samples;            /* how often did we try to sample? */
11         uint16_t        num_samples_valid;      /* how often did we receive valid samples? */
12
13         void            (*outfn)(struct running_avg *, int32_t avg);
14         void            *priv;
15 };
16
17 /* input a new sample into the averaging process */
18 void runavg_input(struct running_avg *ravg, int32_t val, int valid);
19
20 /* check if sufficient samples have been obtained, and call outfn() */
21 int runavg_check_output(struct running_avg *ravg);
22
23 #endif /* _AVG_H */