Skip to main content

SpiRegisters

Struct SpiRegisters 

Source
pub struct SpiRegisters<SPI> { /* private fields */ }
Expand description

A register map behind an SPI chip select, in the Bosch framing.

The first byte of every transfer is the control byte: the register address with bit 7 set to read or cleared to write. On a read the part then streams consecutive registers; on a write the value follows. The part accepts SPI modes 0 and 3.

Implementations§

Source§

impl<SPI> SpiRegisters<SPI>

Source

pub fn new(device: SPI) -> SpiRegisters<SPI>

Wraps an SPI device, which is the bus plus the part’s chip-select line.

§Arguments
  • device - the SPI device.
§Returns

The register map.

Source

pub fn release(self) -> SPI

Gives back the device.

§Returns

The device the map was built from.

Trait Implementations§

Source§

impl<SPI: Debug> Debug for SpiRegisters<SPI>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<SPI: SpiDevice> RegisterBus for SpiRegisters<SPI>

Source§

type Error = <SPI as ErrorType>::Error

The error the bus underneath reports.
Source§

fn read_registers( &mut self, first: u8, buffer: &mut [u8], ) -> Result<(), Self::Error>

Reads consecutive registers starting at first, as many as buffer holds. Read more
Source§

fn write_register(&mut self, register: u8, value: u8) -> Result<(), Self::Error>

Writes one register. Read more
Source§

fn read_register(&mut self, register: u8) -> Result<u8, Self::Error>

Reads one register. Read more

Auto Trait Implementations§

§

impl<SPI> Freeze for SpiRegisters<SPI>
where SPI: Freeze,

§

impl<SPI> RefUnwindSafe for SpiRegisters<SPI>
where SPI: RefUnwindSafe,

§

impl<SPI> Send for SpiRegisters<SPI>
where SPI: Send,

§

impl<SPI> Sync for SpiRegisters<SPI>
where SPI: Sync,

§

impl<SPI> Unpin for SpiRegisters<SPI>
where SPI: Unpin,

§

impl<SPI> UnsafeUnpin for SpiRegisters<SPI>
where SPI: UnsafeUnpin,

§

impl<SPI> UnwindSafe for SpiRegisters<SPI>
where SPI: 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 = 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.