Skip to content

Commit 844ee7e

Browse files
committed
Fix microseconds delay, typos
1 parent 7925367 commit 844ee7e

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

src/lib.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub fn delay(count: u32) {
4646
:)}
4747
}
4848

49-
///delay for N miliseconds
49+
///delay for N milliseconds
5050
/// # Arguments
5151
/// * 'ms' - an u32, number of milliseconds to busy-wait
5252
pub fn delay_ms(ms: u32) {
@@ -57,12 +57,10 @@ pub fn delay_ms(ms: u32) {
5757

5858
///delay for N microseconds
5959
/// # Arguments
60-
/// * 'ms' - an u32, number of microseconds to busy-wait
60+
/// * 'us' - an u32, number of microseconds to busy-wait
6161
pub fn delay_us(us: u32) {
62-
// picoseconds
63-
let ps = us * 1000;
64-
let ps_lp = 1000000000 / (avr_config::CPU_FREQUENCY_HZ / 4);
65-
let loops = (ps / ps_lp) as u32;
62+
let us_lp = avr_config::CPU_FREQUENCY_HZ / 1000000 / 4;
63+
let loops = (us * us_lp) as u32;
6664
delay(loops);
6765
}
6866

0 commit comments

Comments
 (0)