Addition USB jump table macros.
[fx2lib.git] / include / usbjt.h
blob8538e125f14847e14b1a23995cd5515e9e320998
1 /**
2 * Copyright (C) 2008 Ubixum, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 **/
19 /**
20 * To use usbjt, you must tell the linker where to put the IN2JT.
21 * It must lie on a page boundary or your interrupts won't work right.
23 * example:
24 * -Wl"-b INT2JT = 0x1A00"
26 * Make sure that INT2JT doesn't overlap your other stuff!
27 **/
29 #ifndef USBJT_H
30 #define USBJT_H
32 #include "fx2regs.h"
37 // this causes usbjt to be included from the lib
38 // not used for anything
39 extern volatile BYTE INT2JT;
40 // enable all interrupts (EA=1) separate from this macro
41 #define USE_USB_INTS() {BYTE dummy=INT2JT;\
42 EUSB=1;\
43 INTSETUP|=bmAV2EN;}
44 // don't use this if you want external pin generated int4 interrupts
45 #define USE_GPIF_INTS() {BYTE dummy=INT2JT;\
46 EIEX4=1;\
47 INTSETUP|=bmAV4EN|INT4IN;}
51 #define CLEAR_USBINT() EXIF &= ~0x10
52 #define CLEAR_GPIF() EXIF &= ~0x40
54 #define ENABLE_SUDAV() USBIE|=bmSUDAV
55 #define CLEAR_SUDAV() CLEAR_USBINT(); USBIRQ=bmSUDAV
57 #define ENABLE_SOF() USBIE|=bmSOF
58 #define CLEAR_SOF() CLEAR_USBINT(); USBIRQ=bmSOF
60 #define ENABLE_SUSPEND() USBIE|=bmSUSP
61 #define CLEAR_SUSPEND() CLEAR_USBINT(); USBIRQ=bmSUSP
63 #define ENABLE_USBRESET() USBIE|= bmURES
64 #define CLEAR_USBRESET() CLEAR_USBINT(); USBIRQ=bmURES
66 #define ENABLE_HISPEED() USBIE|=bmHSGRANT
67 #define CLEAR_HISPEED() CLEAR_USBINT(); USBIRQ=bmHSGRANT
69 #define ENABLE_EP1IN() EPIE|=bmEP1IN;
70 #define CLEAR_EP1IN() CLEAR_USBINT(); EPIRQ=bmEP1IN
72 #define ENABLE_EP2() EPIE|=bmEP2;
73 #define CLEAR_EP2() CLEAR_USBINT(); EPIRQ=bmEP2;
75 #define ENABLE_EP6() EPIE|=bmEP6;
76 #define CLEAR_EP6() CLEAR_USBINT(); EPIRQ=bmEP6;
78 #define ENABLE_EP2ISOERR() USBERRIE |= bmISOEP2;
79 #define CLEAR_EP2ISOERR() CLEAR_USBINT(); USBERRIRQ = bmISOEP2
82 #define ENABLE_GPIFDONE() GPIFIE |= 0x01;
83 #define CLEAR_GPIFDONE() CLEAR_GPIF(); GPIFIRQ = 0x01;
85 #define ENABLE_GPIFWF() GPIFIE |= 0x02;
86 #define CLEAR_GPIFWF() GLEAR_GPIF(); GPIFIRQ = 0x02;
88 /**
89 * ez-usb has 12 built in ISRs, to get
90 * sdcc to put these USB ISRs immediately
91 * after the other ISRs (and not waste space)
92 * we start at 13
93 **/
94 typedef enum {
95 SUDAV_ISR=13,
96 SOF_ISR,
97 SUTOK_ISR,
98 SUSPEND_ISR,
99 USBRESET_ISR,
100 HISPEED_ISR,
101 EP0ACK_ISR,
102 EP0IN_ISR,
103 EP0OUT_ISR,
104 EP1IN_ISR,
105 EP1OUT_ISR,
106 EP2_ISR,
107 EP4_ISR,
108 EP6_ISR,
109 EP8_ISR,
110 IBN_ISR,
111 EP0PING_ISR,
112 EP1PING_ISR,
113 EP2PING_ISR,
114 EP4PING_ISR,
115 EP6PING_ISR,
116 EP8PING_ISR,
117 ERRLIMIT_ISR,
118 EP2ISOERR_ISR,
119 EP4ISOERR_ISR,
120 EP6ISOERR_ISR,
121 EP8ISOERR_ISR,
122 RESERVED_ISR,
123 EP2PF_ISR,
124 EP4PF_ISR,
125 EP6PF_ISR,
126 EP8PF_ISR,
127 EP2EF_ISR,
128 EP4EF_ISR,
129 EP6EF_ISR,
130 EP8EF_ISR,
131 EP2FF_ISR,
132 EP4FF_ISR,
133 EP6FF_ISR,
134 EP8FF_ISR,
135 GPIFDONE_ISR,
136 GPIFWF_ISR
137 } USB_ISR;
139 // you must include the predef of these in the file with your main
140 // so lets just define them here
142 void sudav_isr() interrupt SUDAV_ISR;
143 void sof_isr() interrupt SOF_ISR;
144 void sutok_isr() interrupt SUTOK_ISR;
145 void suspend_isr() interrupt SUSPEND_ISR;
146 void usbreset_isr() interrupt USBRESET_ISR;
147 void hispeed_isr() interrupt HISPEED_ISR;
148 void ep0ack_isr() interrupt EP0ACK_ISR;
149 void ep0in_isr() interrupt EP0IN_ISR;
150 void ep0out_isr() interrupt EP0OUT_ISR;
151 void ep1in_isr() interrupt EP1IN_ISR;
152 void ep1out_isr() interrupt EP1OUT_ISR;
153 void ep2_isr() interrupt EP2_ISR;
154 void ep4_isr() interrupt EP4_ISR;
155 void ep6_isr() interrupt EP6_ISR;
156 void ep8_isr() interrupt EP8_ISR;
157 void ibn_isr() interrupt IBN_ISR;
158 void ep0ping_isr() interrupt EP0PING_ISR;
159 void ep1ping_isr() interrupt EP1PING_ISR;
160 void ep2ping_isr() interrupt EP2PING_ISR;
161 void ep4ping_isr() interrupt EP4PING_ISR;
162 void ep6ping_isr() interrupt EP6PING_ISR;
163 void ep8ping_isr() interrupt EP8PING_ISR;
164 void errlimit_isr() interrupt ERRLIMIT_ISR;
165 void ep2isoerr_isr() interrupt EP2ISOERR_ISR;
166 void ep4isoerr_isr() interrupt EP4ISOERR_ISR;
167 void ep6isoerr_isr() interrupt EP6ISOERR_ISR;
168 void ep8isoerr_isr() interrupt EP8ISOERR_ISR;
169 void spare_isr() interrupt RESERVED_ISR; // not used
170 // gpif ints
171 void ep2pf_isr() interrupt EP2PF_ISR;
172 void ep4pf_isr() interrupt EP4PF_ISR;
173 void ep6pf_isr() interrupt EP6PF_ISR;
174 void ep8pf_isr() interrupt EP8PF_ISR;
175 void ep2ef_isr() interrupt EP2EF_ISR;
176 void ep4ef_isr() interrupt EP4EF_ISR;
177 void ep6ef_isr() interrupt EP6EF_ISR;
178 void ep8ef_isr() interrupt EP8EF_ISR;
179 void ep2ff_isr() interrupt EP2FF_ISR;
180 void ep4ff_isr() interrupt EP4FF_ISR;
181 void ep6ff_isr() interrupt EP6FF_ISR;
182 void ep8ff_isr() interrupt EP8FF_ISR;
183 void gpifdone_isr() interrupt GPIFDONE_ISR;
184 void gpifwf_isr() interrupt GPIFWF_ISR;
187 // and for ease, here is a quick section you can copy paste
188 // into your own code somewhere
191 void sudav_isr() interrupt SUDAV_ISR {}
192 void sof_isr() interrupt SOF_ISR {}
193 void sutok_isr() interrupt SUTOK_ISR {}
194 void suspend_isr() interrupt SUSPEND_ISR {}
195 void usbreset_isr() interrupt USBRESET_ISR {}
196 void hispeed_isr() interrupt HISPEED_ISR {}
197 void ep0ack_isr() interrupt EP0ACK_ISR {}
198 void ep0in_isr() interrupt EP0IN_ISR {}
199 void ep0out_isr() interrupt EP0OUT_ISR {}
200 void ep1in_isr() interrupt EP1IN_ISR {}
201 void ep1out_isr() interrupt EP1OUT_ISR {}
202 void ep2_isr() interrupt EP2_ISR {}
203 void ep4_isr() interrupt EP4_ISR {}
204 void ep6_isr() interrupt EP6_ISR {}
205 void ep8_isr() interrupt EP8_ISR {}
206 void ibn_isr() interrupt IBN_ISR {}
207 void ep0ping_isr() interrupt EP0PING_ISR {}
208 void ep1ping_isr() interrupt EP1PING_ISR {}
209 void ep2ping_isr() interrupt EP2PING_ISR {}
210 void ep4ping_isr() interrupt EP4PING_ISR {}
211 void ep6ping_isr() interrupt EP6PING_ISR {}
212 void ep8ping_isr() interrupt EP8PING_ISR {}
213 void errlimit_isr() interrupt ERRLIMIT_ISR {}
214 void ep2isoerr_isr() interrupt EP2ISOERR_ISR {}
215 void ep4isoerr_isr() interrupt EP4ISOERR_ISR {}
216 void ep6isoerr_isr() interrupt EP6ISOERR_ISR {}
217 void ep8isoerr_isr() interrupt EP8ISOERR_ISR {}
218 void spare_isr() interrupt RESERVED_ISR {}
219 void ep2pf_isr() interrupt EP2PF_ISR{}
220 void ep4pf_isr() interrupt EP4PF_ISR{}
221 void ep6pf_isr() interrupt EP6PF_ISR{}
222 void ep8pf_isr() interrupt EP8PF_ISR{}
223 void ep2ef_isr() interrupt EP2EF_ISR{}
224 void ep4ef_isr() interrupt EP4EF_ISR{}
225 void ep6ef_isr() interrupt EP6EF_ISR{}
226 void ep8ef_isr() interrupt EP8EF_ISR{}
227 void ep2ff_isr() interrupt EP2FF_ISR{}
228 void ep4ff_isr() interrupt EP4FF_ISR{}
229 void ep6ff_isr() interrupt EP6FF_ISR{}
230 void ep8ff_isr() interrupt EP8FF_ISR{}
231 void gpifdone_isr() interrupt GPIFDONE_ISR{}
232 void gpifwf_isr() interrupt GPIFWF_ISR{}
236 #endif