mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-20 20:18:05 +11:00
124da6adec
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.
16 lines
481 B
Plaintext
16 lines
481 B
Plaintext
: _sdc@ ( dstaddr blkno -- )
|
|
(spie) 0x51 ( CMD17 ) 0 ROT ( a cmd 0 blkno ) _cmd
|
|
IF _err THEN
|
|
_wait 0xfe = NOT IF _err THEN
|
|
0 SWAP ( crc a )
|
|
512 0 DO ( crc a )
|
|
DUP _idle ( crc a a n )
|
|
DUP ROT C! ( crc a n )
|
|
ROT SWAP _crc16 ( a crc )
|
|
SWAP 1+ ( crc a+1 )
|
|
LOOP
|
|
DROP ( crc1 )
|
|
_idle 8 LSHIFT _idle + ( crc2 )
|
|
_wait DROP (spid)
|
|
= NOT IF _err THEN ;
|