全志 gt911 触摸屏驱动

本文详细解析了GT9XX系列触摸屏的Linux驱动源码,包括配置信息定义、寄存器设置、中断触发模式及日志输出等关键部分。针对不同传感器ID提供了具体的配置组,展示了如何在嵌入式系统中集成Goodix触控芯片。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

gt9xx.h

 

/* drivers/input/touchscreen/gt9xx.h
 *
 * 2010 - 2013 Goodix Technology.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be a reference
 * to you, when you are integrating the GOODiX's CTP IC into your system,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 */

#ifndef _GOODIX_GT9XX_H_
#define _GOODIX_GT9XX_H_

#include <linux/kernel.h>
#include <linux/hrtimer.h>
#include <linux/i2c.h>
#include <linux/input.h>
#include <linux/module.h>
#include <linux/delay.h>
#include <linux/i2c.h>
#include <linux/proc_fs.h>
#include <linux/string.h>
#include <asm/uaccess.h>
#include <linux/vmalloc.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/slab.h>

#ifdef CONFIG_HAS_EARLYSUSPEND
#include <linux/earlysuspend.h>
#endif
#include <linux/gpio.h>
#include "../../init-input.h"
#include <linux/pinctrl/consumer.h>

/***************************PART1:ON/OFF define*******************************/
#define GTP_CUSTOM_CFG        0
#define GTP_CHANGE_X2Y        0
#define GTP_DRIVER_SEND_CFG   1
#define GTP_HAVE_TOUCH_KEY    1
#define GTP_ICS_SLOT_REPORT   0


//#define GTP_CUSTOM_CFG        0 //关
//#define GTP_DRIVER_SEND_CFG   1 //开



#define GTP_AUTO_UPDATE       1    /* auto update fw by .bin file as default*/
#define GTP_HEADER_FW_UPDATE  1    /* auto update fw by gtp_default_FW in gt9xx_firmware.h, function together with GTP_AUTO_UPDATE */
#define GTP_AUTO_UPDATE_CFG   0    /* auto update config by .cfg file, function together with GTP_AUTO_UPDATE*/

#define GTP_COMPATIBLE_MODE   0    /* compatible with GT9XXF*/

#define GTP_CREATE_WR_NODE    1
#define GTP_ESD_PROTECT       0    /* esd protection with a cycle of 2 seconds*/

#define GTP_WITH_PEN          0
#define GTP_PEN_HAVE_BUTTON   0    /* active pen has buttons, function together with GTP_WITH_PEN*/

#define GTP_DEBUG_ON          0
#define GTP_DEBUG_ARRAY_ON    0
#define GTP_DEBUG_FUNC_ON     0

#if GTP_COMPATIBLE_MODE
typedef enum {
    CHIP_TYPE_GT9  = 0,
    CHIP_TYPE_GT9F = 1,
} CHIP_TYPE_T;
#endif

struct goodix_ts_data {
	spinlock_t irq_lock;
    struct i2c_client *client;
	struct input_dev  *input_dev;
	struct hrtimer timer;
	struct work_struct  work;
#ifdef CONFIG_HAS_EARLYSUSPEND
	struct early_suspend early_suspend;
#endif
	s32 irq_is_disable;
	s32 use_irq;
	u16 abs_x_max;
	u16 abs_y_max;
	u8  max_touch_num;
	u8  int_trigger_type;
	u8  green_wake_mode;
	u8  enter_update;
    u8  gtp_is_suspend;
    u8  gtp_rawdiff_mode;
    u8  gtp_cfg_len;
    u8  fixed_cfg;
    u8  fw_error;
    u8  pnl_init_error;
#if GTP_WITH_PEN
    struct input_dev *pen_dev;
#endif

#if GTP_ESD_PROTECT
    spinlock_t esd_lock;
    u8  esd_running;
    s32 clk_tick_cnt;
#endif

#if GTP_COMPATIBLE_MODE
    u16 bak_ref_len;
    s32 ref_chk_fs_times;
    s32 clk_chk_fs_times;
    CHIP_TYPE_T chip_type;
    u8 rqst_processing;
    u8 is_950;
#endif
};

extern u16 show_len;
extern u16 total_len;

