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