avr-delay
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:
NOTE: This library currently hardcodes the microcontroller frequency to 16MHz. This will not always be correct. See avr-rust/delay#2 for more details.
delay
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.
delay_us
delay us microseconds
delay_ms
delay ms milliseconds
A simple example of how to use it follows.
Cargo.toml:
[]
= "dlyblink"
= "0.1.0"
= ["John Jorgensen"]
[]
= "0.1"
= { = "https://github.com/avr-rust/delay" }
and your main.rs:
extern crate arduino;
extern crate avr_delay;
use ;
use write_volatile;
use ;
pub extern
// These do not need to be in a module, but we group them here for clarity.
No attempt is made to handle arithmetic overruns.