diff options
| author | Finomnis <Finomnis@users.noreply.github.com> | 2023-12-06 08:49:38 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-06 07:49:38 +0000 |
| commit | 89160b7cb9b3623e0a50f6745296d470fa7ea79d (patch) | |
| tree | 1409920c1fe8dec4857cd1e73f2f02485229fcad /rtic-monotonics/src/imxrt.rs | |
| parent | 1622f6b953c93c3a680769636b60733f281f1ac0 (diff) | |
Fix nrf monotonics (#852)
* Fix nrf::timer
* Bootstrap nrf52840-blinky example
* More work on nrf blinky example
* Fix README
* Add asserts for correct timer functionality
* Add correctness check to other monotonics as well
* Update Changelog
* Fix potential timing issues
* Fix race condition in nrf::rtc
* Add changelog
* Add rtc blinky example
* Change rtc example to RC lf clock source
* Add changelog to rtic-time
* Add changelog
* Attempt to fix CI
* Update teensy4-blinky Cargo.lock
Diffstat (limited to 'rtic-monotonics/src/imxrt.rs')
| -rw-r--r-- | rtic-monotonics/src/imxrt.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/rtic-monotonics/src/imxrt.rs b/rtic-monotonics/src/imxrt.rs index 5f9fc08..ecf9129 100644 --- a/rtic-monotonics/src/imxrt.rs +++ b/rtic-monotonics/src/imxrt.rs @@ -141,13 +141,15 @@ macro_rules! make_timer { // so it gets combined with rollover interrupt ral::write_reg!(ral::gpt, gpt, OCR[1], 0x0000_0000); + // Initialize timer queue + $tq.initialize(Self {}); + // Enable the timer ral::modify_reg!(ral::gpt, gpt, CR, EN: 1); ral::modify_reg!(ral::gpt, gpt, CR, ENMOD: 0, // Keep state when disabled ); - $tq.initialize(Self {}); // SAFETY: We take full ownership of the peripheral and interrupt vector, // plus we are not using any external shared resources so we won't impact @@ -244,13 +246,15 @@ macro_rules! make_timer { let (rollover, half_rollover) = ral::read_reg!(ral::gpt, gpt, SR, ROV, OF1); if rollover != 0 { - $period.fetch_add(1, Ordering::Relaxed); + let prev = $period.fetch_add(1, Ordering::Relaxed); ral::write_reg!(ral::gpt, gpt, SR, ROV: 1); + assert!(prev % 2 == 1, "Monotonic must have skipped an interrupt!"); } if half_rollover != 0 { - $period.fetch_add(1, Ordering::Relaxed); + let prev = $period.fetch_add(1, Ordering::Relaxed); ral::write_reg!(ral::gpt, gpt, SR, OF1: 1); + assert!(prev % 2 == 0, "Monotonic must have skipped an interrupt!"); } } } |
