mirror of
https://github.com/sakumisu/CherryUSB.git
synced 2025-05-08 07:59:31 +08:00
update(osal/freertos): update usb_osal_mq_recv and usb_osal_mq_send for isr api
This commit is contained in:
parent
037c2a8323
commit
6ea1e2f94f
@ -101,9 +101,13 @@ int usb_osal_mq_send(usb_osal_mq_t mq, uintptr_t addr)
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
int ret;
|
||||
|
||||
ret = xQueueSendFromISR((usb_osal_mq_t)mq, &addr, &xHigherPriorityTaskWoken);
|
||||
if (ret == pdPASS) {
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
if (xPortInIsrContext()) {
|
||||
ret = xQueueSendFromISR((usb_osal_mq_t)mq, &addr, &xHigherPriorityTaskWoken);
|
||||
if (ret == pdPASS) {
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
}
|
||||
} else {
|
||||
ret = xQueueSend((usb_osal_mq_t)mq, &addr, 0xffffffff);
|
||||
}
|
||||
|
||||
return (ret == pdPASS) ? 0 : -USB_ERR_TIMEOUT;
|
||||
@ -111,10 +115,21 @@ int usb_osal_mq_send(usb_osal_mq_t mq, uintptr_t addr)
|
||||
|
||||
int usb_osal_mq_recv(usb_osal_mq_t mq, uintptr_t *addr, uint32_t timeout)
|
||||
{
|
||||
if (timeout == USB_OSAL_WAITING_FOREVER) {
|
||||
return (xQueueReceive((usb_osal_mq_t)mq, addr, portMAX_DELAY) == pdPASS) ? 0 : -USB_ERR_TIMEOUT;
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
int ret;
|
||||
|
||||
if (xPortInIsrContext()) {
|
||||
ret = xQueueReceiveFromISR((usb_osal_mq_t)mq, addr, &xHigherPriorityTaskWoken);
|
||||
if (ret == pdPASS) {
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
}
|
||||
return (ret == pdPASS) ? 0 : -USB_ERR_TIMEOUT;
|
||||
} else {
|
||||
return (xQueueReceive((usb_osal_mq_t)mq, addr, pdMS_TO_TICKS(timeout)) == pdPASS) ? 0 : -USB_ERR_TIMEOUT;
|
||||
if (timeout == USB_OSAL_WAITING_FOREVER) {
|
||||
return (xQueueReceive((usb_osal_mq_t)mq, addr, portMAX_DELAY) == pdPASS) ? 0 : -USB_ERR_TIMEOUT;
|
||||
} else {
|
||||
return (xQueueReceive((usb_osal_mq_t)mq, addr, pdMS_TO_TICKS(timeout)) == pdPASS) ? 0 : -USB_ERR_TIMEOUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,9 +118,13 @@ int usb_osal_mq_send(usb_osal_mq_t mq, uintptr_t addr)
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
int ret;
|
||||
|
||||
ret = xQueueSendFromISR((usb_osal_mq_t)mq, &addr, &xHigherPriorityTaskWoken);
|
||||
if (ret == pdPASS) {
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
if (xPortIsInsideInterrupt()) {
|
||||
ret = xQueueSendFromISR((usb_osal_mq_t)mq, &addr, &xHigherPriorityTaskWoken);
|
||||
if (ret == pdPASS) {
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
}
|
||||
} else {
|
||||
ret = xQueueSend((usb_osal_mq_t)mq, &addr, 0xffffffff);
|
||||
}
|
||||
|
||||
return (ret == pdPASS) ? 0 : -USB_ERR_TIMEOUT;
|
||||
@ -128,10 +132,21 @@ int usb_osal_mq_send(usb_osal_mq_t mq, uintptr_t addr)
|
||||
|
||||
int usb_osal_mq_recv(usb_osal_mq_t mq, uintptr_t *addr, uint32_t timeout)
|
||||
{
|
||||
if (timeout == USB_OSAL_WAITING_FOREVER) {
|
||||
return (xQueueReceive((usb_osal_mq_t)mq, addr, portMAX_DELAY) == pdPASS) ? 0 : -USB_ERR_TIMEOUT;
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
int ret;
|
||||
|
||||
if (xPortIsInsideInterrupt()) {
|
||||
ret = xQueueReceiveFromISR((usb_osal_mq_t)mq, addr, &xHigherPriorityTaskWoken);
|
||||
if (ret == pdPASS) {
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
}
|
||||
return (ret == pdPASS) ? 0 : -USB_ERR_TIMEOUT;
|
||||
} else {
|
||||
return (xQueueReceive((usb_osal_mq_t)mq, addr, pdMS_TO_TICKS(timeout)) == pdPASS) ? 0 : -USB_ERR_TIMEOUT;
|
||||
if (timeout == USB_OSAL_WAITING_FOREVER) {
|
||||
return (xQueueReceive((usb_osal_mq_t)mq, addr, portMAX_DELAY) == pdPASS) ? 0 : -USB_ERR_TIMEOUT;
|
||||
} else {
|
||||
return (xQueueReceive((usb_osal_mq_t)mq, addr, pdMS_TO_TICKS(timeout)) == pdPASS) ? 0 : -USB_ERR_TIMEOUT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user