BPIO2 and SPI mode:
I have found a discrepancy between using the terminal cli and using the BPIO2 python interface.
I can connect using either mode to my SPI slave and send/receive single write-then-read transfers.
In the VT100 terminal mode, I can use this:
SPI> {0x5A 0x06 0x00 0x10 rrrr}
CS Enabled
TX: 0x5A(0x00) 0x06(0x00) 0x00(0x00) 0x10(0x00)
RX: 0x00 0x07 0xF0 0x24
CS Disabled
And using the BPIO2 interface, I can write this:
from pybpio.bpio_client import BPIOClient
from pybpio.bpio_spi import BPIOSPI
client = BPIOClient(...)
spi = BPIOSPI(client)
if not spi.configure(...):
client.close()
raise RuntimeError("Failed to configure SPI interface")
print(spi.transfer([0x5A, 0x06, 0x00, 0x10], read_bytes=4)
# prints something like b'\x00\x08\x08\xd1'
print(spi.transfer_duplex([0x5A, 0x06, 0x00, 0x10, 0xFF, 0xFF, 0xFF, 0xFF])
# prints something like b'\x00\x00\x00\x00\x00\x08\x08\xd1'
These work as expected. However, when I try to send a burst 2 or more of these sequences, this only works in the VT100 terminal.
In the VT100 terminal mode, I get this:
SPI> {0x5A 0x06 0x00 0x10 rrrr 0x5A 0x06 0x00 0x10 rrrr}
CS Enabled
TX: 0x5A(0x00) 0x06(0x00) 0x00(0x00) 0x10(0x00)
RX: 0x00 0x08 0x20 0x50
TX: 0x5A(0x00) 0x06(0x00) 0x00(0x00) 0x10(0x00)
RX: 0x00 0x08 0x20 0x50
CS Disabled
And using the BPIO2 interface, I can write this:
from pybpio.bpio_client import BPIOClient
from pybpio.bpio_spi import BPIOSPI
client = BPIOClient(...)
spi = BPIOSPI(client)
if not spi.configure(...):
client.close()
raise RuntimeError("Failed to configure SPI interface")
print(spi.transfer_duplex([0x5A, 0x06, 0x00, 0x10, 0xFF, 0xFF, 0xFF, 0xFF] * 2)
# prints something like b'\x00\x00\x00\x00\x00\x08$\x82\x00\x00\x00\x00\x00\x00\x00\x00'
I would have expected the last four bytes of the response to not be zero, just like in VT100 mode. I am interested getting the BPIO2 interface to work like the VT100 so that I can queue multiple “requests” into one, thereby increasing my polling rates to the slave device.
I am new to the BusPirate, so any feedback or help is much appreciated.
Issue opened by: sksg