1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/stage2/irq.c Tue Jun 23 23:08:19 2015 +0200
1.3 @@ -0,0 +1,95 @@
1.4 +/*
1.5 + * Interrupt handling.
1.6 + *
1.7 + * Copyright (C) 2015 Paul Boddie <paul@boddie.org.uk>
1.8 + *
1.9 + * This program is free software: you can redistribute it and/or modify
1.10 + * it under the terms of the GNU General Public License as published by
1.11 + * the Free Software Foundation, either version 3 of the License, or
1.12 + * (at your option) any later version.
1.13 + *
1.14 + * This program is distributed in the hope that it will be useful,
1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 + * GNU General Public License for more details.
1.18 + *
1.19 + * You should have received a copy of the GNU General Public License
1.20 + * along with this program. If not, see <http://www.gnu.org/licenses/>.
1.21 + */
1.22 +
1.23 +#include "board-specific.h"
1.24 +#include "board.h"
1.25 +#include "lcd.h"
1.26 +#include "jzlcd.h"
1.27 +#include "cpu.h"
1.28 +
1.29 +extern vidinfo_t panel_info;
1.30 +static unsigned short pixel_type;
1.31 +static unsigned short x, y;
1.32 +extern unsigned long lastdec;
1.33 +
1.34 +void next_pixel()
1.35 +{
1.36 + x++;
1.37 + if (x >= panel_info.vl_col) {
1.38 + x = 0;
1.39 + y++;
1.40 + if (y >= panel_info.vl_row)
1.41 + y = 0;
1.42 + }
1.43 +}
1.44 +
1.45 +/* Tasks. */
1.46 +
1.47 +void plot_pattern()
1.48 +{
1.49 + while (1) {
1.50 + if (pixel_type)
1.51 + test_pixel(x, y);
1.52 + else
1.53 + clear_pixel(x, y);
1.54 + next_pixel();
1.55 + udelay(100);
1.56 + }
1.57 +}
1.58 +
1.59 +/* Initialisation and handling. */
1.60 +
1.61 +void irq_init()
1.62 +{
1.63 + timer_init_irq();
1.64 + x = 0; y = 0; pixel_type = 1;
1.65 + enable_interrupts();
1.66 +}
1.67 +
1.68 +void irq_handle()
1.69 +{
1.70 + unsigned short i;
1.71 +
1.72 + /* Check interrupt identity. */
1.73 +
1.74 + if (REG_INTC_IPR & (1 << TIMER_CHAN_IRQ)) {
1.75 +
1.76 + /* Update the pixel type. */
1.77 +
1.78 + pixel_type = 1 - pixel_type;
1.79 +
1.80 + /* Clear interrupt status. */
1.81 +
1.82 + __intc_ack_irq(TIMER_CHAN_IRQ);
1.83 + __tcu_clear_full_match_flag(TIMER_CHAN);
1.84 +
1.85 + /* Handle other interrupts, anyway. */
1.86 +
1.87 + } else {
1.88 + for (i = 0; i < 32; i++) {
1.89 + if (REG_INTC_IPR & (1 << i))
1.90 + __intc_ack_irq(i);
1.91 + }
1.92 + }
1.93 +}
1.94 +
1.95 +void start_task()
1.96 +{
1.97 + plot_pattern();
1.98 +}