mirror of
https://github.com/hsoft/collapseos.git
synced 2024-12-26 07:38:04 +11:00
1a6a549857
Working on programming AVR chips exposes a glaring omission in my first design of the SPI Relay: not allowing multiple devices make this task hard. I constantly have to unplug my SD card before, plug the AVR chip holder, then play a bit, then unplug the AVR holder, then replug the SD card... My prototype for a SPI relay design is built, but I haven't tested it yet. I need to adapt the code first, which is what I do here. When the prototype is tested, I'll update the SDC recipe with a new schema.
17 lines
745 B
Plaintext
17 lines
745 B
Plaintext
: _err 0 (spie) ABORT" SDerr" ;
|
|
|
|
( Tight definition ahead, pre-comment.
|
|
|
|
Initialize a SD card. This should be called at least 1ms
|
|
after the powering up of the card. We begin by waking up the
|
|
SD card. After power up, a SD card has to receive at least
|
|
74 dummy clocks with CS and DI high. We send 80.
|
|
Then send cmd0 for a maximum of 10 times, success is when
|
|
we get 0x01. Then comes the CMD8. We send it with a 0x01aa
|
|
argument and expect a 0x01aa argument back, along with a
|
|
0x01 R1 response. After that, we need to repeatedly run
|
|
CMD55+CMD41 (0x40000000) until the card goes out of idle
|
|
mode, that is, when it stops sending us 0x01 response and
|
|
send us 0x00 instead. Any other response means that
|
|
initialization failed. )
|