现有两块STM32的板子,一个SPI主机,一个SPI从机,
主机发送程序
HAL_Delay(1000);
ucSpi_Tmessage_initial[7]=ucDevice_eChecksum(ucSpi_Tmessage_initial,7);
HAL_SPI_TransmitReceive_IT(&hspi1,ucSpi_Tmessage_initial,ucSpi_Rmessage,1);
while(hspi1.State!= HAL_SPI_STATE_READY);
HAL_SPI_TransmitReceive_IT(&hspi1,&ucSpi_Tmessage_initial[1],&ucSpi_Rmessage[1],1);
while(hspi1.State!= HAL_SPI_STATE_READY);
HAL_SPI_TransmitReceive_IT(&hspi1,&ucSpi_Tmessage_initial[2],&ucSpi_Rmessage[2],1);//ucSpi_Rmessage
while(hspi1.State!= HAL_SPI_STATE_READY);
HAL_SPI_TransmitReceive_IT(&hspi1,&ucSpi_Tmessage_initial[3],&ucSpi_Rmessage[3],1);
while(hspi1.State!= HAL_SPI_STATE_READY);
HAL_SPI_TransmitReceive_IT(&hspi1,&ucSpi_Tmessage_initial[4],&ucSpi_Rmessage[4],1);
while(hspi1.State!= HAL_SPI_STATE_READY);
HAL_SPI_TransmitReceive_IT(&hspi1,&ucSpi_Tmessage_initial[5],&ucSpi_Rmessage[5],1);
while(hspi1.State!= HAL_SPI_STATE_READY);
HAL_SPI_TransmitReceive_IT(&hspi1,&ucSpi_Tmessage_initial[6],&ucSpi_Rmessage[6],1);
while(hspi1.State!= HAL_SPI_STATE_READY);
HAL_SPI_TransmitReceive_IT(&hspi1,&ucSpi_Tmessage_initial[7],&ucSpi_Rmessage[7],1);
while(hspi1.State!= HAL_SPI_STATE_READY);
从机一直送8个字节
简单说就是主机发送0K,主机接收OK,从机接收OK,就是从机发送不OK |