Add SD card software interface
Adds a function to send a command to the sd card.
This commit is contained in:
@@ -11,4 +11,7 @@ SW = LED
|
||||
MM_CTRL = $7ff7
|
||||
MM_DATA = $7fe0
|
||||
|
||||
SD_ARG = $7ff8
|
||||
SD_CMD = $7ffc
|
||||
|
||||
IRQ_STATUS = $7fff
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "board_io.h"
|
||||
#include "uart.h"
|
||||
#include "mapper.h"
|
||||
#include "sd_card.h"
|
||||
|
||||
int main() {
|
||||
int i;
|
||||
@@ -46,6 +47,9 @@ int main() {
|
||||
cprintf("Reading from 0x4000: %x\n", *(unsigned int*)(0x4000));
|
||||
cprintf("Reading from 0x5000: %x\n", *(unsigned int*)(0x5000));
|
||||
|
||||
sd_card_command(0, 0);
|
||||
sd_card_command(0x000001aa, 8);
|
||||
|
||||
while (1) {
|
||||
|
||||
sw = sw_read();
|
||||
|
||||
8
sw/sd_card.h
Normal file
8
sw/sd_card.h
Normal file
@@ -0,0 +1,8 @@
|
||||
#ifndef _SD_CARD_H
|
||||
#define _SD_CARD_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
void sd_card_command(uint32_t arg, uint8_t cmd);
|
||||
|
||||
#endif
|
||||
27
sw/sd_card.s
Normal file
27
sw/sd_card.s
Normal file
@@ -0,0 +1,27 @@
|
||||
.include "io.inc65"
|
||||
|
||||
.importzp sp, sreg
|
||||
|
||||
.export _sd_card_command
|
||||
|
||||
.autoimport on
|
||||
|
||||
.code
|
||||
|
||||
; Send sd card command.
|
||||
; command is in A register, the args are on the stack
|
||||
; I think the order is high byte first?
|
||||
_sd_card_command:
|
||||
pha
|
||||
|
||||
jsr popeax
|
||||
sta SD_ARG
|
||||
stx SD_ARG+1
|
||||
lda sreg
|
||||
sta SD_ARG+2
|
||||
lda sreg+1
|
||||
sta SD_ARG+3
|
||||
|
||||
pla
|
||||
sta SD_CMD
|
||||
rts
|
||||
Reference in New Issue
Block a user