fxload fx2lp dev board
[fx2fw-sdcc] / fx2 / usb_common.h
1 /* -*- c++ -*- */\r
2 /*-----------------------------------------------------------------------------\r
3  * Common USB code for FX2\r
4  *-----------------------------------------------------------------------------\r
5  * Code taken from USRP2 firmware (GNU Radio Project), version 3.0.2,\r
6  * Copyright 2003 Free Software Foundation, Inc.\r
7  *-----------------------------------------------------------------------------\r
8  * This code is part of usbjtag. usbjtag is free software; you can redistribute\r
9  * it and/or modify it under the terms of the GNU General Public License as\r
10  * published by the Free Software Foundation; either version 2 of the License,\r
11  * or (at your option) any later version. usbjtag is distributed in the hope\r
12  * that it will be useful, but WITHOUT ANY WARRANTY; without even the implied\r
13  * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14  * GNU General Public License for more details.  You should have received a\r
15  * copy of the GNU General Public License along with this program in the file\r
16  * COPYING; if not, write to the Free Software Foundation, Inc., 51 Franklin\r
17  * St, Fifth Floor, Boston, MA  02110-1301  USA\r
18  *-----------------------------------------------------------------------------\r
19  */\r
20 \r
21 #ifndef _USB_COMMON_H_\r
22 #define _USB_COMMON_H_\r
23 \r
24 #define bit __bit\r
25 \r
26 #define bRequestType    SETUPDAT[0]\r
27 #define bRequest        SETUPDAT[1]\r
28 #define wValueL         SETUPDAT[2]\r
29 #define wValueH         SETUPDAT[3]\r
30 #define wIndexL         SETUPDAT[4]\r
31 #define wIndexH         SETUPDAT[5]\r
32 #define wLengthL        SETUPDAT[6]\r
33 #define wLengthH        SETUPDAT[7]\r
34 \r
35 #define MSB(x)  (((unsigned short) x) >> 8)\r
36 #define LSB(x)  (((unsigned short) x) & 0xff)\r
37 \r
38 extern volatile bit _usb_got_SUDAV;\r
39 \r
40 // Provided by user application to report device status.\r
41 // returns non-zero if it handled the command.\r
42 unsigned char app_get_status (void);\r
43 // Provided by user application to handle VENDOR commands.\r
44 // returns non-zero if it handled the command.\r
45 unsigned char app_vendor_cmd (void);\r
46 \r
47 void usb_install_handlers (void);\r
48 void usb_handle_setup_packet (void);\r
49 \r
50 #define usb_setup_packet_avail()        _usb_got_SUDAV\r
51 \r
52 #endif /* _USB_COMMON_H_ */\r