-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrpi-interrupt.c
55 lines (38 loc) · 1.13 KB
/
rpi-interrupt.c
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
/*
Reference:
Brian Sidebotham's Bare Metal Pi Tutorial. www.valvers.com
Davis Welch's Pi Repo. www.github.com/dwelch67/raspberrypi
Huanle Zhang at UC Davis
www.huanlezhang.com
*/
#include "rpi-interrupt.h"
#include "rpi-gpio.h"
#include "rpi-armtimer.h"
typedef void (*TimerTask)(void);
static TimerTask myTimerTask;
volatile Interrupt_registers* sysInterrupt = (Interrupt_registers *)
INTERRUPT_CONTROLLER_BASE;
// repetively call f for interval of us microsends
void startTimerTask(unsigned int us, void (*f)(void))
{
sysInterrupt->base_disable = INTERRUPT_TABLE_ARM_TIMER;
myTimerTask = f;
setTimer(us);
sysInterrupt->base_interrupt_enable = INTERRUPT_TABLE_ARM_TIMER;
}
void c_undefined_handler(void){}
void c_swi_handler(void){}
void c_prefetch_handler(void){}
void c_data_handler(void){}
void c_hyp_handler(void){}
// timer processing
void c_irq_handler(void){
_disable_interrupts();
if ( ((sysInterrupt->basic_pending) & INTERRUPT_BASIC_PENDING_TIMER) == 1){
// timer task irq
clearTimerPendingBit();
myTimerTask();
}
_enable_interrupts();
}
void c_fiq_handler(void){}