Change the second parameter of the ser_open method from "baud" into a

"union pinfo", so the USB parameters can be passed without hacks.



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1276 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
joerg_wunsch 2014-02-21 13:44:11 +00:00
parent f7cc3ff662
commit 66e2a16c9c
16 changed files with 155 additions and 77 deletions

View File

@ -1,3 +1,23 @@
2014-02-21 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
* serial.h: Change the second parameter of the ser_open method
from "baud" into a "union pinfo", so the USB parameters can be
passed without hacks.
* arduino.c: (Dito.)
* avr910.c: (Dito.)
* buspirate.c: (Dito.)
* butterfly.c: (Dito.)
* jtag3.c: (Dito.)
* jtagmkI.c: (Dito.)
* jtagmkII.c: (Dito.)
* ser_avrdoper.c: (Dito.)
* ser_posix.c: (Dito.)
* ser_win32.c: (Dito.)
* stk500.c: (Dito.)
* stk500v2.c: (Dito.)
* usb_libusb.c: (Dito.)
* wiring.c: (Dito.)
2014-01-30 Joerg Wunsch <j.gnu@uriah.heep.sax.de> 2014-01-30 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
[bug #41402] dfu.c missing include <stdint.h> [bug #41402] dfu.c missing include <stdint.h>

View File

@ -85,8 +85,10 @@ static int arduino_read_sig_bytes(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m)
static int arduino_open(PROGRAMMER * pgm, char * port) static int arduino_open(PROGRAMMER * pgm, char * port)
{ {
union pinfo pinfo;
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, pgm->baudrate? pgm->baudrate: 115200, &pgm->fd)==-1) { pinfo.baud = pgm->baudrate? pgm->baudrate: 115200;
if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }

View File

@ -375,6 +375,7 @@ static int avr910_parseextparms(PROGRAMMER * pgm, LISTID extparms)
static int avr910_open(PROGRAMMER * pgm, char * port) static int avr910_open(PROGRAMMER * pgm, char * port)
{ {
union pinfo pinfo;
/* /*
* If baudrate was not specified use 19.200 Baud * If baudrate was not specified use 19.200 Baud
*/ */
@ -383,7 +384,8 @@ static int avr910_open(PROGRAMMER * pgm, char * port)
} }
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, pgm->baudrate, &pgm->fd)==-1) { pinfo.baud = pgm->baudrate;
if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }

View File

@ -416,12 +416,14 @@ buspirate_verifyconfig(struct programmer_t *pgm)
/* ====== Programmer methods ======= */ /* ====== Programmer methods ======= */
static int buspirate_open(struct programmer_t *pgm, char * port) static int buspirate_open(struct programmer_t *pgm, char * port)
{ {
union pinfo pinfo;
/* BusPirate runs at 115200 by default */ /* BusPirate runs at 115200 by default */
if(pgm->baudrate == 0) if(pgm->baudrate == 0)
pgm->baudrate = 115200; pgm->baudrate = 115200;
pinfo.baud = pgm->baudrate;
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, pgm->baudrate, &pgm->fd)==-1) { if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }

View File

