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.

31 lines
1.2KB

  1. # Accessing SD cards
  2. SD cards support the SPI protocol. If you have a SPI relay
  3. (doc/hw/spi.txt) and a driver for it that implement the SPI
  4. protocol (doc/protocol.txt), you're a few steps away from
  5. accessing SD cards!
  6. What you need to do is to add the SDC subsystem to your Collapse
  7. OS binary. First, define SDC_DEVID to a mask selecting the
  8. proper device on your SPI relay (this is what is sent to
  9. "(spie)"). For example, a SDC_DEVID or 1, 2, 4, or 8 would
  10. select SPI device 1, 2, 3 or 4.
  11. The subsystem is loaded with "423 436 LOADR".
  12. Initialization of the SDC system is done in multiple steps.
  13. First, the BLK system needs to be initialized with "BLK$". Then
  14. you can plug SDC@ and SDC! into BLK with "' SDC@ ' BLK@* **!"
  15. and "' SDC! ' BLK! **!". That only needs to be done once per
  16. boot.
  17. Then, the SD card that was inserted needs to be initialized. You
  18. can do it with "SDC$". If you have no error, it means that the
  19. system can spek to your card, that sync is fine, etc. You can
  20. read/write right now. SDC$ needs to run every time a new card
  21. is inserted.
  22. Collapse OS' SDC drivers are designed to read from the very
  23. first 512 sector of the card, mapping them to blocks
  24. sequentially, 2 sectors per block.