@@ -10,7 +10,7 @@ mod regs;
10
10
11
11
use core:: convert:: Infallible ;
12
12
13
- use embassy_time:: { with_timeout, Duration , TimeoutError , Timer } ;
13
+ use embassy_time:: { with_timeout, Duration , Instant , TimeoutError , Timer } ;
14
14
use embedded_hal:: digital:: { InputPin , OutputPin } ;
15
15
use embedded_hal_async:: digital:: Wait ;
16
16
pub use interface:: * ;
@@ -133,7 +133,14 @@ where
133
133
134
134
debug ! ( "softreset" ) ;
135
135
self . regs ( ) . command ( ) . write ( |w| w. set_command ( regs:: CommandVal :: SOFTRESET ) ) ;
136
- while self . regs ( ) . command ( ) . read ( ) . command ( ) != regs:: CommandVal :: IDLE { }
136
+
137
+ let deadline = Instant :: now ( ) + Duration :: from_secs ( 1 ) ;
138
+ while self . regs ( ) . command ( ) . read ( ) . command ( ) != regs:: CommandVal :: IDLE {
139
+ if Instant :: now ( ) > deadline {
140
+ warn ! ( "timeout waiting for softreset." ) ;
141
+ break ;
142
+ }
143
+ }
137
144
138
145
// again, just in case
139
146
Timer :: after ( Duration :: from_millis ( 1 ) ) . await ;
@@ -456,7 +463,13 @@ where
456
463
//cortex_m::asm::delay(640_000); // 100ms
457
464
458
465
//info!("calib: waiting for irq..");
459
- while !self . regs ( ) . lpcd_irq ( ) . read ( ) . calib_irq ( ) { }
466
+ let deadline = Instant :: now ( ) + Duration :: from_secs ( 1 ) ;
467
+ while !self . regs ( ) . lpcd_irq ( ) . read ( ) . calib_irq ( ) {
468
+ if Instant :: now ( ) > deadline {
469
+ warn ! ( "timeout waiting for adc calibration." ) ;
470
+ break ;
471
+ }
472
+ }
460
473
461
474
// calibra_en = 0
462
475
self . regs ( ) . lpcd_ctrl1 ( ) . write ( |w| {
0 commit comments