最近在做,把一个EFM32的例程移植到
STM32F1的板子上实现。有下面一段函数不太理解,想问一下这段函数的具体意思,并且我需要用STM32F1哪一部分的程序来代替这段代码
新手求教,望大家不吝赐教!
谢谢!
/***************************************************************************//**
* @brief
* Perform one 8 bit frame SPI transfer.
*
* @note
* This func
tion 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;
}
一周热门 更多>