fixed typo
This commit is contained in:
@@ -63,11 +63,11 @@ async fn main(spawner: Spawner) {
|
||||
// let result = device.read_temperature().await;
|
||||
// info!("T: {:?}", result);
|
||||
// device
|
||||
// .trigger_messurement()
|
||||
// .trigger_measurement()
|
||||
// .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),
|
||||
Err(e) => error!("Error: {:?}", e),
|
||||
}
|
||||
|
||||
26
src/lib.rs
26
src/lib.rs
@@ -41,11 +41,11 @@ bitflags! {
|
||||
|
||||
/// 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.
|
||||
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 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 {
|
||||
/// 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.
|
||||
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
|
||||
/// 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
|
||||
/// 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
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct MagneticMessurement {
|
||||
pub struct MagneticMeasurement {
|
||||
/// X-Axis in µT
|
||||
pub x: f32,
|
||||
|
||||
@@ -172,7 +172,7 @@ pub struct MagneticMessurement {
|
||||
pub z: f32,
|
||||
}
|
||||
|
||||
impl MagneticMessurement {
|
||||
impl MagneticMeasurement {
|
||||
/// Convert the µT from the measurement to Gaus. It's just x0.01.
|
||||
pub fn convert_micro_tesla_to_gaus(tesla: f32) -> f32 {
|
||||
tesla * 0.01
|
||||
@@ -383,10 +383,10 @@ where
|
||||
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?;
|
||||
|
||||
self.wait_for_status_flag(StatusRegisterFlags::MESSUREMENT_T_DONE)
|
||||
self.wait_for_status_flag(StatusRegisterFlags::MEASUREMENT_T_DONE)
|
||||
.await?;
|
||||
|
||||
let t_out = self.read_reg_temperature().await?;
|
||||
@@ -399,7 +399,7 @@ where
|
||||
|
||||
/// Read the last measurement
|
||||
#[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];
|
||||
self.read_registers(REG_OUT_START, &mut data).await?;
|
||||
|
||||
@@ -420,17 +420,17 @@ where
|
||||
let y: f32 = y 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.
|
||||
/// Waits for the measurement to complete.
|
||||
#[maybe_async]
|
||||
pub async fn trigger_messurement(&mut self) -> Result<(), Error<I::Error>> {
|
||||
self.write_reg_controll_0(self.ctrl0 | Control0RegisterFlags::TAKE_MESSUREMENT_M)
|
||||
pub async fn trigger_measurement(&mut self) -> Result<(), Error<I::Error>> {
|
||||
self.write_reg_controll_0(self.ctrl0 | Control0RegisterFlags::TAKE_MEASUREMENT_M)
|
||||
.await?;
|
||||
|
||||
self.wait_for_status_flag(StatusRegisterFlags::MESSUREMENT_M_DONE)
|
||||
self.wait_for_status_flag(StatusRegisterFlags::MEASUREMENT_M_DONE)
|
||||
.await
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user