File tree Expand file tree Collapse file tree 1 file changed +11
-19
lines changed Expand file tree Collapse file tree 1 file changed +11
-19
lines changed Original file line number Diff line number Diff line change 11// (c) Ralph Doncaster 2020
22// ArduinoShrink
33
4- #include <util/delay.h>
5-
6- inline void delayMicroseconds (unsigned int us )
7- {
8- _delay_us (us );
9- }
10-
11- // move millis to millis.c - LTO can inline
12- // millis_raw is slow by 2.4% (1000/1024), so multiply by 1.024
13- // shift and add instead of multiply: 1 6/256 = 1.0234375
14- // ifdef RAW_MILLIS - else precise millis
15- extern "C" uint32_t millis_raw ();
16- inline uint32_t millis ()
4+ extern "C" void delay_impl ();
5+ // lightweight custom function call abi
6+ __attribute((always_inline ))
7+ inline void delay (uint32_t msec )
178{
18- uint32_t m = millis_raw ();
19- // return m;
20- // high-precision millis correction =~ 32 extra bytes
21- // 1 + 1573/2^16 = 1.0240
22- // return m + ((m * 1573) >> 16);
23- return m + m >>6 + m >>7 ;
9+ register __uint24 ms asm ("r24" ) = msec ;
10+ asm volatile (
11+ "rcall %x1\n"
12+ : "+r" (ms )
13+ : "i" (delay_impl )
14+ : "r19" , "r20" , "r21" // clobbers
15+ );
2416}
2517
You can’t perform that action at this time.
0 commit comments