Closed tcoram closed 1 year ago
@tcoram were you able to locate the issue? From your description it looks like there could be some issue with the buffer handling in spi.c, right?
Please look at these pull requests: Fix for issue #345 and #337
@Mynogs thanks for your PRs!
I am working with a delta-sigma ADC chip (TI ads1120) that talks SPI. I am sending a mix of write() and readwrite() and my chip goes into weird modes.
Here is what my code looks like:
Here is my SPI configuration:
ads.dev = spi.attach(ads.spi, spi.MASTER, ads.ns, 1000000, 8, 1)
Using my Saleae Logic Analyzer, I can see that 4 (instead of 3) master transactions are being sent. The final (extra/spurious) one sends the last byte read (which unfortunately sends my ads chip into a weird state). Here is what my analyzer sees (decoded):
If I modify lua/modules/hw/spi.c:lspi_rw_helper() to remove the buffering (and write individual bytes) then the issue goes away and the same above Lua code gives: