Blame
|
1 | # Handling Interrupts |
||||||
| 2 | ||||||||
|
3 | This actually is very simple. gcc provides the means to mark a function as an interrupt service routine, namely prefixing a function with `__attribute__(interrupt)`. So, something like this: |
||||||
| 4 | ```c |
|||||||
| 5 | __attribute__((interrupt)) duart_interrupt(void) { |
|||||||
| 6 | /* Handle the interrupt */ |
|||||||
|
7 | |||||||
| 8 | } |
|||||||
|
9 | ``` |
||||||
|
10 | But there's a macro in `machine.h` to help, so you could replace the above with: |
||||||
| 11 | ```c |
|||||||
| 12 | #include <machine.h> |
|||||||
| 13 | ||||||||
| 14 | ISR duart_interrupt(void) { |
|||||||
| 15 | /* Handle the interrupt */ |
|||||||
| 16 | ||||||||
| 17 | } |
|||||||
| 18 | ``` |
|||||||
| 19 | gcc knows that functions declared using either of the above methods should end with the `rte` rather than `rts` instruction. |
|||||||