Skip to content
Snippets Groups Projects
Verified Commit d254418e authored by Jonathan Brouwer's avatar Jonathan Brouwer
Browse files

Reset fifo when len is very large

parent 7882f9cc
No related branches found
No related tags found
1 merge request!11Resolve "Reading MPU over I2C hangs"
Pipeline #822679 failed
......@@ -6,6 +6,7 @@ use crate::once_cell::OnceCell;
use crate::twi::{TwiWrapper, TWI};
use nb::Error::WouldBlock;
use structs::{Accel, Gyro, Quaternion};
use crate::uart::send_bytes;
#[allow(unused)]
mod config;
......@@ -113,6 +114,10 @@ pub fn read_dmp_bytes() -> nb::Result<Quaternion, Error<TwiWrapper>> {
if len < 28 {
return Err(WouldBlock);
}
if len > 28 * 5 {
mpu.mpu.reset_fifo(twi)?;
return Err(WouldBlock);
}
// If we got mis-aligned, we skip a packet
if len % 28 != 0 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment