Skip to content
  • Radomir Dopieralski's avatar
    extmod/machine_i2c: Add support for the addrsize parameter in mem xfers. · 219245e1
    Radomir Dopieralski authored
    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.
    219245e1