Get SD card reads working
This commit is contained in:
@@ -15,7 +15,7 @@ LISTS=lists
|
||||
TESTS=tests
|
||||
|
||||
SRCS=$(wildcard *.s) $(wildcard *.c)
|
||||
SRCS+=$(filter-out $(wildcard tests/*), $(wildcard **/*.s)) $(filter-out $(wildcard tests/*) $(wildcard filesystem/*) devices/sd_print.c, $(wildcard **/*.c))
|
||||
SRCS+=$(filter-out $(wildcard tests/*), $(wildcard **/*.s)) $(filter-out $(wildcard tests/*) $(wildcard filesystem/*), $(wildcard **/*.c))
|
||||
OBJS+=$(patsubst %.s,%.o,$(filter %s,$(SRCS)))
|
||||
OBJS+=$(patsubst %.c,%.o,$(filter %c,$(SRCS)))
|
||||
|
||||
|
||||
@@ -282,8 +282,6 @@ uint8_t SD_readSingleBlock(uint32_t addr, uint8_t *buf, uint8_t *token)
|
||||
uint16_t readAttempts;
|
||||
uint16_t i;
|
||||
|
||||
/*
|
||||
|
||||
// set token to none
|
||||
*token = 0xFF;
|
||||
|
||||
@@ -326,8 +324,6 @@ uint8_t SD_readSingleBlock(uint32_t addr, uint8_t *buf, uint8_t *token)
|
||||
spi_deselect(0);
|
||||
spi_exchange(0xFF);
|
||||
|
||||
*/
|
||||
|
||||
return res1;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "sd_print.h"
|
||||
#include "sd_card.h"
|
||||
|
||||
/*
|
||||
void SD_printR1(uint8_t res)
|
||||
{
|
||||
if(res == 0xFF)
|
||||
@@ -26,7 +27,9 @@ void SD_printR1(uint8_t res)
|
||||
if(IN_IDLE(res))
|
||||
cputs("\tIn Idle State\r\n");
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
void SD_printR2(uint8_t *res)
|
||||
{
|
||||
SD_printR1(res[0]);
|
||||
@@ -52,7 +55,9 @@ void SD_printR2(uint8_t *res)
|
||||
if(CARD_LOCKED(res[1]))
|
||||
cputs("\tCard Locked\r\n");
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
void SD_printR3(uint8_t *res)
|
||||
{
|
||||
SD_printR1(res[0]);
|
||||
@@ -84,7 +89,9 @@ void SD_printR3(uint8_t *res)
|
||||
if(VDD_3536(res[2])) cputs("3.5-3.6");
|
||||
cputs("\r\n");
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
void SD_printR7(uint8_t *res)
|
||||
{
|
||||
SD_printR1(res[0]);
|
||||
@@ -112,7 +119,9 @@ void SD_printR7(uint8_t *res)
|
||||
cprintf("%x", res[4]);
|
||||
cputs("\r\n");
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
void SD_printCSD(uint8_t *buf)
|
||||
{
|
||||
cputs("CSD:\r\n");
|
||||
@@ -139,6 +148,7 @@ void SD_printCSD(uint8_t *buf)
|
||||
cprintf("%x", buf[9]);
|
||||
cputs("\r\n");
|
||||
}
|
||||
*/
|
||||
|
||||
void SD_printBuf(uint8_t *buf)
|
||||
{
|
||||
@@ -146,7 +156,7 @@ void SD_printBuf(uint8_t *buf)
|
||||
uint16_t i;
|
||||
for(i = 0; i < SD_BLOCK_LEN; i++)
|
||||
{
|
||||
cprintf("%x", *buf++);
|
||||
cprintf("%2x", *buf++);
|
||||
if(colCount == 19)
|
||||
{
|
||||
cputs("\r\n");
|
||||
@@ -161,6 +171,7 @@ void SD_printBuf(uint8_t *buf)
|
||||
cputs("\r\n");
|
||||
}
|
||||
|
||||
/*
|
||||
void SD_printDataErrToken(uint8_t token)
|
||||
{
|
||||
if(token & 0xF0)
|
||||
@@ -174,3 +185,4 @@ void SD_printDataErrToken(uint8_t token)
|
||||
if(SD_TOKEN_ERROR(token))
|
||||
cputs("\tError\r\n");
|
||||
}
|
||||
*/
|
||||
@@ -24,31 +24,31 @@ int main() {
|
||||
// initialize sd card
|
||||
if(SD_init() != SD_SUCCESS)
|
||||
{
|
||||
cputs("Error init SD CARD\r\n");
|
||||
cputs("Error\r\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
cputs("SD Card init\r\n");
|
||||
cputs("Success\r\n");
|
||||
|
||||
// read sector 0
|
||||
// cputs("\r\nReading sector: 0x");
|
||||
cputs("\r\nReading sector: 0x");
|
||||
// ((uint8_t)(addr >> 24));
|
||||
// cprintf("%x", (uint8_t)(addr >> 16));
|
||||
// cprintf("%x", (uint8_t)(addr >> 8));
|
||||
// cprintf("%x", (uint8_t)addr);
|
||||
// res[0] = SD_readSingleBlock(addr, buf, &token);
|
||||
// cputs("\r\nResponse:\r\n");
|
||||
// //SD_printR1(res[0]);
|
||||
res[0] = SD_readSingleBlock(addr, buf, &token);
|
||||
cputs("\r\nResponse:\r\n");
|
||||
//SD_printR1(res[0]);
|
||||
|
||||
// if no error, print buffer
|
||||
// if((res[0] == 0x00) && (token == SD_START_TOKEN))
|
||||
// SD_printBuf(buf);
|
||||
// else if error token received, print
|
||||
// else if(!(token & 0xF0))
|
||||
// {
|
||||
// cputs("Ercputsror token:\r\n");
|
||||
// SD_printDataErrToken(token);
|
||||
// }
|
||||
if((res[0] == 0x00) && (token == SD_START_TOKEN))
|
||||
SD_printBuf(buf);
|
||||
//else if error token received, print
|
||||
else if(!(token & 0xF0))
|
||||
{
|
||||
cputs("Error token:\r\n");
|
||||
//SD_printDataErrToken(token);
|
||||
}
|
||||
|
||||
// update address to 0x00000100
|
||||
// addr = 0x00000100;
|
||||
|
||||
Reference in New Issue
Block a user