当前位置:网站首页>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 .
边栏推荐
- 2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
- Build op-tee development environment based on qemuv8
- zabbix 代理服务器 与 zabbix-snmp 监控
- Aardio - 通过变量名将变量值整合到一串文本中
- 【sdx62】WCN685X将bdwlan.bin和bdwlan.txt相互转化操作方法
- 雅思口语的具体步骤和时间安排是什么样的?
- const关键字
- 新手程序员该不该背代码?
- 图像的spatial domain 和 frequency domain 图像压缩
- GPS from getting started to giving up (12), Doppler constant speed
猜你喜欢
Aardio - 通过变量名将变量值整合到一串文本中
HDR image reconstruction from a single exposure using deep CNNs阅读札记
Oracle control file and log file management
Learn the principle of database kernel from Oracle log parsing
重磅新闻 | Softing FG-200获得中国3C防爆认证 为客户现场测试提供安全保障
ZABBIX proxy server and ZABBIX SNMP monitoring
MySQL数据库基本操作-DML
硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件
Unity3d minigame-unity-webgl-transform插件转换微信小游戏报错To use dlopen, you need to use Emscripten‘s...问题
Web APIs DOM 时间对象
随机推荐
AI enterprise multi cloud storage architecture practice | Shenzhen potential technology sharing
Data storage (1)
[sciter bug] multi line hiding
PVL EDI project case
Leetcode question brushing (XI) -- sequential questions brushing 51 to 55
2020 Bioinformatics | GraphDTA: predicting drug target binding affinity with graph neural networks
[leetcode daily clock in] 1020 Number of enclaves
如何用程序确认当前系统的存储模式?
i. Mx6ull build boa server details and some of the problems encountered
Support multiple API versions in flask
MySQL约束的分类、作用及用法
How does the uni admin basic framework close the creation of super administrator entries?
zabbix 代理服务器 与 zabbix-snmp 监控
Assembly and interface technology experiment 5-8259 interrupt experiment
return 关键字
[线性代数] 1.3 n阶行列式
Powerful domestic API management tool
Seata aggregates at, TCC, Saga and XA transaction modes to create a one-stop distributed transaction solution
sizeof关键字
自制J-Flash烧录工具——Qt调用jlinkARM.dll方式