summaryrefslogtreecommitdiffstats
path: root/fpga/xilinx/programmer/dependencies/libxsvf/xsvftool-xpcu.src/fx2sdly.h
blob: b4835c5e363dedddccf11ef610c51af542d2d1ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
// **** Auto-generated using genfx2hrd.sh from CY3684 EZ USB FX2LP Development Kit headers
//-----------------------------------------------------------------------------
//   File:      fx2sdly.h
//   Contents:  EZ-USB FX2 Synchronization Delay (SYNCDELAY) Macro
//				
//	 Enter with _IFREQ = IFCLK in kHz
//	 Enter with _CFREQ = CLKOUT in kHz
//
//   Copyright (c) 2001 Cypress Semiconductor, All rights reserved
//-----------------------------------------------------------------------------
#define _nop_() do { _asm nop; _endasm; } while(0)

  // Registers which require a synchronization delay, see section 15.14
  // FIFORESET        FIFOPINPOLAR
  // INPKTEND         OUTPKTEND
  // EPxBCH:L         REVCTL
  // GPIFTCB3         GPIFTCB2
  // GPIFTCB1         GPIFTCB0
  // EPxFIFOPFH:L     EPxAUTOINLENH:L
  // EPxFIFOCFG       EPxGPIFFLGSEL
  // PINFLAGSxx       EPxFIFOIRQ
  // EPxFIFOIE        GPIFIRQ
  // GPIFIE           GPIFADRH:L
  // UDMACRCH:L       EPxGPIFTRIG
  // GPIFTRIG
  
  // Note: The pre-REVE EPxGPIFTCH/L register are affected, as well...
  //      ...these have been replaced by GPIFTC[B3:B0] registers

// _IFREQ can be in the range of: 5000 to 48000
#ifndef _IFREQ 
#define _IFREQ 48000   // IFCLK frequency in kHz
#endif

// CFREQ can be any one of: 48000, 24000, or 12000
#ifndef _CFREQ
#define _CFREQ 48000   // CLKOUT frequency in kHz
#endif

#if( _IFREQ < 5000 )
#error "_IFREQ too small!  Valid Range: 5000 to 48000..."
#endif

#if( _IFREQ > 48000 )
#error "_IFREQ too large!  Valid Range: 5000 to 48000..."
#endif

#if( _CFREQ != 48000 )
#if( _CFREQ != 24000 )
#if( _CFREQ != 12000 )
#error "_CFREQ invalid!  Valid values: 48000, 24000, 12000..."
#endif
#endif
#endif

// Synchronization Delay formula: see TRM section 15-14
#define _SCYCL ( 3*(_CFREQ) + 5*(_IFREQ) - 1 ) / ( 2*(_IFREQ) )

#if( _SCYCL == 1 )
#define SYNCDELAY _nop_( )
#endif

#if( _SCYCL == 2 )
#define SYNCDELAY _nop_( ); \
                  _nop_( )
#endif

#if( _SCYCL == 3 )
#define SYNCDELAY _nop_( ); \
                  _nop_( ); \
                  _nop_( ) 
#endif

#if( _SCYCL == 4 )
#define SYNCDELAY _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( )
#endif

#if( _SCYCL == 5 )
#define SYNCDELAY _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( )
#endif

#if( _SCYCL == 6 )
#define SYNCDELAY _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( )
#endif

#if( _SCYCL == 7 )
#define SYNCDELAY _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( )
#endif

#if( _SCYCL == 8 )
#define SYNCDELAY _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( )
#endif

#if( _SCYCL == 9 )
#define SYNCDELAY _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( )
#endif

#if( _SCYCL == 10 )
#define SYNCDELAY _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( )
#endif

#if( _SCYCL == 11 )
#define SYNCDELAY _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( )
#endif

#if( _SCYCL == 12 )
#define SYNCDELAY _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( )
#endif

#if( _SCYCL == 13 )
#define SYNCDELAY _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( )
#endif

#if( _SCYCL == 14 )
#define SYNCDELAY _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( )
#endif

#if( _SCYCL == 15 )
#define SYNCDELAY _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( )
#endif

#if( _SCYCL == 16 )
#define SYNCDELAY _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( ); \
                  _nop_( )
#endif