uint16_t USART_ReceiveData(USART_TypeDef* USARTx)
{
/* Check the parameters */
assert_param(IS_USART_ALL_PERIPH(USARTx));
/* Receive Data */
return (uint16_t)(USARTx->DR & (uint16_t)0x01FF);
}
串口接受的数据类型要看它函数的返回值类型;
/* exact-width unsigned integer types */
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned __INT64 uint64_t;
************************************************
uint16_t被定义成短整型,短整型对于16位以上的机器来说是16位的(长整型是32位,4个字节),固然能接收数据表示成0x00_ _;为什么用后两位呢,不用前两位呢,因为数据传输是8位,固然只用到了后两位。
原子例程中定义 u8 Res;去接收串口数据,这个很迷惑为什么可以,为什么可以用无符号字符型的变量接收短整型的返回值呢;