paul@68 | 1 | /* |
paul@68 | 2 | * Interrupt handling. |
paul@68 | 3 | * |
paul@68 | 4 | * Copyright (C) 2015 Paul Boddie <paul@boddie.org.uk> |
paul@68 | 5 | * |
paul@68 | 6 | * This program is free software: you can redistribute it and/or modify |
paul@68 | 7 | * it under the terms of the GNU General Public License as published by |
paul@68 | 8 | * the Free Software Foundation, either version 3 of the License, or |
paul@68 | 9 | * (at your option) any later version. |
paul@68 | 10 | * |
paul@68 | 11 | * This program is distributed in the hope that it will be useful, |
paul@68 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@68 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@68 | 14 | * GNU General Public License for more details. |
paul@68 | 15 | * |
paul@68 | 16 | * You should have received a copy of the GNU General Public License |
paul@68 | 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
paul@68 | 18 | */ |
paul@68 | 19 | |
paul@68 | 20 | #include "board-specific.h" |
paul@68 | 21 | #include "board.h" |
paul@68 | 22 | #include "lcd.h" |
paul@68 | 23 | #include "jzlcd.h" |
paul@68 | 24 | #include "cpu.h" |
paul@68 | 25 | |
paul@68 | 26 | extern vidinfo_t panel_info; |
paul@68 | 27 | static unsigned short pixel_type; |
paul@68 | 28 | static unsigned short x, y; |
paul@68 | 29 | extern unsigned long lastdec; |
paul@68 | 30 | |
paul@68 | 31 | void next_pixel() |
paul@68 | 32 | { |
paul@68 | 33 | x++; |
paul@68 | 34 | if (x >= panel_info.vl_col) { |
paul@68 | 35 | x = 0; |
paul@68 | 36 | y++; |
paul@68 | 37 | if (y >= panel_info.vl_row) |
paul@68 | 38 | y = 0; |
paul@68 | 39 | } |
paul@68 | 40 | } |
paul@68 | 41 | |
paul@68 | 42 | /* Tasks. */ |
paul@68 | 43 | |
paul@68 | 44 | void plot_pattern() |
paul@68 | 45 | { |
paul@68 | 46 | while (1) { |
paul@68 | 47 | if (pixel_type) |
paul@68 | 48 | test_pixel(x, y); |
paul@68 | 49 | else |
paul@68 | 50 | clear_pixel(x, y); |
paul@68 | 51 | next_pixel(); |
paul@68 | 52 | udelay(100); |
paul@68 | 53 | } |
paul@68 | 54 | } |
paul@68 | 55 | |
paul@68 | 56 | /* Initialisation and handling. */ |
paul@68 | 57 | |
paul@68 | 58 | void irq_init() |
paul@68 | 59 | { |
paul@68 | 60 | timer_init_irq(); |
paul@68 | 61 | x = 0; y = 0; pixel_type = 1; |
paul@84 | 62 | handle_error_level(); |
paul@84 | 63 | init_interrupts(); |
paul@73 | 64 | /* enable_interrupts(); */ |
paul@68 | 65 | } |
paul@68 | 66 | |
paul@68 | 67 | void irq_handle() |
paul@68 | 68 | { |
paul@68 | 69 | unsigned short i; |
paul@68 | 70 | |
paul@68 | 71 | /* Check interrupt identity. */ |
paul@68 | 72 | |
paul@68 | 73 | if (REG_INTC_IPR & (1 << TIMER_CHAN_IRQ)) { |
paul@68 | 74 | |
paul@68 | 75 | /* Update the pixel type. */ |
paul@68 | 76 | |
paul@68 | 77 | pixel_type = 1 - pixel_type; |
paul@68 | 78 | |
paul@68 | 79 | /* Clear interrupt status. */ |
paul@68 | 80 | |
paul@68 | 81 | __intc_ack_irq(TIMER_CHAN_IRQ); |
paul@68 | 82 | __tcu_clear_full_match_flag(TIMER_CHAN); |
paul@68 | 83 | |
paul@68 | 84 | /* Handle other interrupts, anyway. */ |
paul@68 | 85 | |
paul@68 | 86 | } else { |
paul@68 | 87 | for (i = 0; i < 32; i++) { |
paul@68 | 88 | if (REG_INTC_IPR & (1 << i)) |
paul@68 | 89 | __intc_ack_irq(i); |
paul@68 | 90 | } |
paul@68 | 91 | } |
paul@68 | 92 | } |
paul@68 | 93 | |
paul@68 | 94 | void start_task() |
paul@68 | 95 | { |
paul@68 | 96 | plot_pattern(); |
paul@68 | 97 | } |