avr-rust / delay

arduino-like delay routines based on busy-wait loops
Apache License 2.0
15 stars 11 forks source link

Consider converting the delay loop to asm #5

Closed pusherofbrooms closed 6 years ago

pusherofbrooms commented 6 years ago

In the Arduino repo (https://github.com/arduino/Arduino), hardware/arduino/avr/cores/arduino/wiring.c at line 120 starts the function for microsecond delay including an asm loop at the end of the function (line 234). Cycles are counted carefully throughout the function.

This may be a good enough model to follow for the rust version.

pusherofbrooms commented 6 years ago

this is done in HEAD. I'm ignoring about 11 cycles per outer loop and an initial 13 to 20 cycles depending on which function you call.