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

5
static bool int_enabled[EPIC_INT_NUM];
6

7
int api_interrupt_trigger(api_int_id_t id)
8
{
9
	if (id >= EPIC_INT_NUM) {
10
		return -EINVAL;
11
	}
12

13
	if (int_enabled[id]) {
14
15
16
17
18
19
		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
}

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

26
27
	for (int i = 0; i < EPIC_INT_NUM; i++) {
		int_enabled[i] = false;
28
29
30
	}
}

31
int epic_interrupt_enable(api_int_id_t int_id)
32
{
33
	if (int_id >= EPIC_INT_NUM) {
34
		return -EINVAL;
35
	}
36

37
	int_enabled[int_id] = true;
38
	return 0;
39
40
}

41
int epic_interrupt_disable(api_int_id_t int_id)
42
{
43
	if (int_id >= EPIC_INT_NUM) {
44
		return -EINVAL;
45
	}
46

47
	int_enabled[int_id] = false;
48
	return 0;
49
}