最近需要用到 9位數(shù)據(jù)的發(fā)送格式? ?1個(gè)起始位 + 9數(shù)據(jù)位 +1停止位;共11位? 我看庫(kù)文件的格式都是按照9位處理的;
那8位 9位的使用區(qū)別在哪?
/*********************************************************************
?* @fn? ? ? USART_SendData
?*
?* @brief? ?Transmits single data through the USARTx peripheral.
?*
?* @param? ?USARTx - where x can be 1, 2, 3 to select the USART peripheral.
?*? ? ? ? ? Data - the data to transmit.
?*
?* @return? none
?*/
void USART_SendData(USART_TypeDef *USARTx, uint16_t Data)
{
? ? USARTx->DATAR = (Data & (uint16_t)0x01FF);
}
/*********************************************************************
?* @fn? ? ? USART_ReceiveData
?*
?* @brief? ?Returns the most recent received data by the USARTx peripheral.
?*
?* @param? ?USARTx - where x can be 1, 2, 3 to select the USART peripheral.
?*
?* @return? The received data.
?*/
uint16_t USART_ReceiveData(USART_TypeDef *USARTx)
{
? ? return (uint16_t)(USARTx->DATAR & (uint16_t)0x01FF);
}