DmaSpi
DmaSpi copied to clipboard
Support SPI slave
It would be useful if the Teensy could act as a SPI slave device when connecting to another micro-controller.
I've thought about this a couple of times and also started a thread in the teensy forum, but there seemed to be little need.
What exactly would you like to do? Can you post an example protocol? What should happen if the master stopped SPI communication early?
My use case is as follows. I have a proprietary microcontroller that reads data from sensors over SPI. I'd like the Teensy to be able to act as a sensor. The propitiatory microcontroller acts as the SPI master and the sensors are all slaves.
If the master stopped SPI communication before the slave finished transmitting then that slave device should stop and wait for the enable signal from the master before resuming sending data. This is not to say that the entire Teensy should wait, other operations should be able to continue and optionally poll the SPI library to see the status of the transfer.
Does that seem reasonable?
Depends... You didn't go much into detail about the SPI protocol. Would it be a kind of "command and response" protocol or rather a very simple "read the same array again and again" protocol? I guess that is something that is open to be decided, but simple protocols require less work and lessons learned during the work might be useful later.
I'm still working on reverse-engineering the protocol. from what I've learned so far it seems to be command and response.
I'd think that ideally the SPI library would be generic enough so that either model could be built on top of it.
Sorry for the delay!
Well, a generic library is of course the thing to go for, but: even a simple command-response protocol might be hard to implement even with code tailored for that purpose, because the master might not leave enough time for the slave to prepare a response after the command was sent. This has a ton of implications for just about any part of the code and protocol details.
hi guys, sorry to intrude, this “issue” caught my eye.
Teensy does have a spi slave/master communication library now, you may check the forums for it