usart_interrupt_enable(USART2,USART_INT_IDLE); //空闲中断 //usart_interrupt_enable(USART...
usart_flag_clear(uartx->uart_x,USART_FLAG_IDLE); USART_STAT0(uartx->uart_x); USART_DATA(uartx->uart_x); usart_interrupt_enable(uartx->uart_x,USART_INT_RBNE); usart_interrupt_enable(uartx->uart_x,USART_INT_IDLE); return DRV_SUCCESS; } 10.4.3 main函数实现 以下为main函数代码:...
中断函数如代码清单 USART 中断函数所示,GD32 所有函数中断接收函数相同:先检测 USART_INT_FLAG_RBNE 置 1 时,执行数据接收,当数据接收到设定的位数后,关闭 USART 接收中断。 void USART0_IRQHandler(void) { if(RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_RBNE)){ /* receive data */ ...
中断函数如代码清单 USART 中断函数所示,GD32 所有函数中断接收函数相同:先检测 USART_INT_FLAG_RBNE 置 1 时,执行数据接收,当数据接收到设定的位数后,关闭 USART 接收中断。 void USART0_IRQHandler(void) { if(RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_RBNE)){ /* receive data */ ...
usart_flag_clear(uartx->uart_x,USART_FLAG_IDLE); USART_STAT0(uartx->uart_x); USART_DATA(uartx->uart_x); usart_interrupt_enable(uartx->uart_x,USART_INT_RBNE); usart_interrupt_enable(uartx->uart_x,USART_INT_IDLE);return DRV_SUCCESS; ...
int main(void){ delay_init();//初始化UART为中断模式,注册接受完成(IDLE)回调函数 BOARD_UART....
}elseif(USART_GetFlagStatus(USART1, USART_FLAG_IDLE) != RESET) { USART1->SR; USART1->DR; flag =1; } }intmain(){while(1) {if(flag ==1) {printf("count %d\r\n", count); flag =0; count =0; } delay_ms(10); }
USART_FLAG_IDLE USART_FLAG_ORE USART_FLAG_NE USART_FLAG_FE USART_FLAG_PE // 类似USART_GetFlagStatus,但是专门用来判断中断时间的状态 USART_GetITStatus(USART_TypeDef* USARTx, uint16_t USART_IT); ...
else if(USART_GetFlagStatus(USART1, USART_FLAG_IDLE) != RESET) { USART1->SR; USART1->DR; flag = 1; } } int main() { while(1) { if(flag == 1) { printf("count %d\r\n", count); flag = 0; count = 0; } delay_ms(10); ...
#define USART_FLAG_TC ((uint16_t)0x0040) #define USART_FLAG_RXNE ((uint16_t)0x0020) #define USART_FLAG_IDLE ((uint16_t)0x0010) #define USART_FLAG_ORE ((uint16_t)0x0008) #define USART_FLAG_NE ((uint16_t)0x0004) #define USART_FLAG_FE ((uint16_t)0x0002) ...