res1_cmd assembly rewrite
This commit is contained in:
@@ -67,6 +67,7 @@ uint8_t SD_init()
|
||||
return SD_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
// Send a command with starting end ending clock pulses
|
||||
uint8_t res1_cmd(uint8_t cmd, uint32_t arg, uint8_t crc)
|
||||
{
|
||||
@@ -89,6 +90,7 @@ uint8_t res1_cmd(uint8_t cmd, uint32_t arg, uint8_t crc)
|
||||
|
||||
return res1;
|
||||
}
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
Run power up sequence
|
||||
|
||||
@@ -75,4 +75,6 @@ uint8_t SD_sendOpCond();
|
||||
uint8_t SD_readSingleBlock(uint32_t addr, uint8_t *buf, uint8_t *error);
|
||||
uint8_t SD_writeSingleBlock(uint32_t addr, uint8_t *buf, uint8_t *res);
|
||||
|
||||
uint8_t res1_cmd(uint8_t cmd, uint32_t arg, uint8_t crc);
|
||||
|
||||
#endif
|
||||
@@ -3,6 +3,7 @@
|
||||
.export _SD_readRes2
|
||||
.export _SD_readRes3
|
||||
.export _SD_readBytes
|
||||
.export _res1_cmd
|
||||
|
||||
.importzp sp, ptr1
|
||||
|
||||
@@ -52,7 +53,7 @@ tryread:
|
||||
dex
|
||||
bne tryread
|
||||
|
||||
end:
|
||||
end: ; x will be 0 here anyway
|
||||
rts
|
||||
|
||||
.endproc
|
||||
@@ -120,4 +121,35 @@ read:
|
||||
|
||||
@L1: rts
|
||||
|
||||
.endproc
|
||||
|
||||
; uint8_t res1_cmd(uint8_t cmd, uint32_t arg, uint8_t crc)
|
||||
|
||||
.proc _res1_cmd: near
|
||||
|
||||
pha ; push crc to processor stack
|
||||
lda #$ff
|
||||
jsr _spi_exchange
|
||||
lda #$00 ; this gets ignored anyway
|
||||
jsr _spi_select
|
||||
lda #$ff
|
||||
jsr _spi_exchange
|
||||
|
||||
pla
|
||||
jsr _SD_command ; rely on command to teardown stack
|
||||
|
||||
jsr _SD_readRes1
|
||||
tay ; spi doesn't touch y
|
||||
|
||||
lda #$ff
|
||||
jsr _spi_exchange
|
||||
lda #$00 ; this gets ignored anyway
|
||||
jsr _spi_deselect
|
||||
lda #$ff
|
||||
jsr _spi_exchange
|
||||
|
||||
tya
|
||||
ldx #$00 ; Promote to integer
|
||||
rts
|
||||
|
||||
.endproc
|
||||
Reference in New Issue
Block a user