1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-24 15:38:05 +11:00
collapseos/arch/z80/sms/blk/622
Virgil Dupras 7d568bd782 sms: simplify and solidify ports-related drivers
Add _TRA!, _THA!, _TRB!, _THB! routines to easily handle those pins'
value without stepping on other pins like the drivers previously
did. For SDC driver, it's going to be important soon because it turns
out that I can't get away with "always on" CS, so I'll need a scheme
where it's important that TH/TR pins have stable values.
2020-11-02 18:53:57 -05:00

11 lines
377 B
Plaintext

: (spie) DROP ; ( always enabled )
: (spix) ( x -- x, for port B )
0 SWAP ( rx tx ) 8 0 DO
( send current bit to TRB, TR's output bit )
DUP 7 I - RSHIFT 1 AND _TRB!
1 _THB! ( CLK hi )
0 _THB! ( CLK lo )
( read into rx ) SWAP 1 LSHIFT _D1@ ( tx rx<< x )
( out bit is the 6th ) 6 RSHIFT 1 AND OR
SWAP LOOP ( rx tx ) DROP ;