# serial.h

    00001 /*
    00002  * avrdude - A Downloader/Uploader for AVR device programmers
    00003  * Copyright (C) 2003-2004  Theodore A. Roth  <troth@openavr.org>
    00004  *
    00005  * This program is free software; you can redistribute it and/or modify
    00006  * it under the terms of the GNU General Public License as published by
    00007  * the Free Software Foundation; either version 2 of the License, or
    00008  * (at your option) any later version.
    00009  *
    00010  * This program is distributed in the hope that it will be useful,
    00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00013  * GNU General Public License for more details.
    00014  *
    00015  * You should have received a copy of the GNU General Public License
    00016  * along with this program; if not, write to the Free Software
    00017  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    00018  */
    00019
    00020 /* $Id: serial.h,v 1.14 2008/03/14 13:00:06 joerg_wunsch Exp $ */
    00021
    00022 /* This is the API for the generic serial interface. The implementations are
    00023    actually provided by the target dependant files:
    00024
    00025    ser_posix.c : posix serial interface.
    00026    ser_win32.c : native win32 serial interface.
    00027
    00028    The target file will be selected at configure time. */
    00029
    00030 #ifndef serial_h
    00031 #define serial_h
    00032
    00033 extern long serial_recv_timeout;
    00034
    00039 union filedescriptor
    00040 {
    00041   int ifd;
    00042   void *pfd;
    00043   struct
    00044   {
    00045     void *handle;
    00046     int ep;
    00047   } usb;
    00048 };
    00049
    00056 struct serial_device
    00057 {
    00058   void (*open)(char * port, long baud, union filedescriptor *fd);
    00059   int (*setspeed)(union filedescriptor *fd, long baud);
    00060   void (*close)(union filedescriptor *fd);
    00061
    00062   int (*send)(union filedescriptor *fd, unsigned char * buf, size_t buflen);
    00063   int (*recv)(union filedescriptor *fd, unsigned char * buf, size_t buflen);
    00064   int (*drain)(union filedescriptor *fd, int display);
    00065   void (*poll)(void);
    00066
    00067   int flags;
    00068 #define SERDEV_FL_NONE         0x0000 /* no flags */
    00069 #define SERDEV_FL_CANSETSPEED  0x0001 /* device can change speed */
    00070 };
    00071
    00072 extern struct serial_device *serdev;
    00073 extern struct serial_device serial_serdev;
    00074 extern struct serial_device usb_serdev;
    00075 extern struct serial_device usb_serdev_frame;
    00076 extern struct serial_device avrdoper_serdev;
    00077
    00078 #define serial_open (serdev->open)
    00079 #define serial_setspeed (serdev->setspeed)
    00080 #define serial_close (serdev->close)
    00081 #define serial_send (serdev->send)
    00082 #define serial_recv (serdev->recv)
    00083 #define serial_drain (serdev->drain)
    00084 #define serial_poll (serdev->poll)
    00085
    00086 #endif /* serial_h */