Line 48... |
Line 48... |
#else
|
#else
|
.stream_out_func = cable_common_write_stream ,
|
.stream_out_func = cable_common_write_stream ,
|
.stream_inout_func = cable_common_read_stream,
|
.stream_inout_func = cable_common_read_stream,
|
#endif
|
#endif
|
.flush_func = NULL,
|
.flush_func = NULL,
|
.opts = "",
|
.opts = "p:v:",
|
.help = "no options\n",
|
.help = "-p [PID] Alteranate PID for USB device (hex value)\n\t-v [VID] Alternate VID for USB device (hex value)\n",
|
};
|
};
|
|
|
// USBBlaster has a max. single transaction of 63 bytes. We assume
|
// USBBlaster has a max. single transaction of 63 bytes. We assume
|
// the FT245 has the same limit.
|
// the FT245 has the same limit.
|
// So, size the max read and write to create 64-byte USB packets
|
// So, size the max read and write to create 64-byte USB packets
|
#define USBBLASTER_MAX_WRITE 63
|
#define USBBLASTER_MAX_WRITE 63
|
static uint8_t data_out_scratchpad[USBBLASTER_MAX_WRITE+1];
|
static uint8_t data_out_scratchpad[USBBLASTER_MAX_WRITE+1];
|
#define USBBLASTER_MAX_READ 62
|
#define USBBLASTER_MAX_READ 62
|
static uint8_t data_in_scratchpad[USBBLASTER_MAX_READ+2];
|
static uint8_t data_in_scratchpad[USBBLASTER_MAX_READ+2];
|
|
|
// USB constants for the USB Blaster
|
// USB constants for the USB Blaster, can be changed on the command line
|
#define ALTERA_VID 0x09FB
|
static uint32_t ALTERA_VID = 0X09FB;
|
#define ALTERA_PID 0x6001
|
static uint32_t ALTERA_PID = 0x6001;
|
|
|
|
|
static struct ftdi_context ftdic;
|
static struct ftdi_context ftdic;
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
/*-------------------------------------[ USB Blaster specific functions ]---*/
|
/*-------------------------------------[ USB Blaster specific functions ]---*/
|
Line 440... |
Line 441... |
return -1;
|
return -1;
|
}
|
}
|
|
|
/* context, vendor id, product id */
|
/* context, vendor id, product id */
|
if (ftdi_usb_open(&ftdic, ALTERA_VID, ALTERA_PID) < 0) {
|
if (ftdi_usb_open(&ftdic, ALTERA_VID, ALTERA_PID) < 0) {
|
printf("unable to open ftdi device: %s\n", ftdic.error_str);
|
printf("unable to open ftdi device with VID 0x%0X, PID 0x%0X: %s\n", ALTERA_VID, ALTERA_PID, ftdic.error_str);
|
return -1;
|
return -1;
|
}
|
}
|
|
|
if (ftdi_usb_reset(&ftdic) < 0) {
|
if (ftdi_usb_reset(&ftdic) < 0) {
|
printf("unable to reset ftdi device\n");
|
printf("unable to reset ftdi device\n");
|
Line 476... |
Line 477... |
}
|
}
|
|
|
|
|
int cable_ft245_opt(int c, char *str)
|
int cable_ft245_opt(int c, char *str)
|
{
|
{
|
|
uint32_t newvid;
|
|
uint32_t newpid;
|
|
|
|
switch(c) {
|
|
case 'p':
|
|
if(!sscanf(str, "%x", &newpid)) {
|
|
fprintf(stderr, "p parameter must have a hex number as parameter\n");
|
|
return APP_ERR_BAD_PARAM;
|
|
}
|
|
else {
|
|
ALTERA_PID = newpid;
|
|
}
|
|
break;
|
|
|
|
case 'v':
|
|
if(!sscanf(str, "%x", &newvid)) {
|
|
fprintf(stderr, "v parameter must have a hex number as parameter\n");
|
|
return APP_ERR_BAD_PARAM;
|
|
}
|
|
else {
|
|
ALTERA_VID = newvid;
|
|
}
|
|
break;
|
|
|
|
default:
|
fprintf(stderr, "Unknown parameter '%c'\n", c);
|
fprintf(stderr, "Unknown parameter '%c'\n", c);
|
return APP_ERR_BAD_PARAM;
|
return APP_ERR_BAD_PARAM;
|
}
|
}
|
|
return APP_ERR_NONE;
|
|
}
|
|
|
|
|
|
|
No newline at end of file
|
No newline at end of file
|