SD_command assembly rewrite
This commit is contained in:
@@ -94,6 +94,7 @@ void SD_powerUpSeq()
|
||||
/*******************************************************************************
|
||||
Send command to SD card
|
||||
*******************************************************************************/
|
||||
/*
|
||||
void SD_command(uint8_t cmd, uint32_t arg, uint8_t crc)
|
||||
{
|
||||
// transmit command to sd card
|
||||
@@ -108,6 +109,7 @@ void SD_command(uint8_t cmd, uint32_t arg, uint8_t crc)
|
||||
// transmit crc
|
||||
spi_exchange(crc|0x01);
|
||||
}
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
Read R1 from SD card
|
||||
|
||||
32
sw/bootloader/devices/sd_card_asm.s
Normal file
32
sw/bootloader/devices/sd_card_asm.s
Normal file
@@ -0,0 +1,32 @@
|
||||
.export _SD_command
|
||||
|
||||
.importzp sp
|
||||
|
||||
.autoimport on
|
||||
|
||||
; void SD_command(uint8_t cmd, uint32_t arg, uint8_t crc)
|
||||
|
||||
; The plan: push crc to stack, load arg into tmp1 through 4
|
||||
|
||||
.proc _SD_command: near
|
||||
|
||||
pha ; Push CRC to cpu stack
|
||||
ldy #$04
|
||||
lda (sp),y ; Load CMD
|
||||
ora #$40 ; start bit
|
||||
jsr _spi_exchange
|
||||
|
||||
dey
|
||||
arg_loop: ; send ARG
|
||||
lda (sp),y
|
||||
jsr _spi_exchange
|
||||
dey
|
||||
bpl arg_loop
|
||||
|
||||
pla ; Pull CRC from stack
|
||||
ora #$01 ; stop bit
|
||||
jsr _spi_exchange
|
||||
jsr incsp5 ; pop all off stack
|
||||
rts
|
||||
|
||||
.endproc
|
||||
Reference in New Issue
Block a user