gpvidal/adxl355-python

Problem with read_multiple_data() function

Opened this issue · 1 comments

There is a problem with the read_multiple_data() function in this library. It assumes you can send arbitrary register addresses to the ADXL355 and that it will give you the values in those registers. However, the ADXL355 implements an autoincrement scheme for multi-byte transactions. You send the first address, keep toggling the clock, and it will autoincrement and send the data out of the next register, then the next, etc. Subsequent addresses sent on the MOSI line will be ignored. After the first byte (which gives the start address and R/W bit), the ADXL355 ignores the MOSI line. Consequently, you can read multiple bytes, but you can only read them in order.

For example if you do read_multiple_data([0x0A, 0x09, 0x08]) you will not get back the values you think because the ADXL355 ignores the 0x09 and 0x08 bytes. Instead you will get back the values out of registers 0x0A, 0x0B, 0x0C.

You are right, indeed in SPI libraries you normally specify the starting register and the number of bytes; not a list of registers