Skip to content

Commit a74021a

Browse files
committed
samples: blink: Fix for upstream API changes
Several things have become unsafe, so use those in unsafe blocks. The GPIO driver now has a token that must be passed to each action, to enforce single threadded use. Signed-off-by: David Brown <[email protected]>
1 parent 04ecb3f commit a74021a

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

samples/blinky/src/lib.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use zephyr::time::{ Duration, sleep };
1818

1919
#[no_mangle]
2020
extern "C" fn rust_main() {
21-
zephyr::set_logger();
21+
unsafe { zephyr::set_logger().unwrap(); }
2222

2323
warn!("Starting blinky");
2424
// println!("Blinky!");
@@ -52,6 +52,7 @@ fn do_blink() {
5252
warn!("Inside of blinky");
5353

5454
let mut led0 = zephyr::devicetree::aliases::led0::get_instance().unwrap();
55+
let mut gpio_token = unsafe { zephyr::device::gpio::GpioToken::get_instance().unwrap() };
5556

5657
if !led0.is_ready() {
5758
warn!("LED is not ready");
@@ -60,10 +61,10 @@ fn do_blink() {
6061
// return;
6162
}
6263

63-
led0.configure(GPIO_OUTPUT_ACTIVE);
64+
unsafe { led0.configure(&mut gpio_token, GPIO_OUTPUT_ACTIVE); }
6465
let duration = Duration::millis_at_least(500);
6566
loop {
66-
led0.toggle_pin();
67+
unsafe { led0.toggle_pin(&mut gpio_token); }
6768
sleep(duration);
6869
}
6970
}

0 commit comments

Comments
 (0)