summaryrefslogtreecommitdiff
path: root/osal/usb_osal_freertos.c
diff options
context:
space:
mode:
authorsakimisu <[email protected]>2022-12-11 18:50:33 +0800
committersakimisu <[email protected]>2022-12-11 20:27:18 +0800
commit843af28b2bfe4e669aa9f9dc51bdf8bc4f661da7 (patch)
treeac9fd901ca9eb5e76ce94f2920305b86e67dbf8c /osal/usb_osal_freertos.c
parent9a67853751c3ff42e1ef4b59cdfa6c7596ce82d5 (diff)
update hub thread wakeup with queue not sem&list
Diffstat (limited to 'osal/usb_osal_freertos.c')
-rw-r--r--osal/usb_osal_freertos.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/osal/usb_osal_freertos.c b/osal/usb_osal_freertos.c
index 009a61b3..65d9f1c3 100644
--- a/osal/usb_osal_freertos.c
+++ b/osal/usb_osal_freertos.c
@@ -43,7 +43,7 @@ int usb_osal_sem_give(usb_osal_sem_t sem)
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
}
- return (ret == pdPASS) ? 0 : -EINVAL;
+ return (ret == pdPASS) ? 0 : -ETIMEDOUT;
}
usb_osal_mutex_t usb_osal_mutex_create(void)
@@ -63,7 +63,30 @@ int usb_osal_mutex_take(usb_osal_mutex_t mutex)
int usb_osal_mutex_give(usb_osal_mutex_t mutex)
{
- return (xSemaphoreGive((SemaphoreHandle_t)mutex) == pdPASS) ? 0 : -EINVAL;
+ return (xSemaphoreGive((SemaphoreHandle_t)mutex) == pdPASS) ? 0 : -ETIMEDOUT;
+}
+
+usb_osal_mq_t usb_osal_mq_create(uint32_t max_msgs)
+{
+ return (usb_osal_mq_t)xQueueCreate(max_msgs, 4);
+}
+
+int usb_osal_mq_send(usb_osal_mq_t mq, uint32_t addr)
+{
+ BaseType_t xHigherPriorityTaskWoken = pdFALSE;
+ int ret;
+
+ ret = xQueueSendFromISR((usb_osal_mq_t)mq, &addr, &xHigherPriorityTaskWoken);
+ if (ret == pdPASS) {
+ portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
+ }
+
+ return (ret == pdPASS) ? 0 : -ETIMEDOUT;
+}
+
+int usb_osal_mq_recv(usb_osal_mq_t mq, uint32_t *addr, uint32_t timeout)
+{
+ return (xQueueReceive((usb_osal_mq_t)mq, addr, timeout) == pdPASS) ? 0 : -ETIMEDOUT;
}
size_t usb_osal_enter_critical_section(void)