1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-14 15:18:06 +11:00
collapseos/arch/z80/sms/blk/622
Virgil Dupras 4b71f0a344 sms/spi: sample DO when CLK is high
I was sampling DO at the wrong moment, so my input was always
one-off.
2020-11-08 10:24:36 -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 )
( read into rx ) SWAP 1 LSHIFT _D1@ ( tx rx<< x )
0 _THB! ( CLK lo )
( out bit is the 6th ) 6 RSHIFT 1 AND OR
SWAP LOOP ( rx tx ) DROP ;