summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorJoey Castillo <joeycastillo@utexas.edu>2022-02-17 16:36:21 -0500
committerJoey Castillo <joeycastillo@utexas.edu>2022-02-17 16:36:21 -0500
commit0c59c972e7296ac8c23049e713da9350a9af39a5 (patch)
treeee4d59f6269a3012636ea7477d790451e7fb78fd /apps
parentdeda65b3136b740a9504d80bacc2714978964119 (diff)
downloadSensor-Watch-0c59c972e7296ac8c23049e713da9350a9af39a5.tar.gz
Sensor-Watch-0c59c972e7296ac8c23049e713da9350a9af39a5.tar.bz2
Sensor-Watch-0c59c972e7296ac8c23049e713da9350a9af39a5.zip
lis2dw: add FIFO support
Diffstat (limited to 'apps')
-rw-r--r--apps/accelerometer-test/app.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/apps/accelerometer-test/app.c b/apps/accelerometer-test/app.c
index 1f7803c6..1a3acafa 100644
--- a/apps/accelerometer-test/app.c
+++ b/apps/accelerometer-test/app.c
@@ -24,17 +24,13 @@ static void cb_tick(void) {
if (!lis2dw_have_new_data()) return;
watch_set_indicator(WATCH_INDICATOR_SIGNAL);
- lis2dw_reading raw_reading;
- lis2dw_acceleration_measurement measurement = lis2dw_get_acceleration_measurement(&raw_reading);
- printf("%f, %f, %f\n", measurement.x, measurement.y, measurement.z);
- char buf[128];
- sprintf(buf, "%f, %f, %f\n", measurement.x, measurement.y, measurement.z);
- watch_debug_puts(buf);
+ lis2dw_fifo_t fifo;
+ bool overrun = lis2dw_read_fifo(&fifo);
+ printf("FIFO captured %d readings.\n", fifo.count);
+ if (overrun) printf("\tThere was an overrun!\n\n");
}
void app_init(void) {
- watch_enable_debug_uart(460800); // this is glitchy now, but this enables a baud rate of 115200 when USB is disabled.
-
watch_enable_display();
watch_display_string("AC Strean", 0);
@@ -45,12 +41,14 @@ void app_init(void) {
watch_enable_i2c();
lis2dw_begin();
- lis2dw_set_data_rate(LIS2DW_DATA_RATE_25_HZ); // is this enough for training?
- lis2dw_set_low_noise_mode(true); // consumes a little more power
lis2dw_set_low_power_mode(LIS2DW_LP_MODE_2); // lowest power 14-bit mode, 25 Hz is 3.5 µA @ 1.8V w/ low noise, 3µA without
+ lis2dw_set_low_noise_mode(true); // consumes a little more power
lis2dw_set_range(LIS2DW_CTRL6_VAL_RANGE_4G);
+ lis2dw_set_data_rate(LIS2DW_DATA_RATE_25_HZ); // is this enough for training?
+
+ lis2dw_enable_fifo();
- watch_rtc_register_periodic_callback(cb_tick, 64);
+ watch_rtc_register_periodic_callback(cb_tick, 1);
}
void app_wake_from_backup(void) {