mikaelpatel / Arduino-Shell

RPN Postscript/Forth Command Shell for Arduino

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enhance: Add instructions for TWI

mikaelpatel opened this issue · comments

I2C requires at least two function; twi-read ( n addr -- x1 ... xn) and twi-write ( x1 ... xn n addr -- ). Many driver functions have the form;

reg 1 addr twi-write n addr twi-read // read a register
val reg 2 addr twi-write // write a register

Using stack markes is elegant:

[_reg] _addr $I 
2 _addr $i
[23 _reg] _addr $I
[2,3,4,5] _addr $I

(I used $I for twi-write and $i for twi-read)

Yes, the stack marker and operations are great contribution by PostScript. Much more rethinking stack machines was done in the design.

I have changed the extended instruction set handling (trap) to a general trap on any op-code that was not handled. The trap handler can parse any number of op-codes.