Dear all
1.Because the SPI-DR register in STMWL series MCU is 16 bits instead of 8 bits, which conflicts with the officially provided readfromspi function based on HAL bottom layer, so consider modifying readfromspi function.
Modify readfromspi function based on HAL library:
while(readlength-- > 0)
{
/* Wait until TXE flag is set to send data */
while(__HAL_SPI_GET_FLAG(&hspi1, SPI_FLAG_TXE) == RESET)
{
}
hspi1.Instance->DR = 0; /* set output to 0 (MOSI), this is necessary for
e.g. when waking up DW1000 from DEEPSLEEP via dwt_spicswakeup() function.
*/
/* Wait until RXNE flag is set to read data */
while(__HAL_SPI_GET_FLAG(&hspi1, SPI_FLAG_RXNE) == RESET)
{
}
(*readBuffer++) = hspi1.Instance->DR; //copy data read form (MISO)
}
revised as
while(readlength-- > 0)
{
HAL_SPI_Receive(&hspi1,readBuffer++,1,1000);
}
2.Is there a problem with this modification?
After this modification, the interval time of SPI-CLK will be increased by more than ten microseconds, which will affect the subsequent TWR ranging