11 #include <sys/types.h>
12 #include <driver/i2c.h>
13 #include <driver/gpio.h>
41 void read(uint8_t* bytes,
size_t length,
bool ack =
true);
42 void read(uint8_t* byte,
bool ack =
true);
49 void write(uint8_t byte,
bool ack =
true);
50 void write(uint8_t* bytes,
size_t length,
bool ack =
true);
54 i2c_cmd_handle_t m_cmd;
55 bool m_directionKnown;
void start()
Add an I2C start request to the command stream.
Definition: I2C.cpp:240
I2C()
Create an instance of an I2C object.
Definition: I2C.cpp:25
bool slavePresent(uint8_t address)
Determine if the slave is present and responding.
Definition: I2C.cpp:224
void scan()
Scan the I2C bus looking for devices.
Definition: I2C.cpp:181
static const gpio_num_t DEFAULT_SDA_PIN
The default SDA pin.
Definition: I2C.h:24
void read(uint8_t *bytes, size_t length, bool ack=true)
Read a sequence of bytes from the slave.
Definition: I2C.cpp:134
void write(uint8_t byte, bool ack=true)
Write a single byte to the I2C slave.
Definition: I2C.cpp:275
void stop()
Add an I2C stop request to the command stream.
Definition: I2C.cpp:256
static const gpio_num_t DEFAULT_CLK_PIN
The default Clock pin.
Definition: I2C.h:29
void beginTransaction()
Begin a new I2C transaction.
Definition: I2C.cpp:41
void init(uint8_t address, gpio_num_t sdaPin=DEFAULT_SDA_PIN, gpio_num_t sclPin=DEFAULT_CLK_PIN, uint32_t clkSpeed=DEFAULT_CLK_SPEED, i2c_port_t portNum=I2C_NUM_0, bool pullup=true)
Initialize the I2C interface.
Definition: I2C.cpp:97
void setAddress(uint8_t address)
Set the address of the I2C slave against which we will be working.
Definition: I2C.cpp:204
uint8_t getAddress() const
Get the address of the I2C slave against which we are working.
Definition: I2C.cpp:84
Interface to I2C functions.
Definition: I2C.h:19
void endTransaction()
End an I2C transaction.
Definition: I2C.cpp:61
void setDebug(bool enabled)
enable or disable debugging.
Definition: I2C.cpp:214
static const uint32_t DEFAULT_CLK_SPEED
The default Clock speed.
Definition: I2C.h:34