Skip to content

Commit

Permalink
Merge pull request #257 from mrx23dot/isr_asm
Browse files Browse the repository at this point in the history
added __isenabled_irq __get_cpu_sp, minor linting
  • Loading branch information
cnlohr authored Dec 24, 2023
2 parents 2fa932a + b3a4ef4 commit 0c138b8
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions ch32v003fun/ch32v003fun.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit 0c138b8

Please sign in to comment.