[−][src]Struct buspirate::spi::SPI
SPI
represents a Bus Pirate device in SPI mode.
Methods
impl<TX, RX, TXErr, RXErr> SPI<TX, RX> where
TX: Write<u8, Error = TXErr>,
RX: Read<u8, Error = RXErr>,
[src]
TX: Write<u8, Error = TXErr>,
RX: Read<u8, Error = RXErr>,
pub fn close(self) -> Result<BusPirate<TX, RX>, Error<TXErr, RXErr>>
[src]
close
resets the Bus Pirate back into normal terminal mode, exiting
SPI mode.
pub fn to_bitbang(self) -> Result<BitBang<TX, RX>, Error<TXErr, RXErr>>
[src]
to_bitbang
switches back to "binary bit-bang" mode.
pub fn set_speed(&mut self, speed: Speed) -> Result<(), Error<TXErr, RXErr>>
[src]
set_speed
changes the SPI clock rate for subsequent transactions.
pub fn set_config(&mut self, config: Config) -> Result<(), Error<TXErr, RXErr>>
[src]
set_config
changes some SPI-mode-specific configuration settings.
pub fn configure_peripherals(
&mut self,
config: Config
) -> Result<(), Error<TXErr, RXErr>>
[src]
&mut self,
config: Config
) -> Result<(), Error<TXErr, RXErr>>
configure_peripherals
changes some settings related to general
peripherals that can be used alongside SPI mode.
pub fn chip_select(&mut self, active: bool) -> Result<(), Error<TXErr, RXErr>>
[src]
chip_select
sets the state of the chip select signal.
Chip select is an inverted signal, so passing true
will cause the
electrical signal to move low, and false
will cause the electrical
signal to move high.
pub fn transfer_byte(&mut self, v: u8) -> Result<u8, Error<TXErr, RXErr>>
[src]
transfer_byte
performs a single-byte SPI transfer.
An SPI transfer receeives one bit in for every bit transmitted, so the result is the byte receieved from the connected device.
To transmit a single byte without receiving any result, simply disregard the resulting byte. It is not possible to receive data without transmitting, but a common convention for recieving data only is to transmit zero.
pub fn transfer_bytes<'w>(
&mut self,
v: &'w mut [u8]
) -> Result<&'w [u8], Error<TXErr, RXErr>>
[src]
&mut self,
v: &'w mut [u8]
) -> Result<&'w [u8], Error<TXErr, RXErr>>
transfer_bytes
performs a multi-byte SPI transfer.
An SPI transfer receeives one bit in for every bit transmitted, so the result gives the bytes receieved from the connected device. The backing array of the source slice is overwritten in-place, so the resulting slice refers to the same bytes as the argument.
A maximum of 16 bytes can be transmitted per call. If a longer slice
is given, the Request
error is returned.
pub fn write_then_read<'w>(
&mut self,
write_from: &[u8],
read_into: &mut [u8],
cs: bool
) -> Result<(), Error<TXErr, RXErr>>
[src]
&mut self,
write_from: &[u8],
read_into: &mut [u8],
cs: bool
) -> Result<(), Error<TXErr, RXErr>>
write_then_read
transmits zero or more bytes and then receives zero
or more bytes, optionally setting the chip select signal active
throughout.
A common pattern with SPI devices is to transmit some sort of request
(a register address, for example) and then transmit sufficient zero
bits to receieve the device's response to that request. write_then_read
implements that common pattern in an efficient way that allows the
Bus Pirate to be in full control of the timing, and thus not be stalled
by delays caused by waiting for further requests from its host.
A maximum of 4096 bytes can be transmitted and recieved by this function.
If either slice is greater than 4096 characters then the Request
error is returned.
Trait Implementations
impl<TX, RX, TXErr, RXErr> Comms for SPI<TX, RX> where
TX: Write<u8, Error = TXErr>,
RX: Read<u8, Error = RXErr>,
[src]
TX: Write<u8, Error = TXErr>,
RX: Read<u8, Error = RXErr>,
Auto Trait Implementations
impl<TX, RX> Send for SPI<TX, RX> where
RX: Send,
TX: Send,
RX: Send,
TX: Send,
impl<TX, RX> Sync for SPI<TX, RX> where
RX: Sync,
TX: Sync,
RX: Sync,
TX: Sync,
impl<TX, RX> Unpin for SPI<TX, RX> where
RX: Unpin,
TX: Unpin,
RX: Unpin,
TX: Unpin,
Blanket Implementations
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,