how can my program tell if code is in a interrupt handler?(riscv32)

61 Views Asked by At

Is there an exact way to tell if code is running in a interrupt handler? Since I need to distinguish between interrupt context and non-interrupt 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, we can see that the mcause register contains the execption code field. Can I use this field to directly determine whether the current code is in an interrupt handler function?

I want the confirm solutions of my questions,Thanks.

0

There are 0 best solutions below