Mirror of CollapseOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

17 lines
586B

  1. ( cmd arg1 arg2 -- resp )
  2. ( Sends a command to the SD card, along with arguments and
  3. specified CRC fields. (CRC is only needed in initial commands
  4. though). This does *not* handle CS. You have to
  5. select/deselect the card outside this routine. )
  6. : _cmd
  7. _wait DROP ROT ( a1 a2 cmd )
  8. 0 _s+crc ( a1 a2 crc )
  9. ROT 256 /MOD ROT ( a2 h l crc )
  10. _s+crc _s+crc ( a2 crc )
  11. SWAP 256 /MOD ROT ( h l crc )
  12. _s+crc _s+crc ( crc )
  13. 0x01 OR ( ensure stop bit )
  14. _sdcSR DROP ( send CRC )
  15. _wait ( wait for a valid response... )
  16. ;