1 |
9 |
jlechner |
/* Exception handling code for SCARTS.
|
2 |
|
|
* Copyright (C) 2010, 2011 Embedded Computing Systems Group,
|
3 |
|
|
* Department of Computer Engineering, Vienna University of Technology.
|
4 |
|
|
* Contributed by Wolfgang Puffitsch <hausesn@gmx.at>
|
5 |
|
|
* Martin Walter <mwalter@opencores.org>
|
6 |
|
|
*
|
7 |
|
|
* The authors hereby grant permission to use, copy, modify, distribute,
|
8 |
|
|
* and license this software and its documentation for any purpose, provided
|
9 |
|
|
* that existing copyright notices are retained in all copies and that this
|
10 |
|
|
* notice is included verbatim in any distributions. No written agreement,
|
11 |
|
|
* license, or royalty fee is required for any of the authorized uses.
|
12 |
|
|
* Modifications to this software may be copyrighted by their authors
|
13 |
|
|
* and need not follow the licensing terms described here, provided that
|
14 |
|
|
* the new terms are clearly indicated on the first page of each file where
|
15 |
|
|
* they apply.
|
16 |
|
|
*/
|
17 |
|
|
|
18 |
|
|
#ifndef __SCARTS_INTERRUPTS_H__
|
19 |
|
|
#define __SCARTS_INTERRUPTS_H__
|
20 |
|
|
|
21 |
|
|
#include <stdint.h>
|
22 |
|
|
#include "modules.h"
|
23 |
|
|
|
24 |
|
|
/* Set sleep mode. */
|
25 |
|
|
#define SLEEP_MODE() (PROC_CTRL_CONFIG_C |= (1 << (PROC_CTRL_CONFIG_C_SLEEP)))
|
26 |
|
|
#define sleep_mode SLEEP_MODE
|
27 |
|
|
|
28 |
|
|
/* Set the Global Interrupt Flag. */
|
29 |
|
|
#define SEI() (PROC_CTRL_CONFIG_C |= (1 << (PROC_CTRL_CONFIG_C_GIE)))
|
30 |
|
|
#define sei SEI
|
31 |
|
|
|
32 |
|
|
/* Clear the Global Interrupt Flag. */
|
33 |
|
|
#define CLI() (PROC_CTRL_CONFIG_C &= ~(1 << (PROC_CTRL_CONFIG_C_GIE)))
|
34 |
|
|
#define cli CLI
|
35 |
|
|
|
36 |
|
|
/* Register function FUNC as SW trap NUM (0..15). */
|
37 |
|
|
#define REGISTER_TRAP(FUNC, NUM) asm ("stvec %0, %1" : : "r" (&FUNC), "i" (NUM))
|
38 |
|
|
#define register_trap REGISTER_TRAP
|
39 |
|
|
|
40 |
|
|
/* Register function FUNC as HW interrupt NUM (0..15). */
|
41 |
|
|
#define REGISTER_INTERRUPT(FUNC, NUM) asm ("stvec %0, %1" : : "r" (&FUNC), "i" ((NUM)-16))
|
42 |
|
|
#define register_interrupt REGISTER_INTERRUPT
|
43 |
|
|
|
44 |
|
|
/* Mask / unmask a single interrupt. */
|
45 |
|
|
#define MASKI(NUM) (PROC_CTRL_INTMASK |= (1 << (NUM)))
|
46 |
|
|
#define maski MASKI
|
47 |
|
|
|
48 |
|
|
#define UMASKI(NUM) (PROC_CTRL_INTMASK &= ~(1 << (NUM)))
|
49 |
|
|
#define umaski UMASKI
|
50 |
|
|
|
51 |
|
|
/* Mask / unmask multiple interrupts at once. */
|
52 |
|
|
#define MASKIL(NUMS) (PROC_CTRL_INTMASK |= (NUMS))
|
53 |
|
|
#define maskil MASKIL
|
54 |
|
|
|
55 |
|
|
#define UMASKIL(NUMS) (PROC_CTRL_INTMASK &= ~(NUMS))
|
56 |
|
|
#define umaskil UMASKIL
|
57 |
|
|
|
58 |
|
|
/* Protocol / unprotocol a single interrupt. */
|
59 |
|
|
#define PROTI(NUM) (PROC_CTRL_INTPROT = (1 << (NUM)))
|
60 |
|
|
#define proti PROTI
|
61 |
|
|
|
62 |
|
|
#define UPROTI(NUM) (PROC_CTRL_INTPROT = (1 << (NUM)))
|
63 |
|
|
#define uproti UPROTI
|
64 |
|
|
|
65 |
|
|
/* Protocol / unprotocol multiple interrupts at once (set corresponding bits in NUMS). */
|
66 |
|
|
#define PROTL(NUMS) (PROC_CTRL_INTPROT = (uint16_t)(NUMS))
|
67 |
|
|
#define protl PROTL
|
68 |
|
|
|
69 |
|
|
#define UPROTL(NUMS) (PROC_CTRL_INTPROT = (uint16_t)(NUMS))
|
70 |
|
|
#define uprotl UPROTL
|
71 |
|
|
|
72 |
|
|
#endif
|
73 |
|
|
|