急!关于程序移植到STM32F103的问题
时间:10-02
整理:3721RD
点击:
最近在做,把一个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;
}
新手求教,望大家不吝赐教!
谢谢!
/***************************************************************************//**
* @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;
}
就是等待串口数据的发送和接受吧.
帮你顶贴,帮自己增长经验
串口的接收和发送 直接用32历程里的替换就可以
顶帖