[][src]Trait bno080::interface::SensorInterface

pub trait SensorInterface {
    type SensorError;
    fn setup(
        &mut self,
        delay_source: &mut impl DelayMs<u8>
    ) -> Result<(), Self::SensorError>;
fn write_packet(&mut self, packet: &[u8]) -> Result<(), Self::SensorError>;
fn read_packet(
        &mut self,
        recv_buf: &mut [u8]
    ) -> Result<usize, Self::SensorError>;
fn read_with_timeout(
        &mut self,
        recv_buf: &mut [u8],
        delay_source: &mut impl DelayMs<u8>,
        max_ms: u8
    ) -> Result<usize, Self::SensorError>;
fn send_and_receive_packet(
        &mut self,
        send_buf: &[u8],
        recv_buf: &mut [u8]
    ) -> Result<usize, Self::SensorError>;
fn requires_soft_reset(&self) -> bool; }

A method of communicating with the sensor

Associated Types

type SensorError

Interface error type

Loading content...

Required methods

fn setup(
    &mut self,
    delay_source: &mut impl DelayMs<u8>
) -> Result<(), Self::SensorError>

give the sensor interface a chance to set up

fn write_packet(&mut self, packet: &[u8]) -> Result<(), Self::SensorError>

Write the whole packet provided

fn read_packet(
    &mut self,
    recv_buf: &mut [u8]
) -> Result<usize, Self::SensorError>

Read the next packet from the sensor Returns the size of the packet read (up to the size of the slice provided)

fn read_with_timeout(
    &mut self,
    recv_buf: &mut [u8],
    delay_source: &mut impl DelayMs<u8>,
    max_ms: u8
) -> Result<usize, Self::SensorError>

Wait for sensor to indicate it has data available before reading

  • max_ms maximum number of milliseconds to wait for data

fn send_and_receive_packet(
    &mut self,
    send_buf: &[u8],
    recv_buf: &mut [u8]
) -> Result<usize, Self::SensorError>

Send a packet and receive the response immediately

fn requires_soft_reset(&self) -> bool

Does this interface require a soft reset after init?

Loading content...

Implementors

impl<I2C, CommE> SensorInterface for I2cInterface<I2C> where
    I2C: Write<Error = CommE> + Read<Error = CommE> + WriteRead<Error = CommE>, 
[src]

type SensorError = Error<CommE, ()>

fn read_packet(
    &mut self,
    recv_buf: &mut [u8]
) -> Result<usize, Self::SensorError>
[src]

Read one packet into the receive buffer

impl<SPI, CSN, IN, RS, CommE, PinE> SensorInterface for SpiInterface<SPI, CSN, IN, RS> where
    SPI: Write<u8, Error = CommE> + Transfer<u8, Error = CommE>,
    CSN: OutputPin<Error = PinE>,
    IN: InputPin<Error = PinE>,
    RS: OutputPin<Error = PinE>,
    CommE: Debug,
    PinE: Debug
[src]

type SensorError = Error<CommE, PinE>

fn read_packet(
    &mut self,
    recv_buf: &mut [u8]
) -> Result<usize, Self::SensorError>
[src]

Read a complete packet from the sensor

Loading content...