#ifndef _aplmt_fd_devices_fdserialapi_h_
#define _aplmt_fd_devices_fdserialapi_h_
/*----------------------------------------------------------------------------
** SUMMARY: APLMT File Descriptor Serial Port Interface (FDSERIAL)
**
** DESCRIPTION:
**  This file provides a common interface for "opening" serial port(s).  The
**  interface provides the mechanism for obtaining a file descriptor to 
**  serial port(s).
**
** CONFIGURATION 
** -------------
**  COMPILE:      none.
**
**  APPLICATION:  none.
**
**  PLATFORM:     Definitions:
**                  PLATFORM_APLMT_FDSERIAL_PORT_x
**                  PLATFORM_APLMT_FDSERIAL_BAUD_xxxx
**                  PLATFORM_APLMT_FDSERIAL_OPTS_xxxx
**
**
**  NOTES:
**  1. Unless explicitly stated otherwise, NONE of the following methods may be 
**     called from interrupt service routines.
**  2. Unless explicitly stated otherwise, NONE of the following methods may be 
**     called before the platform's kernel is running.
**  3. Unless explicitly stated otherwise, all of the following methods ARE 
**     thread-safe.
**  4. For efficency/optimization some methods are 'inlined'.  The inlining
**     is done by using the preprocessor/macros.  The application should
**     treat all methods as function calls and not rely on the fact they may
**     be currently defined as macros.
----------------------------------------------------------------------------*/

#include "aplmt/fd/fdapi.h"            /* for types (file descriptor & basic) */


