Skip to content

Commit 48f7fcd

Browse files
aviscontikartben
authored andcommitted
samples/sensor: stream_fifo: initialize gbias
Add an example of how to initialize gbias. The real application should restore latest valid values taken from non-volatile memory. Signed-off-by: Armando Visconti <[email protected]>
1 parent cc9b93d commit 48f7fcd

File tree

1 file changed

+16
-0
lines changed
  • samples/sensor/stream_fifo/src

1 file changed

+16
-0
lines changed

samples/sensor/stream_fifo/src/main.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,29 @@ static void check_sensor_is_off(const struct device *dev)
230230

231231
int main(void)
232232
{
233+
struct sensor_value gbias[3];
234+
233235
for (size_t i = 0; i < ARRAY_SIZE(sensors); i++) {
234236
if (!device_is_ready(sensors[i])) {
235237
printk("sensor: device %s not ready.\n", sensors[i]->name);
236238
return 0;
237239
}
238240
check_sensor_is_off(sensors[i]);
239241

242+
/*
243+
* Set GBIAS as 0.5 rad/s, -1 rad/s, 0.2 rad/s
244+
*
245+
* (here application should initialize gbias x/y/z with latest values
246+
* calculated from previous run and probably saved to non volatile memory)
247+
*/
248+
gbias[0].val1 = 0;
249+
gbias[0].val2 = 500000;
250+
gbias[1].val1 = -1;
251+
gbias[1].val2 = 0;
252+
gbias[2].val1 = 0;
253+
gbias[2].val2 = 200000;
254+
sensor_attr_set(sensors[i], SENSOR_CHAN_GBIAS_XYZ, SENSOR_ATTR_OFFSET, gbias);
255+
240256
k_thread_create(&thread_id[i], thread_stack[i], TASK_STACK_SIZE, print_stream,
241257
(void *)sensors[i], (void *)iodevs[i], NULL, K_PRIO_COOP(5),
242258
K_INHERIT_PERMS, K_FOREVER);

0 commit comments

Comments
 (0)