27 lines
581 B
C
27 lines
581 B
C
|
#ifndef ATOMIC_H_
|
||
|
#define ATOMIC_H_
|
||
|
|
||
|
//TODO: not for thumbcode?!
|
||
|
|
||
|
#define disable_irqs() \
|
||
|
{ \
|
||
|
int temp_; \
|
||
|
asm volatile ( \
|
||
|
"mrs %0, cpsr" "\n\t" \
|
||
|
"stmfd sp!, {%0}" "\n\t" \
|
||
|
"orr %0, %0, #0xC0" "\n\t" \
|
||
|
"msr cpsr, %0" "\n\t" \
|
||
|
: "=r" (temp_) : ); \
|
||
|
}
|
||
|
|
||
|
#define restore_irqs() \
|
||
|
{ \
|
||
|
int temp_; \
|
||
|
asm volatile ( \
|
||
|
"ldmfd sp!, {%0}" "\n\t" \
|
||
|
"msr cpsr, %0" "\n\t" \
|
||
|
: "=r" (temp_) : ); \
|
||
|
}
|
||
|
|
||
|
#endif /*ATOMIC_H_*/
|