当前位置:网站首页>Gd32f4xx serial port receive interrupt and idle interrupt configuration
Gd32f4xx serial port receive interrupt and idle interrupt configuration
2022-07-06 22:26:00 【fangye945a】
Recently debugging GD32F4xx, Want to use the idle interrupt of serial port , Discovery and STM32 Some differences . Make a record here , Memo , Prevent repeated stepping on the pit .
Serial port enable interrupt related code :
nvic_irq_enable(USART0_IRQn,0,1);
usart_interrupt_enable(USART0, USART_INT_RBNE); /* Can make USART0 Read area non empty interrupt */
usart_interrupt_enable(USART0, USART_INT_IDLE); /* Can make USART0 Idle interrupt */
Serial interrupt processing function :
void USART0_IRQHandler(void)
{
if ((RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_RBNE)) &&
(RESET != usart_flag_get(USART0, USART_FLAG_RBNE))) {
unsigned char value = usart_data_receive(USART0);
RingBufWrite(g_debugRingBuf, value); // Write the received data to ringbuf in
usart_interrupt_flag_clear(USART0, USART_INT_FLAG_RBNE); // Clear the interrupt flag
}
else if (RESET != usart_interrupt_flag_get(USART0, USART_INT_FLAG_IDLE)) {
usart_interrupt_flag_clear(USART0, USART_INT_FLAG_IDLE);
usart_data_receive(USART0); /* Clear the receive completion flag bit */
(void)LOS_EventWrite(&g_shellInputEvent, 0x1); // Event notification reception completed
}
}
Special attention is paid to : And STM32F4 The difference is , After entering idle interrupt , Need to call usart_data_receive function , Used to clear the receive completion flag bit , Otherwise, the idle interrupt will be triggered many times or not .
stay STM32f4xx in , Clear idle interrupt flag macro is defined as follows :
/** @brief Clears the UART IDLE pending flag. * @param __HANDLE__ specifies the UART Handle. * UART Handle selects the USARTx or UARTy peripheral * (USART,UART availability and x,y values depending on device). * @retval None */
#define __HAL_UART_CLEAR_IDLEFLAG(__HANDLE__) __HAL_UART_CLEAR_PEFLAG(__HANDLE__)
/** @brief Clears the UART PE pending flag. * @param __HANDLE__ specifies the UART Handle. * UART Handle selects the USARTx or UARTy peripheral * (USART,UART availability and x,y values depending on device). * @retval None */
#define __HAL_UART_CLEAR_PEFLAG(__HANDLE__) \ do{
\ __IO uint32_t tmpreg = 0x00U; \ tmpreg = (__HANDLE__)->Instance->SR; \ tmpreg = (__HANDLE__)->Instance->DR; \ UNUSED(tmpreg); \ } while(0U)
You can see that there are read operation pairs DR Register to read , amount to GD32 Standard library usart_data_receive Function function .
边栏推荐
猜你喜欢

LeetCode刷题(十一)——顺序刷题51至55

每日一题:力扣:225:用队列实现栈

RESNET rs: Google takes the lead in tuning RESNET, and its performance comprehensively surpasses efficientnet series | 2021 arXiv

Memorabilia of domestic database in June 2022 - ink Sky Wheel

基于 QEMUv8 搭建 OP-TEE 开发环境
![[10:00 public class]: basis and practice of video quality evaluation](/img/d8/a367c26b51d9dbaf53bf4fe2a13917.png)
[10:00 public class]: basis and practice of video quality evaluation

Aardio - 封装库时批量处理属性与回调函数的方法

Management background --3, modify classification

Spatial domain and frequency domain image compression of images

Crawler obtains real estate data
随机推荐
qt quick项目offscreen模式下崩溃的问题处理
sizeof关键字
Aardio - 不声明直接传float数值的方法
return 关键字
Embedded common computing artifact excel, welcome to recommend skills to keep the document constantly updated and provide convenience for others
The nearest common ancestor of binary (search) tree ●●
将MySQL的表数据纯净方式导出
Hardware development notes (10): basic process of hardware development, making a USB to RS232 module (9): create ch340g/max232 package library sop-16 and associate principle primitive devices
Force buckle 575 Divide candy
Report on technological progress and development prospects of solid oxide fuel cells in China (2022 Edition)
解决项目跨域问题
C#實現水晶報錶綁定數據並實現打印4-條形碼
在IPv6中 链路本地地址的优势
Management background --3, modify classification
新手程序员该不该背代码?
Force deduction question 500, keyboard line, JS implementation
Unity3d Learning Notes 6 - GPU instantiation (1)
Heavyweight news | softing fg-200 has obtained China 3C explosion-proof certification to provide safety assurance for customers' on-site testing
MySQL数据库基本操作-DML
十二、启动流程