~vdupras/collapseos

ref: ac3629b817115b1af75096856ee9499cfbbd3392 collapseos/doc/hw/sdcard.txt -rw-r--r-- 1.2 KiB
ac3629b8Virgil Dupras Make BLK@* and BLK!* into ialiases 1 year, 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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
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.