version 4.1.0 from http://fpga4u.epfl.ch/wiki/FX2
[fx2fw-sdcc] / fx2 / usb_common.h
1 /* -*- c++ -*- */\r
2 \r
3 /*-----------------------------------------------------------------------------\r
4 \r
5  * Common USB code for FX2\r
6 \r
7  *-----------------------------------------------------------------------------\r
8 \r
9  * Code taken from USRP2 firmware (GNU Radio Project), version 3.0.2,\r
10 \r
11  * Copyright 2003 Free Software Foundation, Inc.\r
12 \r
13  *-----------------------------------------------------------------------------\r
14 \r
15  * This code is part of usbjtag. usbjtag is free software; you can redistribute\r
16 \r
17  * it and/or modify it under the terms of the GNU General Public License as\r
18 \r
19  * published by the Free Software Foundation; either version 2 of the License,\r
20 \r
21  * or (at your option) any later version. usbjtag is distributed in the hope\r
22 \r
23  * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied\r
24 \r
25  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
26 \r
27  * GNU General Public License for more details.  You should have received a\r
28 \r
29  * copy of the GNU General Public License along with this program in the file\r
30 \r
31  * COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin\r
32 \r
33  * St, Fifth Floor, Boston, MA  02110-1301  USA\r
34 \r
35  *-----------------------------------------------------------------------------\r
36 \r
37  */\r
38 \r
39 \r
40 \r
41 #ifndef _USB_COMMON_H_\r
42 \r
43 #define _USB_COMMON_H_\r
44 \r
45 \r
46 \r
47 #define bRequestType    SETUPDAT[0]\r
48 \r
49 #define bRequest        SETUPDAT[1]\r
50 \r
51 #define wValueL         SETUPDAT[2]\r
52 \r
53 #define wValueH         SETUPDAT[3]\r
54 \r
55 #define wIndexL         SETUPDAT[4]\r
56 \r
57 #define wIndexH         SETUPDAT[5]\r
58 \r
59 #define wLengthL        SETUPDAT[6]\r
60 \r
61 #define wLengthH        SETUPDAT[7]\r
62 \r
63 \r
64 \r
65 #define MSB(x)  (((unsigned short) x) >> 8)\r
66 \r
67 #define LSB(x)  (((unsigned short) x) & 0xff)\r
68 \r
69 \r
70 \r
71 extern volatile bit _usb_got_SUDAV;\r
72 \r
73 \r
74 \r
75 // Provided by user application to report device status.\r
76 \r
77 // returns non-zero if it handled the command.\r
78 \r
79 unsigned char app_get_status (void);\r
80 \r
81 // Provided by user application to handle VENDOR commands.\r
82 \r
83 // returns non-zero if it handled the command.\r
84 \r
85 unsigned char app_vendor_cmd (void);\r
86 \r
87 \r
88 \r
89 void usb_install_handlers (void);\r
90 \r
91 void usb_handle_setup_packet (void);\r
92 \r
93 \r
94 \r
95 #define usb_setup_packet_avail()        _usb_got_SUDAV\r
96 \r
97 \r
98 \r
99 #endif /* _USB_COMMON_H_ */\r
100 \r