- Timestamp:
- Mar 14, 2011, 8:37:34 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FirmwareFX2/usbjtag.c
r40 r135 34 34 #include "hardware.h" 35 35 36 #include "spi.h"37 38 36 //----------------------------------------------------------------------------- 39 37 // Define USE_MOD256_OUTBUFFER: … … 136 134 EP8FIFOCFG = bmAUTOIN; SYNCDELAY; // Endpoint 8 used for user communication, auto commitment, 8 bits data bus 137 135 138 EP8AUTOINLENH = 0x0 0; SYNCDELAY; // Size in bytes of the IN data automatically commited (64bytes here, but changed dynamically depending on the connection)139 EP8AUTOINLENL = 0x 40; SYNCDELAY; // Can use signal PKTEND if you want to commit a shorter packet136 EP8AUTOINLENH = 0x02; SYNCDELAY; // Size in bytes of the IN data automatically commited (512 bytes here, but changed dynamically depending on the connection) 137 EP8AUTOINLENL = 0x00; SYNCDELAY; // Can use signal PKTEND if you want to commit a shorter packet 140 138 141 139 // Out endpoints do not come up armed 142 140 // Since the defaults are double buffered we must write dummy byte counts twice 143 EP2BCL = 0x80; SYNCDELAY; // Arm EP2OUT by writing byte count w/skip. =141 EP2BCL = 0x80; SYNCDELAY; // Arm EP2OUT by writing byte count w/skip. 144 142 EP4BCL = 0x80; SYNCDELAY; 145 EP2BCL = 0x80; SYNCDELAY; // Arm EP4OUT by writing byte count w/skip. =143 EP2BCL = 0x80; SYNCDELAY; // Arm EP4OUT by writing byte count w/skip. 146 144 EP4BCL = 0x80; SYNCDELAY; 147 145 148 146 PINFLAGSAB = 0xFA; SYNCDELAY; // 1111_1010 => FLAGA = EMPTY flag for EP6; FLAGB = FULL flag for EP8 149 150 147 151 148 // LED turned off by default … … 370 367 } 371 368 372 if (bRequest == VEN_SPI_WR) // 0x99373 {374 // get EP0 data375 EP0BCL = 0; // arm EP0 for OUT xfer. This sets the busy bit376 377 while (EP0CS & bmEPBUSY) // wait for busy to clear378 ;379 380 // head_hi, head_l , format , address, *buf , len381 return !spi_write (wValueH, wValueL, wIndexH, wIndexL, EP0BUF, EP0BCL);382 }383 384 385 369 return 1; 386 370 } … … 388 372 // IN requests. 389 373 390 // change USB speed391 if (bRequest == 0x91)392 {393 if (wIndexL == 0) // high speed394 {395 CT1 &= ~0x02;396 fx2_renumerate(); // renumerate397 }398 else // full speed399 {400 CT1 |= 0x02;401 fx2_renumerate(); // renumerate402 }403 }404 405 // change synchronous/asynchronous mode406 if (bRequest == 0x92)407 {408 if(IFCONFIG & bmASYNC)409 {410 IFCONFIG &= ~bmASYNC;411 }412 else413 {414 IFCONFIG |= bmASYNC;415 }416 }417 418 if (bRequest == 0x93) // change to synchronous mode419 {420 IFCONFIG &= ~bmASYNC;421 }422 423 if (bRequest == VEN_SPI_EN) // 0x96424 {425 SPI_OE |= bmSPI_OE; // PA.0,1,3,7 output enable426 init_spi();427 EP0BUF[0] = 0;428 EP0BUF[1] = 0;429 }430 431 if (bRequest == VEN_SPI_DIS) // 0x97432 {433 SPI_OE &= ~bmSPI_OE; // PA.0,1,3,7 output disable434 EP0BUF[0] = 0x42;435 EP0BUF[1] = 0x43;436 EP0BUF[2] = 0x42;437 EP0BUF[3] = 0x43;438 EP0BCH = 0;439 EP0BCL = wLengthL;440 return 1;441 }442 443 if (bRequest == VEN_SPI_RD) // 0x98444 {445 // header_H,header_L, format, address, *buf , len446 if (spi_read (wValueH, wValueL, wIndexH, wIndexL, EP0BUF, wLengthL))447 return 0;448 449 EP0BCH = 0;450 EP0BCL = wLengthL;451 return 1;452 }453 454 374 if(bRequest == 0x90) 455 375 {
Note:
See TracChangeset
for help on using the changeset viewer.