金牌会员
- 积分
- 1108
- 金钱
- 1108
- 注册时间
- 2018-11-6
- 在线时间
- 240 小时
|
发表于 2020-5-20 15:58:23
|
显示全部楼层
本帖最后由 霸王猫 于 2020-5-20 16:01 编辑
- </div>void USART1_IRQHandler(void)
- {
- uint16_t ch;
- BaseType_t xHigherPriorityTaskWoken = pdFALSE;
-
-
- if (USART_GetITStatus(USART1,USART_IT_IDLE) != RESET)
- {
- USART_ClearITPendingBit(USART1 , USART_IT_IDLE); //必须先清除总线空闲中断标识,然后读一下数据寄存器,DMA接收才会正确(先读SR,然后读DR才能清除空闲中断标识)注意:这句必须要,否则不能够清除中断标志位。
- ch = USART_ReceiveData(USART1);
- DMA_Cmd(DMA1_Channel5 , DISABLE); //关闭DMA,防止处理其间有数据
- DMA_ClearFlag(DMA1_FLAG_GL5 | DMA1_FLAG_TC5 | DMA1_FLAG_HT5 | DMA1_FLAG_TE5);
- ch = USART1_DMA_RX_BUFFER_MAX_LENGTH - DMA_GetCurrDataCounter(DMA1_Channel5);
- if (ch > 0)
- {
-
- MB_USART1.receCount = ch;
- memcpy(MB_USART1.mscomm_buffer , USART1_DMA_RX_Buffer , MB_USART1.receCount);
- }
- DMA_SetCurrDataCounter(DMA1_Channel5 , USART1_DMA_RX_BUFFER_MAX_LENGTH);
- DMA_Cmd(DMA1_Channel5, ENABLE);
-
- xSemaphoreGiveFromISR(xSemaphore, &xHigherPriorityTaskWoken);//发送信号量
- portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
-
- }
-
- }
复制代码 |
|