/* Enable and disable functions "ripped" from a sample by R O Software. * Copyright 2004, R O SoftWare * No guarantees, warrantees, or promises, implied or otherwise. * May be used for hobby or commercial purposes provided copyright * notice remains intact. */ /*modify by yuanguiyou for tkstudio ide 2008/04/08 */ #include "VIClowlevel.h" #define IRQ_MASK 0x00000080 static inline uint32_t asm_get_cpsr(void) { uint32_t retval; asm volatile (" mrs %0, cpsr" : "=r" (retval) : /* no inputs */ ); return retval; } static inline void asm_set_cpsr(uint32_t val) { asm volatile (" msr cpsr, %0" : /* no outputs */ : "r" (val) ); } uint32_t enableIRQ(void) { uint32_t _cpsr; _cpsr = asm_get_cpsr(); asm_set_cpsr(_cpsr & ~IRQ_MASK); return _cpsr; } uint32_t disableIRQ(void) { uint32_t _cpsr; _cpsr = asm_get_cpsr(); asm_set_cpsr(_cpsr | IRQ_MASK); return _cpsr; } uint32_t restoreIRQ(uint32_t oldCPSR) { uint32_t _cpsr; _cpsr = asm_get_cpsr(); asm_set_cpsr((_cpsr & ~IRQ_MASK) | (oldCPSR & IRQ_MASK)); return _cpsr; } /* end of R O code */