Move SDCard SPI clock dividers into target.h (they depend on the bus Hz)

This commit is contained in:
Nicholas Sherlock 2015-11-16 23:46:05 +13:00 committed by borisbstyle
parent 96182c7c07
commit 04d8dd27bf
2 changed files with 6 additions and 2 deletions

View File

@ -1181,7 +1181,7 @@ static bool sdcard_completeInit()
DESELECT_SDCARD;
}
spiSetDivisor(SDCARD_SPI_INSTANCE, 4);
spiSetDivisor(SDCARD_SPI_INSTANCE, SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER);
sdcard.state = SDCARD_STATE_READY;
@ -1211,7 +1211,7 @@ static bool sdcard_checkInitDone() {
bool sdcard_init()
{
// Max frequency is initially 400kHz
spiSetDivisor(SDCARD_SPI_INSTANCE, 128);
spiSetDivisor(SDCARD_SPI_INSTANCE, SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER);
// SDCard wants 1ms minimum delay after power is applied to it
delay(1000);

View File

@ -100,6 +100,10 @@
#define SDCARD_SPI_CS_GPIO GPIOB
#define SDCARD_SPI_CS_PIN GPIO_Pin_12
#define SDCARD_SPI_CS_GPIO_CLK_PERIPHERAL RCC_APB2Periph_GPIOB
// SPI2 is on the APB1 bus whose clock runs at 36MHz. Divide to under 400kHz for init:
#define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 128
// Divide to under 25MHz for normal operation:
#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 2
#define ACC
#define USE_ACC_LSM303DLHC