Enhance: Add instructions for SPI
mikaelpatel opened this issue · 5 comments
SPI transfer function; spi-transfer ( data0 -- data1 ).
cs low
data spi-transfer
cs high
It occurs that you are running out of single characters. (So far you have done an admirable job of assigning them.) '$' is not taken, but perhaps you need to use an escape character. Possibly $ could represent 'serial', so $S might be SPI, $I be I2C,
It occurs to me that these buses are bidirectional, so ine needs two commands each. Perhaps noncapitalized and capitalized letters? Eg $s and $S for SPI.
( You have done such a good job so far, please take these as off-the-top suggestions.)
Using $ as a prefix to extend the opcode is a great idea. I have used that before in the vfm project. That is an advanced forth virtual machine. Unfortunately not yet ported to the Arduino. The Shell is a short-cut :). Anyway a virtual member function that is called for $ prefix opcodes is a neat way to extend the Shell opcodes. That goes on the todo list.
Added a simple sketch to demonstrate how to handle extended instructions (trap). Please see commit 430b91e.
So, SPI write might be:
[ 1,2,3,4] $S
Leaving 4 read values and n on stack?
5 6 7 8 4
Xn...X0 n --- Yn...Y0 n