MAE 3185 - Introduction to Mechatronics

Logo

View the Project on GitHub Abhiricky1992/UTA-MAE3185-Notes

hardware_i2c Library Functions

To use this library, add following to the C/C++ file,

#include <hardware/i2c.h>

and following to the CMakeLists.txt file.

target_link_libraries(projectName pico_stdlib hardware_gpio hardware_i2c)

Following are some of the most commonly used functions for configuring and using the I2C peripheral.

uint i2c_init(i2c_inst_t* i2c, uint baudRate)

Initialize a specific instance of I2C on the μC.

int i2c_write_blocking(i2c_inst_t* i2c, uint8_t addr, const uint8_t* src, size_t len, bool nostop)

Initiate an I2C message to write data to a target.

int i2c_read_blocking(i2c_inst_t* i2c, uint8_t addr, const uint8_t* dst, size_t len, bool nostop)

Initiate an I2C message to read data from a target.

Next

Code Examples