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>
impl<Spi: SpiDevice> IcMd<Spi>
Sourcepub fn new(spi: Spi) -> Self
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.
Sourcepub fn init(&mut self) -> Result<(), DeviceError<Spi::Error>>
pub fn init(&mut self) -> Result<(), DeviceError<Spi::Error>>
Initialize the iC-MD device with the given configuration.
Sourcepub fn configure_actuator_pins(
&mut self,
act0: &PinStatus,
act1: &PinStatus,
) -> Result<(), DeviceError<Spi::Error>>
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).
Sourcepub fn get_device_status(&self) -> DeviceStatus
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().
Sourcepub fn get_full_device_status(
&mut self,
) -> Result<FullDeviceStatus, DeviceError<Spi::Error>>
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.
Sourcepub fn read_counter(&mut self) -> Result<CntCount, DeviceError<Spi::Error>>
pub fn read_counter(&mut self) -> Result<CntCount, DeviceError<Spi::Error>>
Read the current counter value and return it.
Sourcepub fn reset_counters(
&mut self,
cnt0: bool,
cnt1: bool,
cnt2: bool,
) -> Result<(), DeviceError<Spi::Error>>
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.
Sourcepub fn reset_all_counters(&mut self) -> Result<(), DeviceError<Spi::Error>>
pub fn reset_all_counters(&mut self) -> Result<(), DeviceError<Spi::Error>>
Reset all counters. Can be used to send reset commands to all counters.
Sourcepub fn touch_probe_instruction(&mut self) -> Result<(), DeviceError<Spi::Error>>
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.
Sourcepub fn set_counter_config(&mut self, config: CntCfg)
pub fn set_counter_config(&mut self, config: CntCfg)
Set the counter configuration.
This should be done prior to calling init().