1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-20 20:18:05 +11:00
collapseos/blk/434
Virgil Dupras 124da6adec Move SD Card subsystem outside of RC2014 recipe and add protocols
Although the SPI Relay driver is RC2014-specific, the SD Card driver
is generic enough to be a subsystem. That's the second subsystem we
add and this warrants, I think, the formalization of a new concept:
protocols.
2020-08-16 14:30:33 -04:00

17 lines
493 B
Plaintext

: _sdc! ( srcaddr blkno -- )
(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 (spid) ;