7
7
#![ no_std]
8
8
#![ no_main]
9
9
10
+ #[ cfg( feature = "unstable" ) ] // unused in stable build
10
11
use core:: cell:: RefCell ;
11
12
13
+ #[ cfg( feature = "unstable" ) ] // unused in stable build
12
14
use critical_section:: Mutex ;
13
15
#[ cfg( feature = "unstable" ) ]
14
16
use embassy_time:: { Duration , Timer } ;
17
+ use esp_hal:: gpio:: { AnyPin , Input , Level , Output , Pin , Pull } ;
18
+ #[ cfg( feature = "unstable" ) ]
15
19
use esp_hal:: {
20
+ // OutputOpenDrain is here because will be unused otherwise
16
21
delay:: Delay ,
17
- gpio:: { AnyPin , Input , Level , Output , OutputOpenDrain , Pin , Pull } ,
22
+ gpio:: { Event , Flex , Io , OutputOpenDrain } ,
18
23
handler,
19
- } ;
20
- #[ cfg( feature = "unstable" ) ]
21
- use esp_hal:: {
22
- gpio:: { Event , Flex , Io } ,
23
24
interrupt:: InterruptConfigurable ,
24
25
timer:: timg:: TimerGroup ,
25
26
} ;
26
27
use hil_test as _;
27
28
#[ cfg( feature = "unstable" ) ]
28
29
use portable_atomic:: { AtomicUsize , Ordering } ;
29
30
31
+ #[ cfg( feature = "unstable" ) ] // unused in stable build
30
32
static COUNTER : Mutex < RefCell < u32 > > = Mutex :: new ( RefCell :: new ( 0 ) ) ;
33
+ #[ cfg( feature = "unstable" ) ] // unused in stable build
31
34
static INPUT_PIN : Mutex < RefCell < Option < Input > > > = Mutex :: new ( RefCell :: new ( None ) ) ;
32
35
33
36
struct Context {
34
37
test_gpio1 : AnyPin ,
35
38
test_gpio2 : AnyPin ,
39
+ #[ cfg( feature = "unstable" ) ]
36
40
delay : Delay ,
37
41
}
38
42
39
- #[ handler]
43
+ #[ cfg_attr( feature = "unstable" , handler) ]
44
+ #[ cfg( feature = "unstable" ) ]
40
45
pub fn interrupt_handler ( ) {
41
46
critical_section:: with ( |cs| {
42
47
* COUNTER . borrow_ref_mut ( cs) += 1 ;
@@ -56,6 +61,7 @@ mod tests {
56
61
fn init ( ) -> Context {
57
62
let peripherals = esp_hal:: init ( esp_hal:: Config :: default ( ) ) ;
58
63
64
+ #[ cfg( feature = "unstable" ) ]
59
65
let delay = Delay :: new ( ) ;
60
66
61
67
let ( gpio1, gpio2) = hil_test:: common_test_pins!( peripherals) ;
@@ -74,6 +80,7 @@ mod tests {
74
80
Context {
75
81
test_gpio1 : gpio1. degrade ( ) ,
76
82
test_gpio2 : gpio2. degrade ( ) ,
83
+ #[ cfg( feature = "unstable" ) ]
77
84
delay,
78
85
}
79
86
}
@@ -244,6 +251,7 @@ mod tests {
244
251
}
245
252
246
253
#[ test]
254
+ #[ cfg( feature = "unstable" ) ] // delay is unstable
247
255
fn gpio_od ( ctx : Context ) {
248
256
let mut test_gpio1 = OutputOpenDrain :: new ( ctx. test_gpio1 , Level :: High , Pull :: Up ) ;
249
257
let mut test_gpio2 = OutputOpenDrain :: new ( ctx. test_gpio2 , Level :: High , Pull :: Up ) ;
0 commit comments