void USART3_IRQHandler(void)
{
u8 res;
if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET)//接收到数据
{
res =USART_ReceiveData(USART3);
if((USART3_RX_STA&(1<<15))==0)//接收完的一批数据,还没有处理,则不再接收其它数据
{
if(USART3_RX_STA<USART3_MAX_RECV_LEN) //还可以接收数据
{
TIM_SetCounter(TIM7,0);//计数器清空
if(USART3_RX_STA==0)
TIM_Cmd(TIM7, ENABLE); //使能定时器7
USART3_RX_BUF[USART3_RX_STA++]=res; //记录接收到的值
}else
{
USART3_RX_STA|=1<<15; //强制标志接收完成
}
}
}
}
大佬们,这一句USART3_RX_BUF[USART3_RX_STA++]=res; 怎么用HAL库函数改写??
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
{
if(huart->Instance==USART1)
{
if(r_state&0x8000)
{
if((r_buf[0]==0x0a)&&(r_state&0x7fff))
{
s_buf[r_state&0x7fff]=0x0d;
s_buf[(r_state&0x7fff)+1]=0x0a;
HAL_UART_Transmit(&huart1,s_buf,(r_state&0x7fff)+2,1000);
while(__HAL_UART_GET_FLAG(&huart1,UART_FLAG_TC)!=SET);
}
r_state=0;
}
else
{
if(r_buf[0]==0x0d) r_state|=0x8000;
else
{
s_buf[r_state&0x7fff]=r_buf[0];
r_state++;
if((r_state&0x7fff)>MAX_N-2) r_state=0;
}
}
while (HAL_UART_GetState(&huart1) != HAL_UART_STATE_READY);
while(HAL_UART_Receive_IT(&huart1, (uint8_t *)r_buf, 1) != HAL_OK);
//HAL_UART_Receive_IT(&huart1, (uint8_t *)r_buf, 8);
}
}
没办法啊,小白一只。标准库都没学好,就做HAL的项目了
一周热门 更多>