代码出错区域:
__INLINE int MSD1_spi_read_write(uint8_t data)
{
/* Loop while DR register in not emplty */
//while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_TXE) == RESET);
while(!(SPI2->SR & SPI_I2S_FLAG_TXE));
/* Send byte through the SPI2 peripheral */
//SPI_I2S_SendData(SPI2, data);
SPI2->DR = data;
/* Wait to receive a byte */
//while (SPI_I2S_GetFlagStatus(SPI2, SPI_I2S_FLAG_RXNE) == RESET);
while(!(SPI2->SR & SPI_I2S_FLAG_RXNE));
/* Return the byte read from the SPI2 bus */
//return SPI_I2S_ReceiveData(SPI2);
return SPI2->DR;
}
附件附有整个工程和原理图,程序陷入while(!(SPI2->SR & SPI_I2S_FLAG_RXNE));死循环了,好几天找不出问题出哪了,很急很急,麻烦大家了,谢谢! |