# 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 /* \cond Not trying to document any of this.. */
    00021
    00022 /* $Id: serial.h,v 1.14 2008/03/14 13:00:06 joerg_wunsch Exp $ */
    00023
    00024 /* This is the API for the generic serial interface. The implementations are
    00025    actually provided by the target dependant files:
    00026
    00027    ser_posix.c : posix serial interface.
    00028    ser_win32.c : native win32 serial interface.
    00029
    00030    The target file will be selected at configure time. */
    00031
    00032 #ifndef serial_h
    00033 #define serial_h
    00034
    00035 extern long serial_recv_timeout;
    00036
    00041 union filedescriptor
    00042 {
    00043   int ifd;
    00044   void *pfd;
    00045   struct
    00046   {
    00047     void *handle;
    00048     int ep;
    00049   } usb;
    00050 };
    00051
    00058 struct serial_device
    00059 {
    00060   void (*open)(char * port, long baud, union filedescriptor *fd);
    00061   int (*setspeed)(union filedescriptor *fd, long baud);
    00062   void (*close)(union filedescriptor *fd);
    00063
    00064   int (*send)(union filedescriptor *fd, unsigned char * buf, size_t buflen);
    00065   int (*recv)(union filedescriptor *fd, unsigned char * buf, size_t buflen);
    00066   int (*drain)(union filedescriptor *fd, int display);
    00067   void (*poll)(void);
    00068
    00069   int flags;
    00070 #define SERDEV_FL_NONE         0x0000 /* no flags */
    00071 #define SERDEV_FL_CANSETSPEED  0x0001 /* device can change speed */
    00072 };
    00073
    00074 extern struct serial_device *serdev;
    00075 extern struct serial_device serial_serdev;
    00076 extern struct serial_device usb_serdev;
    00077 extern struct serial_device usb_serdev_frame;
    00078 extern struct serial_device avrdoper_serdev;
    00079
    00080 #define serial_open (serdev->open)
    00081 #define serial_setspeed (serdev->setspeed)
    00082 #define serial_close (serdev->close)
    00083 #define serial_send (serdev->send)
    00084 #define serial_recv (serdev->recv)
    00085 #define serial_drain (serdev->drain)
    00086 #define serial_poll (serdev->poll)
    00087
    00088 /* \endcond */
    00089
    00090 #endif /* serial_h */