forked from frankshc/guitar_amp_sim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nios2_interrupt.h
67 lines (61 loc) · 2.12 KB
/
nios2_interrupt.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#ifndef NIOS2_INTERRUPT_H
#define NIOS2_INTERRUPT_H
/*!
* \brief This is a NIOS II interrupt handler interface
* \details This interface employs a simple, priority-less interrupt handler.
* If multiple interrupt requests are active at the beginning of a handling
* cycle, each request is service starting from the lowest IRQ number.
* \author Frank Chen
* \version 0.1
* \date 2018-03-22
* \pre Set linker section presets to "Exceptions" in the Monitor Program.
*/
/*! \brief Registers a callback function for an IRQ line.
*
* Registering a callback for an IRQ line also enables interrupt request listening
* on that IRQ line.
*
* \note
* Each IRQ line has at most one callback; registering a new callback overwites
* the existing one.
*
* \warning
* IRQ line must be an integer in [0...32].
*
*/
void register_interrupt_callback(int IRQ, void (*callback)(void));
/*! \brief Unregisters the callback function for an IRQ line, if it exists.
*
* \warning
* IRQ line must be an integer in [0...32].
*
* \bug
* It is unsafe to register/unregister interrupts from within an interrupt.
*/
void unregister_interrupt_callback(int IRQ);
/*! \brief Enables master interrupt.
*
* Enables the interrupt handler. Callbacks for each IRQ line will not be invoked
* unless the interrupt handler is enabled.
*
* \warning
* Enabling master interrupt inside an interrupt callback has undefined behavior.
*/
void enable_master_interrupt(void);
/*! \brief Disables master interrupt.
*
* Disables the interrupt service routine. Devices may still emit interrupt requests,
* but they won't be serviced. Does not affect registered callbacks.
*/
void disable_master_interrupt(void);
/*! \brief Returns the current master interrupt state.
*
* Use this function with toggle_master_interrupt to implement atomic sections.
*/
int is_master_interrupt_enabled(void);
/*! \brief Toggles the master interrupt enable switch.
*
* Use this function with is_master_interrupt_enabled to implement atomic sections.
*/
void toggle_master_interrupt(int toggle);
#endif /*NIOS2_INTERRUPT_H*/