extern struct ctp_config_info config_info;
extern void gtp_set_int_value(int status);
extern void gtp_set_io_int(void);
#define GTP_INT_PORT    		(config_info.irq_gpio.gpio)
#define GTP_RST_PORT    		(config_info.wakeup_gpio.gpio)
#define GTP_INT_IRQ     		(gpio_to_irq(GTP_INT_PORT))

/*******************************************************************************

#define GTP_GPIO_AS_INPUT(pin)          do{\
                                        	long unsigned int	config; \
											char pin_name[8]; \
											sunxi_gpio_to_name(pin,pin_name); \
											config = SUNXI_PINCFG_PACK(SUNXI_PINCFG_TYPE_FUNC,0xFFFF); \
	    									pin_config_get(SUNXI_PINCTRL,pin_name,&config); \
											if (1 != SUNXI_PINCFG_UNPACK_VALUE(config)){ \
		      										config = SUNXI_PINCFG_PACK(SUNXI_PINCFG_TYPE_FUNC,1); \
			  										pin_config_set(SUNXI_PINCTRL,pin_name,config); \
	    										} \
                                        }while(0)
#define GTP_GPIO_AS_INT(pin)            do{\
											long unsigned int	config; \
											char pin_name[8]; \
											sunxi_gpio_to_name(pin,pin_name); \
											config = SUNXI_PINCFG_PACK(SUNXI_PINCFG_TYPE_FUNC,0xFFFF); \
	    									pin_config_get(SUNXI_PINCTRL,pin_name,&config); \
											if (4 != SUNXI_PINCFG_UNPACK_VALUE(config)){ \
												config = SUNXI_PINCFG_PACK(SUNXI_PINCFG_TYPE_FUNC,4); \
			  									pin_config_set(SUNXI_PINCTRL,pin_name,config); \
	    									} \
                                        }while(0)
#define GTP_GPIO_GET_VALUE(pin)         gpio_get_value(pin)
#define GTP_GPIO_OUTPUT(pin,level)      gpio_direction_output(pin,level)
#define GTP_GPIO_REQUEST(pin, label)    gpio_request(pin, label)
#define GTP_GPIO_FREE(pin)              gpio_free(pin)
#define GTP_IRQ_TAB                     {IRQ_TYPE_EDGE_RISING, IRQ_TYPE_EDGE_FALLING, IRQ_TYPE_LEVEL_LOW, IRQ_TYPE_LEVEL_HIGH}

********************************************************************************/

/*************************** PART2:TODO define **********************************
 STEP_1(REQUIRED): Define Configuration Information Group(s)
 Sensor_ID Map:
 sensor_opt1 sensor_opt2 Sensor_ID
    GND         GND         0
    VDDIO       GND         1
    NC          GND         2
    GND         NC/300K     3
    VDDIO       NC/300K     4
    NC          NC/300K     5

 TODO: define your own default or for Sensor_ID == 0 config here.
 The predefined one is just a sample config, which is not suitable for your tp in most cases.
 suozhi,1536*2048,gt9271,COF
************************************************************************************/
#define CTP_CFG_GROUP1 {\
	0x46,0x80,0x07,0xB0,0x04,0x0A,0x3D,0x00,0x01,0x0A,\
	0x1E,0x0F,0x50,0x3C,0x03,0x04,0x01,0x01,0x00,0x00,\
	0x00,0x00,0x00,0x1A,0x1C,0x1E,0x14,0x90,0x30,0xAA,\
	0x32,0x30,0x03,0x15,0x00,0x00,0x02,0x03,0x03,0x1D,\
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0x00,\
	0x00,0x27,0x3B,0x94,0xC5,0x02,0x08,0x00,0x00,0x04,\
	0x8C,0x28,0x00,0x85,0x2C,0x00,0x80,0x30,0x00,0x7B,\
	0x34,0x00,0x77,0x38,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,0x19,0x18,0x17,0x16,0x15,0x14,0x11,0x10,\
	0x0F,0x0E,0x0D,0x0C,0x09,0x08,0x07,0x06,0x05,0x04,\
	0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x00,0x02,0x04,0x06,0x07,0x08,0x0A,0x0C,\
	0x0D,0x0E,0x0F,0x10,0x11,0x12,0x13,0x14,0x2A,0x29,\
	0x28,0x27,0x26,0x25,0x24,0x23,0x22,0x21,0x20,0x1F,\
	0x1E,0x1C,0x1B,0x19,0x00,0x00,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x00,0x00,0x61,0x01}


