static void WR_CMD (unsigned char cmd)
{
/* Wait for SPI1 Tx buffer empty */
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_TXE) == RESET);
//int i;
//while(SPI1->SR & 0x0002 == 0);
//for(i = 0;i<5;i++);
/* Send SPI1 data */
SPI_I2S_SendData(SPI1,cmd);
/* Wait for SPI1 data reception */
while (SPI_I2S_GetFlagStatus(SPI1, SPI_I2S_FLAG_RXNE) == RESET);
//while(SPI1->SR & 0x0001 == 0);
//for(i = 0;i<5;i++);
/* Read SPI1 received data */
SPI_I2S_ReceiveData(SPI1);
}为什么不用库函数直接用寄存器等待就运行不了? |