急!关于程序移植到STM32F103的问题

2019-07-14 19:54发布

最近在做,把一个EFM32的例程移植到STM32F1的板子上实现。有下面一段函数不太理解,想问一下这段函数的具体意思,并且我需要用STM32F1哪一部分的程序来代替这段代码
新手求教,望大家不吝赐教!
谢谢!
/***************************************************************************//**
* @brief
*   Perform one 8 bit frame SPI transfer.
*
* @note
*   This function will stall if the transmit buffer is full. When a transmit
*   buffer becomes available, data is written and the function will wait until
*   the data is fully transmitted. The SPI return value is then read out and
*   returned.
*
* @param[in] usart
*   Pointer to USART peripheral register block.
*
* @param[in] data
*   Data to transmit.
*
* @return
*   Data received.
******************************************************************************/
uint8_t USART_SpiTransfer(USART_TypeDef *usart, uint8_t data)
{
  while (!(usart->STATUS & USART_STATUS_TXBL))
    ;
  usart->TXDATA = (uint32_t)data;
  while (!(usart->STATUS & USART_STATUS_TXC))
    ;
  return (uint8_t)usart->RXDATA;
}


友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。