在线时间221 小时
UID1422616
ST金币0
蝴蝶豆0
注册时间2015-1-22
金牌会员
- 最后登录
- 2018-9-27
|
发表于 2015-7-14 09:04:43
|
显示全部楼层
a0a.1 32b0c
void HW_USART_SendOneChar(USART_TypeDef* usartnum, uint8_t data)
{
USART_SendData(usartnum, data);
/* wait until transmission is complete */
while (!(USART_GetFlagStatus(usartnum, USART_FLAG_TC))) {
;
}
}
void HW_USART_SendChars(USART_TypeDef* usartnum, uint16_t len, void *buff)
{
uint16_t i;
uint8_t *ptr = (uint8_t *)buff;
for (i = 0; i < len; i++) {
HW_USART_SendOneChar(usartnum, ptr[i]);
}
}
void HW_USART_SendString(USART_TypeDef* usartnum, void *buff)
{
uint8_t *ptr = (uint8_t *)buff;
while (*ptr != '\0') {
HW_USART_SendOneChar(usartnum, *ptr++);
}
}
uint16_t HW_USART_ReceOneChar(USART_TypeDef* usartnum)
{
/* Wait until data to be received */
while (!(USART_GetFlagStatus(usartnum, USART_FLAG_RXNE))) {
;
}
return USART_ReceiveData(usartnum);
}
以上这几种发送在HAL库里都有对应的函数,可以试下,使用中断方式,应该没问题的 |
|