TEST: Read 50 byte from sd card and write to terminal

This commit is contained in:
Klemens Schölhorn 2018-05-14 23:59:00 +02:00
parent 10c26c0f7b
commit 5ed6fb3d37
1 changed files with 20 additions and 10 deletions

View File

@ -160,7 +160,8 @@ static int copy(void)
int rc = 0; int rc = 0;
dputs("CMD18"); dputs("CMD18");
kprintf("LOADING "); //~ kprintf("LOADING ");
kprintf("READ: ");
REG32(spi, SPI_REG_SCKDIV) = (F_CLK / 20000000UL); REG32(spi, SPI_REG_SCKDIV) = (F_CLK / 20000000UL);
if (sd_cmd(0x52, 0, 0xE1) != 0x00) { if (sd_cmd(0x52, 0, 0xE1) != 0x00) {
@ -172,14 +173,18 @@ static int copy(void)
long n; long n;
crc = 0; crc = 0;
n = 512; //~ n = 512;
n = 50;
while (sd_dummy() != 0xFE); while (sd_dummy() != 0xFE);
do { do {
uint8_t x = sd_dummy(); uint8_t x = sd_dummy();
*p++ = x; kputc(x);
crc = crc16_round(crc, x); //~ *p++ = x;
//~ crc = crc16_round(crc, x);
} while (--n > 0); } while (--n > 0);
return 0;
crc_exp = ((uint16_t)sd_dummy() << 8); crc_exp = ((uint16_t)sd_dummy() << 8);
crc_exp |= sd_dummy(); crc_exp |= sd_dummy();
@ -219,9 +224,6 @@ int main(void)
uint32_t counter = 0; uint32_t counter = 0;
for(uint32_t* ram = RAMTEST_START; ram < RAMTEST_END; ++ram) { for(uint32_t* ram = RAMTEST_START; ram < RAMTEST_END; ++ram) {
*ram = counter++; *ram = counter++;
if((counter % 1024) == 0) {
kprintf("\r%lx", ram);
}
} }
kprintf("\rChecking RAM...\n"); kprintf("\rChecking RAM...\n");
@ -237,12 +239,20 @@ int main(void)
++correct; ++correct;
} }
++counter; ++counter;
if((counter % 1024) == 0) {
kprintf("\r%lx", ram);
}
} }
kprintf("\rSummary: %x matches, %x mismatches.\n", correct, wrong); kprintf("\rSummary: %x matches, %x mismatches.\n", correct, wrong);
kprintf("\nTrying to read from SD card...\n");
kputs("POWERON");
sd_poweron();
kprintf("sd_cmd0: %hx\n", sd_cmd0());
kprintf("sd_cmd8: %hx\n", sd_cmd8());
kprintf("sd_acmd41: %hx\n", sd_acmd41());
kprintf("sd_cmd58: %hx\n", sd_cmd58());
kprintf("sd_cmd16: %hx\n", sd_cmd16());
kprintf("\ncopy: %hx\n", copy());
while(1) { while(1) {
//uint8_t dip_value = GPIO_REG(GPIO_INPUT_VAL) & 0b01111111; //uint8_t dip_value = GPIO_REG(GPIO_INPUT_VAL) & 0b01111111;
//kprintf("dip value: %hx, ram value: %c\n", dip_value, ram[dip_value]); //kprintf("dip value: %hx, ram value: %c\n", dip_value, ram[dip_value]);