mirror of
https://gitee.com/Vancouver2017/luban-lite-t3e-pro.git
synced 2025-12-13 09:58:54 +00:00
add gt911 firmware
This commit is contained in:
@@ -21,25 +21,25 @@
|
||||
|
||||
static struct rt_i2c_client gt911_client;
|
||||
|
||||
// /* hardware section */
|
||||
// static rt_uint8_t GT911_CFG_TBL[] = {
|
||||
// 0x6b, 0x00, 0x04, 0x58, 0x02, 0x05, 0x0d, 0x00, 0x01, 0x0f, 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, 0x40, 0x03, 0x2c, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x64, 0x32,
|
||||
// 0x00, 0x00, 0x00, 0x28, 0x64, 0x94, 0xd5, 0x02, 0x07, 0x00, 0x00, 0x04,
|
||||
// 0x95, 0x2c, 0x00, 0x8b, 0x34, 0x00, 0x82, 0x3f, 0x00, 0x7d, 0x4c, 0x00,
|
||||
// 0x7a, 0x5b, 0x00, 0x7a, 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, 0x79, 0x01,
|
||||
// };
|
||||
/* hardware section */
|
||||
static rt_uint8_t GT911_CFG_TBL[] = {
|
||||
0x61,0xE0,0x01,0xE0,0x01,0x01,0xF5,0x00,0x01,0xC8,0x28,0x0D,
|
||||
0x50,0x32,0x03,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x16,
|
||||
0x18,0x1E,0x14,0x85,0x25,0x0A,0x9B,0x9D,0x7C,0x06,0x00,0x00,
|
||||
0x00,0x00,0x01,0x2D,0x00,0x01,0x00,0x00,0x00,0x03,0x64,0x32,
|
||||
0x00,0x00,0x00,0x50,0x7D,0x94,0xC5,0x02,0x07,0x00,0x00,0x04,
|
||||
0x99,0x53,0x00,0x8D,0x5B,0x00,0x82,0x64,0x00,0x77,0x6D,0x00,
|
||||
0x6E,0x77,0x00,0x6E,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,0x1C,0x00,0x00,0x00,0x00,0x00,0x00,
|
||||
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x06,
|
||||
0x04,0x02,0x00,0x1D,0x1E,0x1F,0x20,0x21,0xFF,0xFF,0xFF,0xFF,
|
||||
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,0x00,0x00,0x34,0x01
|
||||
};
|
||||
|
||||
static rt_err_t gt911_write_reg(struct rt_i2c_client *dev, rt_uint8_t *data,
|
||||
rt_uint8_t len)
|
||||
@@ -94,7 +94,20 @@ static rt_err_t gt911_get_product_id(struct rt_i2c_client *dev,
|
||||
}
|
||||
return RT_EOK;
|
||||
}
|
||||
static rt_err_t gt911_get_config_version(struct rt_i2c_client *dev,rt_uint8_t *data, rt_uint8_t len)
|
||||
{
|
||||
rt_uint8_t reg[2];
|
||||
|
||||
reg[0] = (rt_uint8_t)(GT911_CONFIG_REG >> 8);
|
||||
reg[1] = (rt_uint8_t)(GT911_CONFIG_REG & 0xff);
|
||||
|
||||
if (gt911_read_regs(dev, reg, data, len) != RT_EOK) {
|
||||
LOG_E("read id failed");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
return RT_EOK;
|
||||
}
|
||||
static rt_err_t gt911_get_info(struct rt_i2c_client *dev,
|
||||
struct rt_touch_info *info)
|
||||
{
|
||||
@@ -344,6 +357,112 @@ exit_:
|
||||
|
||||
static rt_err_t gt911_control(struct rt_touch_device *touch, int cmd, void *arg)
|
||||
{
|
||||
rt_uint8_t regver;
|
||||
gt911_get_config_version(>911_client, ®ver, 1);
|
||||
LOG_I("Cconfig version:%d",regver);
|
||||
if(regver<=96)
|
||||
{
|
||||
LOG_I("update config ver:97");
|
||||
|
||||
rt_uint8_t buf[4];
|
||||
rt_uint8_t i = 0;
|
||||
rt_uint8_t *config;
|
||||
|
||||
config = (rt_uint8_t *)rt_calloc(1, sizeof(GT911_CFG_TBL) + GT911_REGITER_LEN);
|
||||
if (config == RT_NULL) {
|
||||
LOG_D("malloc config memory failed\n");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
//conmmand
|
||||
config[0] =(rt_uint8_t)((GT911_CONFIG_REG >> 8) & 0xFF);
|
||||
config[1] =(rt_uint8_t)(GT911_CONFIG_REG & 0xFF);
|
||||
//data
|
||||
memcpy(&config[2], GT911_CFG_TBL, sizeof(GT911_CFG_TBL));
|
||||
|
||||
// switch (cmd) {
|
||||
// case RT_TOUCH_CTRL_SET_X_RANGE: {
|
||||
// rt_uint16_t x_range;
|
||||
|
||||
// x_range = *(rt_uint16_t *)arg;
|
||||
// config[4] = (rt_uint8_t)(x_range >> 8);
|
||||
// config[3] = (rt_uint8_t)(x_range & 0xff);
|
||||
|
||||
// GT911_CFG_TBL[2] = config[4];
|
||||
// GT911_CFG_TBL[1] = config[3];
|
||||
// break;
|
||||
// }
|
||||
// case RT_TOUCH_CTRL_SET_Y_RANGE: {
|
||||
// rt_uint16_t y_range;
|
||||
|
||||
// y_range = *(rt_uint16_t *)arg;
|
||||
// config[6] = (rt_uint8_t)(y_range >> 8);
|
||||
// config[5] = (rt_uint8_t)(y_range & 0xff);
|
||||
|
||||
// GT911_CFG_TBL[4] = config[6];
|
||||
// GT911_CFG_TBL[3] = config[5];
|
||||
// break;
|
||||
// }
|
||||
// case RT_TOUCH_CTRL_SET_X_TO_Y: {
|
||||
// config[8] ^= (1 << 3);
|
||||
// break;
|
||||
// }
|
||||
// case RT_TOUCH_CTRL_SET_MODE: {
|
||||
// rt_uint16_t trig_type;
|
||||
// trig_type = *(rt_uint16_t *)arg;
|
||||
|
||||
// switch (trig_type) {
|
||||
// case RT_DEVICE_FLAG_INT_RX:
|
||||
// config[8] &= 0xFC;
|
||||
// break;
|
||||
// case RT_DEVICE_FLAG_RDONLY:
|
||||
// config[8] &= 0xFC;
|
||||
// config[8] |= 0x02;
|
||||
// break;
|
||||
// default:
|
||||
// break;
|
||||
// }
|
||||
// break;
|
||||
// }
|
||||
// default: {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//写入配置
|
||||
if (gt911_write_reg(>911_client, config,sizeof(GT911_CFG_TBL) + GT911_ADDR_LEN) != RT_EOK) //lenght=cmd+data--->sizeof(GT911_CFG_TBL) + GT911_ADDR_LEN)
|
||||
{
|
||||
LOG_D("send config failed");
|
||||
return -1;
|
||||
}
|
||||
//checksum
|
||||
buf[0] = (rt_uint8_t)((GT911_CHECK_SUM >> 8) & 0xFF);
|
||||
buf[1] = (rt_uint8_t)(GT911_CHECK_SUM & 0xFF);
|
||||
buf[2] = 0;
|
||||
buf[3] = 1;
|
||||
|
||||
//计算校验和
|
||||
// for (i = GT911_ADDR_LEN; i < sizeof(GT911_CFG_TBL) + GT911_ADDR_LEN; i++)
|
||||
// {
|
||||
// buf[GT911_ADDR_LEN] += config[i];
|
||||
// }
|
||||
for (i = 0; i < sizeof(GT911_CFG_TBL) ; i++)
|
||||
{
|
||||
buf[2] += GT911_CFG_TBL[i];
|
||||
}
|
||||
|
||||
buf[2] = (~buf[2]) + 1;
|
||||
buf[3] = 1;//是否写入到GT9147 FLASH? 即是否掉电保存
|
||||
LOG_I("checksum:%x",buf[2]);
|
||||
|
||||
gt911_write_reg(>911_client, buf, 4);
|
||||
rt_free(config);
|
||||
|
||||
LOG_I("update config suss");
|
||||
}
|
||||
|
||||
if (cmd == RT_TOUCH_CTRL_GET_ID) {
|
||||
return gt911_get_product_id(>911_client, arg, 6);
|
||||
}
|
||||
|
||||
if (cmd == RT_TOUCH_CTRL_GET_ID) {
|
||||
return gt911_get_product_id(>911_client, arg, 6);
|
||||
}
|
||||
@@ -351,92 +470,7 @@ static rt_err_t gt911_control(struct rt_touch_device *touch, int cmd, void *arg)
|
||||
if (cmd == RT_TOUCH_CTRL_GET_INFO) {
|
||||
return gt911_get_info(>911_client, arg);
|
||||
}
|
||||
/*
|
||||
rt_uint8_t buf[4];
|
||||
rt_uint8_t i = 0;
|
||||
rt_uint8_t *config;
|
||||
|
||||
config =
|
||||
(rt_uint8_t *)rt_calloc(1, sizeof(GT911_CFG_TBL) + GT911_REGITER_LEN);
|
||||
if (config == RT_NULL) {
|
||||
LOG_D("malloc config memory failed\n");
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
config[0] = (rt_uint8_t)((GT911_CONFIG_REG >> 8) & 0xFF);
|
||||
config[1] = (rt_uint8_t)(GT911_CONFIG_REG & 0xFF);
|
||||
|
||||
memcpy(&config[2], GT911_CFG_TBL, sizeof(GT911_CFG_TBL));
|
||||
|
||||
switch (cmd) {
|
||||
case RT_TOUCH_CTRL_SET_X_RANGE: {
|
||||
rt_uint16_t x_range;
|
||||
|
||||
x_range = *(rt_uint16_t *)arg;
|
||||
config[4] = (rt_uint8_t)(x_range >> 8);
|
||||
config[3] = (rt_uint8_t)(x_range & 0xff);
|
||||
|
||||
GT911_CFG_TBL[2] = config[4];
|
||||
GT911_CFG_TBL[1] = config[3];
|
||||
break;
|
||||
}
|
||||
case RT_TOUCH_CTRL_SET_Y_RANGE: {
|
||||
rt_uint16_t y_range;
|
||||
|
||||
y_range = *(rt_uint16_t *)arg;
|
||||
config[6] = (rt_uint8_t)(y_range >> 8);
|
||||
config[5] = (rt_uint8_t)(y_range & 0xff);
|
||||
|
||||
GT911_CFG_TBL[4] = config[6];
|
||||
GT911_CFG_TBL[3] = config[5];
|
||||
break;
|
||||
}
|
||||
case RT_TOUCH_CTRL_SET_X_TO_Y: {
|
||||
config[8] ^= (1 << 3);
|
||||
break;
|
||||
}
|
||||
case RT_TOUCH_CTRL_SET_MODE: {
|
||||
rt_uint16_t trig_type;
|
||||
trig_type = *(rt_uint16_t *)arg;
|
||||
|
||||
switch (trig_type) {
|
||||
case RT_DEVICE_FLAG_INT_RX:
|
||||
config[8] &= 0xFC;
|
||||
break;
|
||||
case RT_DEVICE_FLAG_RDONLY:
|
||||
config[8] &= 0xFC;
|
||||
config[8] |= 0x02;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (gt911_write_reg(>911_client, config,
|
||||
sizeof(GT911_CFG_TBL) + GT911_ADDR_LEN) != RT_EOK) {
|
||||
LOG_D("send config failed");
|
||||
return -1;
|
||||
}
|
||||
|
||||
buf[0] = (rt_uint8_t)((GT911_CHECK_SUM >> 8) & 0xFF);
|
||||
buf[1] = (rt_uint8_t)(GT911_CHECK_SUM & 0xFF);
|
||||
buf[2] = 0;
|
||||
|
||||
for (i = GT911_ADDR_LEN; i < sizeof(GT911_CFG_TBL) + GT911_ADDR_LEN; i++) {
|
||||
buf[GT911_ADDR_LEN] += config[i];
|
||||
}
|
||||
|
||||
buf[2] = (~buf[2]) + 1;
|
||||
buf[3] = 1;
|
||||
|
||||
gt911_write_reg(>911_client, buf, 4);
|
||||
rt_free(config);
|
||||
*/
|
||||
return -RT_ERROR;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4
tools/env/tools/ConEmu/ConEmu.xml
vendored
4
tools/env/tools/ConEmu/ConEmu.xml
vendored
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<key name="Software">
|
||||
<key name="ConEmu">
|
||||
<key name=".Vanilla" modified="2025-09-30 12:55:46" build="180206">
|
||||
<key name=".Vanilla" modified="2025-10-09 18:24:20" build="180206">
|
||||
<value name="StartType" type="hex" data="02"/>
|
||||
<value name="CmdLine" type="string" data=""/>
|
||||
<value name="StartTasksFile" type="string" data=""/>
|
||||
@@ -261,7 +261,7 @@
|
||||
<value name="WindowMode" type="dword" data="0000051f"/>
|
||||
<value name="ConWnd X" type="long" data="963"/>
|
||||
<value name="ConWnd Y" type="long" data="196"/>
|
||||
<value name="LastMonitor" type="string" data="0,0,1920,1040"/>
|
||||
<value name="LastMonitor" type="string" data="0,0,3840,2060"/>
|
||||
<value name="ConWnd Width" type="dword" data="00000071"/>
|
||||
<value name="ConWnd Height" type="dword" data="00000027"/>
|
||||
<value name="16bit Height" type="ulong" data="0"/>
|
||||
|
||||
Reference in New Issue
Block a user