mikaelpatel / Arduino-Shell

RPN Postscript/Forth Command Shell for Arduino
19 stars 5 forks source link

Enhance: Add instructions for SPI #7

Closed mikaelpatel closed 8 years ago

mikaelpatel commented 8 years ago

SPI transfer function; spi-transfer ( data0 -- data1 ).

cs low
data spi-transfer 
cs high
dpharris commented 8 years ago

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, $1 be Serial 1, etc. Also possibly $> and $< could be serial in and out.

dpharris commented 8 years ago

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.)

mikaelpatel commented 8 years ago

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.

mikaelpatel commented 8 years ago

Added a simple sketch to demonstrate how to handle extended instructions (trap). Please see commit https://github.com/mikaelpatel/Arduino-Shell/commit/430b91e0014c627fcf116bc5a6978e3121be40c2.

dpharris commented 8 years ago

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