SPIConfig for FLASH looks like so, as copied from various available references, most notably testhal/STM32F1xx/SPI:
Code: Select all
/*
* SPI configuration (maybe 18MHz for flash, CPHA=0, CPOL=0, MSb first).
*/
static const SPIConfig spicfg = {
NULL,
GPIOC,
GPIOC_SPI1_FLASH_CSn,
SPI_CR1_BR_2 | SPI_CR1_BR_1 | SPI_CR1_BR_0 // SPI_CR1_DFF // 8 bit data frame
};BR means BaudRate. Setting more BR bits slows the SPI clock down, as per the testhal multithreaded example.
It appears that SPIConfig can configure the CR1 register of the SPI (see stm32f10x.h or similar platform header file for your device).
So if I had an SPI_InitStructure like so:
Code: Select all
/* SPI1 configuration */
SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;
SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;
SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
SPI_InitStructure.SPI_CRCPolynomial = 7;
SPI_Init(SPI1, &SPI_InitStructure);
/* Enable SPI1 */
SPI_Cmd(SPI1, ENABLE);That would indicate the need to set more CR1 registers, such as CPOL and CPHA, which is not obvious due to STM's naming convention. See the Wikipedia page on CPOL and such to help keep things straight.
From the stm32f1xx.h header file, I grabbed the CPOL and CPHA defines for CR1 and added it to my SPIConfig, which has resolved high speed issues with the EEPROM, as the ADC just doesn't run that fast:
Code: Select all
/*
* SPI configuration (maybe 18MHz for flash, CPHA=0, CPOL=0, MSb first).
*/
static const SPIConfig spicfg = {
NULL,
GPIOC,
GPIOC_SPI1_FLASH_CSn,
SPI_CR1_CPHA | SPI_CR1_CPOL
};FLASH is still not yet up, but I am sure it is a silly mistake that I will find after some proper rest. I hope this can help other users of ChibiOS.
Cheers!