Skip to content
Snippets Groups Projects
Verified Commit b74b7c56 authored by rahix's avatar rahix
Browse files

fix(bhi160): Fix FIFO parsing algorithm


FIFO parsing would parse certain packets late because of an incorrect
assumption about FIFO-internals.

Signed-off-by: default avatarRahix <rahix@rahix.de>
parent ed46ab5a
Branches rahix/bhi
No related tags found
No related merge requests found
...@@ -262,12 +262,7 @@ static int bhi160_fetch_fifo(void) ...@@ -262,12 +262,7 @@ static int bhi160_fetch_fifo(void)
/* Handle all full packets received in this transfer */ /* Handle all full packets received in this transfer */
uint8_t *fifo_ptr = bhi160_fifo; uint8_t *fifo_ptr = bhi160_fifo;
uint16_t bytes_left = bytes_read; uint16_t bytes_left = bytes_read;
while (ret == BHY_SUCCESS && while (bytes_left > 0) {
bytes_left > sizeof(bhy_data_generic_t)) {
/*
* TODO: sizeof(bhy_data_generic_t) is probably
* incorrect and makes some measurements arrive late.
*/
bhy_data_generic_t sensor_data; bhy_data_generic_t sensor_data;
bhy_data_type_t data_type; bhy_data_type_t data_type;
ret = bhy_parse_next_fifo_packet( ret = bhy_parse_next_fifo_packet(
...@@ -279,6 +274,8 @@ static int bhi160_fetch_fifo(void) ...@@ -279,6 +274,8 @@ static int bhi160_fetch_fifo(void)
if (ret == BHY_SUCCESS) { if (ret == BHY_SUCCESS) {
bhi160_handle_packet(data_type, &sensor_data); bhi160_handle_packet(data_type, &sensor_data);
} else {
break;
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment