/*
 * TouchCommon.h
 *
 *  Created on: Nov 10, 2021
 *      Author: Administrator
 */
#ifndef INCLUDE_TASKPROCESSCOM_H_
#define INCLUDE_TASKPROCESSCOM_H_
#include "ch32v30x.h"
#include "ch32x035_usbpd.h"
#include "ms933x_app.h"

#define PERIO_10ms 1
#define PERIO_50ms 80
#define PERIO_100ms 160
#define PERIO_200ms (160 * 2)
#define PERIO_300ms (160 * 3)
#define PERIO_500ms (160 * 5)
#define PERIO_800ms (160 * 8)
#define PERIO_1s 1600
#define PERIO_2s (PERIO_1s*2)
#define PERIO_5s (PERIO_1s*5)
#define PERIO_40s (PERIO_1s*40)


#define RESOLUTION_X  (16384-1)
#define RESOLUTION_Y  (9600-1)

#define DEVICE_MODE_MOUSE 0
#define DEVICE_MODE_SIGLETOUCH 1
#define DEVICE_MODE_MULTITOUCH  2

typedef enum {
  CHIP_TYPE_UNKNOW,
  CHIP_TYPE_MS1826A, //0xB6-B7
}CHIP_TYPE;


#define   BIT0                    (0X01)
#define   BIT1                    (0X02)
#define   BIT2                    (0X04)
#define   BIT3                    (0X08)
#define   BIT4                    (0X10)
#define   BIT5                    (0X20)
#define   BIT6                    (0X40)
#define   BIT7                    (0X80)


extern uint8_t GT_CMD_WR;
extern uint8_t GT_CMD_RD;

extern CHIP_TYPE ChipType;


extern uint8_t DeviceMode;
extern volatile BOOL UsbReportPosEn;

extern uint16_t wESDCheckTime;
extern BOOL enable_INT_irq;
extern BOOL enable_ESD_check;
extern uint8_t IdleTimer;
extern uint16_t UsbInitTimer;
extern void (*TouchProc)(void);
//extern UINT16 g_u16_timer_out;

void CheckUsbStatus();
void IICTouchInit();
void InitChipStartTask();

BOOL SearchAddress( uint8_t num );

void USART4_SendData(PUINT8 txbuf, uint16_t length);
void TIM3_Init( uint16_t arr, uint16_t psc );
#endif
