Is there an exact way to tell if code is running in a interrupt handler? Since I need to distinguish between interrupt context and thread context to use correct FreeRTOS API(eg:xSemaphoreGive/xSemaphoreGiveFromISR)
Referring to the arm platform, whether in interrupt handler can be obtained through IPSR or SCB->ICSR.Similarly, on riscv, I wonder if there is similar way to tell if code is in interrupt handler.
If your core implements [CLIC extension ], you can probably use mintstatus CSR.
I have learned about this CSR, and feel it can satisfy my need. By the way, I wonder how or where you found this CSR can determine code is in isr.
Can you not call the FromISR APIs from your ISR? Why do you need to determine the context?
because we write an abstraction layer for wrapping freertos api. Take api OS_SemaphoreRelease for example, we determine which context to call xSemaphoreGive or xSemaphoreGiveFromISR.