From e27ed657e9fff1bc2f3e398d7389194b3678cc62 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Tue, 9 Jun 2020 13:50:16 +0200 Subject: [PATCH] software/liblitesdcard/spisdcard: rename #defines and allow external definition. --- litex/soc/software/liblitesdcard/spisdcard.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/litex/soc/software/liblitesdcard/spisdcard.c b/litex/soc/software/liblitesdcard/spisdcard.c index 9b66f702..993380a9 100644 --- a/litex/soc/software/liblitesdcard/spisdcard.c +++ b/litex/soc/software/liblitesdcard/spisdcard.c @@ -18,15 +18,19 @@ #ifdef CSR_SPISDCARD_BASE -#define SDCARD_DEBUG +#define SPISDCARD_DEBUG + +#ifndef SPISDCARD_CLK_FREQ_INIT +#define SPISDCARD_CLK_FREQ_INIT 400000 +#endif +#ifndef SPISDCARD_CLK_FREQ +#define SPISDCARD_CLK_FREQ 10000000 +#endif /*-----------------------------------------------------------------------*/ /* SPI Master low-level functions */ /*-----------------------------------------------------------------------*/ -#define SPI_CLK_FREQ_INIT 400000 -#define SPI_CLK_FREQ_OPERATIONAL 10000000 - static void spi_set_clk_freq(uint32_t clk_freq) { uint32_t divider; divider = CONFIG_CLOCK_FREQUENCY/clk_freq + 1; @@ -34,7 +38,7 @@ static void spi_set_clk_freq(uint32_t clk_freq) { divider = 65535; if (divider <= 2) /* At least half CPU speed */ divider = 2; -#ifdef SDCARD_DEBUG +#ifdef SPISDCARD_DEBUG printf("Setting SDCard clk freq to "); if (clk_freq > 1000000) printf("%d MHz\n", (CONFIG_CLOCK_FREQUENCY/divider)/1000000); @@ -197,7 +201,7 @@ uint8_t spisdcard_init(void) { uint16_t timeout; /* Set SPI clk freq to initialization frequency */ - spi_set_clk_freq(SPI_CLK_FREQ_INIT); + spi_set_clk_freq(SPISDCARD_CLK_FREQ_INIT); /* Wait 10ms */ busy_wait(10); @@ -227,7 +231,7 @@ uint8_t spisdcard_init(void) { return 0; /* Set SPI clk freq to operational frequency */ - spi_set_clk_freq(SPI_CLK_FREQ_OPERATIONAL); + spi_set_clk_freq(SPISDCARD_CLK_FREQ); return 1; } -- 2.30.2