PiicoDev Unified Methods

June 9, 2021 ยท View on GitHub

The following methods can be used for I2C communication:

MethodUsageDescription
writeto_mem(addr, memaddr, buf, *, addrsize=8)PreferredWrite buf to the target specified by addr starting from the memory address specified by memaddr. The argument addrsize specifies the address size in bits. The method returns None.
readfrom_mem(addr, memaddr, nbytes, *, addrsize=8)PreferredRead nbytes from the target specified by addr starting from the memory address specified by memaddr. The argument addrsize specifies the address size in bits. Returns a bytes object with the data read.
write8(addr, reg, data)Not preferredWrite reg immediately followed by data to the target specified by addr. If reg is None, only data will be sent to the target.
read16(addr, reg)Not preferredRead two bytes from the target specified by addr after writing reg to the target. Returns a bytes object with the data read.

Where:

ValueType
addrbytes
memaddrint
regbytes
databytes
nbytesint
addrsizeint