📄 gpiflongxfr.lst
字号:
201 #define GPIF_EP4 1
202 #define GPIF_EP6 2
203 #define GPIF_EP8 3
204
205
206
207 void TD_Poll( void )
208 { // Called repeatedly while the device is idle
209 1 static WORD xFIFOTC_OUT = 0x0000;
210 1 if(xfrvia_TD_Poll ) // Set to TRUE vendor command 0
-xD1...
211 1 {
212 2 if( !( EP2468STAT & 0x01 ) ) // Is the host busy sending data
213 2 { // ...EP2E=0, when endp FIFO not
C51 COMPILER V6.10 GPIFLONGXFR 07/07/2005 13:31:08 PAGE 5
- ...empty, host sent pkt.
214 3 // Since the host sent data, a slave FIFO buffer was availa
-ble
215 3 // ... GO on with GPIF write
-
216 3 if( GPIFTRIG & 0x80 ) // if GPIF done then check sla
-ve status
217 3 {
218 4 xFIFOTC_OUT = ((EP2BCH<<8) + EP2BCL);
219 4 if( xFIFOTC_OUT ) // pkt is not zerolen, xfr the
- data
220 4 {
221 5 EP2GPIFTCH = EP2BCH; // Setup transaction count
222 5 EP2GPIFTCL = EP2BCL; // Set EP2GPIFTC = EP2BC
223 5 EP2BCL = 0x00; // AUTOOUT=0, so "pass-on" pkt
-. to master (GPIF)
224 5 // Skip bit is 0 +> pass on packet to master
225 5 // Once master xfr's OUT pkt, it "auto" (re)arms
-
226 5 GPIFTRIG = GPIF_EP2; // Trigger FIFO write transact
-ion(s), using SFR
227 5 // R/W=0, EP[1:0]=FIFO_EpNum for EPx write(s)
228 5 while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 D
-one bit
229 5 {
230 6 }
231 5 //////////////////////////////////////////////////////////////更新
-高位的地址线/////////
232 5 if(LSB(xFIFOTC_OUT))//如果传输了64字节
233 5 {
234 6 HighAddr+=1;
235 6 }
236 5 else
237 5 {
238 6 HighAddr+=8;
239 6 }
240 5 IOD=LSB(HighAddr>>3);
241 5 IOE=MSB(HighAddr>>3);
242 5 //////////////////////////////////////////////////////////////////
-/////////////////////
243 5 }
244 4 else // Handle host sending zero length pkt.
245 4 {
246 5 EP2BCL = 0x80; // AUTOOUT=0, so "skip" zerolen p
-kt and manually commit packet to the master
247 5 }
248 4 }
249 3 else
250 3 { // GPIF is busy
251 4 }
252 3 }
253 2 else // Host is "not" sending data and the
254 2 { // ...slave has taken all data and
255 3 } // ...nothing in the buffer
-
256 2 // Does the slave have data for us...
257 2 if( GPIFTRIG & 0x80 ) // If GPIF done then check sla
-ve status
258 2 {
259 3 if( in_token_event ) // Set via vendor command 0xE0
260 3 {
261 4 if( !( EP2468STAT & 0x20 ) )// if EP6F=0, buffer is avail
C51 COMPILER V6.10 GPIFLONGXFR 07/07/2005 13:31:08 PAGE 6
-able
262 4 {
263 5 // Trigger FIFO read transaction(s), using SFR
264 5 // R/W=1, EP[1:0]=FIFO_EpNum for EPx read(s)
265 5 EP6GPIFTCH = 0x00; // setup transaction count
266 5 EP6GPIFTCL = 0x40; // set EP8GPIFTC = 8
267 5 if( !( EP2468STAT & 0x20 ) )
268 5 { // EP8FF=0, when buffer is available...
269 6 // trigger FIFO read transaction(s), using SFR
270 6 while( !( GPIFTRIG & 0x80 ) ) // Poll GPIFTRIG.7 Done
-bit
271 6 {
272 7 }
273 6 GPIFTRIG = GPIFTRIGRD | GPIF_EP6; // R/W=1, EP[1:0]=FIFO_
-EpNum for EPx read(s)
274 6 *EP0BUF = 0xA8; // return that there was a buffe
-r available
275 6 }
276 5 else
277 5 { // If EP busy then host is behind...two buffe
-rs containing data
278 6 }
279 5 while( !( GPIFTRIG & 0x80 ) ) // poll GPIFTRIG.7 Done bit
280 5 {
281 6 }
282 5 INPKTEND = 0x06; // AUTOIN=0, so 8051 must "pass-on" p
-kt to host
283 5 HighAddr+=1;
284 5 IOD=LSB(HighAddr>>3);
285 5 IOE=MSB(HighAddr>>3);
286 5 } // ....to the INPKTEND register
287 4 else // If EP busy then host is behind (slow) and we
288 4 { // ...still have two buffers containing data
289 5 }
290 4 }
291 3 else // in_token_event not asserted by vendor request
292 3 {
293 4 }
294 3 }
295 2 else // GPIF is busy
296 2 {
297 3 }
298 2 }
299 1 else
300 1 {
301 2 }
302 1 }
303
304 BOOL TD_Suspend( void )
305 { // Called before the device goes into suspend mode
306 1 return( TRUE );
307 1 }
308
309 BOOL TD_Resume( void )
310 { // Called after the device resumes
311 1 return( TRUE );
312 1 }
313
314 //----------------------------------------------------------------
--------------
315 // Device Request hooks
316 // The following hooks are called by the end point 0 device requ
C51 COMPILER V6.10 GPIFLONGXFR 07/07/2005 13:31:08 PAGE 7
-est parser.
317 //----------------------------------------------------------------
--------------
318 BOOL DR_GetDescriptor( void )
319 {
320 1 return( TRUE );
321 1 }
322
323 BOOL DR_SetConfiguration( void )
324 { // Called when a Set Configuration command is received
325 1
326 1 if( EZUSB_HIGHSPEED( ) )
327 1 { // ...FX2 in high speed mode
328 2 SYNCDELAY; //
329 2 EP6AUTOINLENH = 0x02; // set core AUTO commit len = 512
-bytes
330 2 SYNCDELAY; //
331 2 EP6AUTOINLENL = 0x00;
332 2 SYNCDELAY; //
333 2 enum_pkt_size = 512; // max. pkt. size = 512 bytes
334 2 }
335 1 else
336 1 { // ...FX2 in full speed mode
337 2 SYNCDELAY; //
338 2 EP6AUTOINLENH = 0x00; // set core AUTO commit len = 64 b
-ytes
339 2 SYNCDELAY; //
340 2 EP6AUTOINLENL = 0x40;
341 2 SYNCDELAY; //
342 2 enum_pkt_size = 64; // max. pkt. size = 64 bytes
343 2 }
344 1
345 1 Configuration = SETUPDAT[ 2 ];
346 1 return( TRUE ); // Handled by user code
347 1 }
348
349 BOOL DR_GetConfiguration( void )
350 { // Called when a Get Configuration command is received
351 1 EP0BUF[ 0 ] = Configuration;
352 1 EP0BCH = 0;
353 1 EP0BCL = 1;
354 1 return(TRUE); // Handled by user code
355 1 }
356
357 BOOL DR_SetInterface( void )
358 { // Called when a Set Interface command is received
359 1 AlternateSetting = SETUPDAT[ 2 ];
360 1 return( TRUE ); // Handled by user code
361 1 }
362
363 BOOL DR_GetInterface( void )
364 { // Called when a Set Interface command is received
365 1 EP0BUF[ 0 ] = AlternateSetting;
366 1 EP0BCH = 0;
367 1 EP0BCL = 1;
368 1 return( TRUE ); // Handled by user code
369 1 }
370
371 BOOL DR_GetStatus( void )
372 {
373 1 return( TRUE );
374 1 }
C51 COMPILER V6.10 GPIFLONGXFR 07/07/2005 13:31:08 PAGE 8
375
376 BOOL DR_ClearFeature( void )
377 {
378 1 return( TRUE );
379 1 }
380
381 BOOL DR_SetFeature( void )
382 {
383 1 return( TRUE );
384 1 }
385
386
387
388
389 ///////////////////////////////////////////////////////////子函数/
-////////////
390 void SUB_SETTING(void)
391 {
392 1 if(R_SETTING&0x01)//设置O_DIR
393 1 IOA|=0x02;
394 1 else
395 1 IOA&=0xFD;
396 1
397 1 if(R_SETTING&0x02)//设置S_SWITCH
398 1 S_SWITCH=1;
399 1 else
400 1 S_SWITCH=0;
401 1 }
402
403 void SUB_STEPIN(void)
404 {
405 1 BYTE i,j,k,l;
406 1 if(S_SWITCH)//根据电子开关设定决定是否打开电子开关
407 1 IOA&=0xF7;//clear O_SWITCH
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -