-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
41 lines (32 loc) · 876 Bytes
/
main.c
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
#include <assert.h>
#include <stdio.h>
#include "icm4000.h"
int main() {
printf("initialize all devices ...\n");
int r = device_init();
if (r) {
return r;
}
struct device* icm_4000 = device_get(device_icm4000);
if (!icm_4000) {
return -1;
}
static const struct icm_configuration icm_conf = {
.rate_hz = 100,
.fsr = 4,
.events = accel_event_new_sample | accel_event_tap_detected,
};
printf("playing with icm ...\n");
accel_setup_conf(icm_4000, &icm_conf);
int lpf = 15;
r = accel_set_attrib(icm_4000, accel_lpf, &lpf);
accel_setup_event(icm_4000, accel_event_tap_detected, 1);
accel_register_data_cb(icm_4000, NULL);
struct accel_new_sample sample = {0};
accel_read_sample(icm_4000, &sample);
int r_lpf = 0;
accel_get_attrib(icm_4000, accel_lpf, &r_lpf);
assert(r_lpf == lpf);
accel_powerdown(icm_4000);
return r;
}