mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
Merge pull request #20303 from chrysn-pull-requests/rust-updates
treewide: Rust updates
This commit is contained in:
commit
55cbb7bdfa
@ -11,7 +11,5 @@ license = "LGPL-2.1-only"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
lsm303agr = "^0.2"
|
||||
lsm303agr = "1.0"
|
||||
riot-wrappers = "^0.8"
|
||||
# Whatever lsm uses
|
||||
nb = "*"
|
||||
|
@ -1,3 +1,4 @@
|
||||
USEMODULE += rust_riotmodules
|
||||
USEMODULE += ztimer_msec
|
||||
|
||||
FEATURES_REQUIRED += periph_i2c
|
||||
|
@ -1,6 +1,6 @@
|
||||
#![no_std]
|
||||
|
||||
use lsm303agr::{interface, mode, Lsm303agr, AccelOutputDataRate::Hz50};
|
||||
use lsm303agr::{interface, mode, Lsm303agr, AccelOutputDataRate::Hz50, AccelMode};
|
||||
|
||||
use riot_wrappers::{saul, println, i2c, cstr::cstr, mutex::Mutex};
|
||||
use saul::{Phydat, registration};
|
||||
@ -59,9 +59,11 @@ fn init() -> Result<(), &'static str> {
|
||||
for (&i2cdev, (lsm, (reg, reg_mag))) in I2C_DEVICES.iter().zip(lsm.iter_mut().zip(reg.iter_mut().zip(reg_mag.iter_mut()))) {
|
||||
let mut device = Lsm303agr::new_with_i2c(i2c::I2CDevice::new(i2cdev));
|
||||
|
||||
let mut init_clock = riot_wrappers::ztimer::Clock::msec();
|
||||
|
||||
device.init()
|
||||
.map_err(|_| "Device initialization failed")?;
|
||||
device.set_accel_odr(Hz50)
|
||||
device.set_accel_mode_and_odr(&mut init_clock, AccelMode::Normal, Hz50)
|
||||
.map_err(|_| "Device configuration failed")?;
|
||||
|
||||
let lsm = lsm.insert(SaulLSM { device: Mutex::new(device) });
|
||||
@ -90,10 +92,10 @@ impl registration::Drivable for &SaulLSM {
|
||||
let mut device = self.device.try_lock()
|
||||
.ok_or(registration::Error)?;
|
||||
|
||||
let data = device.accel_data()
|
||||
let data = device.acceleration()
|
||||
.map_err(|_| registration::Error)?;
|
||||
// Data is in the +-2g range by default, which doesn't overflow even the i16 SAUL uses
|
||||
Ok(Phydat::new(&[data.x as _, data.y as _, data.z as _], Some(saul::Unit::GForce), -3))
|
||||
Ok(Phydat::new(&[data.x_mg() as _, data.y_mg() as _, data.z_mg() as _], Some(saul::Unit::GForce), -3))
|
||||
}
|
||||
}
|
||||
|
||||
@ -115,9 +117,8 @@ impl registration::Drivable for MagAspect {
|
||||
let mut device = self.0.device.try_lock()
|
||||
.ok_or(registration::Error)?;
|
||||
|
||||
let data = nb::block!(device.mag_data())
|
||||
let data = device.magnetic_field()
|
||||
.map_err(|_| registration::Error)?;
|
||||
// Original data is in nanotesla
|
||||
return Ok(Phydat::fit(&[data.x, data.y, data.z], Some(saul::Unit::T), -9))
|
||||
return Ok(Phydat::fit(&[data.x_nt(), data.y_nt(), data.z_nt()], Some(saul::Unit::T), -9))
|
||||
}
|
||||
}
|
||||
|
BIN
examples/rust-gcoap/Cargo.lock
generated
BIN
examples/rust-gcoap/Cargo.lock
generated
Binary file not shown.
@ -22,7 +22,7 @@ opt-level = "s"
|
||||
riot-wrappers = { version = "^0.8", features = [ "set_panic_handler", "panic_handler_format", "with_coap_message", "with_coap_handler" ] }
|
||||
|
||||
coap-message-demos = { git = "https://gitlab.com/chrysn/coap-message-demos/", default-features = false }
|
||||
coap-handler-implementations = "0.4"
|
||||
coap-handler-implementations = "0.5"
|
||||
riot-coap-handler-demos = { git = "https://gitlab.com/etonomy/riot-module-examples/", features = [ "vfs" ] }
|
||||
|
||||
# While currently this exmple does not use any RIOT modules implemented in
|
||||
|
@ -26,7 +26,7 @@ fn main() {
|
||||
.below(&["vfs"], riot_coap_handler_demos::vfs::vfs("/const"))
|
||||
.with_wkc()
|
||||
;
|
||||
let mut handler = riot_wrappers::coap_handler::GcoapHandler(handler);
|
||||
let mut handler = riot_wrappers::coap_handler::v0_2::GcoapHandler(handler);
|
||||
|
||||
let mut listener = gcoap::SingleHandlerListener::new_catch_all(&mut handler);
|
||||
|
||||
|
BIN
examples/rust-hello-world/Cargo.lock
generated
BIN
examples/rust-hello-world/Cargo.lock
generated
Binary file not shown.
BIN
sys/rust_riotmodules_standalone/Cargo.lock
generated
BIN
sys/rust_riotmodules_standalone/Cargo.lock
generated
Binary file not shown.
BIN
tests/rust_minimal/Cargo.lock
generated
BIN
tests/rust_minimal/Cargo.lock
generated
Binary file not shown.
Loading…
Reference in New Issue
Block a user