I2C

Module NameI2C
Import NameI2C

Initialize

sub Initialize()

Initialize I2C bus.

Start

 sub Start()

Send an I2C bus start condition. A start condition is HIGH to LOW of SDA line when the clock is HIGH.

Stop

 sub Stop()

Send an I2C bus stop condition. A stop condition is LOW to HIGH of SDA when line when the clock is HIGH.

Restart

 sub Restart()

Send an I2C bus restart condition.

Acknowledge

 sub Acknowledge(Optional ack As Bit = IsAcknowledge)
  • ack - Ack can be IsAcknowledge or IsNotAcknowledge.

Initiate I2C acknowledge.

ReadByte

 Overloads Function ReadByte() As Byte

Read a single byte from the I2C bus

ReadByte

 Overloads Function ReadByte(ack As Bit) As Byte
  • ack - Ack can be IsAcknowledge or IsNotAcknowledge.

Read a single byte from the I2C bus, with acknowledge.

WriteByte

 sub WriteByte(data As Byte)
  • data - Byte data to send.

Write a single byte to the I2C bus

Options

#option I2C_SCL ' define SCL pin
#option I2C_SDA ' define SDA pin