[riot-notifications] [RIOT-OS/RIOT] core: add irq_is_enabled() function to irq interface (#11117)

Koen Zandberg notifications at github.com
Tue Jun 29 10:13:56 CEST 2021


@fjmolinas This should work on RISC-V (compiles, but didn't test)

```Patch
diff --git a/cpu/riscv_common/include/irq_arch.h b/cpu/riscv_common/include/irq_arch.h
index d6876de964..fa7cd92513 100644
--- a/cpu/riscv_common/include/irq_arch.h
+++ b/cpu/riscv_common/include/irq_arch.h
@@ -84,6 +84,18 @@ static inline __attribute__((always_inline)) void irq_restore(
         );
 }
 
+static inline __attribute__((always_inline)) int irq_is_enabled(void)
+{
+   unsigned state;
+   __asm__ volatile (
+       "csrr %[dest], mstatus"
+       :[dest]    "=r" (state)
+       : /* no inputs */
+       : "memory"
+       );
+   return state & MSTATUS_MIE;
+}
+
 /**
  * @brief See if the current context is inside an ISR
  */
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11117#issuecomment-870380348
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210629/9f3c057e/attachment-0001.htm>


More information about the notifications mailing list