interrupt-sender.c 757 Bytes
Newer Older
1
2
3
4
5
6
#include "api/interrupt-sender.h"
#include "api/common.h"
#include "tmr_utils.h"

static bool enabled[API_INT_MAX + 1];

7
int api_interrupt_trigger(api_int_id_t id)
8
{
9
10
	if (id > API_INT_MAX) {
		return EINVAL;
11
	}
12
13
14
15
16
17
18
19

	if (enabled[id]) {
		while (API_CALL_MEM->int_id)
			;
		API_CALL_MEM->int_id = id;
		TMR_TO_Start(MXC_TMR5, 1, 0);
	}
	return 0;
20
21
22
23
24
25
26
27
28
29
30
31
}

void api_interrupt_init(void)
{
	int i;
	API_CALL_MEM->int_id = 0;

	for (i = 0; i <= API_INT_MAX; i++) {
		enabled[i] = false;
	}
}

32
int epic_interrupt_enable(api_int_id_t int_id)
33
{
34
35
	if (int_id > API_INT_MAX) {
		return EINVAL;
36
	}
37
38
39

	enabled[int_id] = true;
	return 0;
40
41
}

42
int epic_interrupt_disable(api_int_id_t int_id)
43
{
44
45
	if (int_id > API_INT_MAX) {
		return EINVAL;
46
	}
47
48
49

	enabled[int_id] = false;
	return 0;
50
}