software/liblitesdcard/spisdcard: remove optimization on receive_block (not working on all configs) and increase max clk_freq to 20MHz.
This commit is contained in:
parent
100aa5a4ca
commit
4a18b828bc
|
@ -24,7 +24,7 @@
|
||||||
#define SPISDCARD_CLK_FREQ_INIT 400000
|
#define SPISDCARD_CLK_FREQ_INIT 400000
|
||||||
#endif
|
#endif
|
||||||
#ifndef SPISDCARD_CLK_FREQ
|
#ifndef SPISDCARD_CLK_FREQ
|
||||||
#define SPISDCARD_CLK_FREQ 12500000
|
#define SPISDCARD_CLK_FREQ 20000000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
|
|
||||||
static void spi_set_clk_freq(uint32_t clk_freq) {
|
static void spi_set_clk_freq(uint32_t clk_freq) {
|
||||||
uint32_t divider;
|
uint32_t divider;
|
||||||
divider = CONFIG_CLOCK_FREQUENCY/clk_freq;
|
divider = CONFIG_CLOCK_FREQUENCY/clk_freq + 1;
|
||||||
divider = max(divider, 2);
|
divider = max(divider, 2);
|
||||||
divider = min(divider, 256);
|
divider = min(divider, 256);
|
||||||
#ifdef SPISDCARD_DEBUG
|
#ifdef SPISDCARD_DEBUG
|
||||||
|
@ -135,7 +135,6 @@ static void busy_wait_us(unsigned int us)
|
||||||
|
|
||||||
static uint8_t spisdcardreceive_block(uint8_t *buf) {
|
static uint8_t spisdcardreceive_block(uint8_t *buf) {
|
||||||
uint16_t i;
|
uint16_t i;
|
||||||
uint8_t done;
|
|
||||||
uint32_t timeout;
|
uint32_t timeout;
|
||||||
|
|
||||||
/* Wait 100ms for a start of block */
|
/* Wait 100ms for a start of block */
|
||||||
|
@ -151,18 +150,10 @@ static uint8_t spisdcardreceive_block(uint8_t *buf) {
|
||||||
|
|
||||||
/* Receive block */
|
/* Receive block */
|
||||||
spisdcard_mosi_write(0xff);
|
spisdcard_mosi_write(0xff);
|
||||||
i = 0;
|
for (i=0; i<512; i++) {
|
||||||
for (;;) {
|
spisdcard_control_write(8*SPI_LENGTH | SPI_START);
|
||||||
done = spisdcard_status_read() & SPI_DONE;
|
while (spisdcard_status_read() != SPI_DONE);
|
||||||
if (done) {
|
*buf++ = spisdcard_miso_read();
|
||||||
spisdcard_control_write(8*SPI_LENGTH | SPI_START);
|
|
||||||
*buf = spisdcard_miso_read();
|
|
||||||
if (i == 512)
|
|
||||||
break;
|
|
||||||
if (i != 0)
|
|
||||||
buf++;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Discard CRC */
|
/* Discard CRC */
|
||||||
|
|
Loading…
Reference in New Issue