/********************************** (C) COPYRIGHT *******************************
* File Name          : I2Ctouchservice.h
* Author             : WingCool
* Version            : V1.0
* Date               : 2019/11/29
* Description        :
*******************************************************************************/
#ifndef _TOUCH_CONFIG_H
#define _TOUCH_CONFIG_H
#include "typedef.h"

#define FLASH_Base   0x08004000
#define APP_FALG_ADDR   (FLASH_Base - 256)
#define HASH_FLAG_ADDR  (APP_FALG_ADDR + 4)

#define AUTO_TEST           0
#define USBCONFIG           1
#define MOUSE_REPORT

typedef enum {
    CHIP_TYPE_UNKNOW,
    CHIP_TYPE_9XXX,
    CHIP_TYPE_9PXX,
    CHIP_TYPE_73XX,
    CHIP_TYPE_BERLINB,
    CHIP_TYPE_BERLINA,
    CHIP_TYPE_BERLIND,
    CHIP_TYPE_78XX,
    CHIP_TYPE_JD9366,
    CHIP_TYPE_NUM,
}CHIP_TYPE;


typedef enum _OPRATE_SYSTEM{
	ANDROID,
	ANDROID_OS,
	IOS
}OPERATE_SYSTEM;

//OPERATE_SYSTEM GetOperateSystem(void);
//void SetOperateSystem(OPERATE_SYSTEM os);
UINT8 DataFlash_BlockErase(UINT32 addr);
UINT8 DataFlash_WriteDW(UINT32 addr, UINT32 dat);

enum {EN_MOUSE_MULTITOUCH, EN_MOUSE_ONLY, EN_MULTITOUCH_ONLY};

#if USBCONFIG
#define CONFIG_ADDR (0x0800BF00)
#define CHIP_TYPE_ADDR  (0x0800BE00)
#define Fsize   (256)

enum {EN_USB_UART, EN_USB_IIC};
enum {EN_UART_PROTOCAL_8, EN_UART_PROTOCAL_10};

#pragma pack(1)
typedef struct{
    UINT8 len;
    UINT8 intf:1;
    UINT8 mouse_right_click_dis:1;
    UINT8 mouse_double_click_en:1;
    UINT8 remote_wakeup_en:1;
    UINT8 report_type:2;
    UINT8 uart_protocol:2;
    UINT8 vid_h;
    UINT8 vid_l;
    //UINT16 vid;
    UINT8 pid_h;
    UINT8 pid_l;
    //UINT16 pid;
    UINT8 uart_buad;
    UINT8 usb_bus_check_en:1;
    UINT8 res2:7;
    UINT8 dimenshion_x_h;
    UINT8 dimenshion_x_l;
    UINT8 dimenshion_Y_h;
    UINT8 dimenshion_Y_l;
    //UINT16 dimenshion_x;
    //UINT16 dimenshion_Y;
    UINT8 resolution_x_h;//RESOLUTION_X;
    UINT8 resolution_x_l;//RESOLUTION_X;
    UINT8 resolution_y_h;//RESOLUTION_Y;
    UINT8 resolution_y_l;//RESOLUTION_Y;
    UINT8 res1[6];
    UINT8 chksum[2]; //24  64 - 44=
}ST_CONFIG;

#define CONFIG_SIZE (sizeof(ST_CONFIG))

extern ST_CONFIG config;
extern void CheckBurnFlag();
extern void ConfigInit();
extern void SaveConfig(PUINT8 cfg);
extern void GetConfigFromFlash(PUINT8 pBuf);

extern void CheckFlag();
extern CHIP_TYPE GetChipTypeFromFlash(void);
extern void SaveChipTypeToFlash(CHIP_TYPE chip_type);
#endif
#endif
