while(1)
{
//Activate Slave
SPI_GPIO->BRR = SPI_PIN_SS;
// Go to active power mode
SPI_I2S_SendData(SPIx, 0x4B01);
while (!(SPIx->SR & (SPI_I2S_FLAG_TXE)));
// delay for applying setting stably
delay_ms(1);
// Go to normal mode
SPI_I2S_SendData(SPIx, 0x4C00);
while (!(SPIx->SR & (SPI_I2S_FLAG_TXE)));
delay_ms(1);
// read request
SPI_I2S_SendData(SPIx, 0xC000);
while (!(SPIx->SR & (SPI_I2S_FLAG_RXNE)));
while (SPIx->SR & (SPI_I2S_FLAG_BSY));
}
复制代码