irq.c 1021 Bytes
Newer Older
1 2 3 4 5 6 7 8
/*
 * This work is part of the White Rabbit project
 *
 * Copyright (C) 2011 CERN (www.cern.ch)
 * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
 *
 * Released according to the GNU GPL, version 2 or any later version.
 */
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
9 10
#include "irq.h"

11
void disable_irq(void)
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
12
{
13 14
	unsigned int ie, im;
	unsigned int Mask = ~1;
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
15

16 17 18 19
	/* 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
20

21 22 23 24
	/* 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
25 26 27

}

28
void enable_irq(void)
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
29
{
30 31
	unsigned int ie, im;
	unsigned int Mask = 1;
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
32

33 34 35 36
	/* 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
37

38 39 40 41
	/* 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
42

43 44
	ie |= 0x1;
	asm volatile ("wcsr ie, %0"::"r" (ie));
Tomasz Wlostowski's avatar
Tomasz Wlostowski committed
45
}