1 /* 2 * Interrupt handling. 3 * 4 * Copyright (C) 2015 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-specific.h" 21 #include "board.h" 22 #include "lcd.h" 23 #include "jzlcd.h" 24 #include "cpu.h" 25 26 extern vidinfo_t panel_info; 27 static unsigned short pixel_type; 28 static unsigned short x, y; 29 extern unsigned long lastdec; 30 31 void next_pixel() 32 { 33 x++; 34 if (x >= panel_info.vl_col) { 35 x = 0; 36 y++; 37 if (y >= panel_info.vl_row) 38 y = 0; 39 } 40 } 41 42 /* Tasks. */ 43 44 void plot_pattern() 45 { 46 while (1) { 47 if (pixel_type) 48 test_pixel(x, y); 49 else 50 clear_pixel(x, y); 51 next_pixel(); 52 udelay(100); 53 } 54 } 55 56 /* Initialisation and handling. */ 57 58 void irq_init() 59 { 60 timer_init_irq(); 61 x = 0; y = 0; pixel_type = 1; 62 enable_interrupts(); 63 } 64 65 void irq_handle() 66 { 67 unsigned short i; 68 69 /* Check interrupt identity. */ 70 71 if (REG_INTC_IPR & (1 << TIMER_CHAN_IRQ)) { 72 73 /* Update the pixel type. */ 74 75 pixel_type = 1 - pixel_type; 76 77 /* Clear interrupt status. */ 78 79 __intc_ack_irq(TIMER_CHAN_IRQ); 80 __tcu_clear_full_match_flag(TIMER_CHAN); 81 82 /* Handle other interrupts, anyway. */ 83 84 } else { 85 for (i = 0; i < 32; i++) { 86 if (REG_INTC_IPR & (1 << i)) 87 __intc_ack_irq(i); 88 } 89 } 90 } 91 92 void start_task() 93 { 94 plot_pattern(); 95 }