[][src]Struct ruspiro_i2c::I2cImpl

pub struct I2cImpl { /* fields omitted */ }

I²C peripheral representation

Methods

impl I2cImpl[src]

pub fn initialize(
    &mut self,
    core_speed: u32,
    fast_mode: bool
) -> Result<(), &'static str>
[src]

Initialize the I²C bus for further usage. This will require the GPIO pins 2 and 3 to be available for usage. If they have been already occupied before this initialization is called an error will be returned.

pub fn scan(&self)[src]

Scan for I²C devices currently connected to the I²C bus. The scan will just try to get an acknowledge message from any slave address between 0x00 and 0x7F. If a device is connected this call succeeds and the corresponding address is written to the console. This function is typically only used to check for device addresses when a new device is connected but it's address is not properly documented.

pub fn get_device(&self, addr: u8) -> Result<I2cDevice, &'static str>[src]

Get a new I²C device with the given address. This functions checks whether ther is really a device connected with the given address to the I²C bus. TODO: ensure there will not be more then 1 request for a device on the same address

pub fn read_register_u8(
    &self,
    device: I2cDevice,
    reg: u8
) -> Result<u8, &'static str>
[src]

Read a u8 from a device register

pub fn read_register_u16(
    &self,
    device: I2cDevice,
    reg: u8
) -> Result<u16, &'static str>
[src]

Read a u16 from a device register

pub fn read_register_buff(
    &self,
    device: I2cDevice,
    reg: u8,
    len: u16
) -> Result<Vec<u8>, &'static str>
[src]

Read a u8 array from a device register

pub fn read_register_bit(
    &self,
    device: I2cDevice,
    reg: u8,
    offset: u16
) -> Result<bool, &'static str>
[src]

Read a specific bit from a device register. Returns Ok(true) if the bit is set or Ok(false) if not.

pub fn read_register_bits(
    &self,
    device: I2cDevice,
    reg: u8,
    offset: u16,
    bits: u16
) -> Result<u8, &'static str>
[src]

Read specific bits from a device register. The bits in the result are shifted to the right so they appear as 0 offset.

pub fn write_u8(&self, device: I2cDevice, data: u8) -> Result<(), &'static str>[src]

Write u8 data to a device without specifying a register

pub fn write_register_u8(
    &self,
    device: I2cDevice,
    reg: u8,
    data: u8
) -> Result<(), &'static str>
[src]

Write u8 data to a device register

pub fn write_register_u16(
    &self,
    device: I2cDevice,
    reg: u8,
    data: u16
) -> Result<(), &'static str>
[src]

Write u16 data to a device register

pub fn write_register_buff(
    &self,
    device: I2cDevice,
    reg: u8,
    data: &[u8]
) -> Result<(), &'static str>
[src]

Write a u8 array to a device register

pub fn write_register_bit(
    &self,
    device: I2cDevice,
    reg: u8,
    offset: u16,
    set: bool
) -> Result<(), &'static str>
[src]

Write a specific bit to a device register. If set is true the bit will be set to 1

pub fn write_register_bits(
    &self,
    device: I2cDevice,
    reg: u8,
    offset: u16,
    bits: u16,
    value: u8
) -> Result<(), &'static str>
[src]

Read specific bits from a device register. The bits in the result are shifted to the right so they appear as 0 offset.

Auto Trait Implementations

impl Unpin for I2cImpl

impl Sync for I2cImpl

impl Send for I2cImpl

Blanket Implementations

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]