1
2
3
4
5
6#ifndef INV_ICM42600_TIMESTAMP_H_
7#define INV_ICM42600_TIMESTAMP_H_
8
9#include <linux/kernel.h>
10
11struct inv_icm42600_state;
12
13
14
15
16
17
18struct inv_icm42600_timestamp_interval {
19 int64_t lo;
20 int64_t up;
21};
22
23
24
25
26
27
28
29struct inv_icm42600_timestamp_acc {
30 uint32_t val;
31 size_t idx;
32 uint32_t values[32];
33};
34
35
36
37
38
39
40
41
42
43
44struct inv_icm42600_timestamp {
45 struct inv_icm42600_timestamp_interval it;
46 int64_t timestamp;
47 uint32_t mult;
48 uint32_t new_mult;
49 uint32_t period;
50 struct inv_icm42600_timestamp_acc chip_period;
51};
52
53void inv_icm42600_timestamp_init(struct inv_icm42600_timestamp *ts,
54 uint32_t period);
55
56int inv_icm42600_timestamp_setup(struct inv_icm42600_state *st);
57
58int inv_icm42600_timestamp_update_odr(struct inv_icm42600_timestamp *ts,
59 uint32_t period, bool fifo);
60
61void inv_icm42600_timestamp_interrupt(struct inv_icm42600_timestamp *ts,
62 uint32_t fifo_period, size_t fifo_nb,
63 size_t sensor_nb, int64_t timestamp);
64
65static inline int64_t
66inv_icm42600_timestamp_pop(struct inv_icm42600_timestamp *ts)
67{
68 ts->timestamp += ts->period;
69 return ts->timestamp;
70}
71
72void inv_icm42600_timestamp_apply_odr(struct inv_icm42600_timestamp *ts,
73 uint32_t fifo_period, size_t fifo_nb,
74 unsigned int fifo_no);
75
76static inline void
77inv_icm42600_timestamp_reset(struct inv_icm42600_timestamp *ts)
78{
79 const struct inv_icm42600_timestamp_interval interval_init = {0LL, 0LL};
80
81 ts->it = interval_init;
82 ts->timestamp = 0;
83}
84
85#endif
86