make comportable with SDCC 3.9.0 (sdcclib was replaced with sdar utility
[fx2lib.git] / include / autovector.h
blobc58677c10d1ee57e9ba18b06e01d1a0b79e3c2b0
1 // Copyright (C) 2010 Ubixum, Inc.
2 //
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.
7 //
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
19 /** \file usbjt.h
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.
24 * example:
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.
33 **/
35 #ifndef USBJT_H
36 #define USBJT_H
38 #include "fx2regs.h"
41 /**
42 * Enable all interrupts (EA=1) separate from this macro.
43 * This macro causes the autovector assembly for int2 interrupts
44 * to be overlayed at 0x43. In addition, the jump table for the
45 * interrupts will be included in the firmware. The jump table
46 * must lie on a page boundary. This is done by passing the linker
47 * arguments to sdcc.
49 * \code
50 * sdcc <files> -Wl"-b INT2JT = 0xaddr"
51 * \endcode
52 **/
53 #define USE_USB_INTS() {EUSB=1;\
54 INTSETUP|=bmAV2EN;}
55 /** This macro causes the autovector assemby for int4 to be overlayed
56 * at 0x53. Don't use this if you want external pin generated int4 interrupts
57 * and want to define your own interrupt handler. It is possible to use
58 * usb interrupts with autovectoring and not use GPIF interrupts but GPIF
59 * interrupts require the USB jump table. (You can't USE your own usb interrupt
60 * handler if you want to enable GPIF interrupts.)
61 **/
62 #define USE_GPIF_INTS() {EIEX4=1;\
63 INTSETUP|=bmAV4EN|INT4IN;}
66 #define CLEAR_USBINT() EXIF &= ~0x10
67 #define CLEAR_GPIF() EXIF &= ~0x40
69 #define ENABLE_SUDAV() USBIE|=bmSUDAV
70 #define CLEAR_SUDAV() CLEAR_USBINT(); USBIRQ=bmSUDAV
72 #define ENABLE_SUTOK() USBIE|=bmSUTOK;
73 #define CLEAR_SUTOK() CLEAR_USBINT(); USBIRQ=bmSUTOK
75 #define ENABLE_SOF() USBIE|=bmSOF
76 #define CLEAR_SOF() CLEAR_USBINT(); USBIRQ=bmSOF
78 #define ENABLE_SUSPEND() USBIE|=bmSUSP
79 #define CLEAR_SUSPEND() CLEAR_USBINT(); USBIRQ=bmSUSP
81 #define ENABLE_USBRESET() USBIE|= bmURES
82 #define CLEAR_USBRESET() CLEAR_USBINT(); USBIRQ=bmURES
84 #define ENABLE_HISPEED() USBIE|=bmHSGRANT
85 #define CLEAR_HISPEED() CLEAR_USBINT(); USBIRQ=bmHSGRANT
87 #define ENABLE_EP0IN() EPIE|=bmEP0IN
88 #define CLEAR_EP0IN() CLEAR_USBINT(); EPIRQ=bmEP0IN
90 #define ENABLE_EP0OUT() EPIE|=bmEP0OUT
91 #define CLEAR_EP0OUT() CLEAR_USBINT(); EPIRQ=bmEP0OUT
93 #define ENABLE_EP1IN() EPIE|=bmEP1IN
94 #define CLEAR_EP1IN() CLEAR_USBINT(); EPIRQ=bmEP1IN
96 #define ENABLE_EP1OUT() EPIE|=bmEP1OUT
97 #define CLEAR_EP1OUT() CLEAR_USBINT(); EPIRQ=bmEP1OUT
99 #define ENABLE_EP2() EPIE|=bmEP2
100 #define CLEAR_EP2() CLEAR_USBINT(); EPIRQ=bmEP2
102 #define ENABLE_EP4() EPIE|=bmEP4
103 #define CLEAR_EP4() CLEAR_USBINT(); EPIRQ=bmEP4
105 #define ENABLE_EP6() EPIE|=bmEP6
106 #define CLEAR_EP6() CLEAR_USBINT(); EPIRQ=bmEP6
108 #define ENABLE_EP8() EPIE|=bmEP8
109 #define CLEAR_EP8() CLEAR_USBINT(); EPIRQ=bmEP8
111 #define ENABLE_EP2ISOERR() USBERRIE |= bmISOEP2
112 #define CLEAR_EP2ISOERR() CLEAR_USBINT(); USBERRIRQ = bmISOEP2
114 #define ENABLE_EP6PF() EP6FIFOIE |= bmBIT2
115 #define CLEAR_EP6PF() CLEAR_GPIF(); EP6FIFOIRQ=bmBIT2
117 #define ENABLE_EP6FF() EP6FIFOIE |= bmBIT0
118 #define CLEAR_EP6FF() CLEAR_GPIF(); EP6FIFOIRQ=bmBIT0
120 #define ENABLE_GPIFDONE() GPIFIE |= 0x01;
121 #define CLEAR_GPIFDONE() CLEAR_GPIF(); GPIFIRQ = 0x01;
123 #define ENABLE_GPIFWF() GPIFIE |= 0x02;
124 #define CLEAR_GPIFWF() GLEAR_GPIF(); GPIFIRQ = 0x02;
127 * ez-usb has 12 built in ISRs, to get
128 * sdcc to put these USB ISRs immediately
129 * after the other ISRs (and not waste space)
130 * we start at 13
132 typedef enum {
133 SUDAV_ISR=13,
134 SOF_ISR,
135 SUTOK_ISR,
136 SUSPEND_ISR,
137 USBRESET_ISR,
138 HISPEED_ISR,
139 EP0ACK_ISR,
140 EP0IN_ISR,
141 EP0OUT_ISR,
142 EP1IN_ISR,
143 EP1OUT_ISR,
144 EP2_ISR,
145 EP4_ISR,
146 EP6_ISR,
147 EP8_ISR,
148 IBN_ISR,
149 EP0PING_ISR,
150 EP1PING_ISR,
151 EP2PING_ISR,
152 EP4PING_ISR,
153 EP6PING_ISR,
154 EP8PING_ISR,
155 ERRLIMIT_ISR,
156 EP2ISOERR_ISR,
157 EP4ISOERR_ISR,
158 EP6ISOERR_ISR,
159 EP8ISOERR_ISR,
160 RESERVED_ISR,
161 EP2PF_ISR,
162 EP4PF_ISR,
163 EP6PF_ISR,
164 EP8PF_ISR,
165 EP2EF_ISR,
166 EP4EF_ISR,
167 EP6EF_ISR,
168 EP8EF_ISR,
169 EP2FF_ISR,
170 EP4FF_ISR,
171 EP6FF_ISR,
172 EP8FF_ISR,
173 GPIFDONE_ISR,
174 GPIFWF_ISR
175 } USB_ISR;
177 // you must include the predef of these in the file with your main
178 // so lets just define them here
180 void usb_isr(void) __interrupt (8);
181 void sudav_isr() __interrupt;
182 void sof_isr() __interrupt;
183 void sutok_isr() __interrupt;
184 void suspend_isr() __interrupt;
185 void usbreset_isr() __interrupt;
186 void hispeed_isr() __interrupt;
187 void ep0ack_isr() __interrupt;
188 void ep0in_isr() __interrupt;
189 void ep0out_isr() __interrupt;
190 void ep1in_isr() __interrupt;
191 void ep1out_isr() __interrupt;
192 void ep2_isr() __interrupt;
193 void ep4_isr() __interrupt;
194 void ep6_isr() __interrupt;
195 void ep8_isr() __interrupt;
196 void ibn_isr() __interrupt;
197 void ep0ping_isr() __interrupt;
198 void ep1ping_isr() __interrupt;
199 void ep2ping_isr() __interrupt;
200 void ep4ping_isr() __interrupt;
201 void ep6ping_isr() __interrupt;
202 void ep8ping_isr() __interrupt;
203 void errlimit_isr() __interrupt;
204 void ep2isoerr_isr() __interrupt;
205 void ep4isoerr_isr() __interrupt;
206 void ep6isoerr_isr() __interrupt;
207 void ep8isoerr_isr() __interrupt;
208 void spare_isr() __interrupt; // not used
209 // gpif ints
210 void gpif_isr(void) __interrupt (10);
211 void ep2pf_isr() __interrupt;
212 void ep4pf_isr() __interrupt;
213 void ep6pf_isr() __interrupt;
214 void ep8pf_isr() __interrupt;
215 void ep2ef_isr() __interrupt;
216 void ep4ef_isr() __interrupt;
217 void ep6ef_isr() __interrupt;
218 void ep8ef_isr() __interrupt;
219 void ep2ff_isr() __interrupt;
220 void ep4ff_isr() __interrupt;
221 void ep6ff_isr() __interrupt;
222 void ep8ff_isr() __interrupt;
223 void gpifdone_isr() __interrupt;
224 void gpifwf_isr() __interrupt;
226 #endif