@@ -453,6 +453,18 @@ impl Default for Interrupts {
453
453
454
454
455
455
/// The RTC wakeup timer
456
+ ///
457
+ /// This timer can be used in two ways:
458
+ /// 1. Continually call `wait` until it returns `Ok(())`.
459
+ /// 2. Set up the RTC interrupt.
460
+ ///
461
+ /// If you use an interrupt, you should still call `wait` once, after the
462
+ /// interrupt fired. This should return `Ok(())` immediately. Doing this will
463
+ /// reset the timer flag. If you don't do this, the interrupt will not fire
464
+ /// again, if you go to sleep.
465
+ ///
466
+ /// You don't need to call `wait`, if you call `cancel`, as that also resets the
467
+ /// flag. Restarting the timer by calling `start` will also reset the flag.
456
468
pub struct WakeupTimer < ' r > {
457
469
rtc : & ' r mut RTC ,
458
470
}
@@ -469,13 +481,15 @@ impl timer::CountDown for WakeupTimer<'_> {
469
481
///
470
482
/// # Panics
471
483
///
472
- /// The `delay` argument supports 17 bits. Panics, if a value larger than
473
- /// 17 bits is passed .
484
+ /// The `delay` argument must be in the range `1 <= delay <= 2^17`.
485
+ /// Panics, if `delay` is outside of that range .
474
486
fn start < T > ( & mut self , delay : T )
475
487
where T : Into < Self :: Time >
476
488
{
477
489
let delay = delay. into ( ) ;
478
- assert ! ( delay < 2 ^17 ) ;
490
+ assert ! ( 1 <= delay && delay <= 2 ^17 ) ;
491
+
492
+ let delay = delay - 1 ;
479
493
480
494
// Can't panic, as the error type is `Void`.
481
495
self . cancel ( ) . unwrap ( ) ;
@@ -535,7 +549,6 @@ impl timer::Cancel for WakeupTimer<'_> {
535
549
536
550
// Clear wakeup timer flag
537
551
rtc. isr . modify ( |_, w| w. wutf ( ) . clear_bit ( ) ) ;
538
- // while self.rtc.isr.read().wutf().bit_is_set() {}
539
552
540
553
// According to the reference manual, section 26.7.4, the WUTF flag
541
554
// must be cleared at least 1.5 RTCCLK periods "before WUTF is set
0 commit comments