Skip to content

Commit 5c78824

Browse files
committed
extended 64-bit monotonic timer
1 parent 66beabc commit 5c78824

17 files changed

+195
-13
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414

1515
### Added
1616

17+
- Extended 64-bit monotonic timer
18+
1719
### Fixed
1820

1921
- map `$SpiSlave` into `SpiSlave` struct in `spi!` macro [#635]

examples/blinky-timer-irq.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use crate::hal::{
2020
use core::cell::RefCell;
2121
use cortex_m::interrupt::Mutex;
2222
use cortex_m_rt::entry;
23+
use fugit::ExtU32;
2324

2425
// NOTE You can uncomment 'hprintln' here and in the code below for a bit more
2526
// verbosity at runtime, at the cost of throwing off the timing of the blink

examples/delay-timer-blinky.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use panic_halt as _; // panic handler
1010

1111
use cortex_m_rt::entry;
12+
use fugit::ExtU32;
1213
use stm32f4xx_hal as hal;
1314

1415
use crate::hal::{pac, prelude::*};

examples/dynamic-gpio.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use nb::block;
88

99
use cortex_m_rt::entry;
1010
use cortex_m_semihosting::hprintln;
11+
use fugit::ExtU32;
1112
use stm32f4xx_hal::{gpio::PinState, pac, prelude::*, timer::Timer};
1213

1314
#[entry]

examples/pwm-sinus.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use panic_halt as _;
77

88
use core::f32::consts::FRAC_PI_2;
99
use cortex_m_rt::entry;
10+
use fugit::ExtU32;
1011
use micromath::F32Ext;
1112
use stm32f4xx_hal::{
1213
pac,

examples/rtc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use cortex_m_rt::entry;
99
use panic_halt as _;
1010
use rtt_target::{rprintln, rtt_init_print};
1111

12+
use fugit::ExtU32;
1213
use stm32f4xx_hal::{pac, prelude::*, rtc::Rtc};
1314
use time::{
1415
macros::{date, time},

examples/rtic-adc-dma.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use panic_probe as _;
77
#[rtic::app(device = stm32f4xx_hal::pac, dispatchers = [EXTI0])]
88
mod app {
99
use dwt_systick_monotonic::DwtSystick;
10+
use fugit::ExtU32;
1011

1112
use stm32f4xx_hal::{
1213
adc::{

examples/rtic-tick.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
#![no_main]
22
#![no_std]
33

4+
use defmt_rtt as _;
45
use panic_halt as _;
56

67
#[rtic::app(device = stm32f4xx_hal::pac, dispatchers = [USART1])]
78
mod app {
9+
use fugit::ExtU64;
810
use stm32f4xx_hal::{
911
gpio::{Output, PC13},
1012
pac,
1113
prelude::*,
12-
timer::MonoTimerUs,
14+
//timer::MonoTimerUs, // Easy monotonic timer for 32-bit TIMs only
15+
timer::MonoTimer64Us, // Extended 64-bit timer for 16/32-bit TIMs
1316
};
1417

1518
#[shared]
@@ -20,8 +23,10 @@ mod app {
2023
led: PC13<Output>,
2124
}
2225

23-
#[monotonic(binds = TIM2, default = true)]
24-
type MicrosecMono = MonoTimerUs<pac::TIM2>;
26+
//#[monotonic(binds = TIM2, default = true)]
27+
//type MicrosecMono = MonoTimerUs<pac::TIM2>;
28+
#[monotonic(binds = TIM3, default = true)]
29+
type MicrosecMono = MonoTimer64Us<pac::TIM3>;
2530

2631
#[init]
2732
fn init(ctx: init::Context) -> (Shared, Local, init::Monotonics) {
@@ -30,8 +35,10 @@ mod app {
3035

3136
let gpioc = ctx.device.GPIOC.split();
3237
let led = gpioc.pc13.into_push_pull_output();
38+
defmt::info!("Start");
3339

34-
let mono = ctx.device.TIM2.monotonic_us(&clocks);
40+
//let mono = ctx.device.TIM2.monotonic_us(&clocks);
41+
let mono = ctx.device.TIM3.monotonic64_us(&clocks);
3542
tick::spawn().ok();
3643
(Shared {}, Local { led }, init::Monotonics(mono))
3744
}
@@ -40,5 +47,6 @@ mod app {
4047
fn tick(ctx: tick::Context) {
4148
tick::spawn_after(1.secs()).ok();
4249
ctx.local.led.toggle();
50+
defmt::info!("Tick");
4351
}
4452
}

examples/serial.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use panic_halt as _;
55

66
use cortex_m_rt::entry;
7+
use fugit::ExtU32;
78
use stm32f4xx_hal as hal;
89

910
use crate::hal::{pac, prelude::*};

examples/stopwatch-with-ssd1306-and-interrupts-and-dma-i2c.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ use embedded_graphics::{
4848
prelude::*,
4949
text::Text,
5050
};
51+
use fugit::ExtU32;
5152
use heapless::String;
5253
use ssd1306::{prelude::*, Ssd1306};
5354

0 commit comments

Comments
 (0)