/****************************************************************************
*
* (C) 2001 by Beck IPC GmbH
*
*  Beck IPC GmbH
*  Garbenheimerstr. 36-38
*  D-35578 Wetzlar
*
*  Phone : (49)-6441-905-240
*  Fax   : (49)-6441-905-245

$Header: fossil.h, 6, 13.06.2002 16:29:12, Christoph Stoidner$

*
* ---------------------------------------------------------------------------
* Module        : fossil.h
*
* Function      : prototypes, constants for fossil functions
*                 functions must should be used with program memory model large!
*
* Author        : Detlef Gerhardt
* Date          : 10.01.01
* ---------------------------------------------------------------------------


$Log:
 6    IPC@CHIP  1.5         13.06.2002 16:29:12  Christoph Stoidner add
      fossil_send_break() and fossil_get_bytes_in_uart()
 5    IPC@CHIP  1.4         16.01.2002 14:15:53  Christoph Stoidner add an
      semicolon
 4    IPC@CHIP  1.3         14.01.2002 13:18:05  Christoph Stoidner correct
      comments, add new functions
 3    IPC@CHIP  1.2         16.11.2001 12:18:11  Ernest Schlösser Added comments
 2    IPC@CHIP  1.1         28.03.2001 16:00:30  Christoph Stoidner Bugfix: add
      Parameter Values to RS485 Mode Macros
 1    IPC@CHIP  1.0         09.03.2001 16:35:57  Christoph Stoidner
$


* History       :
*
*  Vx.yy                   Author  Changes
*
*             10.01.01      db    Create
              10.01.02      cs    add FossilDriverInfo_t
/****************************************************************************/
#ifndef __FOSSIL_H__
#define __FOSSIL_H__
/****************************************************************************/

// constants
#define FOSSIL_EXT 0
#define FOSSIL_COM 1

// parity
#define FOSSIL_PARITY_NO 0
#define FOSSIL_PARITY_ODD 1
#define FOSSIL_PARITY_EVEN 2
#define FOSSIL_PARITY_MARK 3
#define FOSSIL_PARITY_SPACE 4

// status
#define FOSSIL_OUTPUT_BUFFER_EMPTY 0x40
#define FOSSIL_OUTPUT_NOT_FULL 0x20
#define FOSSIL_LINE_BREAK 0x10
#define FOSSIL_FRAMING_ERROR 0x08
#define FOSSIL_PARITY_ERROR 0x04
#define FOSSIL_OVERRUN_ERROR 0x02
#define FOSSIL_DATA_AVAILABLE 0x01

// flowcontrol
#define FOSSIL_FLOWCTRL_OFF 0x00
#define FOSSIL_FLOWCTRL_XONXOFF_SEND 0x01
#define FOSSIL_FLOWCTRL_RTSCTS 0x02
#define FOSSIL_FLOWCTRL_XONXOFF_RECV 0x08

// RS485 mode
#define FOSSIL_RS485_LOWACTIVE       0
#define FOSSIL_RS485_HIGHACTIVE      1
#define FOSSIL_RS485_DISABLE         2


// type definitions
typedef struct
{
  unsigned       size;          // structure size
  unsigned char  version;       // (not used)
  unsigned char  level;         // (not used)
  char          *id;            // (not used)
  unsigned       inputBuffSize; // input buffer size
  unsigned       inputAvaiable; // bytes available on Input buffer
  unsigned       outputBuffSize;// output buffer size
  unsigned       ouputAvaiable; // bytes available on Output buffer
  unsigned char  screenWidth;   // (not used)
  unsigned char  screenHeight;  // (not used)
  unsigned char  baudrateMask;  // (not used)
} FossilDriverInfo_t;



// procedures
int fossil_init(int port);   // ret 0 if o.k.
void fossil_deinit(int port);
int fossil_setbaud(int port, long baudrate, int parity, int wordlen, int stopbits);
int fossil_putbyte_wait(int port, int ch);
int fossil_putbyte(int port, int ch);
int fossil_getbyte_wait(int port);
int fossil_peek_input(int port);    // ret char in buffer, -1 if none available
int fossil_status_request(int port);
void fossil_flush_output(int port);
void fossil_purge_output(int port);
void fossil_purge_input(int port);
void fossil_set_flowcontrol(int port, int flowctrl);
unsigned int fossil_readblock(int port, unsigned char *buffer, unsigned int count);
unsigned int fossil_writeblock(int port, unsigned char *buffer, unsigned int count);
void fossil_set_rs485(int port, int mode);
void fossil_set_rs485_txenable(int port, int pin);
void fossil_set_extctrl(int port, int divider, int parity, int wordlen, int stopbits);
int fossil_get_driver_info(int port, FossilDriverInfo_t *drv_info);
void fossil_send_break(int port, unsigned char longbreak );
int fossil_get_bytes_in_uart(int port);

/*************************************************************************/
#endif /* __FOSSIL_H__ */
/****************************************************************************/
// end of file
/****************************************************************************/
