Skip to content

Commit 69161c5

Browse files
committed
Expand count parameters to u64 to accomodate values > ~1000s
1 parent 844ee7e commit 69161c5

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/lib.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323

2424
/// Internal function to implement a variable busy-wait loop.
2525
/// # Arguments
26-
/// * 'count' - an i32, the number of times to cycle the loop.
27-
pub fn delay(count: u32) {
26+
/// * 'count' - a u64, the number of times to cycle the loop.
27+
pub fn delay(count: u64) {
2828
// Our asm busy-wait takes a 16 bit word as an argument,
2929
// so the max number of loops is 2^16
3030
let outer_count = count / 65536;
@@ -48,19 +48,19 @@ pub fn delay(count: u32) {
4848

4949
///delay for N milliseconds
5050
/// # Arguments
51-
/// * 'ms' - an u32, number of milliseconds to busy-wait
52-
pub fn delay_ms(ms: u32) {
51+
/// * 'ms' - a u64, number of milliseconds to busy-wait
52+
pub fn delay_ms(ms: u64) {
5353
// microseconds
5454
let us = ms * 1000;
5555
delay_us(us);
5656
}
5757

5858
///delay for N microseconds
5959
/// # Arguments
60-
/// * 'us' - an u32, number of microseconds to busy-wait
61-
pub fn delay_us(us: u32) {
62-
let us_lp = avr_config::CPU_FREQUENCY_HZ / 1000000 / 4;
63-
let loops = (us * us_lp) as u32;
60+
/// * 'us' - a u64, number of microseconds to busy-wait
61+
pub fn delay_us(us: u64) {
62+
let us_in_loop = (avr_config::CPU_FREQUENCY_HZ / 1000000 / 4) as u64;
63+
let loops = us * us_in_loop;
6464
delay(loops);
6565
}
6666

0 commit comments

Comments
 (0)