Skip to content

Commit 785efff

Browse files
rkarabutstappersg
authored andcommitted
Fix microsecons delay
1 parent a5fe579 commit 785efff

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,8 @@ pub fn delay_ms(ms: u32) {
6565
/// * 'us' - an u32, number of microseconds to busy-wait
6666
#[inline(always)]
6767
pub fn delay_us(us: u32) {
68-
// picoseconds
69-
let ps = us * 1000;
70-
let ps_lp = 1000000000 / (avr_config::CPU_FREQUENCY_HZ / 4);
71-
let loops = (ps / ps_lp) as u32;
68+
let us_lp = avr_config::CPU_FREQUENCY_HZ / 1000000 / 4;
69+
let loops = (us * us_lp) as u32;
7270
delay(loops);
7371
}
7472

0 commit comments

Comments
 (0)