GNU Radio's HOWTO Package
isr.h
Go to the documentation of this file.
1 /* -*- c++ -*- */
2 /*
3  * Copyright 2003 Free Software Foundation, Inc.
4  *
5  * This file is part of GNU Radio
6  *
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)
10  * any later version.
11  *
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.
16  *
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., 59 Temple Place - Suite 330,
20  * Boston, MA 02111-1307, USA.
21  */
22 
23 #ifndef _ISR_H_
24 #define _ISR_H_
25 
26 /*
27  * ----------------------------------------------------------------
28  * routines for managing interrupt services routines
29  * ----------------------------------------------------------------
30  */
31 
32 /*
33  * The FX2 has three discrete sets of interrupt vectors.
34  * The first set is the standard 8051 vector (13 8-byte entries).
35  * The second set is USB interrupt autovector (32 4-byte entries).
36  * The third set is the FIFO/GPIF autovector (14 4-byte entries).
37  *
38  * Since all the code we're running in the FX2 is ram based, we
39  * forego the typical "initialize the interrupt vectors at link time"
40  * strategy, in favor of calls at run time that install the correct
41  * pointers to functions.
42  */
43 
44 /*
45  * Standard Vector numbers
46  */
47 
48 #define SV_INT_0 0x03
49 #define SV_TIMER_0 0x0b
50 #define SV_INT_1 0x13
51 #define SV_TIMER_1 0x1b
52 #define SV_SERIAL_0 0x23
53 #define SV_TIMER_2 0x2b
54 #define SV_RESUME 0x33
55 #define SV_SERIAL_1 0x3b
56 #define SV_INT_2 0x43 // (INT_2) points at USB autovector
57 #define SV_I2C 0x4b
58 #define SV_INT_4 0x53 // (INT_4) points at FIFO/GPIF autovector
59 #define SV_INT_5 0x5b
60 #define SV_INT_6 0x63
61 
62 #define SV_MIN SV_INT_0
63 #define SV_MAX SV_INT_6
64 
65 /*
66  * USB Auto Vector numbers
67  */
68 
69 #define UV_SUDAV 0x00
70 #define UV_SOF 0x04
71 #define UV_SUTOK 0x08
72 #define UV_SUSPEND 0x0c
73 #define UV_USBRESET 0x10
74 #define UV_HIGHSPEED 0x14
75 #define UV_EP0ACK 0x18
76 #define UV_SPARE_1C 0x1c
77 #define UV_EP0IN 0x20
78 #define UV_EP0OUT 0x24
79 #define UV_EP1IN 0x28
80 #define UV_EP1OUT 0x2c
81 #define UV_EP2 0x30
82 #define UV_EP4 0x34
83 #define UV_EP6 0x38
84 #define UV_EP8 0x3c
85 #define UV_IBN 0x40
86 #define UV_SPARE_44 0x44
87 #define UV_EP0PINGNAK 0x48
88 #define UV_EP1PINGNAK 0x4c
89 #define UV_EP2PINGNAK 0x50
90 #define UV_EP4PINGNAK 0x54
91 #define UV_EP6PINGNAK 0x58
92 #define UV_EP8PINGNAK 0x5c
93 #define UV_ERRLIMIT 0x60
94 #define UV_SPARE_64 0x64
95 #define UV_SPARE_68 0x68
96 #define UV_SPARE_6C 0x6c
97 #define UV_EP2ISOERR 0x70
98 #define UV_EP4ISOERR 0x74
99 #define UV_EP6ISOERR 0x78
100 #define UV_EP8ISOERR 0x7c
101 
102 #define UV_MIN UV_SUDAV
103 #define UV_MAX UV_EP8ISOERR
104 
105 /*
106  * FIFO/GPIF Auto Vector numbers
107  */
108 
109 #define FGV_EP2PF 0x80
110 #define FGV_EP4PF 0x84
111 #define FGV_EP6PF 0x88
112 #define FGV_EP8PF 0x8c
113 #define FGV_EP2EF 0x90
114 #define FGV_EP4EF 0x94
115 #define FGV_EP6EF 0x98
116 #define FGV_EP8EF 0x9c
117 #define FGV_EP2FF 0xa0
118 #define FGV_EP4FF 0xa4
119 #define FGV_EP6FF 0xa8
120 #define FGV_EP8FF 0xac
121 #define FGV_GPIFDONE 0xb0
122 #define FGV_GPIFWF 0xb4
123 
124 #define FGV_MIN FGV_EP2PF
125 #define FGV_MAX FGV_GPIFWF
126 
127 
128 /*
129  * Hook standard interrupt vector.
130  *
131  * vector_number is from the SV_<foo> list above.
132  * addr is the address of the interrupt service routine.
133  */
134 void hook_sv (unsigned char vector_number, unsigned short addr);
135 
136 /*
137  * Hook usb interrupt vector.
138  *
139  * vector_number is from the UV_<foo> list above.
140  * addr is the address of the interrupt service routine.
141  */
142 void hook_uv (unsigned char vector_number, unsigned short addr);
143 
144 /*
145  * Hook fifo/gpif interrupt vector.
146  *
147  * vector_number is from the FGV_<foo> list above.
148  * addr is the address of the interrupt service routine.
149  */
150 void hook_fgv (unsigned char vector_number, unsigned short addr);
151 
152 /*
153  * One time call to enable autovectoring for both USB and FIFO/GPIF
154  */
155 void setup_autovectors (void);
156 
157 
158 /*
159  * Must be called in each usb interrupt handler
160  */
161 #define clear_usb_irq() \
162  EXIF &= ~bmEXIF_USBINT; \
163  INT2CLR = 0
164 
165 /*
166  * Must be calledin each fifo/gpif interrupt handler
167  */
168 #define clear_fifo_gpif_irq() \
169  EXIF &= ~bmEXIF_IE4; \
170  INT4CLR = 0
171 
172 #endif /* _ISR_H_ */
void hook_uv(unsigned char vector_number, unsigned short addr)
void setup_autovectors(void)
void hook_fgv(unsigned char vector_number, unsigned short addr)
void hook_sv(unsigned char vector_number, unsigned short addr)