Changeset 21


Ignore:
Timestamp:
Aug 29, 2009, 8:22:53 PM (15 years ago)
Author:
demin
Message:

cleanup vendor commands

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FirmwareFX2/usbjtag.c

    r4 r21  
    9494
    9595   // Make Timer2 reload at 100 Hz to trigger Keepalive packets
     96
    9697   tmp = 65536 - ( 48000000 / 12 / 100 );
    9798   RCAP2H = tmp >> 8;
     
    101102
    102103   // Enable Autopointer
    103    EXTACC = 1;          // Enable
    104    APTR1FZ = 1;         // Don't freeze
    105    APTR2FZ = 1;         // Don't freeze
     104
     105   EXTACC = 1;                                          // Enable
     106   APTR1FZ = 1;                                         // Don't freeze
     107   APTR2FZ = 1;                                         // Don't freeze
    106108
    107109   // define endpoint configuration
     
    128130   EP6CFG     = 0xA2; SYNCDELAY;                        // Out endpoint, Bulk, Double buffering
    129131   EP6FIFOCFG = 0x00; SYNCDELAY;                        // Firmware has to see a rising edge on auto bit to enable auto arming
    130    EP6FIFOCFG = bmAUTOOUT | bmWORDWIDE; SYNCDELAY;      // Endpoint 6 used for user communicationn, auto commitment, 16 bits data bus
     132   EP6FIFOCFG = bmAUTOOUT; SYNCDELAY;                   // Endpoint 6 used for user communicationn, auto commitment, 8 bits data bus
    131133
    132134   EP8CFG     = 0xE0; SYNCDELAY;                        // In endpoint, Bulk
    133135   EP8FIFOCFG = 0x00; SYNCDELAY;                        // Firmware has to see a rising edge on auto bit to enable auto arming
    134    EP8FIFOCFG = bmAUTOIN  | bmWORDWIDE; SYNCDELAY;      // Endpoint 8 used for user communication, auto commitment, 16 bits data bus
     136   EP8FIFOCFG = bmAUTOIN; SYNCDELAY;                    // Endpoint 8 used for user communication, auto commitment, 8 bits data bus
    135137
    136138   EP8AUTOINLENH = 0x00; SYNCDELAY;                     // Size in bytes of the IN data automatically commited (64 bytes here, but changed dynamically depending on the connection)
     
    143145   EP2BCL = 0x80; SYNCDELAY;                            // Arm EP4OUT by writing byte count w/skip.=
    144146   EP4BCL = 0x80; SYNCDELAY;
    145    
    146    // JTAG from FX2 enabled by default
    147    IOC |= (1 << 7);
    148    
     147
    149148   // Put the system in high speed by default (REM: USB-Blaster is in full speed)
    150149   // This can be changed by vendor commands
     
    398397  }
    399398 
    400   // change JTAG enable
     399  // change synchronous/asynchronous mode
    401400  if (bRequest == 0x92)
    402   {
    403     if (wIndexL == 0)                  // FX2 is master of JTAG
    404     {
    405       IOC |= (1 << 7);
    406     }
    407     else                               // external connector is master of JTAG
    408     {
    409       IOC &= ~(1 << 7);
    410     }
    411   }
    412   // change synchronous/asynchronous mode
    413   if (bRequest == 0x93)
    414401  {
    415402    if(IFCONFIG & bmASYNC)
     
    422409    }
    423410  }
    424  
    425   if (bRequest == 0x94) // change to synchronous mode
     411
     412  if (bRequest == 0x93) // change to synchronous mode
    426413  {
    427414    IFCONFIG &= ~bmASYNC;
     
    445432    EP0BCH = 0;
    446433    EP0BCL = wLengthL;
    447 //    EP0CS |= bmHSNAK; // Bram
    448434    return 1;
    449435  }
     
    460446  }
    461447 
    462   if (bRequest == 0x95) // For debugging purposes
    463   {
    464  
    465     SPI &= ~bmSS; // enable slave select
    466 
    467     spi_write_byte_msb(wValueL); // address
    468     spi_write_byte_msb(wIndexL); // header
    469     EP0BUF[0] = spi_read_byte_msb(); // read back value from slave
    470    
    471     SPI |= bmSS; /* active low, disable slave */
    472    
    473     EP0BCH = 0;
    474     EP0BCL = 1; // Arm the EP
    475     return 1;
    476 
    477     /*static xdata unsigned char buf[2];
    478     buf[0] = 0xFF;
    479     buf[1] = 0x10;
    480     spi_read(0x00, wValueL, SPI_FMT_HDR_1, wValueH, buf, 0);
    481     //spi_write_byte_msb(wValueL);
    482     EP0BUF[0] = 0x51;
    483     EP0BUF[1] = wValueL;
    484     EP0BCH = 0;
    485     EP0BCL = wLengthL;
    486     return 1;*/
    487   }
    488 
    489448  if(bRequest == 0x90)
    490449  {
     
    502461  EP0BCH = 0;
    503462  EP0BCL = (wLengthL<2) ? wLengthL : 2; // Arm endpoint with # bytes to transfer
    504   //EP0CS |= bmHSNAK; // Bram
    505463
    506464  return 1;
     
    526484  usb_jtag_init();
    527485  eeprom_init();
    528   setup_autovectors ();
    529   usb_install_handlers ();
     486  setup_autovectors();
     487  usb_install_handlers();
    530488
    531489
Note: See TracChangeset for help on using the changeset viewer.