I am using the STM32 SPL library with an STM32F103C8 microcontroller. As part of the project, I am using the SPI1 peripheral to interface with an SD card.
Initially the SPI speed must be kept under 400 kHz for the SD card. My SPI1 initialization code is
SPI_InitTypeDef spi;
//ENABLE THE CLOCK TO SPI1 PERIPHERAL
RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
//SET SPI SPEED TO LOW SPEED MODE (~282KHZ)
spi.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_256;
spi.SPI_CPHA = SPI_CPHA_1Edge;
spi.SPI_CPOL = SPI_CPOL_Low;
spi.SPI_DataSize = SPI_DataSize_8b;
spi.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
spi.SPI_FirstBit = SPI_FirstBit_MSB;
spi.SPI_Mode = SPI_Mode_Master;
spi.SPI_NSS = SPI_NSS_Soft;
SPI_Init(SPI1, &spi);
SPI_Cmd(SPI1, ENABLE);
Of course, once the initial initialization of the SD card is complete, I would like to speed up the SPI1 peripheral.
I could not find any function in the SPL that would return a structure of the type SPI_InitTypeDef
containing the currently configured settings of an SPI peripheral.
Does that mean I have to create a new such structure (and repeat all the configuration values even if I only wish to change the speed and keep the rest the same as already configured) and then call SPI_Init()
with this new structure?