fxload fx2lp dev board
[fx2fw-sdcc] / fx2 / fx2utils.c
1 /* -*- c++ -*- */\r
2 /*-----------------------------------------------------------------------------\r
3  * FX2 specific subroutines\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 #include "fx2utils.h"\r
22 #include "fx2regs.h"\r
23 #include "delay.h"\r
24 \r
25 void\r
26 fx2_stall_ep0 (void)\r
27 {\r
28   EP0CS |= bmEPSTALL;\r
29 }\r
30 \r
31 void\r
32 fx2_reset_data_toggle (unsigned char ep)\r
33 {\r
34   TOGCTL = ((ep & 0x80) >> 3 | (ep & 0x0f));\r
35   TOGCTL |= bmRESETTOGGLE;\r
36 }\r
37 \r
38 void\r
39 fx2_renumerate (void)\r
40 {\r
41   USBCS |= bmDISCON | bmRENUM;\r
42 \r
43   // mdelay (1500);             // FIXME why 1.5 seconds?\r
44   mdelay (250);                 // FIXME why 1.5 seconds?\r
45   \r
46   USBIRQ = 0xff;                // clear any pending USB irqs...\r
47   EPIRQ =  0xff;                //   they're from before the renumeration\r
48 \r
49   EXIF &= ~bmEXIF_USBINT;\r
50 \r
51   USBCS &= ~bmDISCON;           // reconnect USB\r
52 }\r