fxload fx2lp dev board
[fx2fw-sdcc] / fx2 / syncdelay.h
1 /* -*- c++ -*- */\r
2 /*-----------------------------------------------------------------------------\r
3  * Synchronization delay for FX2 access to specific registers\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 _SYNCDELAY_H_\r
22 #define _SYNCDELAY_H_\r
23 \r
24 /*\r
25  * Magic delay required between access to certain xdata registers (TRM page 15-106).\r
26  * For our configuration, 48 MHz FX2 / 48 MHz IFCLK, we need three cycles.  Each\r
27  * NOP is a single cycle....\r
28  *\r
29  * From TRM page 15-105:\r
30  *\r
31  * Under certain conditions, some read and write access to the FX2 registers must\r
32  * be separated by a "synchronization delay".  The delay is necessary only under the\r
33  * following conditions:\r
34  *\r
35  *   - between a write to any register in the 0xE600 - 0xE6FF range and a write to one\r
36  *     of the registers listed below.\r
37  *\r
38  *   - between a write to one of the registers listed below and a read from any register\r
39  *     in the 0xE600 - 0xE6FF range.\r
40  *\r
41  *   Registers which require a synchronization delay:\r
42  *\r
43  *      FIFORESET                       FIFOPINPOLAR\r
44  *      INPKTEND                        EPxBCH:L\r
45  *      EPxFIFOPFH:L                    EPxAUTOINLENH:L\r
46  *      EPxFIFOCFG                      EPxGPIFFLGSEL\r
47  *      PINFLAGSAB                      PINFLAGSCD\r
48  *      EPxFIFOIE                       EPxFIFOIRQ\r
49  *      GPIFIE                          GPIFIRQ\r
50  *      UDMACRCH:L                      GPIFADRH:L\r
51  *      GPIFTRIG                        EPxGPIFTRIG\r
52  *      OUTPKTEND                       REVCTL\r
53  *      GPIFTCB3                        GPIFTCB2\r
54  *      GPIFTCB1                        GPIFTCB0\r
55  */\r
56 \r
57 /*\r
58  * FIXME ensure that the peep hole optimizer isn't screwing us\r
59  */\r
60 #define SYNCDELAY       _asm nop; nop; nop; _endasm\r
61 #define NOP             _asm nop; _endasm\r
62 \r
63 \r
64 #endif /* _SYNCDELAY_H_ */\r