Skip to content

Commit

Permalink
rust: Update to latest riot-wrappers
Browse files Browse the repository at this point in the history
  • Loading branch information
chrysn committed Sep 4, 2024
1 parent 4974a34 commit c3b2248
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion rust01-hello-world/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ crate-type = ["staticlib"]
panic = "abort"

[dependencies]
riot-wrappers = { version = "0.8", features = [ "set_panic_handler", "panic_handler_format" ] }
riot-wrappers = { version = "0.9.1", features = [ "set_panic_handler", "panic_handler_format" ] }

rust_riotmodules = { path = "../RIOT/sys/rust_riotmodules/" }
2 changes: 1 addition & 1 deletion rust01-hello-world/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ riot_main!(main);

fn main() {
// Startup delay to ensure the terminal is connected
Clock::sec().sleep(core::time::Duration::from_secs(5));
Clock::sec().sleep_extended(core::time::Duration::from_secs(5));

println!("Hello Rust!");
println!("You are running RIOT on a(n) {} board.\n", riot_wrappers::BOARD);
Expand Down
2 changes: 1 addition & 1 deletion rust02-timers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ crate-type = ["staticlib"]
panic = "abort"

[dependencies]
riot-wrappers = { version = "0.8", features = [ "set_panic_handler", "panic_handler_format" ] }
riot-wrappers = { version = "0.9.1", features = [ "set_panic_handler", "panic_handler_format" ] }

rust_riotmodules = { path = "../RIOT/sys/rust_riotmodules/" }
switch-hal = "0.4.0"
2 changes: 1 addition & 1 deletion rust02-timers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ for _ in 0..10 {

**2. Sleep only for 250 ms for each iteration after setting the LED to "on":**
```rust
Clock::msec().sleep(Duration::from_millis(250));
Clock::msec().sleep_extended(Duration::from_millis(250));
```

**3. Build and flash the application. Connect to the serial port:**
Expand Down
12 changes: 6 additions & 6 deletions rust02-timers/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ riot_main!(main);

fn main() {
// Startup delay to ensure the terminal is connected
Clock::sec().sleep(Duration::from_secs(5));
Clock::sec().sleep_extended(Duration::from_secs(5));

println!("This is a timers example");

// We can use sleep to just get delays
Clock::sec().sleep(Duration::from_secs(2));
Clock::sec().sleep_extended(Duration::from_secs(2));

// Many times can be expressed on different timers, but usable ranges and precision vary.
Clock::msec().sleep(Duration::from_secs(2));
Clock::msec().sleep_extended(Duration::from_secs(2));

println!("Timeout!");

let mut led0 = riot_wrappers::led::LED::<0>::new();
let mut led0 = riot_wrappers::led::LED::<0>::new_checked().expect("Our board has an LED0");


for _ in 0..20 {
Expand All @@ -38,9 +38,9 @@ fn main() {
// In future Rust versions we can express this even more clearly
// <https://github.com/rust-lang/rust/pull/122792>.
led0.on().unwrap();
Clock::msec().sleep(Duration::from_millis(500));
Clock::msec().sleep_extended(Duration::from_millis(500));
led0.off().unwrap();
Clock::msec().sleep(Duration::from_millis(500));
Clock::msec().sleep_extended(Duration::from_millis(500));
}

println!("Done!");
Expand Down
2 changes: 1 addition & 1 deletion rust03-shell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ crate-type = ["staticlib"]
panic = "abort"

[dependencies]
riot-wrappers = { version = "0.8", features = [ "set_panic_handler", "panic_handler_format" ] }
riot-wrappers = { version = "0.9.1", features = [ "set_panic_handler", "panic_handler_format" ] }
switch-hal = "0.4.0"

rust_riotmodules = { path = "../RIOT/sys/rust_riotmodules/" }
2 changes: 1 addition & 1 deletion rust03-shell/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ riot_main!(main);
fn main() {
use riot_wrappers::shell::CommandList;
riot_wrappers::shell::new()
.run_forever_providing_buf();
.run_forever();
}


Expand Down
2 changes: 1 addition & 1 deletion rust04-saul/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ crate-type = ["staticlib"]
panic = "abort"

[dependencies]
riot-wrappers = { version = "0.8", features = [ "set_panic_handler", "panic_handler_format" ] }
riot-wrappers = { version = "0.9.1", features = [ "set_panic_handler", "panic_handler_format" ] }
switch-hal = "0.4.0"

rust_riotmodules = { path = "../RIOT/sys/rust_riotmodules/" }
6 changes: 3 additions & 3 deletions rust04-saul/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ const TEMPERATURE_THRESHOLD: i16 = 2400; // °C * 10^-2

fn main() {
// Startup delay to ensure the terminal is connected
Clock::sec().sleep(Duration::from_secs(5));
Clock::sec().sleep_extended(Duration::from_secs(5));

use switch_hal::OutputSwitch;
let mut led0 = riot_wrappers::led::LED::<0>::new();
let mut led0 = riot_wrappers::led::LED::<0>::new_checked().expect("Our board has an LED0");

let temp_sensor = RegistryEntry::all()
.filter(|e| matches!(e.type_(), Some(Class::Sensor(Some(SensorClass::Temp)))))
Expand All @@ -44,6 +44,6 @@ fn main() {
led0.off().unwrap();
}

Clock::msec().sleep(Duration::from_millis(500));
Clock::msec().sleep_extended(Duration::from_millis(500));
}
}
2 changes: 1 addition & 1 deletion rust05-gpio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ panic = "abort"

[dependencies]
embedded-hal = "1.0.0"
riot-wrappers = { version = "0.8", features = [ "set_panic_handler", "panic_handler_format" ] }
riot-wrappers = { version = "0.9.1", features = [ "set_panic_handler", "panic_handler_format" ] }

rust_riotmodules = { path = "../RIOT/sys/rust_riotmodules/" }
4 changes: 2 additions & 2 deletions rust05-gpio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ we can ensure that changing the board will not accidentally drive a pin that rel
```rust
loop {
led0.set_high();
Clock::msec().sleep(Duration::from_millis(200));
Clock::msec().sleep_extended(Duration::from_millis(200));
led0.set_low();
Clock::msec().sleep(Duration::from_millis(800));
Clock::msec().sleep_extended(Duration::from_millis(800));
}
```

Expand Down
2 changes: 1 addition & 1 deletion rust05-gpio/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ riot_main!(main);

fn main() {
// Startup delay to ensure the terminal is connected
Clock::sec().sleep(Duration::from_secs(5));
Clock::sec().sleep_extended(Duration::from_secs(5));

println!("GPIOs example.");

Expand Down
2 changes: 1 addition & 1 deletion rust06-threads/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ panic = "abort"

[dependencies]
riot-sys = "0.7.12"
riot-wrappers = { version = "0.8", features = ["set_panic_handler", "panic_handler_format"] }
riot-wrappers = { version = "0.9.1", features = ["set_panic_handler", "panic_handler_format"] }

rust_riotmodules = { path = "../RIOT/sys/rust_riotmodules/" }
static_cell = "2.1.0"
Expand Down
4 changes: 2 additions & 2 deletions rust06-threads/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ fn blinky_handler() {
);

led1.on().unwrap();
Clock::msec().sleep(Duration::from_millis(20));
Clock::msec().sleep_extended(Duration::from_millis(20));
led1.off().unwrap();
Clock::msec().sleep(Duration::from_millis(180));
Clock::msec().sleep_extended(Duration::from_millis(180));
}
}
```
Expand Down
8 changes: 4 additions & 4 deletions rust06-threads/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ riot_main!(main);

fn main() {
// Startup delay to ensure the terminal is connected
Clock::sec().sleep(Duration::from_secs(5));
Clock::sec().sleep_extended(Duration::from_secs(5));

println!("Thread example.");

/* [TASK 1: create the thread here] */

let mut led0 = riot_wrappers::led::LED::<0>::new();
let mut led0 = riot_wrappers::led::LED::<0>::new().expect("Our board has an LED0");

loop {
println!(
Expand All @@ -33,8 +33,8 @@ fn main() {
);

led0.on().unwrap();
Clock::msec().sleep(Duration::from_millis(100));
Clock::msec().sleep_extended(Duration::from_millis(100));
led0.off().unwrap();
Clock::msec().sleep(Duration::from_millis(900));
Clock::msec().sleep_extended(Duration::from_millis(900));
}
}

0 comments on commit c3b2248

Please sign in to comment.