pub struct IcMdAsync<Spi> {
pub device: Device<DeviceInterfaceAsync<Spi>>,
/* private fields */
}Expand description
The main driver struct of the crate representing the iC-MD quadrature counter.
This high-level driver provides access to an asynchronous driver interface.
You can also access the underlying device driver directly via the device field.
You are then yourself responsible for reading the correct counter configurations.
Note that the “async” feature must be activated.
Fields§
§device: Device<DeviceInterfaceAsync<Spi>>Provides acces to the underlying device driver.
Implementations§
Source§impl<Spi: SpiDevice> IcMdAsync<Spi>
impl<Spi: SpiDevice> IcMdAsync<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 async fn init(&mut self) -> Result<(), DeviceError<Spi::Error>>
pub async fn init(&mut self) -> Result<(), DeviceError<Spi::Error>>
Initialize the iC-MD device with the given configuration.
Sourcepub async fn configure_actuator_pins(
&mut self,
act0: &PinStatus,
act1: &PinStatus,
) -> Result<(), DeviceError<Spi::Error>>
pub async 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 async fn get_full_device_status(
&mut self,
) -> Result<FullDeviceStatus, DeviceError<Spi::Error>>
pub async 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 async fn read_counter(
&mut self,
) -> Result<CntCount, DeviceError<Spi::Error>>
pub async fn read_counter( &mut self, ) -> Result<CntCount, DeviceError<Spi::Error>>
Read the current counter value and return it.
Sourcepub async fn reset_counters(
&mut self,
cnt0: bool,
cnt1: bool,
cnt2: bool,
) -> Result<(), DeviceError<Spi::Error>>
pub async 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 async fn reset_all_counters(
&mut self,
) -> Result<(), DeviceError<Spi::Error>>
pub async fn reset_all_counters( &mut self, ) -> Result<(), DeviceError<Spi::Error>>
Reset all counters. Can be used to send reset commands to all counters.
Sourcepub async fn touch_probe_instruction(
&mut self,
) -> Result<(), DeviceError<Spi::Error>>
pub async 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().