Skip to main content

Device

Struct Device 

Source
pub struct Device<I> { /* private fields */ }
Expand description

Low-level driver of iC-MD

This is the low-level driver for the iC-MD. It was built with device-driver. All functionality is based on the datasheet Rev. C2.

Root block of the Device driver

Implementations§

Source§

impl<I> Device<I>

Source

pub const fn new(interface: I) -> Self

Create a new instance of the device

Source

pub fn free(self) -> I

Drop the driver instance and reclaim the interface

Source

pub fn counter_configuration( &mut self, ) -> RegisterOperation<'_, Self, CounterConfiguration, u8, RW, ()>
where I: RegisterInterfaceBase<AddressType = u8>,

Counter configuration The iC-MD can be configured for 1 up to 3 channels with counter lengths of 16 to 48 bits. Here, the counter configuration is selected as a u8 value. The higher-level driver takes care of converting from a meaningful configuration to the 8-bit value.

Register operation:

  • Address: 0
  • Reset value: 0
Source

pub fn read_cnt_cfg_0( &mut self, ) -> RegisterOperation<'_, Self, ReadCntCfg0, u8, RO, ()>
where I: RegisterInterfaceBase<AddressType = u8>,

Read the 24 bit counter configuration, 24+2 bits to read (4 bytes) This corresponds to counter configuration 0b000.

Register operation:

  • Address: 8
  • Reset value: 0
Source

pub fn read_cnt_cfg_1( &mut self, ) -> RegisterOperation<'_, Self, ReadCntCfg1, u8, RO, ()>
where I: RegisterInterfaceBase<AddressType = u8>,

Read the 24 bit, 2 counters configuration, 48+2 bits to read (7 bytes) This corresponds to counter configuration 0b001.

Register operation:

  • Address: 8
  • Reset value: 0
Source

pub fn read_cnt_cfg_2( &mut self, ) -> RegisterOperation<'_, Self, ReadCntCfg2, u8, RO, ()>
where I: RegisterInterfaceBase<AddressType = u8>,

Read the 48 bit counter register, 48+2 bits to read (7 bytes) This corresponds to counter configuration 0b010.

Register operation:

  • Address: 8
  • Reset value: 0
Source

pub fn read_cnt_cfg_3( &mut self, ) -> RegisterOperation<'_, Self, ReadCntCfg3, u8, RO, ()>
where I: RegisterInterfaceBase<AddressType = u8>,

Read the 16 bit counter configuration, 16+2 bits to read (3 bytes) This corresponds to counter configuration 0b011.

Register operation:

  • Address: 8
  • Reset value: 0
Source

pub fn read_cnt_cfg_4( &mut self, ) -> RegisterOperation<'_, Self, ReadCntCfg4, u8, RO, ()>
where I: RegisterInterfaceBase<AddressType = u8>,

Read the 32 bit counter configuration, 32+2 bits to read (5 bytes) This corresponds to counter configuration 0b100.

Register operation:

  • Address: 8
  • Reset value: 0
Source

pub fn read_cnt_cfg_5( &mut self, ) -> RegisterOperation<'_, Self, ReadCntCfg5, u8, RO, ()>
where I: RegisterInterfaceBase<AddressType = u8>,

Read the 32 bit and 16 bit counter configuration, 32+16+2 bits to read (7 bytes) This corresponds to counter configuration 0b101.

Register operation:

  • Address: 8
  • Reset value: 0
Source

pub fn read_cnt_cfg_6( &mut self, ) -> RegisterOperation<'_, Self, ReadCntCfg6, u8, RO, ()>
where I: RegisterInterfaceBase<AddressType = u8>,

Read the 16 bit and 16 bit counter configuration, 16+16+2 bits to read (5 bytes) This corresponds to counter configuration 0b110.

Register operation:

  • Address: 8
  • Reset value: 0
Source

pub fn read_cnt_cfg_7( &mut self, ) -> RegisterOperation<'_, Self, ReadCntCfg7, u8, RO, ()>
where I: RegisterInterfaceBase<AddressType = u8>,

Read the 3 x 16 bit counter configuration, 16+16+16+2 bits to read (7 bytes) This corresponds to counter configuration 0b111.

