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, see <http://www.gnu.org/licenses/>.
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.
24 * -Wl"-b INT2JT = 0x1A00"
26 * Make sure that INT2JT doesn't overlap your other code!
28 * Unlike the standard fx2 interrupts (\ref fx2ints.h), the autovectored
29 * interrupts are defined in assemply and have pre-written function names.
30 * Be sure to override the functions defined in this header or your
31 * interrupt handler will not be called.
41 // this causes usbjt to be included from the lib
42 // not used for anything
43 extern volatile BYTE INT2JT;
44 extern volatile BYTE INT4JT;
46 * Enable all interrupts (EA=1) separate from this macro.
47 * This macro causes the autovector assembly for int2 interrupts
48 * to be overlayed at 0x43. In addition, the jump table for the
49 * interrupts will be included in the firmware. The jump table
50 * must lie on a page boundary. This is done by passing the linker
54 * sdcc <files> -Wl"-b INT2JT = 0xaddr"
57 #define USE_USB_INTS() {BYTE dummy=INT2JT;\
60 /** This macro causes the autovector assemby for int4 to be overlayed
61 * at 0x53. Don't use this if you want external pin generated int4 interrupts
62 * and want to define your own interrupt handler. It is possible to use
63 * usb interrupts with autovectoring and not use GPIF interrupts but GPIF
64 * interrupts require the USB jump table. (You can't USE your own usb interrupt
65 * handler if you want to enable GPIF interrupts.)
67 #define USE_GPIF_INTS() {BYTE dummy=INT4JT;\
69 INTSETUP|=bmAV4EN|INT4IN;}
73 #define CLEAR_USBINT() EXIF &= ~0x10
74 #define CLEAR_GPIF() EXIF &= ~0x40
76 #define ENABLE_SUDAV() USBIE|=bmSUDAV
77 #define CLEAR_SUDAV() CLEAR_USBINT(); USBIRQ=bmSUDAV
79 #define ENABLE_SUTOK() USBIE|=bmSUTOK;
80 #define CLEAR_SUTOK() CLEAR_USBINT(); USBIRQ=bmSUTOK
82 #define ENABLE_SOF() USBIE|=bmSOF
83 #define CLEAR_SOF() CLEAR_USBINT(); USBIRQ=bmSOF
85 #define ENABLE_SUSPEND() USBIE|=bmSUSP
86 #define CLEAR_SUSPEND() CLEAR_USBINT(); USBIRQ=bmSUSP
88 #define ENABLE_USBRESET() USBIE|= bmURES
89 #define CLEAR_USBRESET() CLEAR_USBINT(); USBIRQ=bmURES
91 #define ENABLE_HISPEED() USBIE|=bmHSGRANT
92 #define CLEAR_HISPEED() CLEAR_USBINT(); USBIRQ=bmHSGRANT
94 #define ENABLE_EP1IN() EPIE|=bmEP1IN
95 #define CLEAR_EP1IN() CLEAR_USBINT(); EPIRQ=bmEP1IN
97 #define ENABLE_EP2() EPIE|=bmEP2
98 #define CLEAR_EP2() CLEAR_USBINT(); EPIRQ=bmEP2
100 #define ENABLE_EP6() EPIE|=bmEP6
101 #define CLEAR_EP6() CLEAR_USBINT(); EPIRQ=bmEP6
103 #define ENABLE_EP2ISOERR() USBERRIE |= bmISOEP2
104 #define CLEAR_EP2ISOERR() CLEAR_USBINT(); USBERRIRQ = bmISOEP2
106 #define ENABLE_EP6PF() EP6FIFOIE |= bmBIT2
107 #define CLEAR_EP6PF() CLEAR_GPIF(); EP6FIFOIRQ=bmBIT2
109 #define ENABLE_EP6FF() EP6FIFOIE |= bmBIT0
110 #define CLEAR_EP6FF() CLEAR_GPIF(); EP6FIFOIRQ=bmBIT0
112 #define ENABLE_GPIFDONE() GPIFIE |= 0x01;
113 #define CLEAR_GPIFDONE() CLEAR_GPIF(); GPIFIRQ = 0x01;
115 #define ENABLE_GPIFWF() GPIFIE |= 0x02;
116 #define CLEAR_GPIFWF() GLEAR_GPIF(); GPIFIRQ = 0x02;
118 #define ENABLE_IBN() NAKIE |= bmIBN;
119 #define ENABLE_EP2IBN() ENABLE_IBN(); IBNIE |= bmEP2IBN;
122 * ez-usb has 12 built in ISRs, to get
123 * sdcc to put these USB ISRs immediately
124 * after the other ISRs (and not waste space)
172 // you must include the predef of these in the file with your main
173 // so lets just define them here
175 void sudav_isr(void) __interrupt(SUDAV_ISR);
176 void sof_isr(void) __interrupt(SOF_ISR);
177 void sutok_isr(void) __interrupt(SUTOK_ISR);
178 void suspend_isr(void) __interrupt(SUSPEND_ISR);
179 void usbreset_isr(void) __interrupt(USBRESET_ISR);
180 void hispeed_isr(void) __interrupt(HISPEED_ISR);
181 void ep0ack_isr(void) __interrupt(EP0ACK_ISR);
182 void ep0in_isr(void) __interrupt(EP0IN_ISR);
183 void ep0out_isr(void) __interrupt(EP0OUT_ISR);
184 void ep1in_isr(void) __interrupt(EP1IN_ISR);
185 void ep1out_isr(void) __interrupt(EP1OUT_ISR);
186 void ep2_isr(void) __interrupt(EP2_ISR);
187 void ep4_isr(void) __interrupt(EP4_ISR);
188 void ep6_isr(void) __interrupt(EP6_ISR);
189 void ep8_isr(void) __interrupt(EP8_ISR);
190 void ibn_isr(void) __interrupt(IBN_ISR);
191 void ep0ping_isr(void) __interrupt(EP0PING_ISR);
192 void ep1ping_isr(void) __interrupt(EP1PING_ISR);
193 void ep2ping_isr(void) __interrupt(EP2PING_ISR);
194 void ep4ping_isr(void) __interrupt(EP4PING_ISR);
195 void ep6ping_isr(void) __interrupt(EP6PING_ISR);
196 void ep8ping_isr(void) __interrupt(EP8PING_ISR);
197 void errlimit_isr(void) __interrupt(ERRLIMIT_ISR);
198 void ep2isoerr_isr(void) __interrupt(EP2ISOERR_ISR);
199 void ep4isoerr_isr(void) __interrupt(EP4ISOERR_ISR);
200 void ep6isoerr_isr(void) __interrupt(EP6ISOERR_ISR);
201 void ep8isoerr_isr(void) __interrupt(EP8ISOERR_ISR);
202 void spare_isr(void) __interrupt(RESERVED_ISR); // not used
204 void ep2pf_isr(void) __interrupt(EP2PF_ISR);
205 void ep4pf_isr(void) __interrupt(EP4PF_ISR);
206 void ep6pf_isr(void) __interrupt(EP6PF_ISR);
207 void ep8pf_isr(void) __interrupt(EP8PF_ISR);
208 void ep2ef_isr(void) __interrupt(EP2EF_ISR);
209 void ep4ef_isr(void) __interrupt(EP4EF_ISR);
210 void ep6ef_isr(void) __interrupt(EP6EF_ISR);
211 void ep8ef_isr(void) __interrupt(EP8EF_ISR);
212 void ep2ff_isr(void) __interrupt(EP2FF_ISR);
213 void ep4ff_isr(void) __interrupt(EP4FF_ISR);
214 void ep6ff_isr(void) __interrupt(EP6FF_ISR);
215 void ep8ff_isr(void) __interrupt(EP8FF_ISR);
216 void gpifdone_isr(void) __interrupt(GPIFDONE_ISR);
217 void gpifwf_isr(void) __interrupt(GPIFWF_ISR);