res1_cmd assembly rewrite

This commit is contained in:
Byron Lathi
2023-07-23 18:43:39 -07:00
parent 1c693b029d
commit 8f3a1a5968
3 changed files with 37 additions and 1 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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