diff --git a/ch32v003fun/ch32v003fun.h b/ch32v003fun/ch32v003fun.h index 339429f0..f3f18ff2 100644 --- a/ch32v003fun/ch32v003fun.h +++ b/ch32v003fun/ch32v003fun.h @@ -4563,6 +4563,45 @@ RV_STATIC_INLINE void __disable_irq() __asm volatile ("csrw mstatus, %0" : : "r" (result) ); } +/********************************************************************* + * @fn __isenabled_irq + * + * @brief Is Global Interrupt enabled + * + * @return 1: yes, 0: no + */ +RV_STATIC_INLINE uint8_t __isenabled_irq(void) +{ + uint32_t result; + + __asm volatile( +#if __GNUC__ > 10 + ".option arch, +zicsr\n" +#endif + "csrr %0," "mstatus": "=r"(result)); + return (result & 0x08) != 0u; +} + +/********************************************************************* + * @fn __get_cpu_sp + * + * @brief Get stack pointer + * + * @return stack pointer + */ +RV_STATIC_INLINE uint32_t __get_cpu_sp(void); +RV_STATIC_INLINE uint32_t __get_cpu_sp(void) +{ + uint32_t result; + + __asm volatile( +#if __GNUC__ > 10 + ".option arch, +zicsr\n" +#endif + "mv %0, sp" : "=r"(result)); + return result; +} + /********************************************************************* * @fn __NOP *