/* TODO: define your config for Sensor_ID == 1 here, if needed*/
/* for yuxin gt9110,COB*/
#define CTP_CFG_GROUP2 {\
	0x41,0x00,0x06,0x00,0x08,0x0A,0xC5,0x00,0x01,0x08,\
	0x28,0x05,0x50,0x32,0x03,0x05,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x95,0x35,0xFF,\
	0x1E,0x20,0x31,0x0D,0x00,0x00,0x00,0x1A,0x03,0x2D,\
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
	0x00,0x0F,0x4B,0x94,0xC5,0x02,0x08,0x00,0x00,0x04,\
	0xD0,0x11,0x00,0x9A,0x18,0x00,0x76,0x21,0x00,0x5C,\
	0x2E,0x00,0x4A,0x40,0x00,0x4A,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,0x1D,0x1C,0x1B,0x1A,0x19,0x18,0x17,0x16,\
	0x15,0x14,0x13,0x12,0x11,0x10,0x0F,0x0E,0x0D,0x0C,\
	0x0B,0x0A,0x09,0x08,0x07,0x06,0x05,0x04,0x03,0x02,\
	0x01,0x00,0x14,0x13,0x12,0x11,0x10,0x0F,0x0E,0x0D,\
	0x0C,0x0B,0x0A,0x09,0x08,0x07,0x06,0x05,0x04,0x03,\
	0x02,0x01,0x00,0x15,0x16,0x17,0x18,0x19,0x1B,0x1C,\
	0x1D,0x1E,0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,\
	0x27,0x28,0x29,0x2A,0x2A,0x01}


/* TODO: define your config for Sensor_ID == 2 here, if needed*/
/*for yuxin gt9271,COF*/
#define CTP_CFG_GROUP3 {\
	0x41,0x00,0x06,0x00,0x08,0x0A,0x05,0x00,0x01,0x0F,\
	0x28,0x0F,0x50,0x32,0x03,0x05,0x00,0x00,0xFB,0x03,\
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x90,0x30,0xAA,\
	0x1F,0x1C,0xD6,0x09,0x00,0x00,0x00,0x9A,0x33,0x25,\
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
	0x02,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,0x00,0x00,0x00,\
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,\
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x00,0x01,0x04,0x05,0x06,0x07,0x08,0x09,\
	0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x14,0x15,0x16,0x17,\
	0x18,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x14,0x13,0x12,0x11,0x10,0x0F,0x0E,0x0D,\
	0x0C,0x0A,0x08,0x07,0x06,0x04,0x02,0x00,0x19,0x1B,\
	0x1C,0x1E,0x1F,0x20,0x21,0x22,0x23,0x24,0x25,0x26,\
	0x27,0x28,0x29,0x2A,0x00,0x00,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x00,0x00,0x63,0x01}

/* TODO: define your config for Sensor_ID == 3 here, if needed*/
/*for dushulang gt9110,COF*/
#define CTP_CFG_GROUP4 {\
	0x41,0x56,0x05,0x00,0x03,0x0A,0x3D,0x00,0x01,0x08,\
	0x28,0x08,0x50,0x32,0x03,0x07,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x00,0x19,0x1A,0x1E,0x14,0x95,0x35,0xFF,\
	0x2A,0x2C,0x39,0x13,0x00,0x00,0x00,0x9A,0x03,0x2D,\
	0x00,0x00,0x00,0x80,0x83,0x04,0x6E,0x64,0x14,0x00,\
	0x00,0x1E,0x3C,0x94,0xC5,0x02,0x07,0x00,0x00,0x04,\
	0x96,0x20,0x00,0x89,0x25,0x00,0x7F,0x2A,0x00,0x77,\
	0x30,0x00,0x6F,0x38,0x00,0x6F,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,0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,\
	0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,0x10,0x11,\
	0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,\
	0x1C,0x1D,0x2A,0x29,0x28,0x27,0x26,0x25,0x24,0x23,\
	0x22,0x21,0x20,0x1F,0x1E,0x1D,0x1C,0x1B,0x19,0x18,\
	0x17,0x16,0x15,0x14,0x13,0x12,0x11,0x10,0x0F,0x0E,\
	0x0D,0x0C,0x0B,0x0A,0x09,0x08,0x07,0x06,0x05,0x04,\
	0x03,0x02,0x01,0x00,0x24,0x01}
/* TODO: define your config for Sensor_ID == 4 here, if needed*/
/* machine: noah*/
#define CTP_CFG_GROUP5 {\
0x46,0x00,0x05,0x20,0x03,0x0A,0x3D,0x00,0x01,0x0A,\
0x1E,0x0F,0x50,0x3C,0x03,0x04,0x01,0x01,0x00,0x00,\
0x00,0x00,0x00,0x1A,0x1C,0x1E,0x14,0x90,0x30,0xAA,\
0x32,0x30,0x03,0x15,0x00,0x00,0x02,0x03,0x03,0x1D,\
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
0x00,0x27,0x3B,0x94,0xC5,0x02,0x08,0x00,0x00,0x04,\
0x8C,0x28,0x00,0x85,0x2C,0x00,0x80,0x30,0x00,0x7B,\
0x34,0x00,0x77,0x38,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,0x00,0x01,0x04,0x05,0x06,0x07,0x08,0x09,\
0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x14,0x15,0x16,0x17,\
0x18,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
0x00,0x00,0x2A,0x29,0x28,0x27,0x26,0x25,0x24,0x23,\
0x22,0x21,0x20,0x1F,0x1E,0x1C,0x1B,0x19,0x14,0x13,\
0x12,0x11,0x10,0x0F,0x0E,0x0D,0x0C,0x0A,0x08,0x07,\
0x06,0x04,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
0x00,0x00,0x00,0x00,0x7B,0x01}


/* TODO: define your config for Sensor_ID == 5 here, if needed*/
#define CTP_CFG_GROUP6 {\
	0x41,0x00,0x06,0x00,0x08,0x0A,0x35,0x00,0x01,0x0A,\
	0x28,0x0A,0x50,0x32,0x03,0x03,0x00,0x00,0xFF,0x7F,\
	0x00,0x00,0x04,0x16,0x1A,0x1E,0x14,0x90,0x30,0xAA,\
	0x30,0x32,0x2E,0x0B,0x00,0x00,0x00,0x9A,0x33,0x45,\
	0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
	0x23,0x1E,0x41,0x4F,0xC5,0x01,0x08,0x00,0x00,0x04,\
	0xC1,0x20,0x00,0xAD,0x25,0x00,0x99,0x2C,0x00,0x8B,\
	0x33,0x00,0x7E,0x3C,0x00,0x7E,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x19,\
	0x50,0x37,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x00,0x01,0x04,0x05,0x06,0x07,0x08,0x09,\
	0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x14,0x15,0x16,0x17,\
	0x18,0x19,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x2A,0x29,0x28,0x27,0x26,0x25,0x24,0x23,\
	0x22,0x21,0x20,0x1F,0x1E,0x1C,0x1B,0x19,0x14,0x13,\
	0x12,0x11,0x10,0x0F,0x0E,0x0D,0x0C,0x0A,0x08,0x07,\
	0x06,0x04,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x00,0x00,0x21,0x01}


#if 0
#define CTP_CFG_GROUP7 {\
    0x00,0x20,0x03,0x00,0x05,0x0A,0x05,0x01, \
    0x01,0x08,0x28,0x05,0x50,0x32,0x03,0x05, \
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, \
    0x00,0x00,0x00,0x8A,0x2A,0x0C,0x17,0x15, \
    0x31,0x0D,0x00,0x00,0x00,0xBA,0x03,0x2C, \
    0x00,0x00,0x00,0x00,0x00,0x03,0x64,0x32, \
    0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00, \
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, \
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, \
    0x00,0x00,0x00,0x00,0x48,0x50,0x58,0x60, \
    0xF0,0x4A,0x3A,0xFF,0xFF,0x27,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,0xFF,0xFF, \
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, \
    0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x24,0x22, \
    0x21,0x20,0x1F,0x1E,0x1D,0x1C,0x18,0x16, \
    0x12,0x10,0x0F,0x0C,0x0A,0x08,0x06,0x04, \
    0x02,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, \
    0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,0x00, \
    0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, \
    0x2C,0x01 }
