source: trunk/FirmwareFX2/fx2/isr.h@ 23

Last change on this file since 23 was 4, checked in by demin, 15 years ago

initial commit

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