Skip to content

Commit

Permalink
src: lib: change to a for loop
Browse files Browse the repository at this point in the history
  • Loading branch information
RaulTrombin committed Oct 20, 2023
1 parent 840be80 commit aaa2c2e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,13 @@ where
}

pub fn check_data_ready(&mut self) -> Result<(), Error<E>> {
let mut retries = 10;
while retries > 0 {
let retries = 10;
for _ in 0..retries {
let status = self.read_register(Register::ST1)?;
if (status & 0x01) != 0 {
return Ok(()); // Data ready
}
std::thread::sleep(std::time::Duration::from_millis(100));
retries -= 1;
}
Err(Error::DataNotReady)
}
Expand Down

0 comments on commit aaa2c2e

Please sign in to comment.