2003-03-13 03:52:19 +00:00
|
|
|
/*
|
|
|
|
* avrdude - A Downloader/Uploader for AVR device programmers
|
2004-12-22 01:52:45 +00:00
|
|
|
* Copyright (C) 2003-2004 Theodore A. Roth <troth@openavr.org>
|
2003-03-13 03:52:19 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2012-11-20 14:03:50 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-03-13 03:52:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
/* This is the API for the generic serial interface. The implementations are
|
|
|
|
actually provided by the target dependant files:
|
|
|
|
|
|
|
|
ser_posix.c : posix serial interface.
|
|
|
|
ser_win32.c : native win32 serial interface.
|
|
|
|
|
|
|
|
The target file will be selected at configure time. */
|
|
|
|
|
2007-01-24 22:43:46 +00:00
|
|
|
#ifndef serial_h
|
|
|
|
#define serial_h
|
2003-03-13 03:52:19 +00:00
|
|
|
|
Mega-commit to bring in both, the STK500v2 support from Erik
Walthinsen, as well as JTAG ICE mkII support (by me).
Erik's submission has been cleaned up a little bit, mostly to add his
name and the current year to the copyright of the new file, remove
trailing white space before importing the files, and fix the minor
syntax errors in his avrdude.conf.in additions (missing semicolons).
The JTAG ICE mkII support should be considered alpha to beta quality
at this point. Few things are still to be done, like defering the
hfuse (OCDEN) tweaks until they are really required. Also, for
reasons not yet known, the target MCU doesn't start to run after
signing off from the ICE, it needs a power-cycle first (at least on my
STK500).
Note that for the JTAG ICE, I did change a few things in the internal
API. Notably I made the serial receive timeout configurable by the
backends via an exported variable (done in both the Posix and the
Win32 implementation), and I made the serial_recv() function return a
-1 instead of bailing out with exit(1) upon encountering a receive
timeout (currently only done in the Posix implementation). Both
measures together allow me to receive a datastreem from the ICE at 115
kbps on a somewhat lossy PCI multi-UART card that occasionally drops a
character. The JTAG ICE mkII protocol has enough of safety layers to
allow recovering from these events, but the previous code wasn't
prepared for any kind of recovery. The Win32 change for this still
has to be done, and the traditional drivers need to be converted to
exit(1) upon encountering a timeout (as they're now getting a -1
returned they didn't see before in that case).
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@451 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 19:17:12 +00:00
|
|
|
extern long serial_recv_timeout;
|
2006-12-11 12:47:35 +00:00
|
|
|
union filedescriptor
|
|
|
|
{
|
|
|
|
int ifd;
|
|
|
|
void *pfd;
|
2008-03-14 13:00:08 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
void *handle;
|
2012-11-26 16:24:56 +00:00
|
|
|
int rep; /* bulk read endpoint */
|
|
|
|
int wep; /* bulk write endpoint */
|
|
|
|
int eep; /* event read endpoint */
|
|
|
|
int max_xfer; /* max transfer size */
|
2014-02-26 17:54:32 +00:00
|
|
|
int use_interrupt_xfer; /* device uses interrupt transfers */
|
2008-03-14 13:00:08 +00:00
|
|
|
} usb;
|
2006-12-11 12:47:35 +00:00
|
|
|
};
|
Mega-commit to bring in both, the STK500v2 support from Erik
Walthinsen, as well as JTAG ICE mkII support (by me).
Erik's submission has been cleaned up a little bit, mostly to add his
name and the current year to the copyright of the new file, remove
trailing white space before importing the files, and fix the minor
syntax errors in his avrdude.conf.in additions (missing semicolons).
The JTAG ICE mkII support should be considered alpha to beta quality
at this point. Few things are still to be done, like defering the
hfuse (OCDEN) tweaks until they are really required. Also, for
reasons not yet known, the target MCU doesn't start to run after
signing off from the ICE, it needs a power-cycle first (at least on my
STK500).
Note that for the JTAG ICE, I did change a few things in the internal
API. Notably I made the serial receive timeout configurable by the
backends via an exported variable (done in both the Posix and the
Win32 implementation), and I made the serial_recv() function return a
-1 instead of bailing out with exit(1) upon encountering a receive
timeout (currently only done in the Posix implementation). Both
measures together allow me to receive a datastreem from the ICE at 115
kbps on a somewhat lossy PCI multi-UART card that occasionally drops a
character. The JTAG ICE mkII protocol has enough of safety layers to
allow recovering from these events, but the previous code wasn't
prepared for any kind of recovery. The Win32 change for this still
has to be done, and the traditional drivers need to be converted to
exit(1) upon encountering a timeout (as they're now getting a -1
returned they didn't see before in that case).
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@451 81a1dc3b-b13d-400b-aceb-764788c761c2
2005-05-10 19:17:12 +00:00
|
|
|
|
2014-02-21 13:44:11 +00:00
|
|
|
union pinfo
|
|
|
|
{
|
|
|
|
long baud;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
unsigned short vid;
|
|
|
|
unsigned short pid;
|
|
|
|
unsigned short flags;
|
2014-02-26 17:54:32 +00:00
|
|
|
#define PINFO_FL_USEHID 0x0001
|
2014-02-21 13:44:11 +00:00
|
|
|
} usbinfo;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-06-19 21:38:03 +00:00
|
|
|
struct serial_device
|
|
|
|
{
|
2010-10-22 14:29:56 +00:00
|
|
|
// open should return -1 on error, other values on success
|
2014-02-21 13:44:11 +00:00
|
|
|
int (*open)(char * port, union pinfo pinfo, union filedescriptor *fd);
|
2006-12-11 12:47:35 +00:00
|
|
|
int (*setspeed)(union filedescriptor *fd, long baud);
|
|
|
|
void (*close)(union filedescriptor *fd);
|
2005-06-19 21:38:03 +00:00
|
|
|
|
2006-12-11 12:47:35 +00:00
|
|
|
int (*send)(union filedescriptor *fd, unsigned char * buf, size_t buflen);
|
|
|
|
int (*recv)(union filedescriptor *fd, unsigned char * buf, size_t buflen);
|
|
|
|
int (*drain)(union filedescriptor *fd, int display);
|
2006-10-27 08:45:47 +00:00
|
|
|
|
2009-10-10 01:41:40 +00:00
|
|
|
int (*set_dtr_rts)(union filedescriptor *fd, int is_on);
|
|
|
|
|
2006-10-27 08:45:47 +00:00
|
|
|
int flags;
|
|
|
|
#define SERDEV_FL_NONE 0x0000 /* no flags */
|
|
|
|
#define SERDEV_FL_CANSETSPEED 0x0001 /* device can change speed */
|
2005-06-19 21:38:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern struct serial_device *serdev;
|
2006-12-20 23:43:34 +00:00
|
|
|
extern struct serial_device serial_serdev;
|
|
|
|
extern struct serial_device usb_serdev;
|
|
|
|
extern struct serial_device usb_serdev_frame;
|
|
|
|
extern struct serial_device avrdoper_serdev;
|
2005-06-19 21:38:03 +00:00
|
|
|
|
|
|
|
#define serial_open (serdev->open)
|
|
|
|
#define serial_setspeed (serdev->setspeed)
|
|
|
|
#define serial_close (serdev->close)
|
|
|
|
#define serial_send (serdev->send)
|
|
|
|
#define serial_recv (serdev->recv)
|
|
|
|
#define serial_drain (serdev->drain)
|
2009-10-10 01:41:40 +00:00
|
|
|
#define serial_set_dtr_rts (serdev->set_dtr_rts)
|
2003-03-13 03:52:19 +00:00
|
|
|
|
2007-01-24 22:43:46 +00:00
|
|
|
#endif /* serial_h */
|