1 /* 2 * Interrupt handling. 3 * 4 * Copyright (C) 2015, 2016 Paul Boddie <paul@boddie.org.uk> 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #include "board-defs.h" 21 22 #include "init.h" 23 #include "board.h" 24 #include "cpu.h" 25 #include "cpu_op.h" 26 #include "irq.h" 27 #include "tasks.h" 28 29 /* Initialisation and handling. */ 30 31 void irq_init() 32 { 33 handle_error_level(); 34 timer_init_irq(); 35 gpio_init_irq(); 36 init_interrupts(); 37 } 38 39 void irq_handle() 40 { 41 /* Check interrupt identity. */ 42 43 if (REG_INTC_IPR & (1 << TIMER_CHAN_IRQ)) { 44 45 /* Switch task. */ 46 47 switch_task(); 48 49 /* Clear interrupt status. */ 50 51 timer_clear(); 52 } 53 54 /* Handle other interrupts, anyway. */ 55 56 irq_clear(); 57 }