From 96f0740309d29fa923bd5b47d338a5e6b80eda52 Mon Sep 17 00:00:00 2001 From: David Brown Date: Fri, 22 Nov 2024 10:34:22 -0700 Subject: [PATCH] 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 --- samples/blinky/src/lib.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/samples/blinky/src/lib.rs b/samples/blinky/src/lib.rs index f94cf6b0..84d7bac6 100644 --- a/samples/blinky/src/lib.rs +++ b/samples/blinky/src/lib.rs @@ -18,7 +18,7 @@ use zephyr::time::{ Duration, sleep }; #[no_mangle] extern "C" fn rust_main() { - zephyr::set_logger(); + unsafe { zephyr::set_logger().unwrap(); } warn!("Starting blinky"); // println!("Blinky!"); @@ -52,6 +52,7 @@ fn do_blink() { warn!("Inside of blinky"); let mut led0 = zephyr::devicetree::aliases::led0::get_instance().unwrap(); + let mut gpio_token = unsafe { zephyr::device::gpio::GpioToken::get_instance().unwrap() }; if !led0.is_ready() { warn!("LED is not ready"); @@ -60,10 +61,10 @@ fn do_blink() { // return; } - led0.configure(GPIO_OUTPUT_ACTIVE); + unsafe { led0.configure(&mut gpio_token, GPIO_OUTPUT_ACTIVE); } let duration = Duration::millis_at_least(500); loop { - led0.toggle_pin(); + unsafe { led0.toggle_pin(&mut gpio_token); } sleep(duration); } }