aboutsummaryrefslogtreecommitdiff
path: root/interrupts.c
blob: 79007cb0571bf0fa23e5b4fd85e88c59cd349e4e (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
#include "uart.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! */
    }
}

__irq void IRQHandler (void)
{
    volatile unsigned int *base = (unsigned int *) 0x80000000;
    if (*base == 1)          // which interrupt was it?
    {
        uart_putc(*base);     // process the interrupt
    }
    *(base+1) = 0;           // clear the interrupt
}