maix.peripheral.i2c
maix.peripheral.i2c module
You can use
maix.peripheral.i2c
to access this module with MaixPy
This module is generated from MaixPy and MaixCDK
1. Module#
No module
2. Enum#
2.1. AddrSize#
Address size enum
item | describe |
---|---|
values | SEVEN_BIT: 7-bit address mode TEN_BIT: 10-bit address mode |
C++ defination code:
2.2. Mode#
I2C mode enum
item | describe |
---|---|
values | MASTER: master mode SLAVE: slave mode |
C++ defination code:
3. Variable#
4. Function#
4.1. list_devices#
Get supported i2c bus devices.
item | description |
---|---|
return | i2c bus devices list, int type, is the i2c bus id. |
C++ defination code:
5. Class#
5.1. I2C#
Peripheral i2c class
C++ defination code:
5.1.1. __init__#
I2C Device constructor\nthis constructor will be export to MaixPy as _maix.example.Example.init
item | description |
---|---|
type | func |
param | id: direction [in], i2c bus id, int type, e.g. 0, 1, 2 freq: direction [in], i2c clock, int type, default is 100000(100kbit/s), will auto set fast mode if freq > 100000. mode: direction [in], mode of i2c, i2c.Mode.SLAVE or i2c.Mode.MASTER. addr_size: direction [in], address length of i2c, i2c.AddrSize.SEVEN_BIT or i2c.AddrSize.TEN_BIT. |
throw | err::Exception if open i2c device failed. |
static | False |
C++ defination code:
5.1.2. scan#
scan all i2c salve address on the bus
item | description |
---|---|
type | func |
param | addr: If -1, only scan this addr, or scan from 0x08~0x77, default -1. |
return | the list of i2c slave address, int list type. |
static | False |
C++ defination code:
5.1.3. writeto#
write data to i2c slave
item | description |
---|---|
type | func |
param | addr: direction [in], i2c slave address, int type data: direction [in], data to write, bytes type. Note: The range of value should be in [0,255]. |
return | if success, return the length of written data, error occurred will return -err::Err. |
static | False |
C++ defination code:
5.1.4. readfrom#
read data from i2c slave
item | description |
---|---|
type | func |
param | addr: direction [in], i2c slave address, int type len: direction [in], data length to read, int type |
return | the list of data read from i2c slave, bytes type, you should delete it after use in C++. If read failed, return nullptr in C++, None in MaixPy. |
static | False |
C++ defination code:
5.1.5. writeto_mem#
write data to i2c slave's memory address
item | description |
---|---|
type | func |
param | addr: direction [in], i2c slave address, int type mem_addr: direction [in], memory address want to write, int type. data: direction [in], data to write, bytes type. mem_addr_size: direction [in], memory address size, default is 8. mem_addr_le: direction [in], memory address little endian, default is false, that is send high byte first. |
return | data length written if success, error occurred will return -err::Err. |
static | False |
C++ defination code:
5.1.6. readfrom_mem#
read data from i2c slave
item | description |
---|---|
type | func |
param | addr: direction [in], i2c slave address, int type mem_addr: direction [in], memory address want to read, int type. len: direction [in], data length to read, int type mem_addr_size: direction [in], memory address size, default is 8. mem_addr_le: direction [in], memory address little endian, default is false, that is send high byte first. |
return | the list of data read from i2c slave, bytes type, you should delete it after use in C++. If read failed, return nullptr in C++, None in MaixPy. |
static | False |
C++ defination code: