]> sigrok.org Git - sigrok-firmware-fx2lafw.git/blame - fx2lib/include/autovector.h
fx2lafw: add definitions for IBN (IN BULK NAK) interrupt
[sigrok-firmware-fx2lafw.git] / fx2lib / include / autovector.h
CommitLineData
3608c106
UH
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.
12//
13// You should have received a copy of the GNU Lesser General Public
040a6eae 14// License along with this library; if not, see <http://www.gnu.org/licenses/>.
3608c106
UH
15
16
17
18/** \file usbjt.h
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.
22 *
23 * example:
24 * -Wl"-b INT2JT = 0x1A00"
25 *
26 * Make sure that INT2JT doesn't overlap your other code!
27 *
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.
32 **/
33
34#ifndef USBJT_H
35#define USBJT_H
36
37#include "fx2regs.h"
38
39
40
41// this causes usbjt to be included from the lib
42// not used for anything
43extern volatile BYTE INT2JT;
44extern volatile BYTE INT4JT;
45/**
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
51 * arguments to sdcc.
52 *
53 * \code
54 * sdcc <files> -Wl"-b INT2JT = 0xaddr"
55 * \endcode
56 **/
57#define USE_USB_INTS() {BYTE dummy=INT2JT;\
58 EUSB=1;\
59 INTSETUP|=bmAV2EN;}
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.)
66 **/
67#define USE_GPIF_INTS() {BYTE dummy=INT4JT;\
68 EIEX4=1;\
69 INTSETUP|=bmAV4EN|INT4IN;}
70
71
72
73#define CLEAR_USBINT() EXIF &= ~0x10
74#define CLEAR_GPIF() EXIF &= ~0x40
75
76#define ENABLE_SUDAV() USBIE|=bmSUDAV
77#define CLEAR_SUDAV() CLEAR_USBINT(); USBIRQ=bmSUDAV
78
79#define ENABLE_SUTOK() USBIE|=bmSUTOK;
80#define CLEAR_SUTOK() CLEAR_USBINT(); USBIRQ=bmSUTOK
81
82#define ENABLE_SOF() USBIE|=bmSOF
83#define CLEAR_SOF() CLEAR_USBINT(); USBIRQ=bmSOF
84
85#define ENABLE_SUSPEND() USBIE|=bmSUSP
86#define CLEAR_SUSPEND() CLEAR_USBINT(); USBIRQ=bmSUSP
87
88#define ENABLE_USBRESET() USBIE|= bmURES
89#define CLEAR_USBRESET() CLEAR_USBINT(); USBIRQ=bmURES
90
91#define ENABLE_HISPEED() USBIE|=bmHSGRANT
92#define CLEAR_HISPEED() CLEAR_USBINT(); USBIRQ=bmHSGRANT
93
94#define ENABLE_EP1IN() EPIE|=bmEP1IN
95#define CLEAR_EP1IN() CLEAR_USBINT(); EPIRQ=bmEP1IN
96
97#define ENABLE_EP2() EPIE|=bmEP2
98#define CLEAR_EP2() CLEAR_USBINT(); EPIRQ=bmEP2
99
100#define ENABLE_EP6() EPIE|=bmEP6
101#define CLEAR_EP6() CLEAR_USBINT(); EPIRQ=bmEP6
102
103#define ENABLE_EP2ISOERR() USBERRIE |= bmISOEP2
104#define CLEAR_EP2ISOERR() CLEAR_USBINT(); USBERRIRQ = bmISOEP2
105
106#define ENABLE_EP6PF() EP6FIFOIE |= bmBIT2
107#define CLEAR_EP6PF() CLEAR_GPIF(); EP6FIFOIRQ=bmBIT2
108
109#define ENABLE_EP6FF() EP6FIFOIE |= bmBIT0
110#define CLEAR_EP6FF() CLEAR_GPIF(); EP6FIFOIRQ=bmBIT0
111
112#define ENABLE_GPIFDONE() GPIFIE |= 0x01;
113#define CLEAR_GPIFDONE() CLEAR_GPIF(); GPIFIRQ = 0x01;
114
115#define ENABLE_GPIFWF() GPIFIE |= 0x02;
116#define CLEAR_GPIFWF() GLEAR_GPIF(); GPIFIRQ = 0x02;
117
edf37359
SB
118#define ENABLE_IBN() NAKIE |= bmIBN;
119#define ENABLE_EP2IBN() ENABLE_IBN(); IBNIE |= bmEP2IBN;
120
3608c106
UH
121/**
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)
125 * we start at 13
126 **/
127typedef enum {
128 SUDAV_ISR=13,
129 SOF_ISR,
130 SUTOK_ISR,
131 SUSPEND_ISR,
132 USBRESET_ISR,
133 HISPEED_ISR,
134 EP0ACK_ISR,
135 EP0IN_ISR,
136 EP0OUT_ISR,
137 EP1IN_ISR,
138 EP1OUT_ISR,
139 EP2_ISR,
140 EP4_ISR,
141 EP6_ISR,
142 EP8_ISR,
143 IBN_ISR,
144 EP0PING_ISR,
145 EP1PING_ISR,
146 EP2PING_ISR,
147 EP4PING_ISR,
148 EP6PING_ISR,
149 EP8PING_ISR,
150 ERRLIMIT_ISR,
151 EP2ISOERR_ISR,
152 EP4ISOERR_ISR,
153 EP6ISOERR_ISR,
154 EP8ISOERR_ISR,
155 RESERVED_ISR,
156 EP2PF_ISR,
157 EP4PF_ISR,
158 EP6PF_ISR,
159 EP8PF_ISR,
160 EP2EF_ISR,
161 EP4EF_ISR,
162 EP6EF_ISR,
163 EP8EF_ISR,
164 EP2FF_ISR,
165 EP4FF_ISR,
166 EP6FF_ISR,
167 EP8FF_ISR,
168 GPIFDONE_ISR,
169 GPIFWF_ISR
170} USB_ISR;
171
172// you must include the predef of these in the file with your main
173// so lets just define them here
174
175void sudav_isr() __interrupt SUDAV_ISR;
176void sof_isr() __interrupt SOF_ISR;
177void sutok_isr() __interrupt SUTOK_ISR;
178void suspend_isr() __interrupt SUSPEND_ISR;
179void usbreset_isr() __interrupt USBRESET_ISR;
180void hispeed_isr() __interrupt HISPEED_ISR;
181void ep0ack_isr() __interrupt EP0ACK_ISR;
182void ep0in_isr() __interrupt EP0IN_ISR;
183void ep0out_isr() __interrupt EP0OUT_ISR;
184void ep1in_isr() __interrupt EP1IN_ISR;
185void ep1out_isr() __interrupt EP1OUT_ISR;
186void ep2_isr() __interrupt EP2_ISR;
187void ep4_isr() __interrupt EP4_ISR;
188void ep6_isr() __interrupt EP6_ISR;
189void ep8_isr() __interrupt EP8_ISR;
190void ibn_isr() __interrupt IBN_ISR;
191void ep0ping_isr() __interrupt EP0PING_ISR;
192void ep1ping_isr() __interrupt EP1PING_ISR;
193void ep2ping_isr() __interrupt EP2PING_ISR;
194void ep4ping_isr() __interrupt EP4PING_ISR;
195void ep6ping_isr() __interrupt EP6PING_ISR;
196void ep8ping_isr() __interrupt EP8PING_ISR;
197void errlimit_isr() __interrupt ERRLIMIT_ISR;
198void ep2isoerr_isr() __interrupt EP2ISOERR_ISR;
199void ep4isoerr_isr() __interrupt EP4ISOERR_ISR;
200void ep6isoerr_isr() __interrupt EP6ISOERR_ISR;
201void ep8isoerr_isr() __interrupt EP8ISOERR_ISR;
202void spare_isr() __interrupt RESERVED_ISR; // not used
203// gpif ints
204void ep2pf_isr() __interrupt EP2PF_ISR;
205void ep4pf_isr() __interrupt EP4PF_ISR;
206void ep6pf_isr() __interrupt EP6PF_ISR;
207void ep8pf_isr() __interrupt EP8PF_ISR;
208void ep2ef_isr() __interrupt EP2EF_ISR;
209void ep4ef_isr() __interrupt EP4EF_ISR;
210void ep6ef_isr() __interrupt EP6EF_ISR;
211void ep8ef_isr() __interrupt EP8EF_ISR;
212void ep2ff_isr() __interrupt EP2FF_ISR;
213void ep4ff_isr() __interrupt EP4FF_ISR;
214void ep6ff_isr() __interrupt EP6FF_ISR;
215void ep8ff_isr() __interrupt EP8FF_ISR;
216void gpifdone_isr() __interrupt GPIFDONE_ISR;
217void gpifwf_isr() __interrupt GPIFWF_ISR;
218
219#endif
220