Skip to content
Snippets Groups Projects
Commit 56187c78 authored by rahix's avatar rahix
Browse files

fix(bhi160): Don't silently drop errors while reading fifo


Signed-off-by: default avatarRahix <rahix@rahix.de>
parent 546093f5
No related branches found
No related tags found
1 merge request!423BHI160 cleanup
......@@ -351,7 +351,7 @@ static void bhi160_fetch_fifo(void)
static uint8_t bhi160_fifo[BHI160_FIFO_SIZE];
static size_t start_index = 0;
int result = 0;
BHY_RETURN_FUNCTION_TYPE result = 0;
/* Number of bytes left in BHI160's FIFO buffer */
uint16_t bytes_left_in_fifo = 1;
......@@ -361,13 +361,34 @@ static void bhi160_fetch_fifo(void)
while (bytes_left_in_fifo) {
/* Fill local FIFO buffer with as many bytes as possible */
uint16_t bytes_read;
bhy_read_fifo(
result = bhy_read_fifo(
&bhi160_fifo[start_index],
BHI160_FIFO_SIZE - start_index,
&bytes_read,
&bytes_left_in_fifo
);
if (result != BHY_SUCCESS) {
/*
* Honestly not sure how we should handle these errors.
*
* Needs more digging to find out how bhy_read_fifo()
* behaves in error situations (a quick glance at the
* code shows that the function might have written
* _somethings_ into our buffer so we can't just retry
* blindly ...)
*
* For now, just abort everything and disable the
* sensor. Won't cause havoc at least ...
*/
LOG_ERR("bhi160",
"Error while reading fifo: %d. Disabling.",
result);
bhi160_driver_b0rked = true;
break;
}
/* Add the bytes left from the last transfer on top */
bytes_read += start_index;
......@@ -387,6 +408,11 @@ static void bhi160_fetch_fifo(void)
if (result == BHY_SUCCESS) {
bhi160_handle_packet(data_type, &sensor_data);
} else {
LOG_WARN(
"bhi160",
"Error in fifo packet: %d. Ignoring.",
result
);
break;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment