File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -32,21 +32,21 @@ fn main() -> ! {
32
32
let mut stopwatch = dp. TIM3 . stopwatch ( & mut rcc) ;
33
33
34
34
let elapsed_us = stopwatch. trace ( || {
35
- delay. delay ( 10 . us ( ) ) ;
35
+ delay. delay ( 100 . us ( ) ) ;
36
36
} ) ;
37
- hprintln ! ( "Delay: 10us -> {}us" , elapsed_us. 0 ) . unwrap ( ) ;
37
+ hprintln ! ( "Delay: 100 us -> {} us" , elapsed_us. 0 ) . unwrap ( ) ;
38
38
39
- timer. start ( 10 . us ( ) ) ;
39
+ timer. start ( 100 . us ( ) ) ;
40
40
let elapsed_us = stopwatch. trace ( || {
41
41
block ! ( timer. wait( ) ) . unwrap ( ) ;
42
42
} ) ;
43
- hprintln ! ( "Timer: 10us -> {}us" , elapsed_us. 0 ) . unwrap ( ) ;
43
+ hprintln ! ( "Timer: 100 us -> {} us" , elapsed_us. 0 ) . unwrap ( ) ;
44
44
45
45
let elapsed_us = stopwatch. trace ( || {
46
46
let x = calc_something ( ) ;
47
47
assert ! ( x > 0 ) ;
48
48
} ) ;
49
- hprintln ! ( "Calc @ 16MHz : {}us" , elapsed_us. 0 ) . unwrap ( ) ;
49
+ hprintln ! ( "Calc @ 16 MHz : {} us" , elapsed_us. 0 ) . unwrap ( ) ;
50
50
51
51
let rcc = rcc. freeze ( Config :: new ( SysClockSrc :: PLL ) ) ;
52
52
stopwatch. set_clock ( rcc. clocks . apb_tim_clk ) ;
@@ -55,7 +55,7 @@ fn main() -> ! {
55
55
let x = calc_something ( ) ;
56
56
assert ! ( x > 0 ) ;
57
57
} ) ;
58
- hprintln ! ( "Calc @ 64MHz : {}us" , elapsed_us. 0 ) . unwrap ( ) ;
58
+ hprintln ! ( "Calc @ 64 MHz : {} us" , elapsed_us. 0 ) . unwrap ( ) ;
59
59
60
60
loop { }
61
61
}
Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ macro_rules! stopwatches {
71
71
pub fn elapsed( & self , ts: Instant ) -> MicroSecond {
72
72
let now = self . now( ) . 0 ;
73
73
let cycles = now. wrapping_sub( ts. 0 ) ;
74
- self . clk. duration( cycles)
74
+ self . clk. duration( cycles * ( 1 + self . tim . psc . read ( ) . bits ( ) ) )
75
75
}
76
76
77
77
pub fn trace<F >( & self , mut closure: F ) -> MicroSecond
@@ -81,7 +81,7 @@ macro_rules! stopwatches {
81
81
let started = self . now( ) . 0 ;
82
82
closure( ) ;
83
83
let now = self . now( ) . 0 ;
84
- self . clk. duration( now. wrapping_sub( started) )
84
+ self . clk. duration( now. wrapping_sub( started) * ( 1 + self . tim . psc . read ( ) . bits ( ) ) )
85
85
}
86
86
}
87
87
You can’t perform that action at this time.
0 commit comments