fixed typo

This commit is contained in:
2026-05-20 18:41:40 +02:00
parent 95143a44b9
commit 227ac0feb7
2 changed files with 16 additions and 16 deletions

View File

@@ -63,11 +63,11 @@ async fn main(spawner: Spawner) {
// let result = device.read_temperature().await; // let result = device.read_temperature().await;
// info!("T: {:?}", result); // info!("T: {:?}", result);
// device // device
// .trigger_messurement() // .trigger_measurement()
// .await // .await
// .expect("Failed to trigger trigger_messurement"); // .expect("Failed to trigger trigger_measurement");
match device.read_messurement() { match device.read_measurement() {
Ok(d) => info!("Got: {:?}", d), Ok(d) => info!("Got: {:?}", d),
Err(e) => error!("Error: {:?}", e), Err(e) => error!("Error: {:?}", e),
} }

View File

@@ -41,11 +41,11 @@ bitflags! {
/// This bit indicates that a measurement of magnetic field is done and the data is ready to be /// This bit indicates that a measurement of magnetic field is done and the data is ready to be
/// read. This bit is reset only when any of the magnetic data registers is read. /// read. This bit is reset only when any of the magnetic data registers is read.
const MESSUREMENT_M_DONE = 0b0100_0000; const MEASUREMENT_M_DONE = 0b0100_0000;
/// This bit indicates that a measurement of temperature is done and the data is ready to be read. /// This bit indicates that a measurement of temperature is done and the data is ready to be read.
/// This bit is reset only when the temperature register is read. /// This bit is reset only when the temperature register is read.
const MESSUREMENT_T_DONE = 0b1000_0000; const MEASUREMENT_T_DONE = 0b1000_0000;
} }
} }
@@ -55,11 +55,11 @@ bitflags! {
struct Control0RegisterFlags: u8 { struct Control0RegisterFlags: u8 {
/// Take Measure of Magnetic field, or TM_M bit. Writing a 1 into this location causes the chip to /// Take Measure of Magnetic field, or TM_M bit. Writing a 1 into this location causes the chip to
/// perform a magnetic measurement. This bit is self-clearing at the end of each measurement. /// perform a magnetic measurement. This bit is self-clearing at the end of each measurement.
const TAKE_MESSUREMENT_M = 0b0000_0001; const TAKE_MEASUREMENT_M = 0b0000_0001;
/// Take Measure of Temperature, or TM_T bit. Writing a 1 into this location causes the chip to /// Take Measure of Temperature, or TM_T bit. Writing a 1 into this location causes the chip to
/// perform a temperature measurement. This bit is self-clearing at the end of each measurement. /// perform a temperature measurement. This bit is self-clearing at the end of each measurement.
const TAKE_MESSUREMENT_T = 0b0000_0010; const TAKE_MEASUREMENT_T = 0b0000_0010;
/// Writing a 1 into this location will cause the chip to do the Set operation, which will allow large set /// Writing a 1 into this location will cause the chip to do the Set operation, which will allow large set
/// current to flow through the sensor coils for 375ns. This bit is self-cleared at the end of Set operation. /// current to flow through the sensor coils for 375ns. This bit is self-cleared at the end of Set operation.
@@ -161,7 +161,7 @@ bitflags! {
/// All 3 Axis from a measurement /// All 3 Axis from a measurement
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct MagneticMessurement { pub struct MagneticMeasurement {
/// X-Axis in µT /// X-Axis in µT
pub x: f32, pub x: f32,
@@ -172,7 +172,7 @@ pub struct MagneticMessurement {
pub z: f32, pub z: f32,
} }
impl MagneticMessurement { impl MagneticMeasurement {
/// Convert the µT from the measurement to Gaus. It's just x0.01. /// Convert the µT from the measurement to Gaus. It's just x0.01.
pub fn convert_micro_tesla_to_gaus(tesla: f32) -> f32 { pub fn convert_micro_tesla_to_gaus(tesla: f32) -> f32 {
tesla * 0.01 tesla * 0.01
@@ -383,10 +383,10 @@ where
return Err(Error::NotAvailableInContinuousMode); return Err(Error::NotAvailableInContinuousMode);
} }
self.write_reg_controll_0(self.ctrl0 | Control0RegisterFlags::TAKE_MESSUREMENT_T) self.write_reg_controll_0(self.ctrl0 | Control0RegisterFlags::TAKE_MEASUREMENT_T)
.await?; .await?;
self.wait_for_status_flag(StatusRegisterFlags::MESSUREMENT_T_DONE) self.wait_for_status_flag(StatusRegisterFlags::MEASUREMENT_T_DONE)
.await?; .await?;
let t_out = self.read_reg_temperature().await?; let t_out = self.read_reg_temperature().await?;
@@ -399,7 +399,7 @@ where
/// Read the last measurement /// Read the last measurement
#[maybe_async] #[maybe_async]
pub async fn read_messurement(&mut self) -> Result<MagneticMessurement, Error<I::Error>> { pub async fn read_measurement(&mut self) -> Result<MagneticMeasurement, Error<I::Error>> {
let mut data = [0u8; 9]; let mut data = [0u8; 9];
self.read_registers(REG_OUT_START, &mut data).await?; self.read_registers(REG_OUT_START, &mut data).await?;
@@ -420,17 +420,17 @@ where
let y: f32 = y as f32 * RESOLUTION; let y: f32 = y as f32 * RESOLUTION;
let z: f32 = z as f32 * RESOLUTION; let z: f32 = z as f32 * RESOLUTION;
Ok(MagneticMessurement { x, y, z }) Ok(MagneticMeasurement { x, y, z })
} }
/// Trigger a new measurement if not in continuous mode. /// Trigger a new measurement if not in continuous mode.
/// Waits for the measurement to complete. /// Waits for the measurement to complete.
#[maybe_async] #[maybe_async]
pub async fn trigger_messurement(&mut self) -> Result<(), Error<I::Error>> { pub async fn trigger_measurement(&mut self) -> Result<(), Error<I::Error>> {
self.write_reg_controll_0(self.ctrl0 | Control0RegisterFlags::TAKE_MESSUREMENT_M) self.write_reg_controll_0(self.ctrl0 | Control0RegisterFlags::TAKE_MEASUREMENT_M)
.await?; .await?;
self.wait_for_status_flag(StatusRegisterFlags::MESSUREMENT_M_DONE) self.wait_for_status_flag(StatusRegisterFlags::MEASUREMENT_M_DONE)
.await .await
} }