3 * Copyright 2003 Free Software Foundation, Inc.
5 * This file is part of GNU Radio
7 * GNU Radio is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * GNU Radio is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Radio; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street,
20 * Boston, MA 02110-1301, USA.
25 #include "syncdelay.h"
27 extern xdata unsigned char _standard_interrupt_vector[];
28 extern xdata unsigned char _usb_autovector[];
29 extern xdata unsigned char _fifo_gpif_autovector[];
31 #define LJMP_OPCODE 0x02
34 * Hook standard interrupt vector.
36 * vector_number is from the SV_<foo> list.
37 * addr is the address of the interrupt service routine.
40 hook_sv (unsigned char vector_number, unsigned short addr)
46 if (vector_number < SV_MIN || vector_number > SV_MAX)
49 if ((vector_number & 0x0f) != 0x03 && (vector_number & 0x0f) != 0x0b)
54 _standard_interrupt_vector[vector_number] = LJMP_OPCODE;
55 _standard_interrupt_vector[vector_number + 1] = addr >> 8;
56 _standard_interrupt_vector[vector_number + 2] = addr & 0xff;
61 * Hook usb interrupt vector.
63 * vector_number is from the UV_<foo> list.
64 * addr is the address of the interrupt service routine.
67 hook_uv (unsigned char vector_number, unsigned short addr)
73 if (vector_number < UV_MIN || vector_number > UV_MAX)
76 if ((vector_number & 0x3) != 0)
81 _usb_autovector[vector_number] = LJMP_OPCODE;
82 _usb_autovector[vector_number + 1] = addr >> 8;
83 _usb_autovector[vector_number + 2] = addr & 0xff;
88 * Hook fifo/gpif interrupt vector.
90 * vector_number is from the FGV_<foo> list.
91 * addr is the address of the interrupt service routine.
94 hook_fgv (unsigned char vector_number, unsigned short addr)
100 if (vector_number < FGV_MIN || vector_number > FGV_MAX)
103 if ((vector_number & 0x3) != 0)
108 _fifo_gpif_autovector[vector_number] = LJMP_OPCODE;
109 _fifo_gpif_autovector[vector_number + 1] = addr >> 8;
110 _fifo_gpif_autovector[vector_number + 2] = addr & 0xff;
115 * One time call to enable autovectoring for both USB and FIFO/GPIF.
117 * This disables all USB and FIFO/GPIF interrupts and clears
118 * any pending interrupts too. It leaves the master USB and FIFO/GPIF
119 * interrupts enabled.
122 setup_autovectors (void)
124 // disable master usb and fifo/gpif interrupt enables
128 hook_sv (SV_INT_2, (unsigned short) _usb_autovector);
129 hook_sv (SV_INT_4, (unsigned short) _fifo_gpif_autovector);
131 // disable all fifo interrupt enables
133 EP2FIFOIE = 0; SYNCDELAY;
134 EP4FIFOIE = 0; SYNCDELAY;
135 EP6FIFOIE = 0; SYNCDELAY;
136 EP8FIFOIE = 0; SYNCDELAY;
138 // clear all pending fifo irqs
139 EP2FIFOIRQ = 0xff; SYNCDELAY;
140 EP4FIFOIRQ = 0xff; SYNCDELAY;
141 EP6FIFOIRQ = 0xff; SYNCDELAY;
142 EP8FIFOIRQ = 0xff; SYNCDELAY;
152 SYNCDELAY; GPIFIE = 0;
153 SYNCDELAY; GPIFIRQ = 0xff;
158 INTSETUP = bmAV2EN | bmAV4EN | bmINT4IN;
160 // clear master irq's for usb and fifo/gpif
161 EXIF &= ~bmEXIF_USBINT;
164 // enable master usb and fifo/gpif interrrupts