liblitesdcard/sdcard_read: enable multiple block read.

>10MB/s read speed with a 25MHz clock.
This commit is contained in:
Florent Kermarrec 2020-06-25 13:46:39 +02:00
parent 8c572d2b3e
commit c07703124f
1 changed files with 12 additions and 15 deletions

View File

@ -484,25 +484,22 @@ int sdcard_init(void) {
void sdcard_read(uint32_t sector, uint32_t count, uint8_t* buf) void sdcard_read(uint32_t sector, uint32_t count, uint8_t* buf)
{ {
uint32_t i;
for (i=0; i<count; i++) {
/* Initialize DMA Writer */ /* Initialize DMA Writer */
sdreader_enable_write(0); sdreader_enable_write(0);
sdreader_base_write((uint32_t) buf); sdreader_base_write((uint32_t) buf);
sdreader_length_write(512); sdreader_length_write(512*count);
sdreader_enable_write(1); sdreader_enable_write(1);
/* Read Single Block from SDCard */ /* Read Block(s) from SDCard */
sdcard_set_block_count(1); sdcard_set_block_count(count);
if (count > 0)
sdcard_read_multiple_block(sector, count);
else
sdcard_read_single_block(sector); sdcard_read_single_block(sector);
/* Wait for DMA Writer to complete */ /* Wait for DMA Writer to complete */
while ((sdreader_done_read() & 0x1) == 0); while ((sdreader_done_read() & 0x1) == 0);
/* Update buf/sector */
buf += 512;
sector += 1;
}
flush_cpu_dcache(); /* FIXME */ flush_cpu_dcache(); /* FIXME */
} }