pub struct Drv8873<CS: CsControl> { /* private fields */ }Expand description
DRV8873 driver bound to a chip-select control.
The SPI bus is passed in as &mut to each method so that multiple DRV8873 instances can share the
same bus. Use NoChipSelect if the DRV8873’s SPI interface is not connected.
Implementations§
Source§impl<CS: CsControl> Drv8873<CS>
impl<CS: CsControl> Drv8873<CS>
Sourcepub fn new(cs: CS) -> Self
pub fn new(cs: CS) -> Self
Construct a driver from a chip-select control (real pin or NoChipSelect).
Sourcepub fn transfer_word<I, PINS>(
&mut self,
spi: &mut SpiBus<I, PINS>,
word: u16,
) -> Result<Response, Error>where
I: Instance,
PINS: Pins<I>,
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.
spimust 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).
Sourcepub 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>,
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).
Sourcepub fn read_reg<I, PINS>(
&mut self,
spi: &mut SpiBus<I, PINS>,
addr: u8,
) -> Result<Response, Error>where
I: Instance,
PINS: Pins<I>,
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).
Sourcepub fn read_fault<I, PINS>(
&mut self,
spi: &mut SpiBus<I, PINS>,
) -> Result<Fault, Error>where
I: Instance,
PINS: Pins<I>,
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.
Auto Trait Implementations§
impl<CS> Freeze for Drv8873<CS>where
CS: Freeze,
impl<CS> RefUnwindSafe for Drv8873<CS>where
CS: RefUnwindSafe,
impl<CS> Send for Drv8873<CS>where
CS: Send,
impl<CS> Sync for Drv8873<CS>where
CS: Sync,
impl<CS> Unpin for Drv8873<CS>where
CS: Unpin,
impl<CS> UnsafeUnpin for Drv8873<CS>where
CS: UnsafeUnpin,
impl<CS> UnwindSafe for Drv8873<CS>where
CS: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more