Diagnostics

Struct Diagnostics 

Source
pub struct Diagnostics { /* private fields */ }
Expand description

Diagnostics flags from the DIAG_AGC register (0x3FFD)

Implementations§

Source§

impl Diagnostics

Source

pub const fn new(raw: u16) -> Self

Create diagnostics from raw register value

Source

pub const fn raw(&self) -> u16

Get the raw register value

Source

pub const fn comp_high(&self) -> bool

COMP_HIGH: Magnetic field too strong

Set when the magnetic field is above the recommended range The sensor may still work but accuracy could be affected

Source

pub const fn comp_low(&self) -> bool

COMP_LOW: Magnetic field too weak

Set when the magnetic field is below the recommended range The sensor may still work but accuracy could be affected

Source

pub const fn cordic_overflow(&self) -> bool

COF: CORDIC overflow

Set when an overflow occurred in the CORDIC calculation When this bit is set, angle and magnitude data is invalid

Source

pub const fn offset_comp_finished(&self) -> bool

OCF: Offset compensation finished

This flag is set to 1 after power-up when the offset compensation algorithm has finished. After power-up, the flag remains at 1

Source

pub const fn agc_value(&self) -> u8

Get the Automatic Gain Control (AGC) value

Returns an 8-bit value where:

  • 0 = high magnetic field (close to sensor)
  • 255 = low magnetic field (far from sensor)

Typical values are between 60-200. Values outside this range may indicate the magnet is too close or too far

Source

pub const fn magnetic_field_ok(&self) -> bool

Check if the magnetic field strength is within acceptable range

Returns true if neither COMP_HIGH nor COMP_LOW is set

Source

pub const fn is_valid(&self) -> bool

Check if data is valid

Returns true if there’s no CORDIC overflow and the magnetic field is within acceptable range

Trait Implementations§

Source§

impl Clone for Diagnostics

Source§

fn clone(&self) -> Diagnostics

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Diagnostics

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<u16> for Diagnostics

Source§

fn from(raw: u16) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Diagnostics

Source§

fn eq(&self, other: &Diagnostics) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Diagnostics

Source§

impl Eq for Diagnostics

Source§

impl StructuralPartialEq for Diagnostics

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.