#endif

#if 0
    /* TODO: define your config for Sensor_ID == 6 here, if needed 1024*600*/
#define CTP_CFG_GROUP7 {\
	0x41,0x20,0x03,0xe0,0x01,0x02,0x4d,0x00,\
	0x01,0x08,0x19,0x0a,0x50,0x3c,0x03,0x05,\
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x00,0x8a,0x2a,0x0c,0x46,0x44,\
	0x0c,0x08,0x00,0x00,0x00,0xba,0x02,0x1d,\
	0x00,0x01,0x00,0x00,0x00,0x03,0x64,0x32,\
	0x00,0x00,0x00,0x32,0x55,0x8a,0xc5,0x02,\
	0x07,0x00,0x00,0x04,0xa2,0x34,0x00,0x93,\
	0x3a,0x00,0x86,0x41,0x00,0x7b,0x48,0x00,\
	0x71,0x50,0x00,0x71,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,0x00,0x02,\
	0x04,0x06,0x08,0x0a,0x0f,0x10,0x12,0x13,\
	0x16,0x18,0x1c,0x1d,0x1e,0x1f,0x20,0x21,\
	0x22,0x24,0xff,0xff,0xff,0xff,0xff,0xff,\
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
	0x78,0x01}
#endif



#define CTP_CFG_GROUP7 {\
    0x42,0x20,0x03,0x00,0x05,0x0A,0xB5,0x01,0x01,0x0A,0x28,0x0F,0x5A,0x37,0x03,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x17,0x19,0x1D,0x14,0x8A,0x2A,0x0C,0x5B,0x5D,0xB2,0x04,0x00,0x00,0x00,0xB9,0x02,0x11,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0x78,0x94,0xD5,0x02,0x07,0x00,0x00,0x04,0x96,0x49,0x00,0x89,0x52,0x00,0x7F,0x5B,0x00,0x76,0x66,0x00,0x6E,0x71,0x00,0x6E,0x48,0x50,0x58,0x60,0xF0,0x4A,0x3A,0xFF,0xFF,0x27,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,0x12,0x10,0x0F,0x0C,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,0xA5,0x01 }








//————————————————
//版权声明:本文为优快云博主「曉之以礼」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
//原文链接:https://blog.youkuaiyun.com/weixin_44981258/article/details/103782805

#if 0
/*1680 * 480*/
#define CTP_CFG_GROUP7 {\
	0x42,0x40,0x06,0xE0,0x01,0x0A,0x0D,0x00,0x01,0x08,\
	0x28,0x05,0x50,0x32,0x03,0x05,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x8C,0x2D,0x08,\
	0x17,0x15,0x31,0x0D,0x00,0x00,0x01,0xB9,0x04,0x1D,\
	0x00,0x00,0x00,0x00,0x00,0x03,0x64,0x32,0x00,0x00,\
	0x00,0x0F,0x23,0x94,0xC5,0x02,0x07,0x00,0x00,0x04,\
	0x9E,0x10,0x00,0x8A,0x13,0x00,0x7C,0x16,0x00,0x6B,\
	0x1B,0x00,0x60,0x20,0x00,0x60,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,\
	0xFF,0xFF,0xFF,0xFF,0xFF,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,0x14,0x16,0x18,0x1C,0x1D,0x1E,0x1F,\
	0x20,0x21,0x22,0x24,0x26,0x28,0x29,0xFF,0x00,0x00,\
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x00,0x00,0xE1,0x01}
#endif



/* 400 * 1280*/
#define CTP_CFG_GROUP8 {\
	0x9A,0x90,0x01,0x00,0x05,0x0A,0x35,0x00,0x01,0x0F,\
	0x28,0x0F,0x50,0x32,0x03,0x05,0x00,0x41,0x00,0x00,\
	0x00,0x00,0x04,0x16,0x1C,0x1E,0x14,0x8B,0x2B,0x0B,\
	0x28,0x26,0x0C,0x08,0x00,0x00,0x01,0x9C,0x03,0x25,\
	0x00,0x01,0x00,0x00,0x00,0x03,0x64,0x32,0x00,0x00,\
	0x00,0x19,0x50,0x94,0xC5,0x02,0x07,0x00,0x00,0x04,\
	0x8D,0x13,0x00,0x5F,0x1D,0x00,0x3E,0x2E,0x00,0x2B,\
	0x48,0x00,0x20,0x70,0x00,0x20,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,0x16,0x14,0x12,0x10,0x0E,0x0C,0x0A,0x08,\
	0x06,0x04,0x02,0xFF,0xFF,0xFF,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x13,0x12,0x10,0x0F,0x0C,0x0A,0x08,0x06,\
	0x04,0x02,0x00,0x16,0x18,0x1C,0x1D,0x1E,0x1F,0x20,\
	0x21,0x22,0x24,0x26,0xFF,0xFF,0xFF,0xFF,0x00,0x00,\
	0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,\
	0x00,0x00,0x00,0x00,0xDF,0x01}

#if GTP_CUSTOM_CFG
  #define GTP_MAX_HEIGHT   800
  #define GTP_MAX_WIDTH    480
  #define GTP_INT_TRIGGER  0            /* 0: Rising 1: Falling*/
#else
  #define GTP_MAX_HEIGHT   4096
  #define GTP_MAX_WIDTH    4096
  #define GTP_INT_TRIGGER  1
#endif
#define GTP_MAX_TOUCH         10

/* STEP_4(optional): If keys are available and reported as keys, config your key info here*/
#if GTP_HAVE_TOUCH_KEY
    #define GTP_KEY_TAB  {KEY_MENU, KEY_HOME, KEY_BACK, KEY_EJECTCD}
#endif

/***************************PART3:OTHER define**********************************/
#define GTP_DRIVER_VERSION          "V2.2<2014/01/14>"
#define GTP_I2C_NAME                "Goodix-TS"
#define GT91XX_CONFIG_PROC_FILE     "gt9xx_config"
#define GTP_POLL_TIME         10
#define GTP_ADDR_LENGTH       2
#define GTP_CONFIG_MIN_LENGTH 186
#define GTP_CONFIG_MAX_LENGTH 240
#define FAIL                  0
#define SUCCESS               1
#define SWITCH_OFF            0
#define SWITCH_ON             1

/******************** For GT9XXF Start **********************/
#define GTP_REG_BAK_REF                 0x99D0
#define GTP_REG_MAIN_CLK                0x8020
#define GTP_REG_CHIP_TYPE               0x8000
#define GTP_REG_HAVE_KEY                0x804E
#define GTP_REG_MATRIX_DRVNUM           0x8069
#define GTP_REG_MATRIX_SENNUM           0x806A

#define GTP_FL_FW_BURN              0x00
#define GTP_FL_ESD_RECOVERY         0x01
#define GTP_FL_READ_REPAIR          0x02

#define GTP_BAK_REF_SEND                0
#define GTP_BAK_REF_STORE               1
#define CFG_LOC_DRVA_NUM                29
#define CFG_LOC_DRVB_NUM                30
#define CFG_LOC_SENS_NUM                31

#define GTP_CHK_FW_MAX                  40
#define GTP_CHK_FS_MNT_MAX              300
#define GTP_BAK_REF_PATH                "/data/gtp_ref.bin"
#define GTP_MAIN_CLK_PATH               "/data/gtp_clk.bin"
#define GTP_RQST_CONFIG                 0x01
#define GTP_RQST_BAK_REF                0x02
#define GTP_RQST_RESET                  0x03
#define GTP_RQST_MAIN_CLOCK             0x04
#define GTP_RQST_RESPONDED              0x00
#define GTP_RQST_IDLE                   0xFF

/******************** For GT9XXF End **********************/
/* Registers define*/
#define GTP_READ_COOR_ADDR    0x814E
#define GTP_REG_SLEEP         0x8040
#define GTP_REG_SENSOR_ID     0x814A
#define GTP_REG_CONFIG_DATA   0x8047
#define GTP_REG_VERSION       0x8140

#define RESOLUTION_LOC        3
#define TRIGGER_LOC           8

