summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsakumisu <[email protected]>2022-02-07 18:13:28 +0800
committersakumisu <[email protected]>2022-02-07 18:13:28 +0800
commit18685898436023ca83a7e45b4f74709e35faa7f9 (patch)
treea65e7151d1cb11eb933fc4deba327133d9fed824
parent1cb56fe0efcfe46b3008992ff73256759a7a991d (diff)
check if in interrupt context
-rw-r--r--osal/usb_osal_freertos.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/osal/usb_osal_freertos.c b/osal/usb_osal_freertos.c
index ece24eb0..6a551393 100644
--- a/osal/usb_osal_freertos.c
+++ b/osal/usb_osal_freertos.c
@@ -60,14 +60,15 @@ int usb_osal_sem_take(usb_osal_sem_t sem)
int usb_osal_sem_give(usb_osal_sem_t sem)
{
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
- uint32_t intstatus = 1;
+ uint32_t intstatus = 0;
int ret;
+#ifdef __riscv
/* Obtain the level of the currently executing interrupt. */
-// __asm volatile("csrr %0, mintstatus"
-// : "=r"(intstatus)::"memory");
- /* Obtain the number of the currently executing interrupt. */
-// __asm volatile ( "mrs %0, ipsr" : "=r" ( intstatus )::"memory" );
-
+ __asm volatile("csrr %0, mintstatus" : "=r"(intstatus)::"memory");
+#else
+ /* Obtain the number of the currently executing interrupt. */
+ __asm volatile ( "mrs %0, ipsr" : "=r" ( intstatus )::"memory" );
+#endif
if (intstatus == 0) {
ret = xSemaphoreGive((SemaphoreHandle_t)sem);
} else {