Type Alias atmega_hal::i2c::I2c

source ·
pub type I2c<CLOCK> = I2c<Atmega, TWI, Pin<Input, PC4>, Pin<Input, PC5>, CLOCK>;

Aliased Type§

struct I2c<CLOCK> { /* private fields */ }

Implementations

source§

impl<H, I2C, SDAPIN, SCLPIN, CLOCK> I2c<H, I2C, Pin<Input, SDAPIN>, Pin<Input, SCLPIN>, CLOCK>
where I2C: I2cOps<H, Pin<Input, SDAPIN>, Pin<Input, SCLPIN>>, SDAPIN: PinOps, SCLPIN: PinOps, CLOCK: Clock,

source

pub fn new( p: I2C, sda: Pin<Input<PullUp>, SDAPIN>, scl: Pin<Input<PullUp>, SCLPIN>, speed: u32 ) -> I2c<H, I2C, Pin<Input, SDAPIN>, Pin<Input, SCLPIN>, CLOCK>

Initialize an I2C peripheral on the given pins.

Note that the SDA and SCL pins are hardwired for each I2C peripheral and you must pass the correct ones. This is enforced at compile time.

This method expects the internal pull-ups to be configured for both pins to comply with the I2C specification. If you have external pull-ups connected, use I2c::with_external_pullup instead.

source

pub fn with_external_pullup( p: I2C, sda: Pin<Input<Floating>, SDAPIN>, scl: Pin<Input<Floating>, SCLPIN>, speed: u32 ) -> I2c<H, I2C, Pin<Input, SDAPIN>, Pin<Input, SCLPIN>, CLOCK>

Initialize an I2C peripheral on the given pins.

Note that the SDA and SCL pins are hardwired for each I2C peripheral and you must pass the correct ones. This is enforced at compile time.

This method expects that external resistors pull up SDA and SCL.

source§

impl<H, I2C, SDA, SCL, CLOCK> I2c<H, I2C, SDA, SCL, CLOCK>
where I2C: I2cOps<H, SDA, SCL>, CLOCK: Clock, Delay<CLOCK>: DelayMs<u16>,

source

pub fn ping_device( &mut self, address: u8, direction: Direction ) -> Result<bool, Error>

Test whether a device answers on a certain address.

source

pub fn i2cdetect<W>( &mut self, w: &mut W, direction: Direction ) -> Result<(), <W as uWrite>::Error>
where W: uWrite,

Scan the bus for connected devices. This method will output an summary in the format known from i2cdetect(8) on the selected serial connection. For example:

-    0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:       -- -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- 38 39 -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --

Trait Implementations

source§

impl<H, I2C, SDA, SCL, CLOCK> ErrorType for I2c<H, I2C, SDA, SCL, CLOCK>
where I2C: I2cOps<H, SDA, SCL>,

§

type Error = Error

Error type
source§

impl<H, I2C, SDA, SCL, CLOCK> I2c for I2c<H, I2C, SDA, SCL, CLOCK>
where I2C: I2cOps<H, SDA, SCL>,

source§

fn transaction( &mut self, address: u8, operations: &mut [Operation<'_>] ) -> Result<(), <I2c<H, I2C, SDA, SCL, CLOCK> as ErrorType>::Error>

Execute the provided operations on the I2C bus. Read more
source§

fn read(&mut self, address: A, read: &mut [u8]) -> Result<(), Self::Error>

Reads enough bytes from slave with address to fill read. Read more
source§

fn write(&mut self, address: A, write: &[u8]) -> Result<(), Self::Error>

Writes bytes to slave with address address. Read more
source§

fn write_read( &mut self, address: A, write: &[u8], read: &mut [u8] ) -> Result<(), Self::Error>

Writes bytes to slave with address address and then reads enough bytes to fill read in a single transaction. Read more
source§

impl<H, I2C, SDA, SCL, CLOCK> Read for I2c<H, I2C, SDA, SCL, CLOCK>
where I2C: I2cOps<H, SDA, SCL>,

§

type Error = Error

Error type
source§

fn read( &mut self, address: u8, buffer: &mut [u8] ) -> Result<(), <I2c<H, I2C, SDA, SCL, CLOCK> as Read>::Error>

Reads enough bytes from slave with address to fill buffer Read more
source§

impl<H, I2C, SDA, SCL, CLOCK> Write for I2c<H, I2C, SDA, SCL, CLOCK>
where I2C: I2cOps<H, SDA, SCL>,

§

type Error = Error

Error type
source§

fn write( &mut self, address: u8, bytes: &[u8] ) -> Result<(), <I2c<H, I2C, SDA, SCL, CLOCK> as Write>::Error>

Writes bytes to slave with address address Read more
source§

impl<H, I2C, SDA, SCL, CLOCK> WriteRead for I2c<H, I2C, SDA, SCL, CLOCK>
where I2C: I2cOps<H, SDA, SCL>,

§

type Error = Error

Error type
source§

fn write_read( &mut self, address: u8, bytes: &[u8], buffer: &mut [u8] ) -> Result<(), <I2c<H, I2C, SDA, SCL, CLOCK> as WriteRead>::Error>

Writes bytes to slave with address address and then reads enough bytes to fill buffer in a single transaction Read more