#define CFG_GROUP_LEN(p_cfg_grp)  (sizeof(p_cfg_grp) / sizeof(p_cfg_grp[0]))
/* Log define*/
/***********************Add by zhongjian for sunxi tp************************
extern u32 debug_mask;

enum{
	DEBUG_INIT = 1U << 0,
	DEBUG_SUSPEND = 1U << 1,
	DEBUG_INT_INFO = 1U << 2,
	DEBUG_X_Y_INFO = 1U << 3,
	DEBUG_KEY_INFO = 1U << 4,
	DEBUG_WAKEUP_INFO = 1U << 5,
	DEBUG_OTHERS_INFO = 1U << 6,
};

#define dprintk(level_mask,fmt,arg...)    if(unlikely(debug_mask & level_mask)) \
        printk("***CTP***"fmt, ## arg)
***************************************************************************/

//#define GTP_INFO(fmt,arg...)           printk("<<-GTP-INFO->> "fmt"\n",##arg)

#define GTP_INFO(fmt,arg...)          do{\
                                         if(GTP_DEBUG_ON)\
                                         printk("<<-GTP-DEBUG->> [%u]"fmt"\n",__LINE__, ##arg);\
                                       }while(0)



#define GTP_ERROR(fmt,arg...)          printk("<<-GTP-ERROR->> "fmt"\n",##arg)
#define GTP_DEBUG(fmt,arg...)          do{\
                                         if(GTP_DEBUG_ON)\
                                         printk("<<-GTP-DEBUG->> [%u]"fmt"\n",__LINE__, ##arg);\
                                       }while(0)
#define GTP_DEBUG_ARRAY(array, num)    do{\
                                         s32 i;\
                                         u8* a = array;\
                                         if(GTP_DEBUG_ARRAY_ON)\
                                         {\
                                            printk("<<-GTP-DEBUG-ARRAY->>\n");\
                                            for (i = 0; i < (num); i++)\
                                            {\
                                                printk("%02x   ", (a)[i]);\
                                                if ((i + 1 ) %10 == 0)\
                                                {\
                                                    printk("\n");\
                                                }\
                                            }\
                                            printk("\n");\
                                        }\
                                       }while(0)
#define GTP_DEBUG_FUNC()               do{\
                                         if(GTP_DEBUG_FUNC_ON)\
                                         printk("<<-GTP-FUNC->> Func:%s@Line:%u\n",__func__,__LINE__);\
                                       }while(0)
#define GTP_SWAP(x, y)                 do{\
                                         typeof(x) z = x;\
                                         x = y;\
                                         y = z;\
                                       }while (0)

/*****************************End of Part III*********************************/

#endif /* _GOODIX_GT9XX_H_ */

 

### 关于GT1151Q触摸屏驱动程序下载与安装 对于GT1151Q触摸屏,RT-Thread操作系统已经提供了相应的支持。这意味着可以在RT-Thread的软件包管理器中直接搜索并集成该驱动程序[^1]。 #### RT-Thread中的操作步骤说明 为了使GT1151能够在基于RT-Thread系统的项目中工作,需执行如下设置: - **启用驱动功能**:通过RT-Thread的菜单配置界面,定位至外设驱动选项,并确保已勾选针对GT1151的支持项;同时应移除任何不必要的示例工程组件,比如那些专门为其他型号(如GT9147)编写的例子代码。 #### 修改TouchGFX框架下的控制器实现 当使用TouchGFX图形库时,可能还需要调整`STM32TouchController.cpp`文件来适配新的触控IC: - 寻找特定于GT1151的数据获取逻辑; - 解除某些条件编译指令前的预处理宏控制符(即取消`#ifndef`),从而允许调用自定义初始化方法以及单指触控模式下坐标的正确解析。 ```cpp // 假定这是经过适当修改后的部分C++代码片段用于适应GT1151 void STM32TouchController::getXY(uint16_t* x, uint16_t* y){ // ...省略无关细节... /* Read X and Y coordinates directly from GT1151 */ *x = readRegister(GT1151_X_REG); *y = readRegister(GT1151_Y_REG); // No need to subtract offsets like 800 or 480 as mentioned for other models. } ``` 需要注意的是上述信息主要适用于嵌入式Linux环境下采用RT-Thread作为RTOS的情况。如果目标平台不同,则具体实施方式可能会有所变化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值