1 // Copyright (C) 2010 Ubixum, Inc.
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * To use usbjt, you must tell the linker where to put the IN2JT.
22 * It must lie on a page boundary or your interrupts won't work right.
25 * -Wl"-b INT2JT = 0x1A00"
27 * Make sure that INT2JT doesn't overlap your other code!
29 * Unlike the standard fx2 interrupts (\ref fx2ints.h), the autovectored
30 * interrupts are defined in assemply and have pre-written function names.
31 * Be sure to override the functions defined in this header or your
32 * interrupt handler will not be called.
42 // this causes usbjt to be included from the lib
43 // not used for anything
44 extern volatile BYTE INT2JT;
45 extern volatile BYTE INT4JT;
47 * Enable all interrupts (EA=1) separate from this macro.
48 * This macro causes the autovector assembly for int2 interrupts
49 * to be overlayed at 0x43. In addition, the jump table for the
50 * interrupts will be included in the firmware. The jump table
51 * must lie on a page boundary. This is done by passing the linker
55 * sdcc <files> -Wl"-b INT2JT = 0xaddr"
58 #define USE_USB_INTS() {BYTE dummy=INT2JT;\
61 /** This macro causes the autovector assemby for int4 to be overlayed
62 * at 0x53. Don't use this if you want external pin generated int4 interrupts
63 * and want to define your own interrupt handler. It is possible to use
64 * usb interrupts with autovectoring and not use GPIF interrupts but GPIF
65 * interrupts require the USB jump table. (You can't USE your own usb interrupt
66 * handler if you want to enable GPIF interrupts.)
68 #define USE_GPIF_INTS() {BYTE dummy=INT4JT;\
70 INTSETUP|=bmAV4EN|INT4IN;}
74 #define CLEAR_USBINT() EXIF &= ~0x10
75 #define CLEAR_GPIF() EXIF &= ~0x40
77 #define ENABLE_SUDAV() USBIE|=bmSUDAV
78 #define CLEAR_SUDAV() CLEAR_USBINT(); USBIRQ=bmSUDAV
80 #define ENABLE_SUTOK() USBIE|=bmSUTOK;
81 #define CLEAR_SUTOK() CLEAR_USBINT(); USBIRQ=bmSUTOK
83 #define ENABLE_SOF() USBIE|=bmSOF
84 #define CLEAR_SOF() CLEAR_USBINT(); USBIRQ=bmSOF
86 #define ENABLE_SUSPEND() USBIE|=bmSUSP
87 #define CLEAR_SUSPEND() CLEAR_USBINT(); USBIRQ=bmSUSP
89 #define ENABLE_USBRESET() USBIE|= bmURES
90 #define CLEAR_USBRESET() CLEAR_USBINT(); USBIRQ=bmURES
92 #define ENABLE_HISPEED() USBIE|=bmHSGRANT
93 #define CLEAR_HISPEED() CLEAR_USBINT(); USBIRQ=bmHSGRANT
95 #define ENABLE_EP1IN() EPIE|=bmEP1IN
96 #define CLEAR_EP1IN() CLEAR_USBINT(); EPIRQ=bmEP1IN
98 #define ENABLE_EP2() EPIE|=bmEP2
99 #define CLEAR_EP2() CLEAR_USBINT(); EPIRQ=bmEP2
101 #define ENABLE_EP6() EPIE|=bmEP6
102 #define CLEAR_EP6() CLEAR_USBINT(); EPIRQ=bmEP6
104 #define ENABLE_EP2ISOERR() USBERRIE |= bmISOEP2
105 #define CLEAR_EP2ISOERR() CLEAR_USBINT(); USBERRIRQ = bmISOEP2
107 #define ENABLE_EP6PF() EP6FIFOIE |= bmBIT2
108 #define CLEAR_EP6PF() CLEAR_GPIF(); EP6FIFOIRQ=bmBIT2
110 #define ENABLE_EP6FF() EP6FIFOIE |= bmBIT0
111 #define CLEAR_EP6FF() CLEAR_GPIF(); EP6FIFOIRQ=bmBIT0
113 #define ENABLE_GPIFDONE() GPIFIE |= 0x01;
114 #define CLEAR_GPIFDONE() CLEAR_GPIF(); GPIFIRQ = 0x01;
116 #define ENABLE_GPIFWF() GPIFIE |= 0x02;
117 #define CLEAR_GPIFWF() GLEAR_GPIF(); GPIFIRQ = 0x02;
120 * ez-usb has 12 built in ISRs, to get
121 * sdcc to put these USB ISRs immediately
122 * after the other ISRs (and not waste space)
170 // you must include the predef of these in the file with your main
171 // so lets just define them here
173 void sudav_isr() __interrupt SUDAV_ISR;
174 void sof_isr() __interrupt SOF_ISR;
175 void sutok_isr() __interrupt SUTOK_ISR;
176 void suspend_isr() __interrupt SUSPEND_ISR;
177 void usbreset_isr() __interrupt USBRESET_ISR;
178 void hispeed_isr() __interrupt HISPEED_ISR;
179 void ep0ack_isr() __interrupt EP0ACK_ISR;
180 void ep0in_isr() __interrupt EP0IN_ISR;
181 void ep0out_isr() __interrupt EP0OUT_ISR;
182 void ep1in_isr() __interrupt EP1IN_ISR;
183 void ep1out_isr() __interrupt EP1OUT_ISR;
184 void ep2_isr() __interrupt EP2_ISR;
185 void ep4_isr() __interrupt EP4_ISR;
186 void ep6_isr() __interrupt EP6_ISR;
187 void ep8_isr() __interrupt EP8_ISR;
188 void ibn_isr() __interrupt IBN_ISR;
189 void ep0ping_isr() __interrupt EP0PING_ISR;
190 void ep1ping_isr() __interrupt EP1PING_ISR;
191 void ep2ping_isr() __interrupt EP2PING_ISR;
192 void ep4ping_isr() __interrupt EP4PING_ISR;
193 void ep6ping_isr() __interrupt EP6PING_ISR;
194 void ep8ping_isr() __interrupt EP8PING_ISR;
195 void errlimit_isr() __interrupt ERRLIMIT_ISR;
196 void ep2isoerr_isr() __interrupt EP2ISOERR_ISR;
197 void ep4isoerr_isr() __interrupt EP4ISOERR_ISR;
198 void ep6isoerr_isr() __interrupt EP6ISOERR_ISR;
199 void ep8isoerr_isr() __interrupt EP8ISOERR_ISR;
200 void spare_isr() __interrupt RESERVED_ISR; // not used
202 void ep2pf_isr() __interrupt EP2PF_ISR;
203 void ep4pf_isr() __interrupt EP4PF_ISR;
204 void ep6pf_isr() __interrupt EP6PF_ISR;
205 void ep8pf_isr() __interrupt EP8PF_ISR;
206 void ep2ef_isr() __interrupt EP2EF_ISR;
207 void ep4ef_isr() __interrupt EP4EF_ISR;
208 void ep6ef_isr() __interrupt EP6EF_ISR;
209 void ep8ef_isr() __interrupt EP8EF_ISR;
210 void ep2ff_isr() __interrupt EP2FF_ISR;
211 void ep4ff_isr() __interrupt EP4FF_ISR;
212 void ep6ff_isr() __interrupt EP6FF_ISR;
213 void ep8ff_isr() __interrupt EP8FF_ISR;
214 void gpifdone_isr() __interrupt GPIFDONE_ISR;
215 void gpifwf_isr() __interrupt GPIFWF_ISR;