Skip to content

Commit

Permalink
software/libbase/spisdcard: add USE_SPISDCARD_RECLOCKING define to ea…
Browse files Browse the repository at this point in the history
…sily disable reclocking.
  • Loading branch information
enjoy-digital committed Mar 26, 2020
1 parent b509df8 commit 73b4347
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions litex/soc/software/libbase/spisdcard.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include <time.h>
#include <string.h>

#define USE_SPISCARD_RECLOCKING

#ifdef CSR_SPISDCARD_BASE
// Import prototypes for the functions
#include <spisdcard.h>
Expand Down Expand Up @@ -138,7 +140,7 @@ uint8_t spi_setspimode(void)
{
uint32_t r;
int i, timeout=32;

// Initialise SPI mode
// set CS to HIGH
// Send pulses
Expand Down Expand Up @@ -444,6 +446,7 @@ uint8_t spi_sdcard_readMBR(void)
return FAILURE;
}

#ifdef USE_SPISCARD_RECLOCKING
// Reclock the card
// Calculate 16MHz as an integer divider from the CONFIG_CLOCK_FREQUENCY
// Add 1 as will be rounded down
Expand All @@ -454,7 +457,7 @@ uint8_t spi_sdcard_readMBR(void)
divider=2;
printf("Reclocking from %dKHz to %dKHz\n\n", CONFIG_CLOCK_FREQUENCY/(int)spisdcard_clk_divider_read()/1000, CONFIG_CLOCK_FREQUENCY/divider/1000);
spisdcard_clk_divider_write(divider);

// Read in FAT16 File Allocation Table, array of 16bit unsinged integers
// Calculate Storage from TOP of MAIN RAM
sdCardFatTable = (uint16_t *)(MAIN_RAM_BASE+MAIN_RAM_SIZE-sdCardFatBootSector.sector_size*sdCardFatBootSector.fat_size_sectors);
Expand All @@ -468,6 +471,7 @@ uint8_t spi_sdcard_readMBR(void)
return FAILURE;
}
}
#endif

// Read in FAT16 Root Directory
// Calculate Storage from TOP of MAIN RAM
Expand Down

0 comments on commit 73b4347

Please sign in to comment.