aboutsummaryrefslogtreecommitdiff
path: root/interrupts.c
blob: 712cfb9eedc2b555371596ea937f490b5240faeb (plain)
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
#include "uart.h"
#include "interrupts.h"
/**
    @brief The undefined instruction interrupt handler

    If an undefined instruction is encountered, the CPU will start
    executing this function. Just trap here as a debug solution.
*/
void __attribute__((interrupt("UNDEF"))) undefined_instruction_vector(void)
{
    uart_puts("Undefined instruction occured");
    while( 1 )
    {
        /* Do Nothing! */
    }
}

void __attribute__((section(".interrupt_vectors.data")))
(*system_reentry_point) (void);

void
__attribute__((interrupt("ABORT")))
__attribute__((section(".interrupt_vectors.text")))
abort_handler(void)
{
    uart_puts("nwm\r\n");

    system_reentry_point();
}

/* Here is your interrupt function */
void
__attribute__((interrupt("IRQ")))
__attribute__((section(".interrupt_vectors.text")))
irq_handler(void) {
    /* You code goes here */
    uart_puts("GOT INTERRUPT!\r\n");

    local_timer_clr_reload_reg_t temp = { .IntClear = 1, .Reload = 1 };
    QA7->TimerClearReload  = temp;									// Clear interrupt & reload
}

/* here is your main */
int enable_timer(void) {

    QA7->TimerRouting.Routing = LOCALTIMER_TO_CORE0_IRQ;			// Route local timer IRQ to Core0
    QA7->TimerControlStatus.ReloadValue = 100;						// Timer period set
    QA7->TimerControlStatus.TimerEnable = 1;						// Timer enabled
    QA7->TimerControlStatus.IntEnable = 1;							// Timer IRQ enabled
    QA7->TimerClearReload.IntClear = 1;								// Clear interrupt
    QA7->TimerClearReload.Reload = 1;								// Reload now
    QA7->Core0TimerIntControl.nCNTPNSIRQ_IRQ = 1;					// We are in NS EL1 so enable IRQ to core0 that level
    QA7->Core0TimerIntControl.nCNTPNSIRQ_FIQ = 0;					// Make sure FIQ is zero
    uart_puts("Enabled Timer\r\n");
    return(0);
}