Register operation:

  • Address: 8
  • Reset value: 0
Source

pub fn reference_counter( &mut self, ) -> RegisterOperation<'_, Self, ReferenceCounter, u8, RO, ()>
where I: RegisterInterfaceBase<AddressType = u8>,

Read the references registers 24 bits. TODO: It is unclear if this works, as I assume the address for reading is auto-incremented as when reading the data. This should be tested once the actual hardware setup is available with an encoder connected.

Register operation:

  • Address: 16
  • Reset value: 0
Source

pub fn instruction_byte( &mut self, ) -> RegisterOperation<'_, Self, InstructionByte, u8, WO, ()>
where I: RegisterInterfaceBase<AddressType = u8>,

Instruction byte (write only) Allows writing of the instruction bytes. When one of these bits is set to 1, the corresponding instruction is executed and the bit set back to zero, except in the case of Act0 and Act1, which remain set to the written value.

Register operation:

  • Address: 48
  • Reset value: 0
Source

pub fn status_0(&mut self) -> RegisterOperation<'_, Self, Status0, u8, RO, ()>
where I: RegisterInterfaceBase<AddressType = u8>,

Status0: Status of counter 0 Returns the status of counter 0 plus several other status bits. See also Status1 and Status2 for the other counters and more status bits.

Register operation:

  • Address: 72
  • Reset value: 0
Source

pub fn status_1(&mut self) -> RegisterOperation<'_, Self, Status1, u8, RO, ()>
where I: RegisterInterfaceBase<AddressType = u8>,

Status1: Status of counter 1 Returns the status of counter 1 plus several other status bits. See also Status0 and Status2 for the other counters and more status bits.

Register operation:

  • Address: 73
  • Reset value: 0
Source

pub fn status_2(&mut self) -> RegisterOperation<'_, Self, Status2, u8, RO, ()>
where I: RegisterInterfaceBase<AddressType = u8>,

Status2: Status of counter 2 Returns the status of counter 2 plus several other status bits. See also Status0 and Status1 for the other counters and more status bits.

Register operation:

  • Address: 74
  • Reset value: 0

Trait Implementations§

Source§

impl<I> Block for Device<I>

Source§

type Interface = I

The interface used by the block
Source§

type RegisterAddressType = u8

The register address type
Source§

type CommandAddressType = u8

The command address type
Source§

type BufferAddressType = u8

The buffer address type
Source§

type RegisterAddressMode = ()

The address mode of the registers in this block
Source§

fn interface(&mut self) -> &mut Self::Interface

Get a reference to the inner interface. With it you can do out-of-band operations that aren’t defined in the generated code.
Source§

fn bulk_read( &mut self, ) -> BulkRegisterOperation<'_, Self, <Self::Interface as RegisterInterfaceBase>::AddressType, (), RO>
where Self::Interface: RegisterInterfaceBase, Self::RegisterAddressMode: AddressMode,

Start a bulk-read transaction Read more
Source§

fn bulk_write( &mut self, ) -> BulkRegisterOperation<'_, Self, <Self::Interface as RegisterInterfaceBase>::AddressType, (), WO>
where Self::Interface: RegisterInterfaceBase, Self::RegisterAddressMode: AddressMode,

Start a bulk-write transaction Read more
Source§

fn bulk_modify( &mut self, ) -> BulkRegisterOperation<'_, Self, <Self::Interface as RegisterInterfaceBase>::AddressType, (), RW>
where Self::Interface: RegisterInterfaceBase, Self::RegisterAddressMode: AddressMode,

Start a bulk-modify transaction Read more
Source§

impl<I: Debug> Debug for Device<I>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<I> Freeze for Device<I>
where I: Freeze,

§

impl<I> RefUnwindSafe for Device<I>
where I: RefUnwindSafe,

§

impl<I> Send for Device<I>
where I: Send,

§

impl<I> Sync for Device<I>
where I: Sync,

§

impl<I> Unpin for Device<I>
where I: Unpin,

§

impl<I> UnsafeUnpin for Device<I>
where I: UnsafeUnpin,

§

impl<I> UnwindSafe for Device<I>
where I: 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.