unsigned short SPI_Send_2_BYTE(unsigned short i, unsigned char CS)
{
static unsigned int c = 0;
__IO static unsigned short Temp;
static HAL_StatusTypeDef HAL_Status;
/*!< Select the FLASH: Chip Select low */
HAL_GPIO_WritePin(GPIOD, CS, GPIO_PIN_RESET);
/*!< Send byte through the SPI1 peripheral */
HAL_Status = HAL_SPI_TransmitReceive(&hspi1, (unsigned char*)&i,(unsigned char*)&Temp, 1, 1000);
HAL_Status = HAL_Status;
Debug[(c++)%100] = Temp;
/*!< Deselect the FLASH: Chip Select high */
HAL_GPIO_WritePin(sFLASH_CS_GPIO_PORT, CS, GPIO_PIN_SET);
/*!< Return the byte read from the SPI bus */
return Temp;
}
这是spi部分。调用 HAL_Status = HAL_SPI_TransmitReceive(&hspi1, (unsigned char*)&i,(unsigned char*)&Temp, 1, 1000);
总是返回timeout,各位大大来帮忙看看。
|