1
0
mirror of https://github.com/hsoft/collapseos.git synced 2024-11-01 21:20:56 +11:00
collapseos/doc/hw/sdcard.txt

31 lines
1.2 KiB
Plaintext
Raw Normal View History

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