Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code cleanups #43

Merged
merged 10 commits into from
Jan 17, 2025
Prev Previous commit
Next Next commit
samples: blinky: Run cargo fmt
Format the source according to the default rules. This provides a
baseline for future changes to require well-formatted source.

Signed-off-by: David Brown <[email protected]>
d3zd3z committed Jan 16, 2025

Verified

This commit was signed with the committer’s verified signature.
commit 3e4e69e7843e1b57d92a95c051ce1fcc3ca0d571
21 changes: 12 additions & 9 deletions samples/blinky/src/lib.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
// SPDX-License-Identifier: Apache-2.0

#![no_std]

// Sigh. The check config system requires that the compiler be told what possible config values
// there might be. This is completely impossible with both Kconfig and the DT configs, since the
// whole point is that we likely need to check for configs that aren't otherwise present in the
@@ -12,11 +11,13 @@
use log::warn;

use zephyr::raw::GPIO_OUTPUT_ACTIVE;
use zephyr::time::{ Duration, sleep };
use zephyr::time::{sleep, Duration};

#[no_mangle]
extern "C" fn rust_main() {
unsafe { zephyr::set_logger().unwrap(); }
unsafe {
zephyr::set_logger().unwrap();
}

warn!("Starting blinky");

@@ -32,21 +33,23 @@ fn do_blink() {

if !led0.is_ready() {
warn!("LED is not ready");
loop {
}
loop {}
}

unsafe { led0.configure(&mut gpio_token, GPIO_OUTPUT_ACTIVE); }
unsafe {
led0.configure(&mut gpio_token, GPIO_OUTPUT_ACTIVE);
}
let duration = Duration::millis_at_least(500);
loop {
unsafe { led0.toggle_pin(&mut gpio_token); }
unsafe {
led0.toggle_pin(&mut gpio_token);
}
sleep(duration);
}
}

#[cfg(not(dt = "aliases::led0"))]
fn do_blink() {
warn!("No leds configured");
loop {
}
loop {}
}