[][src]Trait mpu9250::Device

pub trait Device: Releasable {
    type Error;
    fn read_many<N: ArrayLength<u8>>(
        &mut self,
        reg: Register
    ) -> Result<GenericArray<u8, N>, Self::Error>;
fn write(&mut self, reg: Register, val: u8) -> Result<(), Self::Error>; fn read(&mut self, reg: Register) -> Result<u8, Self::Error> { ... }
fn modify<F>(&mut self, reg: Register, f: F) -> Result<(), Self::Error>
    where
        F: FnOnce(u8) -> u8
, { ... } }

An MPU communication device abstraction

This allows us to generalize the device over either an I2C or SPI peripheral

Associated Types

type Error

The type of error for all results

Loading content...

Required methods

fn read_many<N: ArrayLength<u8>>(
    &mut self,
    reg: Register
) -> Result<GenericArray<u8, N>, Self::Error>

Read many values from register

fn write(&mut self, reg: Register, val: u8) -> Result<(), Self::Error>

Write the provided value to register

Loading content...

Provided methods

fn read(&mut self, reg: Register) -> Result<u8, Self::Error>

Read a single value from the register

fn modify<F>(&mut self, reg: Register, f: F) -> Result<(), Self::Error> where
    F: FnOnce(u8) -> u8, 

Modify the value in the register using the provided closure. The closure accepts the current value of the register, permitting conditional checks before modification.

Loading content...

Implementors

impl<E, I2C> Device for I2cDevice<I2C> where
    I2C: Read<Error = E> + Write<Error = E> + WriteRead<Error = E>, 
[src]

type Error = E

fn read(&mut self, reg: Register) -> Result<u8, Self::Error>[src]

fn modify<F>(&mut self, reg: Register, f: F) -> Result<(), Self::Error> where
    F: FnOnce(u8) -> u8, 
[src]

impl<SPI, NCS, E> Device for SpiDevice<SPI, NCS> where
    SPI: Write<u8, Error = E> + Transfer<u8, Error = E>,
    NCS: OutputPin
[src]

type Error = E

fn read(&mut self, reg: Register) -> Result<u8, Self::Error>[src]

fn modify<F>(&mut self, reg: Register, f: F) -> Result<(), Self::Error> where
    F: FnOnce(u8) -> u8, 
[src]

Loading content...