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 ) ]
2
2
3
3
#![ no_std]
4
4
5
5
#![ crate_name = "avr_delay" ]
6
6
7
+ use core:: arch:: asm;
8
+
7
9
/// This library is intended to provide a busy-wait delay
8
10
/// similar to the one provided by the arduino c++ utilities
9
11
/// If you need accurate time keeping you should consider a
@@ -31,19 +33,20 @@ pub fn delay(count: u32) {
31
33
let last_count = ( ( count % 65536 ) +1 ) as u16 ;
32
34
for _ in 0 ..outer_count {
33
35
// 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
+ )
40
49
}
41
- unsafe { llvm_asm ! ( "1: sbiw $0,1
42
- brne 1b"
43
- :
44
- : "w" ( last_count)
45
- :
46
- : ) }
47
50
}
48
51
49
52
///delay for N miliseconds
You can’t perform that action at this time.
0 commit comments