File tree Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Expand file tree Collapse file tree 1 file changed +16
-13
lines changed Original file line number Diff line number Diff line change 1- #![ feature( llvm_asm ) ]
1+ #![ feature( asm_experimental_arch ) ]
22
33#![ no_std]
44
55#![ crate_name = "avr_delay" ]
66
7+ use core:: arch:: asm;
8+
79/// This library is intended to provide a busy-wait delay
810/// similar to the one provided by the arduino c++ utilities
911/// If you need accurate time keeping you should consider a
@@ -31,19 +33,20 @@ pub fn delay(count: u32) {
3133 let last_count = ( ( count % 65536 ) +1 ) as u16 ;
3234 for _ in 0 ..outer_count {
3335 // Each loop through should be 4 cycles.
34- unsafe { llvm_asm ! ( "1: sbiw $0,1
35- brne 1b"
36- :
37- : "w" ( 0 )
38- :
39- : ) }
36+ let zero = 0u16 ;
37+ unsafe {
38+ asm ! ( "1: sbiw {i}, 1" ,
39+ "brne 1b" ,
40+ i = inout( reg_iw) zero => _,
41+ )
42+ }
43+ }
44+ unsafe {
45+ asm ! ( "1: sbiw {i}, 1" ,
46+ "brne 1b" ,
47+ i = inout( reg_iw) last_count => _,
48+ )
4049 }
41- unsafe { llvm_asm ! ( "1: sbiw $0,1
42- brne 1b"
43- :
44- : "w" ( last_count)
45- :
46- : ) }
4750}
4851
4952///delay for N miliseconds
You can’t perform that action at this time.
0 commit comments