Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

# xmodem.h

Go to the documentation of this file.

    00001 /*! \file xmodem.h \brief XModem Transmit/Receive Implementation with CRC and 1K support. */
    00002 //*****************************************************************************
    00003 //
    00004 // File Name    : 'xmodem.h'
    00005 // Title        : XModem Transmit/Receive Implementation with CRC and 1K support
    00006 // Author       : Pascal Stang - Copyright (C) 2006
    00007 // Created      : 4/22/2006
    00008 // Revised      : 7/22/2006
    00009 // Version      : 0.1
    00010 // Target MCU   : AVR processors
    00011 // Editor Tabs  : 4
    00012 //
    00013 /// \ingroup general
    00014 /// \defgroup xmodem XModem Transmit/Receive Implementation with CRC and 1K support (xmodem.c)
    00015 /// \code #include "xmodem.h" \endcode
    00016 /// \par Overview
    00017 ///     This XModem implementation supports both 128b and 1K packets with or
    00018 ///     without CRC checking.  The xmodem library must be initialized to use
    00019 ///     a particular I/O stream by passing appropriate getbyte() and sendbyte()
    00020 ///     functions to xmodemInit().  The xmodem transfer routines also expect
    00021 ///     function pointers to read and write data blocks on the local system.
    00022 ///     While this use of function pointers increases code size, it has great
    00023 ///     adaptability.  The generalized read/write data functions mean that it
    00024 ///     is easy to pipe data to/from any storage device like EEPROMs or flash
    00025 ///     cards, rather than being limited to just processor RAM.
    00026 //
    00027 // This code is distributed under the GNU Public License
    00028 //      which can be found at http://www.gnu.org/licenses/gpl.txt
    00029 //
    00030 //*****************************************************************************
    00031 //@{
    00032
    00033 #ifndef XMODEM_H
    00034 #define XMODEM_H
    00035
    00036 // xmodem control characters
    00037 #define SOH         0x01
    00038 #define STX         0x02
    00039 #define EOT         0x04
    00040 #define ACK         0x06
    00041 #define NAK         0x15
    00042 #define CAN         0x18
    00043 #define CTRLZ       0x1A
    00044
    00045 // xmodem timeout/retry parameters
    00046 #define XMODEM_TIMEOUT_DELAY    1000
    00047 #define XMODEM_RETRY_LIMIT      16
    00048
    00049 // error return codes
    00050 #define XMODEM_ERROR_REMOTECANCEL   -1
    00051 #define XMODEM_ERROR_OUTOFSYNC      -2
    00052 #define XMODEM_ERROR_RETRYEXCEED    -3
    00053
    00054
    00055 //! initialize xmodem stream I/O routines
    00056 void xmodemInit(void (*sendbyte_func)(unsigned char c), int (*getbyte_func)(void));
    00057
    00058 //! xmodem receive
    00059 long xmodemReceive( int (*write)(unsigned char* buffer, int size) );
    00060
    00061 //! xmodem transmit
    00062 long xmodemTransmit( int (*read)(unsigned char* buffer, int size) );
    00063
    00064 //! xmodem CRC/checksum error checking
    00065 int xmodemCrcCheck(int crcflag, const unsigned char *buffer, int size);
    00066
    00067 // extra stream I/O functions
    00068 //! get incoming character (wait for timeout)
    00069 int xmodemInTime(unsigned short timeout);
    00070
    00071 //! flush incoming character stream
    00072 void xmodemInFlush(void);
    00073
    00074 #endif
    00075
    00076 //@}