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>
impl<const P: char, const N: u8> Drv8873<P, N>
Sourcepub fn new(cs: ChipSelect<P, N>) -> Self
pub fn new(cs: ChipSelect<P, N>) -> Self
Construct a driver from an active-low chip-select pin.
Sourcepub fn free(self) -> ChipSelect<P, N>
pub fn free(self) -> ChipSelect<P, N>
Release the chip-select pin.
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<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> 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