1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-27 22:58:05 +11:00
collapseos/blk/434
Virgil Dupras 1a6a549857 Make the SPI Relay protocol support multiple devices
Working on programming AVR chips exposes a glaring omission in my
first design of the SPI Relay: not allowing multiple devices make
this task hard. I constantly have to unplug my SD card before, plug
the AVR chip holder, then play a bit, then unplug the AVR holder,
then replug the SD card...

My prototype for a SPI relay design is built, but I haven't tested
it yet. I need to adapt the code first, which is what I do here.

When the prototype is tested, I'll update the SDC recipe with a new
schema.
2020-09-17 09:48:55 -04:00

17 lines
504 B
Plaintext

: _sdc! ( srcaddr blkno -- )
[ SDC_DEVID LITN ] (spie)
0x58 ( CMD24 ) 0 ROT ( a cmd 0 blkno ) _cmd
IF _err THEN
_idle DROP 0xfe (spix) DROP 0 SWAP ( crc a )
512 0 DO ( crc a )
C@+ ( crc a+1 n )
ROT OVER ( a n crc n )
_crc16 ( a n crc )
SWAP ( a crc n )
(spix) DROP ( a crc )
SWAP ( crc a )
LOOP
DROP ( crc ) 256 /MOD ( lsb msb )
(spix) DROP (spix) DROP
_wait DROP 0 (spie) ;