From 219245e10fa01ab81a7dd10b64fffd07e2ec1a49 Mon Sep 17 00:00:00 2001 From: Radomir Dopieralski Date: Mon, 19 Sep 2016 20:53:08 +0200 Subject: extmod/machine_i2c: Add support for the addrsize parameter in mem xfers. The memory read/write I2C functions now take an optional keyword-only parameter that specifies the number of bits in the memory address. Only mem-addrs that are a multiple of 8-bits are supported (otherwise the behaviour is undefined). Due to the integer type used for the address, for values larger than 32 bits, only 32 bits of address will be sent, and the rest will be padded with 0s. Right now no exception is raised when that happens. For values smaller than 8, no address is sent. Also no exception then. Tested with a VL6180 sensor, which has 16-bit register addresses. Due to code refactoring, this patch reduces stmhal and esp8266 builds by about 50 bytes. --- docs/library/machine.I2C.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'docs') diff --git a/docs/library/machine.I2C.rst b/docs/library/machine.I2C.rst index b3bfa68f0..f5820f103 100644 --- a/docs/library/machine.I2C.rst +++ b/docs/library/machine.I2C.rst @@ -170,8 +170,7 @@ methods are convenience functions to communicate with such devices. Read `nbytes` from the slave specified by `addr` starting from the memory address specified by `memaddr`. - The argument `addrsize` specifies the address size in bits (on ESP8266 - this argument is not recognised and the address size is always 8 bits). + The argument `addrsize` specifies the address size in bits. Returns a `bytes` object with the data read. .. method:: I2C.readfrom_mem_into(addr, memaddr, buf, \*, addrsize=8) -- cgit v1.2.3