Struct IcMd

Source
pub struct IcMd<Spi> {
    pub device: Device<DeviceInterface<Spi>>,
    /* private fields */
}
Expand description

The main driver struct of the crate representing the iC-MD quadrature counter. You can also access the underlying device driver directly via the device field. You are then yourself responsible for reading the correct counter configurations.

Fields§

§device: Device<DeviceInterface<Spi>>

Provides acces to the underlying device driver.

Implementations§

Source§

impl<Spi: SpiDevice> IcMd<Spi>

Source

pub fn new(spi: Spi) -> Self

Creates a new instance of the iC-MD driver. By default, the counter is configured to 48-bit mode.

Source

pub fn init(&mut self) -> Result<(), DeviceError<Spi::Error>>

Initialize the iC-MD device with the given configuration.

Source

pub fn configure_actuator_pins( &mut self, act0: &PinStatus, act1: &PinStatus, ) -> Result<(), DeviceError<Spi::Error>>

Set the actuator pins output to the given status. Note that as far as the iC-MD is concerned, this status is “write only”. Thus, there is no function available to read the current status of the actuator pins. However, the stored actuator_status variable will be updated according to what you set here.

§Arguments
  • act0: The status of actuator pin 0 (ACT0).
  • act1: The status of actuator pin 1 (ACT1).
Source

pub fn get_device_status(&self) -> DeviceStatus

Get current device status. This is a cached value that is updated when reading the counter. It contains the error and warning flags of the device. For a full device status, use get_full_device_status().

Source

pub fn get_full_device_status( &mut self, ) -> Result<FullDeviceStatus, DeviceError<Spi::Error>>

Get the full device status by reading all the status registers. This will reset many of the status bits to wait for the next event, problem, issue to occur.

Source

pub fn read_counter(&mut self) -> Result<CntCount, DeviceError<Spi::Error>>

Read the current counter value and return it.

Source

pub fn reset_counters( &mut self, cnt0: bool, cnt1: bool, cnt2: bool, ) -> Result<(), DeviceError<Spi::Error>>

Reset counters to zero. You can select which counters should be set to zero using the specific arguments.

§Arguments
  • cnt0: If true, counter 0 is reset, else not.
  • cnt1: If true, counter 1 is reset, else not.
  • cnt2: If true, counter 2 is reset, else not.
Source

pub fn reset_all_counters(&mut self) -> Result<(), DeviceError<Spi::Error>>

Reset all counters. Can be used to send reset commands to all counters.

Source

pub fn touch_probe_instruction(&mut self) -> Result<(), DeviceError<Spi::Error>>

Touch probe instruction Load touch probe 2 with touch probe 1 value and touch probe 1 wiht ABCNT value.

Source

pub fn set_counter_config(&mut self, config: CntCfg)

Set the counter configuration. This should be done prior to calling init().

Trait Implementations§

Source§

impl<Spi: Debug> Debug for IcMd<Spi>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Spi> Freeze for IcMd<Spi>
where Spi: Freeze,

§

impl<Spi> RefUnwindSafe for IcMd<Spi>
where Spi: RefUnwindSafe,

§

impl<Spi> Send for IcMd<Spi>
where Spi: Send,

§

impl<Spi> Sync for IcMd<Spi>
where Spi: Sync,

§

impl<Spi> Unpin for IcMd<Spi>
where Spi: Unpin,

§

impl<Spi> UnwindSafe for IcMd<Spi>
where Spi: UnwindSafe,

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> 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.