Drv8873

Struct Drv8873 

Source
pub struct Drv8873<const P: char, const N: u8> { /* private fields */ }
Expand description

DRV8873 driver bound to a specific chip-select pin.

The SPI bus is passed in as &mut to each method so that multiple DRV8873 instances can share the same bus.

Implementations§

Source§

impl<const P: char, const N: u8> Drv8873<P, N>

Source

pub fn new(cs: ChipSelect<P, N>) -> Self

Construct a driver from an active-low chip-select pin.

Source

pub fn free(self) -> ChipSelect<P, N>

Release the chip-select pin.

Source

pub fn transfer_word<I, PINS>( &mut self, spi: &mut SpiBus<I, PINS>, word: u16, ) -> Result<Response, Error>
where I: Instance, PINS: Pins<I>,

Send a 16-bit word and receive the status + data bytes.

  • spi must be an enabled 8-bit SPI bus configured in the correct mode for the DRV8873 (CPOL=0, CPHA=1: data captured on falling edge, driven on rising edge).
Source

pub fn write_reg<I, PINS>( &mut self, spi: &mut SpiBus<I, PINS>, addr: u8, value: u8, ) -> Result<Response, Error>
where I: Instance, PINS: Pins<I>,

Write a register and return the response (status + current register contents).

Source

pub fn read_reg<I, PINS>( &mut self, spi: &mut SpiBus<I, PINS>, addr: u8, ) -> Result<Response, Error>
where I: Instance, PINS: Pins<I>,

Read a register and return the response (status + register value).

Source

pub fn read_fault<I, PINS>( &mut self, spi: &mut SpiBus<I, PINS>, ) -> Result<Fault, Error>
where I: Instance, PINS: Pins<I>,

Read the FAULT register and parse into a Fault struct.

To get the status result as well, use read_reg.

Source

pub fn read_diag<I, PINS>( &mut self, spi: &mut SpiBus<I, PINS>, ) -> Result<Diag, Error>
where I: Instance, PINS: Pins<I>,

Read the DIAG register and parse into a Diag struct.

To get the status result as well, use read_reg.

Auto Trait Implementations§

§

impl<const P: char, const N: u8> Freeze for Drv8873<P, N>

§

impl<const P: char, const N: u8> RefUnwindSafe for Drv8873<P, N>

§

impl<const P: char, const N: u8> Send for Drv8873<P, N>

§

impl<const P: char, const N: u8> Sync for Drv8873<P, N>

§

impl<const P: char, const N: u8> Unpin for Drv8873<P, N>

§

impl<const P: char, const N: u8> UnwindSafe for Drv8873<P, N>

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.