From b2fbccdc9ddd701095912425f8f6f3eaaa47166a Mon Sep 17 00:00:00 2001 From: zhaohe Date: Thu, 29 Aug 2024 21:56:13 +0800 Subject: [PATCH] =?UTF-8?q?fix=20zqueue=E5=9C=A8=E4=B8=AD=E6=96=AD?= =?UTF-8?q?=E4=B8=AD=E8=B0=83=E7=94=A8=E5=A4=B1=E8=B4=A5=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zqueue.hpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/zqueue.hpp b/zqueue.hpp index b6c676d..27a1b02 100644 --- a/zqueue.hpp +++ b/zqueue.hpp @@ -1,6 +1,6 @@ #pragma once -#include "cmsis_os.h" #include "basic/zlog.h" +#include "cmsis_os.h" namespace iflytop { template class ZQueue { @@ -30,8 +30,14 @@ class ZQueue { private: bool _send(uint8_t *data, int32_t len, int32_t overtime) { - BaseType_t xStatus = xQueueSend(xQueue, data, overtime); - return xStatus == pdPASS; + if (xPortIsInsideInterrupt()) { + BaseType_t xHigherPriorityTaskWoken = pdFALSE; + BaseType_t xStatus = xQueueSendToFrontFromISR(xQueue, data, &xHigherPriorityTaskWoken); + return xStatus == pdPASS; + } else { + BaseType_t xStatus = xQueueSend(xQueue, data, overtime); + return xStatus == pdPASS; + } } bool _receive(uint8_t *data, int32_t overtime) { BaseType_t xStatus = xQueueReceive(xQueue, data, overtime);