Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
card10
firmware
Commits
56187c78
Commit
56187c78
authored
4 years ago
by
rahix
Browse files
Options
Downloads
Patches
Plain Diff
fix(bhi160): Don't silently drop errors while reading fifo
Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
546093f5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!423
BHI160 cleanup
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
epicardium/modules/bhi.c
+28
-2
28 additions, 2 deletions
epicardium/modules/bhi.c
with
28 additions
and
2 deletions
epicardium/modules/bhi.c
+
28
−
2
View file @
56187c78
...
...
@@ -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
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment