void periphery_init(void) { /*##################################################################################################### * SPI1-Configuration */ // Enable clock for SPI interface RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE); // Initialization of SPI-GPIOs GPIO_InitTypeDef GPIO_SPI; GPIO_SPI.GPIO_Pin = MISO | MOSI | SCK; GPIO_SPI.GPIO_Mode = GPIO_Mode_AF; GPIO_SPI.GPIO_OType = GPIO_OType_PP; GPIO_SPI.GPIO_Speed = GPIO_Speed_50MHz; GPIO_SPI.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOA, &GPIO_SPI); // Enable SPI interface for pins GPIO_PinAFConfig(GPIOA, GPIO_PinSource5, GPIO_AF_0); GPIO_PinAFConfig(GPIOA, GPIO_PinSource6, GPIO_AF_0); GPIO_PinAFConfig(GPIOA, GPIO_PinSource7, GPIO_AF_0); SPI_InitTypeDef SPI_InitStruct; SPI_InitStruct.SPI_Direction = SPI_Direction_1Line_Rx; SPI_InitStruct.SPI_Mode = SPI_Mode_Slave; SPI_InitStruct.SPI_DataSize = SPI_DataSize_16b; SPI_InitStruct.SPI_CPOL = SPI_CPOL_Low; SPI_InitStruct.SPI_CPHA = SPI_CPHA_1Edge; SPI_InitStruct.SPI_NSS = SPI_NSS_Soft | SPI_NSSInternalSoft_Set; SPI_InitStruct.SPI_FirstBit = SPI_FirstBit_MSB; SPI_InitStruct.SPI_CRCPolynomial = 7; SPI_Init(SPI1,&SPI_InitStruct); // Set FIFO threshold SPI_RxFIFOThresholdConfig(SPI1,SPI_RxFIFOThreshold_QF); // Enable SPI1 SPI_Cmd(SPI1, ENABLE); }