STM32H750XB_RT-THREAD/28-电容触摸屏—触摸画板(兼容屏幕版本)/User/touch/bsp_touch_gtxx.c

1353 lines
36 KiB
C
Raw Normal View History

2025-07-21 06:34:29 +00:00
/**
******************************************************************************
* @file gtxx.c
* @author fire
* @version V1.0
* @date 2015-xx-xx
* @brief i2c<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>gt9157/gt911/gt5688оƬ
******************************************************************************
* @attention
*
* ʵ<EFBFBD><EFBFBD>ƽ̨:Ұ<EFBFBD><EFBFBD> STM32 H750/H743 <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD><EFBFBD>̳ :http://www.firebbs.cn
* <EFBFBD>Ա<EFBFBD> :http://firestm32.taobao.com
*
******************************************************************************
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "./touch/bsp_touch_gtxx.h"
#include "./touch/bsp_i2c_touch.h"
#include "./lcd/bsp_lcd.h"
#include "./touch/palette.h"
#include "./delay/core_delay.h"
// 5<><35><EFBFBD><EFBFBD>GT9157<35><37><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
const uint8_t CTP_CFG_GT9157[] ={
0x00,0x20,0x03,0xE0,0x01,0x05,0x3C,0x00,0x01,0x08,
0x28,0x0C,0x50,0x32,0x03,0x05,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x17,0x19,0x1E,0x14,0x8B,0x2B,0x0D,
0x33,0x35,0x0C,0x08,0x00,0x00,0x00,0x9A,0x03,0x11,
0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x32,0x00,0x00,
0x00,0x20,0x58,0x94,0xC5,0x02,0x00,0x00,0x00,0x04,
0xB0,0x23,0x00,0x93,0x2B,0x00,0x7B,0x35,0x00,0x69,
0x41,0x00,0x5B,0x4F,0x00,0x5B,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x02,0x04,0x06,0x08,0x0A,0x0C,0x0E,0x10,
0x12,0x14,0x16,0x18,0x1A,0xFF,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x02,0x04,0x06,0x08,0x0A,0x0C,0x0F,
0x10,0x12,0x13,0x16,0x18,0x1C,0x1D,0x1E,0x1F,0x20,
0x21,0x22,0x24,0x26,0xFF,0xFF,0xFF,0xFF,0x00,0x00,
0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0x48,0x01
};
// 7<><37><EFBFBD><EFBFBD>GT911<31><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>Ĭ<EFBFBD><C4AC>ʹ<EFBFBD>õ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><EFBFBD><ECB3A3><EFBFBD>ɳ<EFBFBD><C9B3><EFBFBD>ʹ<EFBFBD>õڶ<C3B5><DAB6><EFBFBD>
#if 1
const uint8_t CTP_CFG_GT911[] = {
0x41,0x20,0x03,0xE0,0x01,0x05,0x3D,0x00,0x01,0x08,
0x1E,0x05,0x3C,0x3C,0x03,0x05,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x1A,0x1C,0x1E,0x14,0x8A,0x2A,0x0C,
0x2A,0x28,0xEB,0x04,0x00,0x00,0x01,0x61,0x03,0x2C,
0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x14,0x3C,0x94,0xC5,0x02,0x08,0x00,0x00,0x04,
0xB7,0x16,0x00,0x9F,0x1B,0x00,0x8B,0x22,0x00,0x7B,
0x2B,0x00,0x70,0x36,0x00,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x16,0x14,0x12,0x10,0x0E,0x0C,0x0A,
0x08,0x06,0x04,0x02,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x24,0x22,0x21,0x20,0x1F,0x1E,0x1D,0x1C,
0x18,0x16,0x13,0x12,0x10,0x0F,0x0A,0x08,0x06,0x04,
0x02,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x0A,0x00
};
#else
const uint8_t CTP_CFG_GT911[] = {
0x00,0x20,0x03,0xE0,0x01,0x05,0x0D,0x00,0x01,0x08,
0x28,0x0F,0x50,0x32,0x03,0x05,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8A,0x2A,0x0C,
0x45,0x47,0x0C,0x08,0x00,0x00,0x00,0x02,0x02,0x2D,
0x00,0x00,0x00,0x00,0x00,0x03,0x64,0x32,0x00,0x00,
0x00,0x28,0x64,0x94,0xC5,0x02,0x07,0x00,0x00,0x04,
0x9C,0x2C,0x00,0x8F,0x34,0x00,0x84,0x3F,0x00,0x7C,
0x4C,0x00,0x77,0x5B,0x00,0x77,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x16,0x14,0x12,0x10,0x0E,0x0C,0x0A,
0x08,0x06,0x04,0x02,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x16,0x18,0x1C,0x1D,0x1E,0x1F,0x20,0x21,
0x22,0x24,0x13,0x12,0x10,0x0F,0x0A,0x08,0x06,0x04,
0x02,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x24,0x01
};
#endif
// 4.3<EFBFBD><EFBFBD><EFBFBD><EFBFBD>GT5688<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><><D7A2>gt5688<38><38>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫд<D2AA><D0B4>0x97<39>Ż<EFBFBD><C5BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
const uint8_t CTP_CFG_GT5688[] = {
0x97,0xE0,0x01,0x10,0x01,0x05,0x0D,0x00,0x01,0x00,
0x00,0x05,0x5A,0x46,0x53,0x11,0x00,0x00,0x11,0x11,
0x14,0x14,0x14,0x22,0x0A,0x04,0x00,0x00,0x00,0x00,
0x00,0x00,0x53,0x00,0x14,0x00,0x00,0x84,0x00,0x00,
0x3C,0x00,0x00,0x64,0x1E,0x28,0x87,0x27,0x08,0x32,
0x34,0x05,0x0D,0x20,0x33,0x60,0x11,0x02,0x24,0x00,
0x00,0x64,0x80,0x80,0x14,0x02,0x00,0x00,0x54,0x89,
0x68,0x85,0x6D,0x82,0x72,0x80,0x76,0x7D,0x7B,0x7B,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xF0,0x50,0x3C,
0xFF,0xFF,0x07,0x00,0x00,0x00,0x02,0x14,0x14,0x03,
0x04,0x00,0x21,0x64,0x0A,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x32,0x20,0x50,0x3C,0x3C,0x00,0x00,0x00,0x00,0x00,
0x0D,0x06,0x0C,0x05,0x0B,0x04,0x0A,0x03,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0x00,0x01,0x02,0x03,0x04,0x05,
0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x3C,0x00,0x05,0x1E,0x00,0x02,
0x2A,0x1E,0x19,0x14,0x02,0x00,0x03,0x0A,0x05,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0x86,
0x22,0x03,0x00,0x00,0x33,0x00,0x0F,0x00,0x00,0x00,
0x50,0x3C,0x50,0x00,0x00,0x00,0x00,0x2A,0x01
};
// 4.3<EFBFBD><EFBFBD><EFBFBD><EFBFBD>GT1151QM<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
const uint8_t CTP_CFG_GT1151QM[] = {
0x5A,0xE0,0x01,0x10,0x01,0x0A,0x3D,0x14,0xB0,0x80,
0xCB,0x0D,0x55,0x3C,0x55,0x01,0x00,0x0C,0x06,0x30,
0x02,0xA7,0x00,0x00,0x00,0x00,0x00,0x38,0x00,0x00,
0x64,0x00,0x00,0x28,0x28,0x64,0x00,0x00,0x87,0xA5,
0xD2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x88,0x28,0x09,0x2C,0x2E,0x28,
0x07,0x00,0xAA,0x22,0x24,0xF9,0x00,0x1B,0x28,0xB6,
0x39,0x9E,0x41,0x86,0x48,0x80,0x50,0x00,0x00,0x00,
0x00,0x50,0x00,0x00,0x00,0x00,0xFF,0x3C,0x28,0xFF,
0xFF,0x29,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x32,0x5F,0xD0,0x94,0x82,0x1E,
0x11,0x03,0xB0,0x39,0x9B,0x41,0x8D,0x48,0x7F,0x50,
0x76,0x57,0x6D,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x1F,0x1D,0x1B,0x1A,0x19,
0x18,0x17,0x16,0x15,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x06,0x08,0x0C,
0x12,0x13,0x14,0x15,0x17,0x18,0x19,0x1A,0x1B,0x1C,
0x1D,0x1E,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,
0xEB,0x06,0x23,0x23,0x50,0x5D,0x54,0x50,0x3C,0x14,
0x32,0xFF,0xFF,0x06,0x51,0x00,0x8A,0x02,0x40,0x00,
0xAA,0x00,0x22,0x22,0x00,0x40,0x5C,0x3A,0x01,
};
//5<><35><EFBFBD><EFBFBD>GT917S<37><53><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
const uint8_t CTP_CFG_GT917S[] ={
0x97,0x20,0x03,0xE0,0x01,0x0A,0x35,0x04,0x00,0x69,
0x09,0x0F,0x50,0x32,0x33,0x11,0x00,0x32,0x11,0x11,
0x28,0x8C,0xAA,0xDC,0x58,0x04,0x00,0x00,0x1E,0x3C,
0x00,0x00,0x00,0x31,0x00,0x00,0x00,0x00,0x00,0x40,
0x32,0x00,0x00,0x50,0x38,0x00,0x8D,0x20,0x16,0x4E,
0x4C,0x7C,0x05,0x28,0x3E,0x28,0x0D,0x43,0x24,0x00,
0x01,0x39,0x6B,0xC0,0x94,0x84,0x2D,0x00,0x54,0xB0,
0x41,0x9D,0x49,0x8D,0x52,0x7F,0x5A,0x75,0x62,0x6C,
0x42,0x50,0x14,0x00,0x00,0x00,0x00,0xF0,0x50,0x3C,
0x88,0x88,0x27,0x50,0x3C,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x50,0x00,0x02,0x78,
0x0A,0x50,0xFF,0xE4,0x04,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3C,0xB0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x56,0xA2,0x07,0x50,0x1E,
0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,
0x0F,0x10,0x12,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,
0x1D,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0x1F,0x1E,0x1D,0x1C,0x1B,0x1A,0x19,0x18,
0x17,0x15,0x14,0x13,0x12,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0x00,0x30,0x7F,0x7F,0x7F,0xFF,
0x54,0x64,0x00,0x80,0x46,0x07,0x50,0x3C,0x32,0x14,
0x0A,0x64,0x32,0x00,0x00,0x00,0x00,0x11,0x02,0x62,
0x32,0x03,0x14,0x50,0x0C,0xE2,0x14,0x50,0x00,0x54,
0x10,0x00,0x32,0xA2,0x07,0x64,0xA4,0xB6,0x01
};
// 7<><37><EFBFBD><EFBFBD>GT615<31><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
const uint8_t CTP_CFG_GT615[] = {
0x6B,0x20,0x03,0xE0,0x01,0x05,0x0D,0x00,0x01,0x08,
0x28,0x0F,0x50,0x32,0x03,0x05,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8A,0x2A,0x0C,
0x45,0x47,0x0C,0x08,0x00,0x00,0x00,0x02,0x02,0x2D,
0x00,0x00,0x00,0x00,0x00,0x03,0x64,0x32,0x00,0x00,
0x00,0x28,0x64,0x94,0xC5,0x02,0x07,0x00,0x00,0x04,
0x9C,0x2C,0x00,0x8F,0x34,0x00,0x84,0x3F,0x00,0x7C,
0x4C,0x00,0x77,0x5B,0x00,0x77,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x18,0x16,0x14,0x12,0x10,0x0E,0x0C,0x0A,
0x08,0x06,0x04,0x02,0xFF,0xFF,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x16,0x18,0x1C,0x1D,0x1E,0x1F,0x20,0x21,
0x22,0x24,0x13,0x12,0x10,0x0F,0x0A,0x08,0x06,0x04,
0x02,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x19,0x01
};
//uint8_t config[GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH]
// = {GTP_REG_CONFIG_DATA >> 8, GTP_REG_CONFIG_DATA & 0xff};
/* <20><><EFBFBD><EFBFBD>IC<49><43><EFBFBD><EFBFBD>Ĭ<EFBFBD><C4AC>Ϊ5<CEAA><35><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ic */
TOUCH_IC touchIC = GT9157;
const TOUCH_PARAM_TypeDef touch_param[TOUCH_TYPE_NUM] =
{
/* GT9157,5<><35><EFBFBD><EFBFBD> */
{
.max_width = 800,
.max_height = 480,
.config_reg_addr = 0x8047,
},
/* GT911,7<><37><EFBFBD><EFBFBD> */
{
.max_width = 800,
.max_height = 480,
.config_reg_addr = 0x8047,
},
/* GT5688,4.3<EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
{
.max_width = 480,
.max_height = 272,
.config_reg_addr = 0x8050,
},
/* GT917S,5<><35><EFBFBD><EFBFBD> */
{
.max_width = 800,
.max_height = 480,
.config_reg_addr = 0x8050,
},
/* GT615,7<><37><EFBFBD><EFBFBD> */
{
.max_width = 800,
.max_height = 480,
.config_reg_addr = 0x8047, //<2F><><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>ַ<EFBFBD><D6B7>GT911<31><31>һ<EFBFBD><D2BB>
},
#if TOUCH_GT1151QM_LCD_4_3
/* GT1151QM,4.3<EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
{
.max_width = 480,
.max_height = 272,
.config_reg_addr = 0x8050,
},
#elif TOUCH_GT1151QM_LCD_5
/* GT1151QM,5<><35><EFBFBD><EFBFBD> */
{
.max_width = 800,
.max_height = 480,
.config_reg_addr = 0x8050,
},
#endif
};
static int8_t GTP_I2C_Test(void);
//static void GT91xx_Config_Read_Proc(void);
static void Delay(__IO uint32_t nCount) //<2F>򵥵<EFBFBD><F2B5A5B5><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
{
for(; nCount != 0; nCount--);
}
/**
* @brief ʹ<EFBFBD><EFBFBD>IIC<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD>
* @param
* @arg i2c_msg:<EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @arg num:<EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD>
* @retval <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵĴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0xff
*/
static int I2C_Transfer( struct i2c_msg *msgs,int num)
{
int im = 0;
int ret = 0;
GTP_DEBUG_FUNC();
for (im = 0; ret == 0 && im != num; im++)
{
if ((msgs[im].flags&I2C_M_RD)) //<2F><><EFBFBD><EFBFBD>flag<61>ж<EFBFBD><D0B6>Ƕ<EFBFBD><C7B6><EFBFBD><EFBFBD>ݻ<EFBFBD><DDBB><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD>
{
ret = I2C_ReadBytes(msgs[im].addr, msgs[im].buf, msgs[im].len); //IIC<49><43>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>
} else
{
ret = I2C_WriteBytes(msgs[im].addr, msgs[im].buf, msgs[im].len); //IICд<43><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
}
if(ret)
return ret;
return im; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɵĴ<C9B5><C4B4><EFBFBD><EFBFBD><EFBFBD><E1B9B9><EFBFBD><EFBFBD>
}
/**
* @brief <EFBFBD><EFBFBD>IIC<EFBFBD><EFBFBD>ж<EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param
* @arg client_addr:<EFBFBD><EFBFBD><EFBFBD>ַ
* @arg buf[0~1]: <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ݼĴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ַ
* @arg buf[2~len-1]: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĻ<EFBFBD><EFBFBD><EFBFBD>buffer
* @arg len: GTP_ADDR_LENGTH + read bytes count<EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>+<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @retval i2c_msgs<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2Ϊ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʧ<EFBFBD><EFBFBD>
*/
static int32_t GTP_I2C_Read(uint8_t client_addr, uint8_t *buf, int32_t len)
{
struct i2c_msg msgs[2];
int32_t ret=-1;
int32_t retries = 0;
GTP_DEBUG_FUNC();
/*һ<><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵĹ<DDB5><C4B9>̿<EFBFBD><CCBF>Է<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
* 1. IIC д<EFBFBD><EFBFBD> Ҫ<EFBFBD><EFBFBD>ȡ<EFBFBD>ļĴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
* 2. IIC <EFBFBD><EFBFBD>ȡ <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* */
msgs[0].flags = !I2C_M_RD; //д<><D0B4>
msgs[0].addr = client_addr; //IIC<49><EFBFBD><E8B1B8>ַ
msgs[0].len = GTP_ADDR_LENGTH; //<2F>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַΪ2<CEAA>ֽ<EFBFBD>(<28><>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>ֽڵ<D6BD><DAB5><EFBFBD><EFBFBD><EFBFBD>)
msgs[0].buf = &buf[0]; //buf[0~1]<5D><EFBFBD><E6B4A2><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ȡ<EFBFBD>ļĴ<C4BC><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ
msgs[1].flags = I2C_M_RD; //<2F><>ȡ
msgs[1].addr = client_addr; //IIC<49><EFBFBD><E8B1B8>ַ
msgs[1].len = len - GTP_ADDR_LENGTH; //Ҫ<><D2AA>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><DDB3><EFBFBD>
msgs[1].buf = &buf[GTP_ADDR_LENGTH]; //buf[GTP_ADDR_LENGTH]֮<><D6AE><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
while(retries < 5)
{
ret = I2C_Transfer( msgs, 2); //<2F><><EFBFBD><EFBFBD>IIC<49><43><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̺<EFBFBD><CCBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD><32><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(ret == 2)break;
retries++;
}
if((retries >= 5))
{
GTP_ERROR("I2C Read: 0x%04X, %d bytes failed, errcode: %d! Process reset.", (((uint16_t)(buf[0] << 8)) | buf[1]), len-2, ret);
}
return ret;
}
/**
* @brief <EFBFBD><EFBFBD>IIC<EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param
* @arg client_addr:<EFBFBD><EFBFBD><EFBFBD>ַ
* @arg buf[0~1]: Ҫд<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼĴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>ַ
* @arg buf[2~len-1]: Ҫд<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @arg len: GTP_ADDR_LENGTH + write bytes count<EFBFBD><EFBFBD><EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>+д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @retval i2c_msgs<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1Ϊ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʧ<EFBFBD><EFBFBD>
*/
static int32_t GTP_I2C_Write(uint8_t client_addr,uint8_t *buf,int32_t len)
{
struct i2c_msg msg;
int32_t ret = -1;
int32_t retries = 0;
GTP_DEBUG_FUNC();
/*һ<><D2BB>д<EFBFBD><D0B4><EFBFBD>ݵĹ<DDB5><C4B9><EFBFBD>ֻ<EFBFBD><D6BB>Ҫһ<D2AA><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>:
* 1. IIC<EFBFBD><EFBFBD><EFBFBD><EFBFBD> д<EFBFBD><EFBFBD> <EFBFBD><EFBFBD><EFBFBD>ݼĴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* */
msg.flags = !I2C_M_RD; //д<><D0B4>
msg.addr = client_addr; //<2F><><EFBFBD><EFBFBD><E8B1B8>ַ
msg.len = len; //<2F><><EFBFBD><EFBFBD>ֱ<EFBFBD>ӵ<EFBFBD><D3B5><EFBFBD>(<28>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><D6BD><EFBFBD>)
msg.buf = buf; //ֱ<><D6B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EBBBBA><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><EFBFBD>˼Ĵ<CBBC><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ)
while(retries < 5)
{
ret = I2C_Transfer(&msg, 1); //<2F><><EFBFBD><EFBFBD>IIC<49><43><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̺<EFBFBD><CCBA><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (ret == 1)break;
retries++;
}
if((retries >= 5))
{
GTP_ERROR("I2C Write: 0x%04X, %d bytes failed, errcode: %d! Process reset.", (((uint16_t)(buf[0] << 8)) | buf[1]), len-2, ret);
}
return ret;
}
/**
* @brief ʹ<EFBFBD><EFBFBD>IIC<EFBFBD><EFBFBD>ȡ<EFBFBD>ٴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param
* @arg client:<EFBFBD><EFBFBD><EFBFBD>ַ
* @arg addr: <EFBFBD>Ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
* @arg rxbuf: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @arg len: <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD>ֽ<EFBFBD><EFBFBD><EFBFBD>
* @retval
* @arg FAIL
* @arg SUCCESS
*/
int32_t GTP_I2C_Read_dbl_check(uint8_t client_addr, uint16_t addr, uint8_t *rxbuf, int len)
{
uint8_t buf[16] = {0};
uint8_t confirm_buf[16] = {0};
uint8_t retry = 0;
GTP_DEBUG_FUNC();
while (retry++ < 3)
{
memset(buf, 0xAA, 16);
buf[0] = (uint8_t)(addr >> 8);
buf[1] = (uint8_t)(addr & 0xFF);
GTP_I2C_Read(client_addr, buf, len + 2);
memset(confirm_buf, 0xAB, 16);
confirm_buf[0] = (uint8_t)(addr >> 8);
confirm_buf[1] = (uint8_t)(addr & 0xFF);
GTP_I2C_Read(client_addr, confirm_buf, len + 2);
if (!memcmp(buf, confirm_buf, len+2))
{
memcpy(rxbuf, confirm_buf+2, len);
return SUCCESS;
}
}
GTP_ERROR("I2C read 0x%04X, %d bytes, double check failed!", addr, len);
return FAIL;
}
/**
* @brief <EFBFBD>ر<EFBFBD>GT91xx<EFBFBD>ж<EFBFBD>
* @param <EFBFBD><EFBFBD>
* @retval <EFBFBD><EFBFBD>
*/
void GTP_IRQ_Disable(void)
{
GTP_DEBUG_FUNC();
I2C_GTP_IRQDisable();
}
/**
* @brief ʹ<EFBFBD><EFBFBD>GT91xx<EFBFBD>ж<EFBFBD>
* @param <EFBFBD><EFBFBD>
* @retval <EFBFBD><EFBFBD>
*/
void GTP_IRQ_Enable(void)
{
GTP_DEBUG_FUNC();
I2C_GTP_IRQEnable();
}
/**
* @brief <EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>򱨸<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param
* @arg id: <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><EFBFBD>trackID
* @arg x: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> x <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @arg y: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> y <EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @arg w: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <EFBFBD><EFBFBD>С
* @retval <EFBFBD><EFBFBD>
*/
/*<2A><><EFBFBD>ڼ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ(<28><><EFBFBD><EFBFBD>)<29><><EFBFBD><EFBFBD>һ<EFBFBD>δ<EFBFBD><CEB4><EFBFBD>λ<EFBFBD>ã<EFBFBD><C3A3><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ʾ<EFBFBD><CABE>һ<EFBFBD><D2BB><EFBFBD>޴<EFBFBD><DEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
static int16_t pre_x[GTP_MAX_TOUCH] ={-1,-1,-1,-1,-1};
static int16_t pre_y[GTP_MAX_TOUCH] ={-1,-1,-1,-1,-1};
static void GTP_Touch_Down(int32_t id,int32_t x,int32_t y,int32_t w)
{
GTP_DEBUG_FUNC();
/*ȡx<C8A1><78>y<EFBFBD><79>ʼֵ<CABC><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>ֵ*/
GTP_DEBUG("ID:%d, X:%d, Y:%d, W:%d", id, x, y, w);
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
Touch_Button_Down(x,y);
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><ECBCA3><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
Draw_Trail(pre_x[id],pre_y[id],x,y,&brush);
/************************************/
/*<2A>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><E3B0B4>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̼<EFBFBD><CCBC><EFBFBD>*/
/* (x,y) <20><>Ϊ<EFBFBD><CEAA><EFBFBD>µĴ<C2B5><C4B4><EFBFBD><EFBFBD><EFBFBD> *************/
/************************************/
/*prex,prey<65><79><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B4A2>һ<EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>ã<EFBFBD>idΪ<64><EFBFBD><ECBCA3><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><E3B4A5>ʱ<EFBFBD>ж<EFBFBD><D0B6>켣)*/
pre_x[id] = x; pre_y[id] =y;
}
/**
* @brief <EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>򱨸<EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>
* @param <EFBFBD>ͷŵ<EFBFBD><EFBFBD><EFBFBD>id<EFBFBD><EFBFBD>
* @retval <EFBFBD><EFBFBD>
*/
static void GTP_Touch_Up( int32_t id)
{
/*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>,<2C><><EFBFBD>ڴ<EFBFBD><DAB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>*/
Touch_Button_Up(pre_x[id],pre_y[id]);
/*****************************************/
/*<2A>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͷ<EFBFBD>ʱ<EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>̼<EFBFBD><CCBC><EFBFBD>*/
/* pre_x[id],pre_y[id] <20><>Ϊ<EFBFBD><CEAA><EFBFBD>µ<EFBFBD><C2B5>ͷŵ<CDB7> ****/
/*******************************************/
/***idΪ<64><EFBFBD><ECBCA3><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD><E3B4A5>ʱ<EFBFBD>ж<EFBFBD><D0B6>켣)********/
/*<2A><><EFBFBD><EFBFBD><EFBFBD>ͷţ<CDB7><C5A3><EFBFBD>pre xy <20><><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA>*/
pre_x[id] = -1;
pre_y[id] = -1;
GTP_DEBUG("Touch id[%2d] release!", id);
}
/**
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѯ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڴ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϵ<EFBFBD><EFBFBD><EFBFBD>
* @param <EFBFBD><EFBFBD>
* @retval <EFBFBD><EFBFBD>
*/
static void Goodix_TS_Work_Func(void)
{
uint8_t end_cmd[3] = {GTP_READ_COOR_ADDR >> 8, GTP_READ_COOR_ADDR & 0xFF, 0};
uint8_t point_data[2 + 1 + 8 * GTP_MAX_TOUCH + 1]={GTP_READ_COOR_ADDR >> 8, GTP_READ_COOR_ADDR & 0xFF};
uint8_t touch_num = 0;
uint8_t finger = 0;
static uint16_t pre_touch = 0;
static uint8_t pre_id[GTP_MAX_TOUCH] = {0};
uint8_t client_addr=GTP_ADDRESS;
uint8_t* coor_data = NULL;
int32_t input_x = 0;
int32_t input_y = 0;
int32_t input_w = 0;
uint8_t id = 0;
int32_t i = 0;
int32_t ret = -1;
GTP_DEBUG_FUNC();
ret = GTP_I2C_Read(client_addr, point_data, 12);//10<31>ֽڼĴ<DABC><C4B4><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD>ֽڵ<D6BD>ַ
if (ret < 0)
{
GTP_ERROR("I2C transfer error. errno:%d\n ", ret);
return;
}
finger = point_data[GTP_ADDR_LENGTH];//״̬<D7B4>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (finger == 0x00) //û<><C3BB><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3>˳<EFBFBD>
{
return;
}
if((finger & 0x80) == 0)//<2F>ж<EFBFBD>buffer statusλ
{
goto exit_work_func;//<2F><><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
}
touch_num = finger & 0x0f;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (touch_num > GTP_MAX_TOUCH)
{
goto exit_work_func;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>
}
if (touch_num > 1)//<2F><>ֹһ<D6B9><D2BB><EFBFBD><EFBFBD>
{
uint8_t buf[8 * GTP_MAX_TOUCH] = {(GTP_READ_COOR_ADDR + 10) >> 8, (GTP_READ_COOR_ADDR + 10) & 0xff};
ret = GTP_I2C_Read(client_addr, buf, 2 + 8 * (touch_num - 1));
memcpy(&point_data[12], &buf[2], 8 * (touch_num - 1)); //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݵ<EFBFBD>point_data
}
if (pre_touch>touch_num) //pre_touch>touch_num,<2C><>ʾ<EFBFBD>еĵ<D0B5><C4B5>ͷ<EFBFBD><CDB7><EFBFBD>
{
for (i = 0; i < pre_touch; i++) //һ<><D2BB><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><E3B4A6>
{
uint8_t j;
for(j=0; j<touch_num; j++)
{
coor_data = &point_data[j * 8 + 3];
id = coor_data[0] & 0x0F; //track id
if(pre_id[i] == id)
break;
if(j >= touch_num-1) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>id<69><64><EFBFBD>Ҳ<EFBFBD><D2B2><EFBFBD>pre_id[i]<5D><><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>ͷ<EFBFBD>
{
GTP_Touch_Up( pre_id[i]);
}
}
}
}
if (touch_num)
{
for (i = 0; i < touch_num; i++) //һ<><D2BB><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><E3B4A6>
{
coor_data = &point_data[i * 8 + 3];
id = coor_data[0] & 0x0F; //track id
pre_id[i] = id;
input_x = coor_data[1] | (coor_data[2] << 8); //x<><78><EFBFBD><EFBFBD>
input_y = coor_data[3] | (coor_data[4] << 8); //y<><79><EFBFBD><EFBFBD>
input_w = coor_data[5] | (coor_data[6] << 8); //size
{
GTP_Touch_Down( id, input_x, input_y, input_w);//<2F><><EFBFBD>ݴ<EFBFBD><DDB4><EFBFBD>
}
}
}
else if (pre_touch) //touch_ num=0 <20><>pre_touch<63><68>=0
{
for(i=0;i<pre_touch;i++)
{
GTP_Touch_Up(pre_id[i]);
}
}
pre_touch = touch_num;
exit_work_func:
{
ret = GTP_I2C_Write(client_addr, end_cmd, 3);
if (ret < 0)
{
GTP_INFO("I2C write end_cmd error!");
}
}
}
/**
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>оƬ<EFBFBD><EFBFBD><EFBFBD>¸<EFBFBD>λ
* @param <EFBFBD><EFBFBD>
* @retval <EFBFBD><EFBFBD>
*/
int8_t GTP_Reset_Guitar(void)
{
GTP_DEBUG_FUNC();
#if 1
I2C_ResetChip();
return 0;
#else //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ
int8_t ret = -1;
int8_t retry = 0;
uint8_t reset_command[3]={(uint8_t)GTP_REG_COMMAND>>8,(uint8_t)GTP_REG_COMMAND&0xFF,2};
//д<>븴λ<EBB8B4><CEBB><EFBFBD><EFBFBD>
while(retry++ < 5)
{
ret = GTP_I2C_Write(GTP_ADDRESS, reset_command, 3);
if (ret > 0)
{
GTP_INFO("GTP enter sleep!");
return ret;
}
}
GTP_ERROR("GTP send sleep cmd failed.");
return ret;
#endif
}
/**
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD>˯<EFBFBD><EFBFBD>ģʽ
* @param <EFBFBD><EFBFBD>
* @retval 1Ϊ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʧ<EFBFBD><EFBFBD>
*/
//int8_t GTP_Enter_Sleep(void)
//{
// int8_t ret = -1;
// int8_t retry = 0;
// uint8_t reset_comment[3] = {(uint8_t)(GTP_REG_COMMENT >> 8), (uint8_t)GTP_REG_COMMENT&0xFF, 5};//5
//
// GTP_DEBUG_FUNC();
//
// while(retry++ < 5)
// {
// ret = GTP_I2C_Write(GTP_ADDRESS, reset_comment, 3);
// if (ret > 0)
// {
// GTP_INFO("GTP enter sleep!");
//
// return ret;
// }
//
// }
// GTP_ERROR("GTP send sleep cmd failed.");
// return ret;
//}
int8_t GTP_Send_Command(uint8_t command)
{
int8_t ret = -1;
int8_t retry = 0;
uint8_t command_buf[3] = {(uint8_t)(GTP_REG_COMMAND >> 8), (uint8_t)GTP_REG_COMMAND&0xFF, GTP_COMMAND_READSTATUS};
GTP_DEBUG_FUNC();
while(retry++ < 5)
{
ret = GTP_I2C_Write(GTP_ADDRESS, command_buf, 3);
if (ret > 0)
{
GTP_INFO("send command success!");
return ret;
}
}
GTP_ERROR("send command fail!");
return ret;
}
/**
* @brief <EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param <EFBFBD><EFBFBD>
* @retval 0Ϊ<EFBFBD>ɹ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊʧ<EFBFBD><EFBFBD>
*/
int8_t GTP_WakeUp_Sleep(void)
{
uint8_t retry = 0;
int8_t ret = -1;
GTP_DEBUG_FUNC();
while(retry++ < 10)
{
ret = GTP_I2C_Test();
if (ret > 0)
{
GTP_INFO("GTP wakeup sleep.");
return ret;
}
GTP_Reset_Guitar();
}
GTP_ERROR("GTP wakeup sleep failed.");
return ret;
}
static int32_t GTP_Get_Info(void)
{
uint8_t opr_buf[10] = {0};
int32_t ret = 0;
uint16_t abs_x_max = GTP_MAX_WIDTH;
uint16_t abs_y_max = GTP_MAX_HEIGHT;
uint8_t int_trigger_type = GTP_INT_TRIGGER;
opr_buf[0] = (uint8_t)((GTP_REG_CONFIG_DATA+1) >> 8);
opr_buf[1] = (uint8_t)((GTP_REG_CONFIG_DATA+1) & 0xFF);
ret = GTP_I2C_Read(GTP_ADDRESS, opr_buf, 10);
if (ret < 0)
{
return FAIL;
}
abs_x_max = (opr_buf[3] << 8) + opr_buf[2];
abs_y_max = (opr_buf[5] << 8) + opr_buf[4];
GTP_DEBUG("RES");
GTP_DEBUG_ARRAY(&opr_buf[0],10);
opr_buf[0] = (uint8_t)((GTP_REG_CONFIG_DATA+6) >> 8);
opr_buf[1] = (uint8_t)((GTP_REG_CONFIG_DATA+6) & 0xFF);
ret = GTP_I2C_Read(GTP_ADDRESS, opr_buf, 3);
if (ret < 0)
{
return FAIL;
}
int_trigger_type = opr_buf[2] & 0x03;
GTP_INFO("X_MAX = %d, Y_MAX = %d, TRIGGER = 0x%02x",
abs_x_max,abs_y_max,int_trigger_type);
return SUCCESS;
}
/*******************************************************
Function:
Initialize gtp.
Input:
ts: goodix private data
Output:
Executive outcomes.
0: succeed, otherwise: failed
*******************************************************/
int32_t GTP_Init_Panel(void)
{
int32_t ret = -1;
int32_t i = 0;
uint16_t check_sum = 0;
int32_t retry = 0;
const uint8_t* cfg_info;
uint8_t cfg_info_len ;
uint8_t* config;
uint8_t cfg_num =0 ; //<2F><>Ҫ<EFBFBD><D2AA><EFBFBD>õļĴ<C4BC><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
GTP_DEBUG_FUNC();
I2C_Touch_Init();
ret = GTP_I2C_Test();
if (ret < 0)
{
GTP_ERROR("I2C communication ERROR!");
return ret;
}
HAL_Delay(100);
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>IC<49><43><EFBFBD>ͺ<EFBFBD>
GTP_Read_Version();
#if UPDATE_CONFIG
config = (uint8_t *)malloc (GTP_CONFIG_MAX_LENGTH + GTP_ADDR_LENGTH);
config[0] = GTP_REG_CONFIG_DATA >> 8;
config[1] = GTP_REG_CONFIG_DATA & 0xff;
//<2F><><EFBFBD><EFBFBD>IC<49><43><EFBFBD>ͺ<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(touchIC == GT9157)
{
cfg_info = CTP_CFG_GT9157; //ָ<><D6B8><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cfg_info_len = CFG_GROUP_LEN(CTP_CFG_GT9157);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1>Ĵ<EFBFBD>С
}
else if(touchIC == GT911)
{
cfg_info = CTP_CFG_GT911;//ָ<><D6B8><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cfg_info_len = CFG_GROUP_LEN(CTP_CFG_GT911) ;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1>Ĵ<EFBFBD>С
}
else if(touchIC == GT5688)
{
cfg_info = CTP_CFG_GT5688; //ָ<><D6B8><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cfg_info_len = CFG_GROUP_LEN(CTP_CFG_GT5688);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1>Ĵ<EFBFBD>С
}
else if(touchIC == GT917S)
{
cfg_info = CTP_CFG_GT917S; //ָ<><D6B8><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cfg_info_len = CFG_GROUP_LEN(CTP_CFG_GT917S);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1>Ĵ<EFBFBD>С
}
else if(touchIC == GT615)
{
cfg_info = CTP_CFG_GT615; //ָ<><D6B8><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cfg_info_len = CFG_GROUP_LEN(CTP_CFG_GT615);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1>Ĵ<EFBFBD>С
}
else if(touchIC == GT1151QM)
{
cfg_info = CTP_CFG_GT1151QM; //ָ<><D6B8><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
cfg_info_len = CFG_GROUP_LEN(CTP_CFG_GT1151QM);//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ñ<EFBFBD><C3B1>Ĵ<EFBFBD>С
}
memset(&config[GTP_ADDR_LENGTH], 0, GTP_CONFIG_MAX_LENGTH);
memcpy(&config[GTP_ADDR_LENGTH], cfg_info, cfg_info_len);
cfg_num = cfg_info_len;
GTP_DEBUG("cfg_info_len = %d ",cfg_info_len);
GTP_DEBUG("cfg_num = %d ",cfg_num);
GTP_DEBUG_ARRAY(config,6);
/*<2A><><EFBFBD><EFBFBD>LCD<43><44>ɨ<EFBFBD><EFBFBD><E8B7BD><EFBFBD><EFBFBD><EFBFBD>÷ֱ<C3B7><D6B1><EFBFBD>*/
config[GTP_ADDR_LENGTH+1] = LCD_PIXEL_WIDTH & 0xFF;
config[GTP_ADDR_LENGTH+2] = LCD_PIXEL_WIDTH >> 8;
config[GTP_ADDR_LENGTH+3] = LCD_PIXEL_HEIGHT & 0xFF;
config[GTP_ADDR_LENGTH+4] = LCD_PIXEL_HEIGHT >> 8;
/*<2A><><EFBFBD><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>X2Y<32><59><EFBFBD><EFBFBD>*/
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if(touchIC == GT917S)
{
config[GTP_ADDR_LENGTH+6] &= ~(X2Y_LOC);
}
//<2F><><EFBFBD><EFBFBD>
if(touchIC == GT911 || touchIC == GT9157 || touchIC == GT5688)
{
config[GTP_ADDR_LENGTH+6] |= (X2Y_LOC);
}
//<2F><><EFBFBD><EFBFBD>Ҫд<D2AA><D0B4>checksum<75>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ֵ
check_sum = 0;
/* <20><><EFBFBD><EFBFBD>check sumУ<6D><D0A3>ֵ */
if(touchIC == GT911 || touchIC == GT615)
{
for (i = GTP_ADDR_LENGTH; i < cfg_num; i++)
{
check_sum += (config[i] & 0xFF);
}
config[ cfg_num] = (~(check_sum & 0xFF)) + 1; //checksum
config[ cfg_num+1] = 1; //refresh <20><><EFBFBD>ø<EFBFBD><C3B8>±<EFBFBD>־
}
else if(touchIC == GT9157)
{
for (i = GTP_ADDR_LENGTH; i < cfg_num+GTP_ADDR_LENGTH; i++)
{
check_sum += (config[i] & 0xFF);
}
config[ cfg_num+GTP_ADDR_LENGTH] = (~(check_sum & 0xFF)) + 1; //checksum
config[ cfg_num+GTP_ADDR_LENGTH+1] = 1; //refresh <20><><EFBFBD>ø<EFBFBD><C3B8>±<EFBFBD>־
}
else if(touchIC == GT5688 || touchIC == GT917S || touchIC == GT1151QM)
{
for (i = GTP_ADDR_LENGTH; i < (cfg_num+GTP_ADDR_LENGTH -3); i += 2)
{
check_sum += (config[i] << 8) + config[i + 1];
}
check_sum = 0 - check_sum;
GTP_DEBUG("Config checksum: 0x%04X", check_sum);
//<2F><><EFBFBD><EFBFBD>checksum
config[(cfg_num+GTP_ADDR_LENGTH -3)] = (check_sum >> 8) & 0xFF;
config[(cfg_num+GTP_ADDR_LENGTH -2)] = check_sum & 0xFF;
config[(cfg_num+GTP_ADDR_LENGTH -1)] = 0x01;
}
//д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
for (retry = 0; retry < 5; retry++)
{
ret = GTP_I2C_Write(GTP_ADDRESS, config , cfg_num + GTP_ADDR_LENGTH+2);
if (ret > 0)
{
break;
}
}
Delay(0xfffff); //<2F>ӳٵȴ<D9B5>оƬ<D0BE><C6AC><EFBFBD><EFBFBD>
#if 1 //<2F><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>ͬ
{
uint16_t i;
uint8_t buf[300];
buf[0] = config[0];
buf[1] =config[1]; //<2F>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ
GTP_DEBUG_FUNC();
ret = GTP_I2C_Read(GTP_ADDRESS, buf, sizeof(buf));
GTP_DEBUG("read ");
GTP_DEBUG_ARRAY(buf,cfg_num);
GTP_DEBUG("write ");
GTP_DEBUG_ARRAY(config,cfg_num);
//<2F><><EFBFBD>ԱȰ汾<C8B0><E6B1BE>
for(i=3;i<cfg_num+GTP_ADDR_LENGTH-3;i++)
{
if(config[i] != buf[i])
{
GTP_ERROR("Config fail ! i = %d ",i);
free(config);
return -1;
}
}
if(i==cfg_num+GTP_ADDR_LENGTH-3)
GTP_DEBUG("Config success ! i = %d ",i);
}
#endif
free(config);
#endif
/* emXGUIʾ<49><CABE><EFBFBD>в<EFBFBD>ʹ<EFBFBD><CAB9><EFBFBD>ж<EFBFBD> */
I2C_GTP_IRQEnable();
GTP_Get_Info();
return 0;
}
/*******************************************************
Function:
Read chip version.
Input:
client: i2c device
version: buffer to keep ic firmware version
Output:
read operation return.
2: succeed, otherwise: failed
*******************************************************/
int32_t GTP_Read_Version(void)
{
int32_t ret = -1;
uint8_t buf[8] = {GTP_REG_VERSION >> 8, GTP_REG_VERSION & 0xff}; //<2F>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ
GTP_DEBUG_FUNC();
ret = GTP_I2C_Read(GTP_ADDRESS, buf, sizeof(buf));
if (ret < 0)
{
GTP_ERROR("GTP read version failed");
return ret;
}
#ifdef LCD_TOUCH_IC_GT1151QM
//GT1151QMоƬ
if (buf[2]=='1' && buf[3]=='1' && buf[4]=='5')
{
GTP_INFO("IC Version: %c%c%c_%02x%02x", buf[2], buf[3], buf[4], buf[7], buf[6]);
touchIC = GT1151QM;
#if TOUCH_GT1151QM_LCD_4_3
cur_lcd = INCH_4_3; //<2F><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0>Һ<EFBFBD><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#elif TOUCH_GT1151QM_LCD_5
cur_lcd = INCH_5; //<2F><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0>Һ<EFBFBD><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#endif
}
else
{
GTP_INFO("Unknown IC Version: %c%c%c%c_%02x%02x", buf[2], buf[3], buf[4], buf[5], buf[7], buf[6]);
}
#else
if (buf[4] == '1')
{
//GT911оƬ
if(buf[2] == '9' && buf[3] == '1' && buf[4] == '1')
{
GTP_INFO("IC1 Version: %c%c%c_%02x%02x", buf[2], buf[3], buf[4], buf[7], buf[6]);
touchIC = GT911;
/* <20><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0>Һ<EFBFBD><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
cur_lcd = INCH_7;
}
//GT9157оƬ
else
GTP_INFO("Unknown IC Version: %c%c%c%c_%02x%02x", buf[2], buf[3], buf[4], buf[5], buf[7], buf[6]);
}
else if (buf[4] == '5')
{
if( buf[2] == '9' && buf[3] == '1' && buf[4] == '5' && buf[5] == '7')
{
GTP_INFO("IC2 Version: %c%c%c%c_%02x%02x", buf[2], buf[3], buf[4], buf[5], buf[7], buf[6]);
touchIC = GT9157;
/* <20><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0>Һ<EFBFBD><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
cur_lcd = INCH_5;
}
//GT615оƬ
else if( buf[2] == '6' && buf[3] == '1' && buf[4] == '5')
{
GTP_INFO("IC3 Version: %c%c%c%c_%02x%02x", buf[2], buf[3], buf[4], buf[5], buf[7], buf[6]);
touchIC = GT615;
/* <20><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0>Һ<EFBFBD><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
cur_lcd = INCH_7;
}
else
GTP_INFO("Unknown IC Version: %c%c%c%c_%02x%02x", buf[2], buf[3], buf[4], buf[5], buf[7], buf[6]);
}
else if (buf[4] == '8')
{
//GT5688оƬ
if(buf[2] == '5' && buf[3] == '6' && buf[4] == '8' && buf[5] == '8')
{
GTP_INFO("IC4 Version: %c%c%c%c_%02x%02x", buf[2], buf[3], buf[4], buf[5], buf[7], buf[6]);
touchIC = GT5688;
/* <20><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0>Һ<EFBFBD><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
cur_lcd = INCH_4_3;
}
else
GTP_INFO("Unknown IC Version: %c%c%c%c_%02x%02x", buf[2], buf[3], buf[4], buf[5], buf[7], buf[6]);
}
else if(buf[4] == '7')
{
//GT917SоƬ
GTP_INFO("IC5 Version: %c%c%c%c_%02x%02x", buf[2], buf[3], buf[4], buf[5], buf[7], buf[6]);
if(buf[2] == '9' && buf[3] == '1' && buf[4] == '7' && buf[5] == 'S')
{
touchIC = GT917S;
/* <20><><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><C7B0>Һ<EFBFBD><D2BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
cur_lcd = INCH_5;
}
}
else
GTP_INFO("Unknown IC Version: %c%c%c%c_%02x%02x", buf[2], buf[3], buf[4], buf[5], buf[7], buf[6]);
#endif
return ret;
}
/*******************************************************
Function:
I2c test Function.
Input:
client:i2c client.
Output:
Executive outcomes.
2: succeed, otherwise failed.
*******************************************************/
static int8_t GTP_I2C_Test( void)
{
uint8_t test[3] = {GTP_REG_CONFIG_DATA >> 8, GTP_REG_CONFIG_DATA & 0xff};
uint8_t retry = 0;
int8_t ret = -1;
GTP_DEBUG_FUNC();
while(retry++ < 5)
{
ret = GTP_I2C_Read(GTP_ADDRESS, test, 3);
if (ret > 0)
{
return ret;
}
GTP_ERROR("GTP i2c test failed time %d.",retry);
}
return ret;
}
//<2F><><EFBFBD><EFBFBD><E2B5BD><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>ã<EFBFBD>
void GTP_TouchProcess(void)
{
GTP_DEBUG_FUNC();
Goodix_TS_Work_Func();
}
#if 0//û<>е<EFBFBD><D0B5>IJ<EFBFBD><C4B2>Ժ<EFBFBD><D4BA><EFBFBD>
/*******************************************************
Function:
Request gpio(INT & RST) ports.
Input:
ts: private data.
Output:
Executive outcomes.
>= 0: succeed, < 0: failed
*******************************************************/
static int8_t GTP_Request_IO_Port(struct goodix_ts_data *ts)
{
}
/*******************************************************
Function:
Request interrupt.
Input:
ts: private data.
Output:
Executive outcomes.
0: succeed, -1: failed.
*******************************************************/
static int8_t GTP_Request_IRQ(struct goodix_ts_data *ts)
{
}
//<2F><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݼ<EFBFBD>оƬ<D0BE>е<EFBFBD><D0B5><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD>
static void GT91xx_Config_Read_Proc(void)
{
char temp_data[GTP_CONFIG_MAX_LENGTH + 2] = {0x80, 0x47};
int i;
GTP_INFO("==== GT9XX config init value====\n");
for (i = 0 ; i < GTP_CONFIG_MAX_LENGTH ; i++)
{
printf("reg0x%x = 0x%02X ", i+0x8047, config[i + 2]);
if (i % 10 == 9)
printf("\n");
}
GTP_INFO("==== GT9XX config real value====\n");
GTP_I2C_Read(GTP_ADDRESS, (uint8_t *)temp_data, GTP_CONFIG_MAX_LENGTH + 2);
for (i = 0 ; i < GTP_CONFIG_MAX_LENGTH ; i++)
{
printf("reg0x%x = 0x%02X ", i+0x8047,temp_data[i+2]);
if (i % 10 == 9)
printf("\n");
}
}
//<2F><>оƬд<C6AC><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
static int32_t GT91xx_Config_Write_Proc(void)
{
int32_t ret = -1;
int32_t i = 0;
uint8_t check_sum = 0;
int32_t retry = 0;
uint8_t cfg_num =0x80FE-0x8047+1 ; //<2F><>Ҫ<EFBFBD><D2AA><EFBFBD>õļĴ<C4BC><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
uint8_t cfg_info[] = CTP_CFG_GROUP1;
uint8_t cfg_info_len =CFG_GROUP_LEN(cfg_info) ;
GTP_INFO("==== GT9XX send config====\n");
memset(&config[GTP_ADDR_LENGTH], 0, GTP_CONFIG_MAX_LENGTH);
memcpy(&config[GTP_ADDR_LENGTH], cfg_info,cfg_info_len);
//<2F><><EFBFBD><EFBFBD>Ҫд<D2AA><D0B4>checksum<75>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ֵ
check_sum = 0;
for (i = GTP_ADDR_LENGTH; i < cfg_num+GTP_ADDR_LENGTH; i++)
{
check_sum += config[i];
}
config[ cfg_num+GTP_ADDR_LENGTH] = (~check_sum) + 1; //checksum
config[ cfg_num+GTP_ADDR_LENGTH+1] = 1; //refresh <20><><EFBFBD>ø<EFBFBD><C3B8>±<EFBFBD>־
//д<><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
for (retry = 0; retry < 5; retry++)
{
ret = GTP_I2C_Write(GTP_ADDRESS, config , cfg_num + GTP_ADDR_LENGTH+2);
if (ret > 0)
{
break;
}
}
return ret;
}
#endif
/**
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>жϷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>emXGUIʾ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>û<EFBFBD><EFBFBD>ʹ<EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>
* @param <EFBFBD><EFBFBD>
* @retval <EFBFBD><EFBFBD>
*/
void GTP_IRQHandler(void)
{
if(__HAL_GPIO_EXTI_GET_IT(GTP_INT_GPIO_PIN) != RESET) //ȷ<><C8B7><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>EXTI Line<6E>ж<EFBFBD>
{
//LED2_TOGGLE;
GTP_TouchProcess();
__HAL_GPIO_EXTI_CLEAR_IT(GTP_INT_GPIO_PIN); //<2F><><EFBFBD><EFBFBD><EFBFBD>жϱ<D0B6>־λ
}
}
/**
* @brief <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪemXGUI<EFBFBD>Ķ<EFBFBD><EFBFBD>Ƽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* <EFBFBD>ο<EFBFBD>Goodix_TS_Work_Func<EFBFBD>޸Ķ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ֻ<EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @param x[out] y[out] <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
* @retval <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD>1<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>򷵻<EFBFBD>0
*/
int GTP_Execu( int *x,int *y)
{
uint8_t end_cmd[3] = {GTP_READ_COOR_ADDR >> 8, GTP_READ_COOR_ADDR & 0xFF, 0};
//2-<2D>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD>ַ 1-״̬<D7B4>Ĵ<EFBFBD><C4B4><EFBFBD> 8*1-ÿ<><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>8<EFBFBD><38><EFBFBD>Ĵ<EFBFBD><C4B4><EFBFBD>
uint8_t point_data[2 + 1 + 8 * 1 + 1]={GTP_READ_COOR_ADDR >> 8, GTP_READ_COOR_ADDR & 0xFF};
uint8_t touch_num = 0;
uint8_t finger = 0;
uint8_t client_addr=GTP_ADDRESS;
int32_t input_x = 0;
int32_t input_y = 0;
int32_t ret = -1;
GTP_DEBUG_FUNC();
ret = GTP_I2C_Read(client_addr, point_data, 12);//10<31>ֽڼĴ<DABC><C4B4><EFBFBD><EFBFBD><EFBFBD>2<EFBFBD>ֽڵ<D6BD>ַ
if (ret < 0)
{
GTP_ERROR("I2C transfer error. errno:%d\n ", ret);
return 0;
}
finger = point_data[GTP_ADDR_LENGTH];//״̬<D7B4>Ĵ<EFBFBD><C4B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (finger == 0x00) //û<><C3BB><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3>˳<EFBFBD>
{
return 0;
}
if((finger & 0x80) == 0)//<2F>ж<EFBFBD>buffer statusλ
{
goto exit_work_func;//<2F><><EFBFBD><EFBFBD>δ<EFBFBD><CEB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч
}
touch_num = finger & 0x0f;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (touch_num > GTP_MAX_TOUCH)
{
goto exit_work_func;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>
}
if (touch_num)
{
// id = point_data[0] & 0x0F; //track id
input_x = point_data[3+1] | (point_data[3+2] << 8); //x<><78><EFBFBD><EFBFBD>
input_y = point_data[3+3] | (point_data[3+4] << 8); //y<><79><EFBFBD><EFBFBD>
// input_w = coor_data[5] | (coor_data[6] << 8); //size
if(input_x < GTP_MAX_WIDTH && input_y < GTP_MAX_HEIGHT)
{
*x = input_x;
*y = input_y;
}
else
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ<EFBFBD><CEA7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD>
goto exit_work_func;
}
}
exit_work_func:
{
//<2F><><EFBFBD>ձ<EFBFBD>־
ret = GTP_I2C_Write(client_addr, end_cmd, 3);
if (ret < 0)
{
GTP_INFO("I2C write end_cmd error!");
return 0;
}
}
return touch_num;
}
//MODULE_DESCRIPTION("GTP Series Driver");
//MODULE_LICENSE("GPL");