#ifdef __cplusplus
extern "C" {
#endif

/*-------------- ERROR CODES (non-fatal) -----------------------------------*/
/** The specified serial port ID is not supported by the target platform
 */ 
#define APLMT_ERRSTR_FD_SERIAL_PORTID               "FDSERIAL: Specified serial port ID is not supported by the target platform." 
/***/
#define APLMT_ERR_FD_SERIAL_PORTID                  _APLMT_ERR_FD_SERIAL_PORTID

/** The specified baudrate is not supported by the target platform and/or
    specified serial port.
 */
#define APLMT_ERRSTR_FD_SERIAL_BAUDRATE             "FDSERIAL: Specified baud rate is not supported by the target platform."
/***/
#define APLMT_ERR_FD_SERIAL_BAUDRATE                _APLMT_ERR_FD_SERIAL_BAUDRATE

/** One or more of the specified options are not supported by the target 
    platform and/or specified serial port.
 */
#define APLMT_ERRSTR_FD_SERIAL_OPTIONS              "FDSERIAL: One or more the specified option(s) are not supported by the target platform."
/***/
#define APLMT_ERR_FD_SERIAL_OPTIONS                 _APLMT_ERR_FD_SERIAL_OPTIONS



/*-------------- CONSTANTS -------------------------------------------------*/
/** Port Idenfifiers */
#define APLMT_FDSERIAL_PORT_1                       PLATFORM_APLMT_FDSERIAL_PORT_1
#define APLMT_FDSERIAL_PORT_2                       PLATFORM_APLMT_FDSERIAL_PORT_2
#define APLMT_FDSERIAL_PORT_3                       PLATFORM_APLMT_FDSERIAL_PORT_3
#define APLMT_FDSERIAL_PORT_4                       PLATFORM_APLMT_FDSERIAL_PORT_4
#define APLMT_FDSERIAL_PORT_5                       PLATFORM_APLMT_FDSERIAL_PORT_5
#define APLMT_FDSERIAL_PORT_6                       PLATFORM_APLMT_FDSERIAL_PORT_6


/** Baud rate selections */
#define APLMT_FDSERIAL_BAUD_110                     PLATFORM_APLMT_FDSERIAL_BAUD_110
#define APLMT_FDSERIAL_BAUD_300                     PLATFORM_APLMT_FDSERIAL_BAUD_300
#define APLMT_FDSERIAL_BAUD_600                     PLATFORM_APLMT_FDSERIAL_BAUD_600
#define APLMT_FDSERIAL_BAUD_1200                    PLATFORM_APLMT_FDSERIAL_BAUD_1200
#define APLMT_FDSERIAL_BAUD_2400                    PLATFORM_APLMT_FDSERIAL_BAUD_2400
#define APLMT_FDSERIAL_BAUD_4800                    PLATFORM_APLMT_FDSERIAL_BAUD_4800
#define APLMT_FDSERIAL_BAUD_9600                    PLATFORM_APLMT_FDSERIAL_BAUD_9600
#define APLMT_FDSERIAL_BAUD_19200                   PLATFORM_APLMT_FDSERIAL_BAUD_19200
#define APLMT_FDSERIAL_BAUD_38400                   PLATFORM_APLMT_FDSERIAL_BAUD_38400
#define APLMT_FDSERIAL_BAUD_57600                   PLATFORM_APLMT_FDSERIAL_BAUD_57600
#define APLMT_FDSERIAL_BAUD_115200                  PLATFORM_APLMT_FDSERIAL_BAUD_115200
                                                    
/** OPTIONS: Parity */                              
#define APLMT_FDSERIAL_OPTS_NOPARITY                PLATFORM_APLMT_FDSERIAL_OPTS_NOPARITY       
#define APLMT_FDSERIAL_OPTS_ODDPARITY               PLATFORM_APLMT_FDSERIAL_OPTS_ODDPARITY 
#define APLMT_FDSERIAL_OPTS_EVENPARITY              PLATFORM_APLMT_FDSERIAL_OPTS_EVENPARITY

/** OPTIONS: Data size */
#define APLMT_FDSERIAL_OPTS_DATABITS_5              PLATFORM_APLMT_FDSERIAL_OPTS_DATABITS_5
#define APLMT_FDSERIAL_OPTS_DATABITS_6              PLATFORM_APLMT_FDSERIAL_OPTS_DATABITS_6
#define APLMT_FDSERIAL_OPTS_DATABITS_7              PLATFORM_APLMT_FDSERIAL_OPTS_DATABITS_7
#define APLMT_FDSERIAL_OPTS_DATABITS_8              PLATFORM_APLMT_FDSERIAL_OPTS_DATABITS_8

/** OPTIONS: Stop Bits */
#define APLMT_FDSERIAL_OPTS_STOPBITS_1              PLATFORM_APLMT_FDSERIAL_OPTS_STOPBITS_1
#define APLMT_FDSERIAL_OPTS_STOPBITS_2              PLATFORM_APLMT_FDSERIAL_OPTS_STOPBITS_2

/** OPTIONS: Flow control */
#define APLMT_FDSERIAL_OPTS_FLOWCTRL_NONE           PLATFORM_APLMT_FDSERIAL_OPTS_FLOWCTRL_NONE
#define APLMT_FDSERIAL_OPTS_FLOWCTRL_RTSCTS         PLATFORM_APLMT_FDSERIAL_OPTS_FLOWCTRL_RTSCTS
#define APLMT_FDSERIAL_OPTS_FLOWCTRL_DTRDSR         PLATFORM_APLMT_FDSERIAL_OPTS_FLOWCTRL_DTRDSR
#define APLMT_FDSERIAL_OPTS_FLOWCTRL_XONXOFF        PLATFORM_APLMT_FDSERIAL_OPTS_FLOWCTRL_XONXOFF


/*-------------- INLINE PLATFORM IMPLEMENTATION ----------------------------*/
#include "platform/fdserialapi.h"       


/*-------------- PUBLIC/PUBLISHED API --------------------------------------*/
/** Opens the serial port identified by 'portId' for use with the File
    Descriptor IO interface.  On success, the method returns a file
    descriptor (>=0) to the specified serial port.  If an error occurs than
    an error code (value <0) is returned.  
    NOTES:
        o The number (and mapping) of serial ports supported is dependant on 
          the actual target platform.
        o Features such as hardware/software flow control is also target 
          platform dependant.

    Prototype:
        AplmtFD Aplmt_openSerialPort( AplByte portId, AplByte baudrate, Apl16u options );
 */
#define Aplmt_openSerialPort                _Aplmt_openSerialPort



#ifdef __cplusplus
}
#endif
/*--------------------------------------------------------------------------*/
#endif  /* end _aplmt_fd_devices_fdserialapi_h_ */

