这段代码执行的是SPI收发功能,使用仿真器debug时会停在spi_i2s_data_receive处(等待接收标志位),但是如果把datasize改成8bit就能正常收发数据,请问是什么原因呢?
uint32_t Spi_Transfer16(SPI_BusDef *spi, uint16_t *TxBuf, uint16_t *RxBuf,uint16_t len)
{
uint32_t ret= 0;
Spi_Nss(spi->Nss, 0);
spi_master_transfer_start(spi->Periph, SPI_TRANS_START);
for(int i = 0; i<len; i++)
{
while (RESET == (SPI_STAT(spi->Periph) & SPI_FLAG_TP));
spi_i2s_data_transmit(spi->Periph, TxBuf[i]);
RxBuf[i] = spi_i2s_data_receive(spi->Periph);
}
while (RESET == spi_i2s_flag_get(spi->Periph, SPI_FLAG_TC));
Spi_Nss(spi->Nss, 1);
return ret;
}
|