I2C
— 两线串行协议¶
类¶
-
class
GPIO
(...)¶
使用示例:
import haascv
from haascv import driver
i2cObj = driver.i2c();#获取i2c类对象
i2cObj.open(port, 8, i2cObj.DRIVER_I2C_BIT_RATES_100K,
i2cObj.DRIVER_I2C_MODE_MASTER, 0x70, 0)#配置i2c模块
i2c_read_buf = bytearray(6)#定义存储读取数据的对象
i2c_write_buf = bytearray([1, 2, 3, 4, 5, 6])#定义待写的数据
print(i2c_write_buf)#打印写的buffer
i2cObj.write(i2c_write_buf)#开始写数据
i2cObj.read(i2c_read_buf)#读取数据
print(i2c_read_buf)#打印读取的数据
i2cObj.close()#关闭i2c模块