mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-06 03:20:56 +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.
17 lines
586 B
Plaintext
17 lines
586 B
Plaintext
( cmd arg1 arg2 -- resp )
|
|
( Sends a command to the SD card, along with arguments and
|
|
specified CRC fields. (CRC is only needed in initial commands
|
|
though). This does *not* handle CS. You have to
|
|
select/deselect the card outside this routine. )
|
|
: _cmd
|
|
_wait DROP ROT ( a1 a2 cmd )
|
|
0 _s+crc ( a1 a2 crc )
|
|
ROT 256 /MOD ROT ( a2 h l crc )
|
|
_s+crc _s+crc ( a2 crc )
|
|
SWAP 256 /MOD ROT ( h l crc )
|
|
_s+crc _s+crc ( crc )
|
|
0x01 OR ( ensure stop bit )
|
|
(spix) DROP ( send CRC )
|
|
_wait ( wait for a valid response... )
|
|
;
|