@ -386,6 +386,7 @@ static void butterfly_enable(PROGRAMMER * pgm)
static int butterfly_open(PROGRAMMER * pgm, char * port) static int butterfly_open(PROGRAMMER * pgm, char * port)
{ {
union pinfo pinfo;
strcpy(pgm->port, port); strcpy(pgm->port, port);
/* /*
* If baudrate was not specified use 19200 Baud * If baudrate was not specified use 19200 Baud
@ -393,7 +394,8 @@ static int butterfly_open(PROGRAMMER * pgm, char * port)
if(pgm->baudrate == 0) { if(pgm->baudrate == 0) {
pgm->baudrate = 19200; pgm->baudrate = 19200;
} }
if (serial_open(port, pgm->baudrate, &pgm->fd)==-1) { pinfo.baud = pgm->baudrate;
if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }

24
jtag3.c
View File

@ -1021,7 +1021,7 @@ static int jtag3_parseextparms(PROGRAMMER * pgm, LISTID extparms)
static int jtag3_open(PROGRAMMER * pgm, char * port) static int jtag3_open(PROGRAMMER * pgm, char * port)
{ {
long baud; union pinfo pinfo;
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, "%s: jtag3_open()\n", progname); fprintf(stderr, "%s: jtag3_open()\n", progname);
@ -1034,7 +1034,9 @@ static int jtag3_open(PROGRAMMER * pgm, char * port)
if (strncmp(port, "usb", 3) == 0) { if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB) #if defined(HAVE_LIBUSB)
serdev = &usb_serdev_frame; serdev = &usb_serdev_frame;
baud = USB_DEVICE_JTAGICE3; pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
pinfo.usbinfo.pid = USB_DEVICE_JTAGICE3;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3; pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3;
pgm->fd.usb.rep = USBDEV_BULK_EP_READ_3; pgm->fd.usb.rep = USBDEV_BULK_EP_READ_3;
pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_3; pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_3;
@ -1046,7 +1048,7 @@ static int jtag3_open(PROGRAMMER * pgm, char * port)
} }
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, baud, &pgm->fd)==-1) { if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }
@ -1063,7 +1065,7 @@ static int jtag3_open(PROGRAMMER * pgm, char * port)
static int jtag3_open_dw(PROGRAMMER * pgm, char * port) static int jtag3_open_dw(PROGRAMMER * pgm, char * port)
{ {
long baud; union pinfo pinfo;
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, "%s: jtag3_open_dw()\n", progname); fprintf(stderr, "%s: jtag3_open_dw()\n", progname);
@ -1076,7 +1078,9 @@ static int jtag3_open_dw(PROGRAMMER * pgm, char * port)
if (strncmp(port, "usb", 3) == 0) { if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB) #if defined(HAVE_LIBUSB)
serdev = &usb_serdev_frame; serdev = &usb_serdev_frame;
baud = USB_DEVICE_JTAGICE3; pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
pinfo.usbinfo.pid = USB_DEVICE_JTAGICE3;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3; pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3;
pgm->fd.usb.rep = USBDEV_BULK_EP_READ_3; pgm->fd.usb.rep = USBDEV_BULK_EP_READ_3;
pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_3; pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_3;
@ -1088,7 +1092,7 @@ static int jtag3_open_dw(PROGRAMMER * pgm, char * port)
} }
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, baud, &pgm->fd)==-1) { if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }
@ -1105,7 +1109,7 @@ static int jtag3_open_dw(PROGRAMMER * pgm, char * port)
static int jtag3_open_pdi(PROGRAMMER * pgm, char * port) static int jtag3_open_pdi(PROGRAMMER * pgm, char * port)
{ {
long baud; union pinfo pinfo;
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, "%s: jtag3_open_pdi()\n", progname); fprintf(stderr, "%s: jtag3_open_pdi()\n", progname);
@ -1118,7 +1122,9 @@ static int jtag3_open_pdi(PROGRAMMER * pgm, char * port)
if (strncmp(port, "usb", 3) == 0) { if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB) #if defined(HAVE_LIBUSB)
serdev = &usb_serdev_frame; serdev = &usb_serdev_frame;
baud = USB_DEVICE_JTAGICE3; pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
pinfo.usbinfo.pid = USB_DEVICE_JTAGICE3;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3; pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3;
pgm->fd.usb.rep = USBDEV_BULK_EP_READ_3; pgm->fd.usb.rep = USBDEV_BULK_EP_READ_3;
pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_3; pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_3;
@ -1130,7 +1136,7 @@ static int jtag3_open_pdi(PROGRAMMER * pgm, char * port)
} }
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, baud, &pgm->fd)==-1) { if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }

View File

@ -669,11 +669,13 @@ static int jtagmkI_open(PROGRAMMER * pgm, char * port)
PDATA(pgm)->initial_baudrate = -1L; PDATA(pgm)->initial_baudrate = -1L;
for (i = 0; i < sizeof(baudtab) / sizeof(baudtab[0]); i++) { for (i = 0; i < sizeof(baudtab) / sizeof(baudtab[0]); i++) {
union pinfo pinfo;
pinfo.baud = baudtab[i].baud;
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, fprintf(stderr,
"%s: jtagmkI_open(): trying to sync at baud rate %ld:\n", "%s: jtagmkI_open(): trying to sync at baud rate %ld:\n",
progname, baudtab[i].baud); progname, pinfo.baud);
if (serial_open(port, baudtab[i].baud, &pgm->fd)==-1) { if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }

View File

@ -1541,7 +1541,7 @@ static int jtagmkII_parseextparms(PROGRAMMER * pgm, LISTID extparms)
static int jtagmkII_open(PROGRAMMER * pgm, char * port) static int jtagmkII_open(PROGRAMMER * pgm, char * port)
{ {
long baud; union pinfo pinfo;
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, "%s: jtagmkII_open()\n", progname); fprintf(stderr, "%s: jtagmkII_open()\n", progname);
@ -1552,7 +1552,7 @@ static int jtagmkII_open(PROGRAMMER * pgm, char * port)
* a higher baud rate, we switch to it later on, after establishing * a higher baud rate, we switch to it later on, after establishing
* the connection with the ICE. * the connection with the ICE.
*/ */
baud = 19200; pinfo.baud = 19200;
/* /*
* If the port name starts with "usb", divert the serial routines * If the port name starts with "usb", divert the serial routines
@ -1563,7 +1563,9 @@ static int jtagmkII_open(PROGRAMMER * pgm, char * port)
if (strncmp(port, "usb", 3) == 0) { if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB) #if defined(HAVE_LIBUSB)
serdev = &usb_serdev; serdev = &usb_serdev;
baud = USB_DEVICE_JTAGICEMKII; pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
pinfo.usbinfo.pid = USB_DEVICE_JTAGICEMKII;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII;
pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII;
pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII;
@ -1575,7 +1577,7 @@ static int jtagmkII_open(PROGRAMMER * pgm, char * port)
} }
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, baud, &pgm->fd)==-1) { if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }
@ -1592,7 +1594,7 @@ static int jtagmkII_open(PROGRAMMER * pgm, char * port)
static int jtagmkII_open_dw(PROGRAMMER * pgm, char * port) static int jtagmkII_open_dw(PROGRAMMER * pgm, char * port)
{ {
long baud; union pinfo pinfo;
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, "%s: jtagmkII_open_dw()\n", progname); fprintf(stderr, "%s: jtagmkII_open_dw()\n", progname);
@ -1603,7 +1605,7 @@ static int jtagmkII_open_dw(PROGRAMMER * pgm, char * port)
* a higher baud rate, we switch to it later on, after establishing * a higher baud rate, we switch to it later on, after establishing
* the connection with the ICE. * the connection with the ICE.
*/ */
baud = 19200; pinfo.baud = 19200;
/* /*
* If the port name starts with "usb", divert the serial routines * If the port name starts with "usb", divert the serial routines
@ -1614,7 +1616,9 @@ static int jtagmkII_open_dw(PROGRAMMER * pgm, char * port)
if (strncmp(port, "usb", 3) == 0) { if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB) #if defined(HAVE_LIBUSB)
serdev = &usb_serdev; serdev = &usb_serdev;
baud = USB_DEVICE_JTAGICEMKII; pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
pinfo.usbinfo.pid = USB_DEVICE_JTAGICEMKII;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII;
pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII;
pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII;
@ -1626,7 +1630,7 @@ static int jtagmkII_open_dw(PROGRAMMER * pgm, char * port)
} }
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, baud, &pgm->fd)==-1) { if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }
@ -1643,7 +1647,7 @@ static int jtagmkII_open_dw(PROGRAMMER * pgm, char * port)
static int jtagmkII_open_pdi(PROGRAMMER * pgm, char * port) static int jtagmkII_open_pdi(PROGRAMMER * pgm, char * port)
{ {
long baud; union pinfo pinfo;
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, "%s: jtagmkII_open_pdi()\n", progname); fprintf(stderr, "%s: jtagmkII_open_pdi()\n", progname);
@ -1654,7 +1658,7 @@ static int jtagmkII_open_pdi(PROGRAMMER * pgm, char * port)
* a higher baud rate, we switch to it later on, after establishing * a higher baud rate, we switch to it later on, after establishing
* the connection with the ICE. * the connection with the ICE.
*/ */
baud = 19200; pinfo.baud = 19200;
/* /*
* If the port name starts with "usb", divert the serial routines * If the port name starts with "usb", divert the serial routines
@ -1665,7 +1669,9 @@ static int jtagmkII_open_pdi(PROGRAMMER * pgm, char * port)
if (strncmp(port, "usb", 3) == 0) { if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB) #if defined(HAVE_LIBUSB)
serdev = &usb_serdev; serdev = &usb_serdev;
baud = USB_DEVICE_JTAGICEMKII; pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
pinfo.usbinfo.pid = USB_DEVICE_JTAGICEMKII;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII;
pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII;
pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII;
@ -1677,7 +1683,7 @@ static int jtagmkII_open_pdi(PROGRAMMER * pgm, char * port)
} }
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, baud, &pgm->fd)==-1) { if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }
@ -1695,7 +1701,7 @@ static int jtagmkII_open_pdi(PROGRAMMER * pgm, char * port)
static int jtagmkII_dragon_open(PROGRAMMER * pgm, char * port) static int jtagmkII_dragon_open(PROGRAMMER * pgm, char * port)
{ {
long baud; union pinfo pinfo;
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, "%s: jtagmkII_dragon_open()\n", progname); fprintf(stderr, "%s: jtagmkII_dragon_open()\n", progname);
@ -1706,7 +1712,7 @@ static int jtagmkII_dragon_open(PROGRAMMER * pgm, char * port)
* a higher baud rate, we switch to it later on, after establishing * a higher baud rate, we switch to it later on, after establishing
* the connection with the ICE. * the connection with the ICE.
*/ */
baud = 19200; pinfo.baud = 19200;
/* /*
* If the port name starts with "usb", divert the serial routines * If the port name starts with "usb", divert the serial routines
@ -1717,7 +1723,9 @@ static int jtagmkII_dragon_open(PROGRAMMER * pgm, char * port)
if (strncmp(port, "usb", 3) == 0) { if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB) #if defined(HAVE_LIBUSB)
serdev = &usb_serdev; serdev = &usb_serdev;
baud = USB_DEVICE_AVRDRAGON; pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
pinfo.usbinfo.pid = USB_DEVICE_AVRDRAGON;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII;
pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII;
pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII;
@ -1729,7 +1737,7 @@ static int jtagmkII_dragon_open(PROGRAMMER * pgm, char * port)
} }
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, baud, &pgm->fd)==-1) { if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }
@ -1747,7 +1755,7 @@ static int jtagmkII_dragon_open(PROGRAMMER * pgm, char * port)
static int jtagmkII_dragon_open_dw(PROGRAMMER * pgm, char * port) static int jtagmkII_dragon_open_dw(PROGRAMMER * pgm, char * port)
{ {
long baud; union pinfo pinfo;
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, "%s: jtagmkII_dragon_open_dw()\n", progname); fprintf(stderr, "%s: jtagmkII_dragon_open_dw()\n", progname);
@ -1758,7 +1766,7 @@ static int jtagmkII_dragon_open_dw(PROGRAMMER * pgm, char * port)
* a higher baud rate, we switch to it later on, after establishing * a higher baud rate, we switch to it later on, after establishing
* the connection with the ICE. * the connection with the ICE.
*/ */
baud = 19200; pinfo.baud = 19200;
/* /*
* If the port name starts with "usb", divert the serial routines * If the port name starts with "usb", divert the serial routines
@ -1769,7 +1777,9 @@ static int jtagmkII_dragon_open_dw(PROGRAMMER * pgm, char * port)
if (strncmp(port, "usb", 3) == 0) { if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB) #if defined(HAVE_LIBUSB)
serdev = &usb_serdev; serdev = &usb_serdev;
baud = USB_DEVICE_AVRDRAGON; pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
pinfo.usbinfo.pid = USB_DEVICE_AVRDRAGON;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII;
pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII;
pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII;
@ -1781,7 +1791,7 @@ static int jtagmkII_dragon_open_dw(PROGRAMMER * pgm, char * port)
} }
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, baud, &pgm->fd)==-1) { if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }
@ -1799,7 +1809,7 @@ static int jtagmkII_dragon_open_dw(PROGRAMMER * pgm, char * port)
static int jtagmkII_dragon_open_pdi(PROGRAMMER * pgm, char * port) static int jtagmkII_dragon_open_pdi(PROGRAMMER * pgm, char * port)
{ {
long baud; union pinfo pinfo;
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, "%s: jtagmkII_dragon_open_pdi()\n", progname); fprintf(stderr, "%s: jtagmkII_dragon_open_pdi()\n", progname);
@ -1810,7 +1820,7 @@ static int jtagmkII_dragon_open_pdi(PROGRAMMER * pgm, char * port)
* a higher baud rate, we switch to it later on, after establishing * a higher baud rate, we switch to it later on, after establishing
* the connection with the ICE. * the connection with the ICE.
*/ */
baud = 19200; pinfo.baud = 19200;
/* /*
* If the port name starts with "usb", divert the serial routines * If the port name starts with "usb", divert the serial routines
@ -1821,7 +1831,9 @@ static int jtagmkII_dragon_open_pdi(PROGRAMMER * pgm, char * port)
if (strncmp(port, "usb", 3) == 0) { if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB) #if defined(HAVE_LIBUSB)
serdev = &usb_serdev; serdev = &usb_serdev;
baud = USB_DEVICE_AVRDRAGON; pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
pinfo.usbinfo.pid = USB_DEVICE_AVRDRAGON;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII;
pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII;
pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII;
@ -1833,7 +1845,7 @@ static int jtagmkII_dragon_open_pdi(PROGRAMMER * pgm, char * port)
} }
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, baud, &pgm->fd)==-1) { if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }
@ -3438,7 +3450,7 @@ static int jtagmkII_open32(PROGRAMMER * pgm, char * port)
{ {
int status; int status;
unsigned char buf[6], *resp; unsigned char buf[6], *resp;
long baud; union pinfo pinfo;
if (verbose >= 2) if (verbose >= 2)
fprintf(stderr, "%s: jtagmkII_open32()\n", progname); fprintf(stderr, "%s: jtagmkII_open32()\n", progname);
@ -3449,7 +3461,7 @@ static int jtagmkII_open32(PROGRAMMER * pgm, char * port)
* a higher baud rate, we switch to it later on, after establishing * a higher baud rate, we switch to it later on, after establishing
* the connection with the ICE. * the connection with the ICE.
*/ */
baud = 19200; pinfo.baud = 19200;
/* /*
* If the port name starts with "usb", divert the serial routines * If the port name starts with "usb", divert the serial routines
@ -3460,7 +3472,9 @@ static int jtagmkII_open32(PROGRAMMER * pgm, char * port)
if (strncmp(port, "usb", 3) == 0) { if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB) #if defined(HAVE_LIBUSB)
serdev = &usb_serdev; serdev = &usb_serdev;
baud = USB_DEVICE_JTAGICEMKII; pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
pinfo.usbinfo.pid = USB_DEVICE_JTAGICEMKII;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII;
pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII;
pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII;
@ -3472,7 +3486,7 @@ static int jtagmkII_open32(PROGRAMMER * pgm, char * port)
} }
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, baud, &pgm->fd)==-1) { if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }

View File

@ -510,7 +510,7 @@ static char *usbErrorText(int usbErrno)
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
static int avrdoper_open(char *port, long baud, union filedescriptor *fdp) static int avrdoper_open(char *port, union pinfo pinfo, union filedescriptor *fdp)
{ {
int rval; int rval;
char *vname = "obdev.at"; char *vname = "obdev.at";

View File

@ -253,7 +253,7 @@ static int ser_set_dtr_rts(union filedescriptor *fdp, int is_on)
return 0; return 0;
} }
static int ser_open(char * port, long baud, union filedescriptor *fdp) static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp)
{ {
int rc; int rc;
int fd; int fd;
@ -281,7 +281,7 @@ static int ser_open(char * port, long baud, union filedescriptor *fdp)
/* /*
* set serial line attributes * set serial line attributes
*/ */
rc = ser_setspeed(fdp, baud); rc = ser_setspeed(fdp, pinfo.baud);
if (rc) { if (rc) {
fprintf(stderr, fprintf(stderr,
"%s: ser_open(): can't set attributes for device \"%s\": %s\n", "%s: ser_open(): can't set attributes for device \"%s\": %s\n",

View File

@ -111,7 +111,7 @@ static int ser_setspeed(union filedescriptor *fd, long baud)
} }
static int ser_open(char * port, long baud, union filedescriptor *fdp) static int ser_open(char * port, union pinfo pinfo, union filedescriptor *fdp)
{ {
LPVOID lpMsgBuf; LPVOID lpMsgBuf;
HANDLE hComPort=INVALID_HANDLE_VALUE; HANDLE hComPort=INVALID_HANDLE_VALUE;
@ -177,7 +177,7 @@ static int ser_open(char * port, long baud, union filedescriptor *fdp)
} }
fdp->pfd = (void *)hComPort; fdp->pfd = (void *)hComPort;
if (ser_setspeed(fdp, baud) != 0) if (ser_setspeed(fdp, pinfo.baud) != 0)
{ {
CloseHandle(hComPort); CloseHandle(hComPort);
fprintf(stderr, "%s: ser_open(): can't set com-state for \"%s\"\n", fprintf(stderr, "%s: ser_open(): can't set com-state for \"%s\"\n",

View File

@ -44,10 +44,22 @@ union filedescriptor
} usb; } usb;
}; };
union pinfo
{
long baud;
struct
{
unsigned short vid;
unsigned short pid;
unsigned short flags;
} usbinfo;
};
struct serial_device struct serial_device
{ {
// open should return -1 on error, other values on success // open should return -1 on error, other values on success
int (*open)(char * port, long baud, union filedescriptor *fd); int (*open)(char * port, union pinfo pinfo, union filedescriptor *fd);
int (*setspeed)(union filedescriptor *fd, long baud); int (*setspeed)(union filedescriptor *fd, long baud);
void (*close)(union filedescriptor *fd); void (*close)(union filedescriptor *fd);

View File

@ -672,8 +672,10 @@ static void stk500_enable(PROGRAMMER * pgm)
static int stk500_open(PROGRAMMER * pgm, char * port) static int stk500_open(PROGRAMMER * pgm, char * port)
{ {
union pinfo pinfo;
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, pgm->baudrate? pgm->baudrate: 115200, &pgm->fd)==-1) { pinfo.baud = pgm->baudrate? pgm->baudrate: 115200;
if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }

View File

@ -1587,12 +1587,12 @@ static void stk500v2_enable(PROGRAMMER * pgm)
static int stk500v2_open(PROGRAMMER * pgm, char * port) static int stk500v2_open(PROGRAMMER * pgm, char * port)
{ {
long baud = 115200; union pinfo pinfo = { .baud = 115200 };
DEBUG("STK500V2: stk500v2_open()\n"); DEBUG("STK500V2: stk500v2_open()\n");
if (pgm->baudrate) if (pgm->baudrate)
baud = pgm->baudrate; pinfo.baud = pgm->baudrate;
PDATA(pgm)->pgmtype = PGMTYPE_UNKNOWN; PDATA(pgm)->pgmtype = PGMTYPE_UNKNOWN;
@ -1615,7 +1615,9 @@ static int stk500v2_open(PROGRAMMER * pgm, char * port)
if (strncmp(port, "usb", 3) == 0) { if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB) #if defined(HAVE_LIBUSB)
serdev = &usb_serdev_frame; serdev = &usb_serdev_frame;
baud = USB_DEVICE_AVRISPMKII; pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
pinfo.usbinfo.pid = USB_DEVICE_AVRISPMKII;
PDATA(pgm)->pgmtype = PGMTYPE_AVRISP_MKII; PDATA(pgm)->pgmtype = PGMTYPE_AVRISP_MKII;
pgm->set_sck_period = stk500v2_set_sck_period_mk2; pgm->set_sck_period = stk500v2_set_sck_period_mk2;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII;
@ -1629,7 +1631,7 @@ static int stk500v2_open(PROGRAMMER * pgm, char * port)
} }
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, baud, &pgm->fd)==-1) { if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }
@ -1653,12 +1655,12 @@ static int stk500v2_open(PROGRAMMER * pgm, char * port)
static int stk600_open(PROGRAMMER * pgm, char * port) static int stk600_open(PROGRAMMER * pgm, char * port)
{ {
long baud = 115200; union pinfo pinfo = { .baud = 115200 };
DEBUG("STK500V2: stk600_open()\n"); DEBUG("STK500V2: stk600_open()\n");
if (pgm->baudrate) if (pgm->baudrate)
baud = pgm->baudrate; pinfo.baud = pgm->baudrate;
PDATA(pgm)->pgmtype = PGMTYPE_UNKNOWN; PDATA(pgm)->pgmtype = PGMTYPE_UNKNOWN;
@ -1671,7 +1673,9 @@ static int stk600_open(PROGRAMMER * pgm, char * port)
if (strncmp(port, "usb", 3) == 0) { if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB) #if defined(HAVE_LIBUSB)
serdev = &usb_serdev_frame; serdev = &usb_serdev_frame;
baud = USB_DEVICE_STK600; pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
pinfo.usbinfo.pid = USB_DEVICE_STK600;
PDATA(pgm)->pgmtype = PGMTYPE_STK600; PDATA(pgm)->pgmtype = PGMTYPE_STK600;
pgm->set_sck_period = stk600_set_sck_period; pgm->set_sck_period = stk600_set_sck_period;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII;
@ -1685,7 +1689,7 @@ static int stk600_open(PROGRAMMER * pgm, char * port)
} }
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, baud, &pgm->fd)==-1) { if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }
@ -3385,7 +3389,7 @@ static int stk500v2_perform_osccal(PROGRAMMER * pgm)
*/ */
static int stk500v2_jtagmkII_open(PROGRAMMER * pgm, char * port) static int stk500v2_jtagmkII_open(PROGRAMMER * pgm, char * port)
{ {
long baud; union pinfo pinfo;
void *mycookie; void *mycookie;
int rv; int rv;
@ -3398,7 +3402,7 @@ static int stk500v2_jtagmkII_open(PROGRAMMER * pgm, char * port)
* a higher baud rate, we switch to it later on, after establishing * a higher baud rate, we switch to it later on, after establishing
* the connection with the ICE. * the connection with the ICE.
*/ */
baud = 19200; pinfo.baud = 19200;
/* /*
* If the port name starts with "usb", divert the serial routines * If the port name starts with "usb", divert the serial routines
@ -3409,7 +3413,9 @@ static int stk500v2_jtagmkII_open(PROGRAMMER * pgm, char * port)
if (strncmp(port, "usb", 3) == 0) { if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB) #if defined(HAVE_LIBUSB)
serdev = &usb_serdev; serdev = &usb_serdev;
baud = USB_DEVICE_JTAGICEMKII; pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
pinfo.usbinfo.pid = USB_DEVICE_JTAGICEMKII;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII;
pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII;
pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII;
@ -3421,7 +3427,7 @@ static int stk500v2_jtagmkII_open(PROGRAMMER * pgm, char * port)
} }
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, baud, &pgm->fd)==-1) { if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }
@ -3499,7 +3505,7 @@ static void stk500v2_jtag3_close(PROGRAMMER * pgm)
*/ */
static int stk500v2_dragon_isp_open(PROGRAMMER * pgm, char * port) static int stk500v2_dragon_isp_open(PROGRAMMER * pgm, char * port)
{ {
long baud; union pinfo pinfo;
void *mycookie; void *mycookie;
if (verbose >= 2) if (verbose >= 2)
@ -3511,7 +3517,7 @@ static int stk500v2_dragon_isp_open(PROGRAMMER * pgm, char * port)
* a higher baud rate, we switch to it later on, after establishing * a higher baud rate, we switch to it later on, after establishing
* the connection with the ICE. * the connection with the ICE.
*/ */
baud = 19200; pinfo.baud = 19200;
/* /*
* If the port name starts with "usb", divert the serial routines * If the port name starts with "usb", divert the serial routines
@ -3522,7 +3528,9 @@ static int stk500v2_dragon_isp_open(PROGRAMMER * pgm, char * port)
if (strncmp(port, "usb", 3) == 0) { if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB) #if defined(HAVE_LIBUSB)
serdev = &usb_serdev; serdev = &usb_serdev;
baud = USB_DEVICE_AVRDRAGON; pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
pinfo.usbinfo.pid = USB_DEVICE_AVRDRAGON;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII;
pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII;
pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII;
@ -3534,7 +3542,7 @@ static int stk500v2_dragon_isp_open(PROGRAMMER * pgm, char * port)
} }
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, baud, &pgm->fd)==-1) { if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }
@ -3576,7 +3584,7 @@ static int stk500v2_dragon_isp_open(PROGRAMMER * pgm, char * port)
*/ */
static int stk500v2_dragon_hv_open(PROGRAMMER * pgm, char * port) static int stk500v2_dragon_hv_open(PROGRAMMER * pgm, char * port)
{ {
long baud; union pinfo pinfo;
void *mycookie; void *mycookie;
if (verbose >= 2) if (verbose >= 2)
@ -3588,7 +3596,7 @@ static int stk500v2_dragon_hv_open(PROGRAMMER * pgm, char * port)
* a higher baud rate, we switch to it later on, after establishing * a higher baud rate, we switch to it later on, after establishing
* the connection with the ICE. * the connection with the ICE.
*/ */
baud = 19200; pinfo.baud = 19200;
/* /*
* If the port name starts with "usb", divert the serial routines * If the port name starts with "usb", divert the serial routines
@ -3599,7 +3607,9 @@ static int stk500v2_dragon_hv_open(PROGRAMMER * pgm, char * port)
if (strncmp(port, "usb", 3) == 0) { if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB) #if defined(HAVE_LIBUSB)
serdev = &usb_serdev; serdev = &usb_serdev;
baud = USB_DEVICE_AVRDRAGON; pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
pinfo.usbinfo.pid = USB_DEVICE_AVRDRAGON;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII; pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_MKII;
pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII; pgm->fd.usb.rep = USBDEV_BULK_EP_READ_MKII;
pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII; pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_MKII;
@ -3611,7 +3621,7 @@ static int stk500v2_dragon_hv_open(PROGRAMMER * pgm, char * port)
} }
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, baud, &pgm->fd)==-1) { if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }
@ -3652,7 +3662,7 @@ static int stk500v2_dragon_hv_open(PROGRAMMER * pgm, char * port)
*/ */
static int stk500v2_jtag3_open(PROGRAMMER * pgm, char * port) static int stk500v2_jtag3_open(PROGRAMMER * pgm, char * port)
{ {
long baud; union pinfo pinfo;
void *mycookie; void *mycookie;
int rv; int rv;
@ -3667,7 +3677,9 @@ static int stk500v2_jtag3_open(PROGRAMMER * pgm, char * port)
if (strncmp(port, "usb", 3) == 0) { if (strncmp(port, "usb", 3) == 0) {
#if defined(HAVE_LIBUSB) #if defined(HAVE_LIBUSB)
serdev = &usb_serdev_frame; serdev = &usb_serdev_frame;
baud = USB_DEVICE_JTAGICE3; pinfo.usbinfo.vid = USB_VENDOR_ATMEL;
pinfo.usbinfo.flags = 0;
pinfo.usbinfo.pid = USB_DEVICE_JTAGICE3;
pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3; pgm->fd.usb.max_xfer = USBDEV_MAX_XFER_3;
pgm->fd.usb.rep = USBDEV_BULK_EP_READ_3; pgm->fd.usb.rep = USBDEV_BULK_EP_READ_3;
pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_3; pgm->fd.usb.wep = USBDEV_BULK_EP_WRITE_3;
@ -3679,7 +3691,7 @@ static int stk500v2_jtag3_open(PROGRAMMER * pgm, char * port)
} }
strcpy(pgm->port, port); strcpy(pgm->port, port);
if (serial_open(port, baud, &pgm->fd)==-1) { if (serial_open(port, pinfo, &pgm->fd)==-1) {
return -1; return -1;
} }

View File

@ -61,7 +61,7 @@ static int usb_interface;
* The "baud" parameter is meaningless for USB devices, so we reuse it * The "baud" parameter is meaningless for USB devices, so we reuse it
* to pass the desired USB device ID. * to pass the desired USB device ID.
*/ */
static int usbdev_open(char * port, long baud, union filedescriptor *fd) static int usbdev_open(char * port, union pinfo pinfo, union filedescriptor *fd)
{ {
char string[256]; char string[256];
char product[256]; char product[256];
@ -115,8 +115,8 @@ static int usbdev_open(char * port, long baud, union filedescriptor *fd)
{ {
for (dev = bus->devices; dev; dev = dev->next) for (dev = bus->devices; dev; dev = dev->next)
{ {
if (dev->descriptor.idVendor == USB_VENDOR_ATMEL && if (dev->descriptor.idVendor == pinfo.usbinfo.vid &&
dev->descriptor.idProduct == (unsigned short)baud) dev->descriptor.idProduct == pinfo.usbinfo.pid)
{ {
udev = usb_open(dev); udev = usb_open(dev);
if (udev) if (udev)

View File

@ -153,9 +153,11 @@ static int wiring_open(PROGRAMMER * pgm, char * port)
{ {
int timetosnooze; int timetosnooze;
void *mycookie = STK500V2PDATA(pgm)->chained_pdata; void *mycookie = STK500V2PDATA(pgm)->chained_pdata;
union pinfo pinfo;
strcpy(pgm->port, port); strcpy(pgm->port, port);
serial_open(port, pgm->baudrate ? pgm->baudrate: 115200, &pgm->fd); pinfo.baud = pgm->baudrate ? pgm->baudrate: 115200;
serial_open(port, pinfo, &pgm->fd);
/* If we have a snoozetime, then we wait and do NOT toggle DTR/RTS */ /* If we have a snoozetime, then we wait and do NOT toggle DTR/RTS */