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>
impl<H, I2C, SDAPIN, SCLPIN, CLOCK> I2c<H, I2C, Pin<Input, SDAPIN>, Pin<Input, SCLPIN>, CLOCK>
sourcepub 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>
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.
sourcepub 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>
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>
impl<H, I2C, SDA, SCL, CLOCK> I2c<H, I2C, SDA, SCL, CLOCK>
sourcepub fn ping_device(
&mut self,
address: u8,
direction: Direction
) -> Result<bool, Error>
pub fn ping_device( &mut self, address: u8, direction: Direction ) -> Result<bool, Error>
Test whether a device answers on a certain address.
sourcepub fn i2cdetect<W>(
&mut self,
w: &mut W,
direction: Direction
) -> Result<(), <W as uWrite>::Error>where
W: uWrite,
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: -- -- -- -- -- -- -- --