Skip to content

Commit 6ba963c

Browse files
rkarabutstappersg
authored andcommitted
Expand count parameters to u64
to accomodate values > ~1000s
1 parent 785efff commit 6ba963c

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ use core::arch::asm;
2525

2626
/// Internal function to implement a variable busy-wait loop.
2727
/// # Arguments
28-
/// * 'count' - an i32, the number of times to cycle the loop.
28+
/// * 'count' - a u64, the number of times to cycle the loop.
2929
#[inline(always)]
30-
pub fn delay(count: u32) {
30+
pub fn delay(count: u64) {
3131
// Our asm busy-wait takes a 16 bit word as an argument,
3232
// so the max number of loops is 2^16
3333
let outer_count = count / 65536;
@@ -52,21 +52,21 @@ pub fn delay(count: u32) {
5252

5353
///delay for N milliseconds
5454
/// # Arguments
55-
/// * 'ms' - an u32, number of milliseconds to busy-wait
55+
/// * 'ms' - an u64, number of milliseconds to busy-wait
5656
#[inline(always)]
57-
pub fn delay_ms(ms: u32) {
57+
pub fn delay_ms(ms: u64) {
5858
// microseconds
5959
let us = ms * 1000;
6060
delay_us(us);
6161
}
6262

6363
///delay for N microseconds
6464
/// # Arguments
65-
/// * 'us' - an u32, number of microseconds to busy-wait
65+
/// * 'us' - an u64, number of microseconds to busy-wait
6666
#[inline(always)]
67-
pub fn delay_us(us: u32) {
68-
let us_lp = avr_config::CPU_FREQUENCY_HZ / 1000000 / 4;
69-
let loops = (us * us_lp) as u32;
67+
pub fn delay_us(us: u64) {
68+
let us_in_loop = (avr_config::CPU_FREQUENCY_HZ / 1000000 / 4) as u64;
69+
let loops = us * us_in_loop;
7070
delay(loops);
7171
}
7272

0 commit comments

Comments
 (0)