/******************************************************************************
*                                                                            --
*       COPYRIGHT (c)                                 ERICSSON AB,  2005     --
*                                                                            --
*       The  copyright  to  the document(s)  herein  is  the property of     --
*       Ericsson Mobile Platforms, Sweden.                                   --
*                                                                            --
*       The document(s) may be used  and/or copied only with the written     --
*       permission from Ericsson Mobile Platforms or in accordance           --
*       with the terms and conditions stipulated in the agreement/contract   --
*       under which the document(s) have been supplied.                      --
*                                                                            --
*------------------------------------------------------------------------------
*
*       Id:             meflash.h
*
*       Project:        MEFLASH
*
*       Type:           C Include
*
*       Purpose:        USB
*
*       Description:    Functions and type declarations for MEFLASH dll.
*
*       Modification history:
*       YYMMDD Designer Description
*       030303 QMIKANS  Imported.
*       051116 QGEOAND  Removed JNI
*		060216 QGEOAND  Added GetRealPort and disconnect event
*
******************************************************************************/

// The following ifdef block is the standard way of creating macros which make exporting 
// from a DLL simpler. All files within this DLL are compiled with the MEFLASH_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see 
// MEFLASH_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.

#ifdef MEFLASH_DLL_EXPORTS
#define MEFLASH_API __declspec(dllexport)
#else
#define MEFLASH_API __declspec(dllimport)
#endif

extern MEFLASH_API int nMEFLASH;

MEFLASH_API int fnMEFLASH(void);

typedef enum
{
  MEF_OK                       = 0,
  MEF_ALREADY_OPENED           = 500,
  MEF_NOT_OPENED               = 501,
  MEF_EVENT_UNKNOWN            = 502,
  MEF_EVENT_NOT_REGISTERED     = 503,
  MEF_EVENT_ALREADY_REGISTERED = 504,
  MEF_PORT_IS_OPEN             = 1000,
  MEF_OPEN_FAILED              = 1001,
  MEF_PORT_IN_USE              = 1002,
  MEF_PORT_NOT_VALID           = 1003,
  MEF_NO_FREE_INDEX            = 1005,
  MEF_PORT_CLOSE_FAIL          = 1006,
  MEF_PORT_NOT_OPEN            = 1007,
  MEF_FAIL                     = 1008,
  MEF_BUFFER_FULL              = 1009,
  MEF_CHANNEL_NOT_SUPPORTED    = 1010,
  MEF_LOCKFAIL                 = 1011,
  MEF_INPARAM_NULL             = 1012,
  MEF_SIZEZERO                 = 1013,
  MEF_TIMEOUT                  = 1014,
  MEF_INTERNAL_ERROR           = 5000
};
typedef long meferrorcode_t;

typedef enum
{
	MEF_EVENT_CONNECT = 0,
	MEF_EVENT_DISCONNECT,
	MEF_EVENT_RXDATA,
	MEF_EVENT_LAST
};

typedef long mefcallbackevent_t;
typedef long (mefcallbackfunc_t)(long, long, long);

// Exported functions
extern MEFLASH_API meferrorcode_t mefRegisterCallback	(mefcallbackfunc_t*  const func, mefcallbackevent_t eventtype);
extern MEFLASH_API meferrorcode_t mefUnregisterCallback	(mefcallbackevent_t eventtype);
extern MEFLASH_API meferrorcode_t mefOpenPort			(int usbPort);
extern MEFLASH_API meferrorcode_t mefClosePort			(int usbPort);
extern MEFLASH_API meferrorcode_t mefWriteBuff			(int usbPort, unsigned char* const buffer_p, int size);
extern MEFLASH_API meferrorcode_t mefGetRxBuffCount		(int usbPort, int* const count_p);
extern MEFLASH_API meferrorcode_t mefFlushRxBuff		(int usbPort);
extern MEFLASH_API meferrorcode_t mefGetRxBuff			(int usbPort, unsigned char* const buffer_p, int* const buffsize_p);
extern MEFLASH_API meferrorcode_t mefSetRxTimeout		(int usbPort, int timeoutms);
extern MEFLASH_API meferrorcode_t mefSetTxTimeout		(int usbPort, int timeoutms);
extern MEFLASH_API meferrorcode_t mefGetRxTimeout		(int usbPort, int* const timeoutms);
extern MEFLASH_API meferrorcode_t mefGetTxTimeout		(int usbPort, int* const timeoutms);
extern MEFLASH_API meferrorcode_t mefGetErrorString		(meferrorcode_t , const char** const str_pp);
extern MEFLASH_API meferrorcode_t mefGetRealPort		(int usbPort, int* const realport);
