
/********************************************************************************
* File : mipiCntrlDef.h
* Copyright 2014-2015, Raytrex Technology Co., Ltd.	All Rights Reserved.
*
* A Zebra DLL header file, APIs allow application communicating with
* Zebra capture-card through USB interface.
*
* Author: T.J.Hsu
* Date: 2014.04.02
* To use, modify, reproduce, and distribute this file is strictly forbidden
* without the prior written permission of Raytrex Technology Co., Ltd.
********************************************************************************/
#ifndef __mipiCntrlDef_h__
#define __mipiCntrlDef_h__


// Command type to Zebra
#define __CMD_SET_DRIVERS_SETTING__				0x0
#define __CMD_GET_DRIVERS_SETTING__				0x1
#define __CMD_RUN_TESTING_STEP__				0x2
#define	__CMD_GET_SNAPPING_STATE__				0x3		// Get current run step status

#define	__CMD_ZEBRA_RESETT__					0x8
#define	__CMD_GET_ZEBRA_STATUS__				0x9
#define	__CMD_GET_ZEBRA_VERSIONS__				0xa


#define __CMD_I2C_READ_WRITE__					0x10
#define	__CMD_GET_IMAGE__						0x20
#define	__CMD_ZEBEA_LOCAL_ACT__					0x22
#define __CMD_UART_READ_WRITE__					0x30
#define __CMD_GPIO_READ_WRITE__					0x40

#define	__CMD_STORE_STEPS_TO_SD__				0xa0
#define	__CMD_LOAD_STEPS_FROM_SD__				0xa1
#define	__CMD_BROWSE_SD_TESTING_STEPS__			0xa2



/* Get image operation code:
		0 - no operation
*/
#define	__Grab_opt_noneOperation__				0
#define	__Grab_opt_ImageAvg__					1



/* Get image error code
					 Error code - 
												1: no image
												2: snapping now ...
												3: start index fail
												4: end index fail
												5: operation code error
*/
#define	__Error_None__									0
#define	__Error_No_image__								1
#define	__Error_snapping__								2
#define	__Error_start_index__							3
#define	__Error_end_index__								4
#define	__Error_opCode__								5
#define __Error_getPicBufferTooShort				10





// Run step status...
#define	__Sta_step_succeed__					0x0
#define	__Sta_Err_I2cWrite__					0x1
#define	__Sta_step_snapping__					0x2

#define	__Sta_None_Imgage__						0xfc
#define	__Sta_Invalid__							0xfe

// Run step result type
#define		__noMoreData__						0
#define		__SnapPicture__						1
#define		__AppendData__						2

typedef struct __runStepStateStruct__
{
	unsigned char  runResultState;				// 0 - succeed, else error code
	unsigned char  resultType;	// which data in next field
	union
	{
		// resultType : __noMoreData__, 
		unsigned char   none;

		// resultType : Snap data report
		struct {
			unsigned char 	snapCnt;		// How many snap pictures send to host ...
			ULONG			pSnaPicSiz[128];
		};
		// __AppendData__
		struct {
			unsigned char 	appDataLen;	// append data length 
			unsigned char   appendBuffer[256];
		};
	};
} SRUNSTEPSTATE, *PSRUNSTEPSTATE;





#define		__std_sysReady__				0
#define		__std_sysBusy__					1
#define		__std_sysError__				2

typedef struct __ZebraStatusStruct__
{
	unsigned char		zebraState;				// 0 - succeed, else error code
	// add new items ...

} SZEBRASTATUS, *PSZEBRASTATUS;




typedef struct __ZebraVersionStruct__
{
	unsigned short zebraMajorVer;
	unsigned short zebraMinorVer;
	unsigned short zebraBuildNumber;
	unsigned short zebraRevisionNumber;
	// add new items ...
	unsigned short kernelMajorVer;
	unsigned short kernelMinorVer;
	unsigned short kernelBuildNumber;
	unsigned short kernelRevisionNumber;

}SZEBRAVERSION, *PSZEBRAVERSION;

typedef struct __StepAliasNameStruct__
{
	int stepId;
	char stepAliasName[256];
}SSTEP_ALIAS_NAME, *PSSTEP_ALIAS_NAME;


// Locald command definition
#define __LocCmd_ColarBarCmp__			0

#define __ColorBarCmp_Success__			0
#define __ColarBarCmp_Fail__			1		// colar isn't same
#define __ColarBarCmp_NoColarBar__		2		// snapped color bark fail

#define __Zebra_ErrCmdResult__			0x10

#endif // __mipiCntrlDef_h__