You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-14
Original file line number
Diff line number
Diff line change
@@ -5,36 +5,35 @@
5
5
6
6
[API Documentation](https://docs.rs/avr_delay/)
7
7
8
-
The intent of this library is to provide avr specific delay routines similar to the ones provided by the arduino library. The public functions are:
8
+
The intent of this library is to provide avr specific delay routines similar to the ones provided by the arduino library.
9
9
10
10
## `$AVR_CPU_FREQUENCY_HZ`
11
11
12
12
This crate uses the [`avr-config`](https://crates.io/crates/avr-config) crate for fetching the CPU frequency. As such, the `AVR_CPU_FREQUENCY_HZ` environment variable will need to be set when compiling your crate for AVR.
is a raw delay loop. Each loop is 4 cycles. The asm section can loop 65536 times. Initial overhead is about 13 cycles. Each outer loop has an overhead of about 11 cycles.
19
+
## API
26
20
27
21
```rust
28
-
delay_us(us:u32)
22
+
delay_cycles<constCYCLES:u64>()
23
+
delay_us<constUS:u64>()
24
+
delay_ms<constMS:u64>()
25
+
delay_sec<constSEC:u64>()
29
26
```
30
27
31
-
delay _us_ microseconds
28
+
`delay_cycles` accepts 0 to 25_769_803_784 cycles (almost 18 minutes at 24Mhz).
29
+
30
+
The other functions convert time to cycles by using CPU_FREQUENCY_HZ.
32
31
33
32
```rust
34
-
delay_ms(ms:u32)
33
+
delay_ms<42>(); // delay by 42ms (exactly 1_008_000 cycles at 24Mhz).
0 commit comments