irq.c 783 Bytes
Newer Older
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
1 2 3 4
#include "irq.h"

void disable_irq()
{
5 6
	unsigned int ie, im;
	unsigned int Mask = ~1;
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
7

8 9 10 11
	/* disable peripheral interrupts in case they were enabled */
	asm volatile ("rcsr %0,ie":"=r" (ie));
	ie &= (~0x1);
	asm volatile ("wcsr ie, %0"::"r" (ie));
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
12

13 14 15 16
	/* disable mask-bit in im */
	asm volatile ("rcsr %0, im":"=r" (im));
	im &= Mask;
	asm volatile ("wcsr im, %0"::"r" (im));
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
17 18 19 20 21

}

void enable_irq()
{
22 23
	unsigned int ie, im;
	unsigned int Mask = 1;
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
24

25 26 27 28
	/* disable peripheral interrupts in-case they were enabled */
	asm volatile ("rcsr %0,ie":"=r" (ie));
	ie &= (~0x1);
	asm volatile ("wcsr ie, %0"::"r" (ie));
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
29

30 31 32 33
	/* enable mask-bit in im */
	asm volatile ("rcsr %0, im":"=r" (im));
	im |= Mask;
	asm volatile ("wcsr im, %0"::"r" (im));
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
34

35 36
	ie |= 0x1;
	asm volatile ("wcsr ie, %0"::"r" (ie));
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
37
}