Files
luban-lite/doc/topics/sdk/peripheral/touch-revise-existing-gt911-drive.html

554 lines
60 KiB
HTML
Raw Normal View History

2025-04-23 17:54:31 +08:00
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn" data-whc_version="26.1">
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/><meta name="viewport" content="width=device-width, initial-scale=1.0"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><meta name="description" content="本节以将 GT911 驱动修改为 CST826 驱动为例,描述通过修改已有 CTP 驱动进行 CTP 移植的详细流程。 修改编译路径 打开 bsp/peripheral/touch/SConscript 文件,并将 GT911 文件编译路径描述修改为 CST826 文件编译路径。 示例如下: 修改前GT911 文件编译路径: if GetDepend( ..."/><meta name="DC.rights.owner" content="(C) 版权 2025"/><meta name="copyright" content="(C) 版权 2025"/><meta name="generator" content="DITA-OT"/><meta name="DC.type" content="topic"/><meta name="DC.relation" content="../../../topics/sdk/peripheral/touch.html"/><meta name="DC.relation" content="../../../topics/sdk/peripheral/ctp-drive-migrate-demo.html"/><meta name="DC.relation" content="../../../topics/sdk/peripheral/touch-obtain-key-info.html"/><meta name="DC.contributor" content="yan.wang"/><meta name="DC.contributor" content="yan.wang"/><meta name="DC.creator" content="yan.wang"/><meta name="DC.date.modified" content="2025-04-09"/><meta name="DC.format" content="HTML5"/><meta name="DC.identifier" content="touch_revise_existing_gt911_drive"/><title>修改已有 CTP 驱动</title><meta name="wh-path2root" content="../../../"/><meta name="wh-toc-id" content="touch_revise_existing_gt911_drive-d3703e1916"/><meta name="wh-source-relpath" content="topics/sdk/peripheral/touch-revise-existing-gt911-drive.dita"/><meta name="wh-out-relpath" content="topics/sdk/peripheral/touch-revise-existing-gt911-drive.html"/>
2025-01-23 16:37:00 +08:00
2025-04-23 17:54:31 +08:00
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/commons.css?buildId=2024041900"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/topic.css?buildId=2024041900"/>
2025-01-23 16:37:00 +08:00
2025-04-23 17:54:31 +08:00
<script src="../../../webhelp/app/options/properties.js?buildId=20250409170918"></script>
<script src="../../../webhelp/app/localization/strings.js?buildId=2024041900"></script>
<script src="../../../webhelp/app/search/index/keywords.js?buildId=20250409170918"></script>
<script defer="defer" src="../../../webhelp/app/commons.js?buildId=2024041900"></script>
<script defer="defer" src="../../../webhelp/app/topic.js?buildId=2024041900"></script>
<link rel="stylesheet" type="text/css" href="../../../webhelp/template/css/aic-styles-web-internal.css?buildId=2024041900"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/css/notes.css?buildId=2024041900"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/css/aic-common.css?buildId=2024041900"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/css/aic-images.css?buildId=2024041900"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/css/footnote.css?buildId=2024041900"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/css/aic-highlight-changes.css?buildId=2024041900"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/css/search-in-header.css?buildId=2024041900"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/css/topic-body-list.css?buildId=2024041900"/></head>
2025-01-23 16:37:00 +08:00
<body id="touch_revise_existing_gt911_drive" class="wh_topic_page frmBody">
<a href="#wh_topic_body" class="sr-only sr-only-focusable">
跳转到主要内容
</a>
<header class="navbar navbar-default wh_header">
<div class="container-fluid">
2025-04-23 17:54:31 +08:00
<div xmlns:whc="http://www.oxygenxml.com/webhelp/components" class="wh_header_flex_container navbar-nav navbar-expand-md navbar-dark">
2025-01-23 16:37:00 +08:00
<div class="wh_logo_and_publication_title_container">
<div class="wh_logo_and_publication_title">
2025-04-23 17:54:31 +08:00
<a href="https://www.artinchip.com" class=" wh_logo d-none d-sm-block "><img src="../../../company-logo.png" alt=" RTOS SDK 使用指南 SDK 指南文件 "/></a>
<div class=" wh_publication_title "><a href="../../../index.html"><span class="booktitle"> <span class="ph mainbooktitle">RTOS SDK 使用指南</span> <span class="ph booktitlealt">SDK 指南文件</span> </span></a></div>
2025-01-23 16:37:00 +08:00
</div>
</div>
<div class="wh_top_menu_and_indexterms_link collapse navbar-collapse" id="wh_top_menu_and_indexterms_link">
</div>
<div class=" wh_search_input navbar-form wh_topic_page_search search " role="form">
<form id="searchForm" method="get" role="search" action="../../../search.html"><div><input type="search" placeholder="搜索 " class="wh_search_textfield" id="textToSearch" name="searchQuery" aria-label="搜索查询" required="required"/><button type="submit" class="wh_search_button" aria-label="搜索"><span class="search_input_text">搜索</span></button></div></form>
2025-04-23 17:54:31 +08:00
</div></div>
</div>
</header>
2025-01-23 16:37:00 +08:00
<div class="container-fluid" id="wh_topic_container">
<div class="row">
<nav class="wh_tools d-print-none navbar-expand-md" aria-label="Tools">
<div data-tooltip-position="bottom" class=" wh_breadcrumb "><ol class="d-print-none"><li><span class="home"><a href="../../../index.html"><span>主页</span></a></span></li><li><div class="topicref" data-id="id"><div class="title"><a href="../../../topics/sdk/peripheral/peripheral-intro.html">外设移植</a><div class="wh-tooltip"><p class="shortdesc"><span class="ph">CTP、U 盘、SD 卡、有线和无线网络</span>等外设的介绍和使用说明。</p></div></div></div></li><li><div class="topicref" data-id="id"><div class="title"><a href="../../../topics/sdk/peripheral/touch.html">CTP 移植指南</a></div></div></li><li class="active"><div class="topicref" data-id="touch_revise_existing_gt911_drive"><div class="title"><a href="../../../topics/sdk/peripheral/touch-revise-existing-gt911-drive.html">修改已有 CTP 驱动</a></div></div></li></ol></div>
<div class="wh_right_tools">
<button class="wh_hide_highlight" aria-label="切换搜索突出显示" title="切换搜索突出显示"></button>
<button class="webhelp_expand_collapse_sections" data-next-state="collapsed" aria-label="折叠截面" title="折叠截面"></button>
<div class=" wh_navigation_links "><span id="topic_navigation_links" class="navheader">
<span class="navprev"><a class="- topic/link link" href="../../../topics/sdk/peripheral/ctp-drive-migrate-demo.html" title="驱动文件移植解析" aria-label="上一主题: 驱动文件移植解析" rel="prev"></a></span>
<span class="navnext"><a class="- topic/link link" href="../../../topics/sdk/peripheral/touch-obtain-key-info.html" title="获取和配置 IC 关键信息" aria-label="下一主题: 获取和配置 IC 关键信息" rel="next"></a></span> </span></div>
<div class=" wh_print_link print d-none d-md-inline-block "><button onClick="window.print()" title="打印此页" aria-label="打印此页"></button></div>
<button type="button" id="wh_toc_button" class="custom-toggler navbar-toggler collapsed wh_toggle_button navbar-light" aria-expanded="false" aria-label="Toggle publishing table of content" aria-controls="wh_publication_toc">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</nav>
</div>
<div class="wh_content_area">
<div class="row">
<nav id="wh_publication_toc" class="col-lg-3 col-md-3 col-sm-12 d-md-block d-none d-print-none" aria-label="Table of Contents Container">
<div id="wh_publication_toc_content">
2025-04-23 17:54:31 +08:00
<div class=" wh_publication_toc " data-tooltip-position="right"><span class="expand-button-action-labels"><span id="button-expand-action" role="button" aria-label="Expand"></span><span id="button-collapse-action" role="button" aria-label="Collapse"></span><span id="button-pending-action" role="button" aria-label="Pending"></span></span><ul role="tree" aria-label="Table of Contents"><li role="treeitem"><div data-tocid="revinfo_linux-d3703e457" class="topicref" data-id="revinfo_linux" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/revinfo/revinfo_rtos.html" id="revinfo_linux-d3703e457-link">修订记录</a></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="id-d3703e479" class="topicref" data-id="id" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action id-d3703e479-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/env/sdk-compile.html" id="id-d3703e479-link">SDK 编译</a><div class="wh-tooltip"><p class="shortdesc">介绍不同编译环境下 SDK 的详细编译流程。</p></div></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="id-d3703e601" class="topicref" data-id="id" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action id-d3703e601-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/advanced/sdk-usage.html" id="id-d3703e601-link">使用指南</a><div class="wh-tooltip"><p class="shortdesc">命令详解,编译选项,镜像和分区配置,添加应用和驱动等的详细使用说明。</p></div></div></div></li><li role="treeitem" aria-expanded="false"><div data-tocid="concept_rcx_czh_pzb-d3703e1001" class="topicref" data-id="concept_rcx_czh_pzb" data-state="not-ready"><span role="button" tabindex="0" aria-labelledby="button-expand-action concept_rcx_czh_pzb-d3703e1001-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/chapter-app.html" id="concept_rcx_czh_pzb-d3703e1001-link">应用场景</a><div class="wh-tooltip"><p class="shortdesc">描述了 SDK 在不同应用场景中的配置和使用包括系统更新、OTA、安全方案等。</p></div></div></div></li><li role="treeitem" aria-expanded="true"><div data-tocid="id-d3703e1841" class="topicref" data-id="id" data-state="expanded"><span role="button" tabindex="0" aria-labelledby="button-collapse-action id-d3703e1841-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/peripheral/peripheral-intro.html" id="id-d3703e1841-link">外设移植</a><div class="wh-tooltip"><p class="shortdesc"><span class="ph">CTP、U 盘、SD 卡、有线和无线网络</span>等外设的介绍和使用说明。</p></div></div></div><ul role="group" class="navbar-nav nav-list"><li role="treeitem"><div data-tocid="id-d3703e1860" class="topicref" data-id="id" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/peripheral/keyadc.html" id="id-d3703e1860-link">按键矩阵</a></div></div></li><li role="treeitem" aria-expanded="true"><div data-tocid="id-d3703e1874" class="topicref" data-id="id" data-state="expanded"><span role="button" tabindex="0" aria-labelledby="button-collapse-action id-d3703e1874-link" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/peripheral/touch.html" id="id-d3703e1874-link">CTP 移植指南</a></div></div><ul role="group" class="navbar-nav nav-list"><li role="treeitem"><div data-tocid="touch-migrate-ctp-process-d3703e1888" class="topicref" data-id="touch-migrate-ctp-process" data-state="leaf"><span role="button" class="wh-expand-btn"></span><div class="title"><a href="../../../topics/sdk/peripheral/touch-migrate-ctp-process.html" id="touch-migrate-ctp-process-d3703e1888-link">新建 CTP 驱动</a></div></div></li><li role="treeitem"><div data-tocid="ctp-drive-migrate-demo-d3703e1902" class="topicref" data-id="ct
2025-01-23 16:37:00 +08:00
</div>
</nav>
<div class="col-lg-9 col-md-9 col-sm-12" id="wh_topic_body">
<button id="wh_close_publication_toc_button" class="close-toc-button d-none" aria-label="Toggle publishing table of content" aria-controls="wh_publication_toc" aria-expanded="true">
<span class="close-toc-icon-container">
<span class="close-toc-icon"></span>
</span>
</button>
2025-04-23 17:54:31 +08:00
<div class=" wh_topic_content body "><main role="main"><article class="- topic/topic topic" role="article" aria-labelledby="ariaid-title1">
<span class="edit-link" style="font-size:12px; opacity:0.6; text-align:right; vertical-align:middle"><a target="_blank" href="http://aicdocco/taskstopics/sdk/peripheral/touch-revise-existing-gt911-drive.dita">Edit online</a></span><h1 class="- topic/title title topictitle1" id="ariaid-title1">修改已有 CTP 驱动</h1>
<div class="date inPage">9 Apr 2025</div><div style="color: gray;">
2025-01-23 16:37:00 +08:00
Read time: 7 minute(s)
2025-04-23 17:54:31 +08:00
</div>
<div class="- topic/body body">
<div class="- topic/p p" data-ofbid="d55816e36__20250409171035">本节以将 GT911 驱动修改为 CST826 驱动为例,描述通过修改已有 CTP 驱动进行 CTP 移植的详细流程。<ol class="- topic/ol ol" id="touch_revise_existing_gt911_drive__ol_xl5_n3w_12c" data-ofbid="touch_revise_existing_gt911_drive__ol_xl5_n3w_12c">
<li class="- topic/li li" data-ofbid="d55816e40__20250409171035"><strong class="+ topic/ph hi-d/b ph b">修改编译路径</strong><p class="- topic/p p" data-ofbid="d55816e43__20250409171035">打开 <span class="+ topic/ph sw-d/filepath ph filepath">bsp/peripheral/touch/SConscript</span> 文件,并将
GT911 文件编译路径描述修改为 CST826 文件编译路径。</p><div class="- topic/p p" data-ofbid="d55816e48__20250409171035">示例如下:<ul class="- topic/ul ul" id="touch_revise_existing_gt911_drive__ul_nyf_q3w_12c" data-ofbid="touch_revise_existing_gt911_drive__ul_nyf_q3w_12c">
<li class="- topic/li li" data-ofbid="d55816e52__20250409171035">
<div class="- topic/p p" data-ofbid="d55816e54__20250409171035">修改前GT911
2025-01-23 16:37:00 +08:00
文件编译路径:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="touch_revise_existing_gt911_drive__codeblock_m4f_s3w_12c" data-ofbid="touch_revise_existing_gt911_drive__codeblock_m4f_s3w_12c"><strong class="hl-keyword">if</strong> GetDepend(<span class="hl-string">'AIC_TOUCH_PANEL_GT911'</span>):
CPPPATH.append(cwd + <span class="hl-string">'/gt911/inc'</span>)
src += Glob(<span class="hl-string">'gt911/src/*.c'</span>)</pre></div>
2025-04-23 17:54:31 +08:00
</li>
<li class="- topic/li li" data-ofbid="d55816e60__20250409171035">
<div class="- topic/p p" data-ofbid="d55816e62__20250409171035">修改后CST826
2025-01-23 16:37:00 +08:00
文件编译路径:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="touch_revise_existing_gt911_drive__codeblock_sxn_t3w_12c" data-ofbid="touch_revise_existing_gt911_drive__codeblock_sxn_t3w_12c"><strong class="hl-keyword">if</strong> GetDepend(<span class="hl-string">'AIC_TOUCH_PANEL_CST826'</span>):
CPPPATH.append(cwd + <span class="hl-string">'/cst826/inc'</span>)
src += Glob(<span class="hl-string">'cst826/src/*.c'</span>)</pre></div>
2025-04-23 17:54:31 +08:00
</li>
</ul></div></li>
<li class="- topic/li li" data-ofbid="d55816e69__20250409171035"><strong class="+ topic/ph hi-d/b ph b">修改 menuconfig 设备配置</strong><div class="- topic/p p" data-ofbid="d55816e72__20250409171035">打开 <span class="+ topic/ph sw-d/filepath ph filepath">bsp/peripheral/touch/Kconfig</span>
文件,将 GT911 的设备和设备名分别修改为 CST826 的设备和设备名:<ul class="- topic/ul ul" id="touch_revise_existing_gt911_drive__ul_m5c_bjw_12c" data-ofbid="touch_revise_existing_gt911_drive__ul_m5c_bjw_12c">
<li class="- topic/li li" data-ofbid="d55816e79__20250409171035">
<div class="- topic/p p" data-ofbid="d55816e81__20250409171035">修改前:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="touch_revise_existing_gt911_drive__codeblock_ksh_2jw_12c" data-ofbid="touch_revise_existing_gt911_drive__codeblock_ksh_2jw_12c">choice
2025-01-23 16:37:00 +08:00
prompt <span class="hl-string">"Select CTP device"</span>
<strong class="hl-keyword">default</strong> AIC_TOUCH_PANEL_GT911
depends on AIC_USING_CTP
config AIC_TOUCH_PANEL_GT911 <em class="hl-comment">//设备</em>
bool <span class="hl-string">"GT911"</span>
config AIC_TOUCH_PANEL_NAME
string
<strong class="hl-keyword">default</strong> <span class="hl-string">"gt911"</span> <strong class="hl-keyword">if</strong> AIC_TOUCH_PANEL_GT911 <em class="hl-comment">//设备名</em></pre></div>
2025-04-23 17:54:31 +08:00
</li>
<li class="- topic/li li" data-ofbid="d55816e87__20250409171035">
<div class="- topic/p p" data-ofbid="d55816e89__20250409171035">修改后:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="touch_revise_existing_gt911_drive__codeblock_lg2_fjw_12c" data-ofbid="touch_revise_existing_gt911_drive__codeblock_lg2_fjw_12c">choice
2025-01-23 16:37:00 +08:00
prompt <span class="hl-string">"Select CTP device"</span>
<strong class="hl-keyword">default</strong> AIC_TOUCH_PANEL_GT911
depends on AIC_USING_CTP
config AIC_TOUCH_PANEL_CST826 <em class="hl-comment">//设备</em>
bool <span class="hl-string">"CST826"</span>
config AIC_TOUCH_PANEL_NAME
string
<strong class="hl-keyword">default</strong> <span class="hl-string">"cst826"</span> <strong class="hl-keyword">if</strong> AIC_TOUCH_PANEL_CST826 <em class="hl-comment">//设备名</em></pre></div>
2025-04-23 17:54:31 +08:00
</li>
</ul></div></li>
<li class="- topic/li li" data-ofbid="d55816e96__20250409171035"><strong class="+ topic/ph hi-d/b ph b">修改文件名</strong><div class="- topic/p p" data-ofbid="d55816e99__20250409171035">打开 <span class="+ topic/ph sw-d/filepath ph filepath">bsp/peripheral/touch</span> 文件目录,将
2025-01-23 16:37:00 +08:00
<span class="+ topic/ph sw-d/filepath ph filepath">gt911</span>
2025-04-23 17:54:31 +08:00
文件夹名称及其源文件名称修改为<span class="+ topic/ph sw-d/filepath ph filepath">cst826</span><ul class="- topic/ul ul" id="touch_revise_existing_gt911_drive__ul_zml_4jw_12c" data-ofbid="touch_revise_existing_gt911_drive__ul_zml_4jw_12c">
<li class="- topic/li li" data-ofbid="d55816e112__20250409171035">修改前:<div class="- topic/p p" data-ofbid="d55816e114__20250409171035">
2025-01-23 16:37:00 +08:00
<br/><div class="imagecenter"><img class="- topic/image image imagecenter" id="touch_revise_existing_gt911_drive__image_dbh_pjw_12c" src="../../../images/ctp/gt911_code.png"/></div><br/>
2025-04-23 17:54:31 +08:00
</div></li>
<li class="- topic/li li" data-ofbid="d55816e119__20250409171035">修改后:<div class="- topic/p p" data-ofbid="d55816e121__20250409171035">
2025-01-23 16:37:00 +08:00
<br/><div class="imagecenter"><img class="- topic/image image imagecenter" id="touch_revise_existing_gt911_drive__image_ed4_pjw_12c" src="../../../images/ctp/cst826_code.png"/></div><br/>
2025-04-23 17:54:31 +08:00
</div></li>
</ul></div></li>
<li class="- topic/li li" data-ofbid="d55816e127__20250409171035">
<p class="- topic/p p" data-ofbid="d55816e129__20250409171035"><strong class="+ topic/ph hi-d/b ph b">修改源代码中的 <span class="+ topic/ph sw-d/filepath ph filepath">gt911.c</span> 文件</strong></p>
<div class="- topic/p p" data-ofbid="d55816e136__20250409171035">源代码修改包含但不限于下列内容:<div class="- topic/note note note note_note" id="touch_revise_existing_gt911_drive__note_mcq_lp1_b2c" data-ofbid="touch_revise_existing_gt911_drive__note_mcq_lp1_b2c"><span class="note__title">注:</span> 关于如何获取下列信息,可查看<a class="- topic/xref xref" href="touch-obtain-key-info.html">获取和配置 IC 关键信息</a></div><ol class="- topic/ol ol" type="a" id="touch_revise_existing_gt911_drive__ol_jjz_3p1_b2c" data-ofbid="touch_revise_existing_gt911_drive__ol_jjz_3p1_b2c">
<li class="- topic/li li" data-ofbid="d55816e146__20250409171035"><strong class="+ topic/ph hi-d/b ph b">更改设备名称</strong>:将所有与 GT911 相关的名称改为 CST826。</li>
<li class="- topic/li li" data-ofbid="d55816e151__20250409171035"><strong class="+ topic/ph hi-d/b ph b">更改 I2C 地址</strong>:根据 CST826 的数据手册,更改 I2C 地址。</li>
<li class="- topic/li li" data-ofbid="d55816e156__20250409171035"><strong class="+ topic/ph hi-d/b ph b">更改寄存器配置</strong>:根据 CST826 的数据手册,更改初始化和读取数据的寄存器配置。</li>
<li class="- topic/li li" data-ofbid="d55816e161__20250409171035"><strong class="+ topic/ph hi-d/b ph b">更改 GPIO 引脚配置</strong>:确保 GPIO 引脚配置正确。</li>
<li class="- topic/li li" data-ofbid="d55816e166__20250409171035"><strong class="+ topic/ph hi-d/b ph b">更新头文件和宏定义</strong>:确保所有相关头文件和宏定义都正确。</li>
</ol></div>
<div class="- topic/p p" data-ofbid="d55816e172__20250409171035">修改后的代码示例如下:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="touch_revise_existing_gt911_drive__codeblock_rxn_qp1_b2c" data-ofbid="touch_revise_existing_gt911_drive__codeblock_rxn_qp1_b2c">#include &lt;rtthread.h&gt;
2025-01-23 16:37:00 +08:00
#include <span class="hl-string">"touch.h"</span>
#include &lt;rthw.h&gt;
#include &lt;rtdevice.h&gt;
#<span class="hl-directive">define</span> CST826_SALVE_ADDR <span class="hl-number">0x5D</span> <em class="hl-comment">// 根据 CST82 数据手册设置正确的 I2C 地址</em>
#<span class="hl-directive">define</span> CST826_WORK_MODE <span class="hl-number">0x00</span>
#<span class="hl-directive">define</span> CST826_POINT_NUM <span class="hl-number">0x02</span>
#<span class="hl-directive">define</span> CST826_X_COORD_H <span class="hl-number">0x03</span>
#<span class="hl-directive">define</span> CST826_Y_COORD_H <span class="hl-number">0x07</span>
#<span class="hl-directive">define</span> CST826_WEIGHT <span class="hl-number">0x0B</span>
#<span class="hl-directive">define</span> CST826_MISC <span class="hl-number">0x0C</span>
#<span class="hl-directive">define</span> CST826_GESTURE <span class="hl-number">0x0D</span>
#<span class="hl-directive">define</span> CST826_X_COORD_L <span class="hl-number">0x0E</span>
#<span class="hl-directive">define</span> CST826_Y_COORD_L <span class="hl-number">0x0F</span>
#<span class="hl-directive">define</span> CST826_POINT_INFO <span class="hl-number">0x10</span>
<strong class="hl-keyword">struct</strong> cst826_info {
<strong class="hl-keyword">int</strong> point_num;
<strong class="hl-keyword">int</strong> x[<span class="hl-number">5</span>];
<strong class="hl-keyword">int</strong> y[<span class="hl-number">5</span>];
<strong class="hl-keyword">int</strong> weight[<span class="hl-number">5</span>];
};
<strong class="hl-keyword">static</strong> <strong class="hl-keyword">struct</strong> cst826_info info;
<strong class="hl-keyword">static</strong> <strong class="hl-keyword">struct</strong> rt_i2c_bus_device *cst826_bus;
<strong class="hl-keyword">static</strong> <strong class="hl-keyword">int</strong> cst826_read_point(<strong class="hl-keyword">struct</strong> rt_i2c_bus_device *bus, <strong class="hl-keyword">struct</strong> cst826_info *info)
{
<strong class="hl-keyword">int</strong> ret = -<span class="hl-number">1</span>;
<strong class="hl-keyword">unsigned</strong> <strong class="hl-keyword">char</strong> buf[<span class="hl-number">64</span>];
<strong class="hl-keyword">unsigned</strong> <strong class="hl-keyword">char</strong> read_buf[<span class="hl-number">4</span>];
<strong class="hl-keyword">int</strong> i;
buf[<span class="hl-number">0</span>] = CST826_POINT_INFO;
<strong class="hl-keyword">if</strong> (rt_i2c_master_send(bus, CST826_SALVE_ADDR, RT_I2C_WRITE, buf, <span class="hl-number">1</span>) != <span class="hl-number">1</span>) {
LOG_E(<span class="hl-string">"send config failed"</span>);
<strong class="hl-keyword">return</strong> -RT_ERROR;
}
<strong class="hl-keyword">if</strong> (rt_i2c_master_recv(bus, CST826_SALVE_ADDR, RT_I2C_READ, buf, <span class="hl-number">5</span>) != <span class="hl-number">5</span>) {
LOG_E(<span class="hl-string">"read point info failed"</span>);
<strong class="hl-keyword">return</strong> -RT_ERROR;
}
<strong class="hl-keyword">if</strong> (buf[<span class="hl-number">0</span>] &amp; <span class="hl-number">0x80</span>) {
LOG_E(<span class="hl-string">"no touch"</span>);
<strong class="hl-keyword">return</strong> -RT_EOK;
}
info-&gt;point_num = buf[<span class="hl-number">0</span>] &amp; <span class="hl-number">0x0F</span>;
<strong class="hl-keyword">for</strong> (i = <span class="hl-number">0</span>; i &lt; info-&gt;point_num; i++) {
buf[<span class="hl-number">0</span>] = CST826_X_COORD_H + <span class="hl-number">5</span> * i;
<strong class="hl-keyword">if</strong> (rt_i2c_master_send(bus, CST826_SALVE_ADDR, RT_I2C_WRITE, buf, <span class="hl-number">1</span>) != <span class="hl-number">1</span>) {
LOG_E(<span class="hl-string">"send config failed"</span>);
<strong class="hl-keyword">return</strong> -RT_ERROR;
}
<strong class="hl-keyword">if</strong> (rt_i2c_master_recv(bus, CST826_SALVE_ADDR, RT_I2C_READ, read_buf, <span class="hl-number">4</span>) != <span class="hl-number">4</span>) {
LOG_E(<span class="hl-string">"read point coord failed"</span>);
<strong class="hl-keyword">return</strong> -RT_ERROR;
}
info-&gt;x[i] = (read_buf[<span class="hl-number">0</span>] &lt;&lt; <span class="hl-number">8</span>) | read_buf[<span class="hl-number">1</span>];
info-&gt;y[i] = (read_buf[<span class="hl-number">2</span>] &lt;&lt; <span class="hl-number">8</span>) | read_buf[<span class="hl-number">3</span>];
info-&gt;weight[i] = <span class="hl-number">1</span>; <em class="hl-comment">// Placeholder for weight, as CST826 may not support it</em>
}
<strong class="hl-keyword">return</strong> RT_EOK;
}
<strong class="hl-keyword">static</strong> <strong class="hl-keyword">void</strong> cst826_touch_device_register(<strong class="hl-keyword">struct</strong> rt_touch_device *touch_device, <strong class="hl-keyword">const</strong> <strong class="hl-keyword">char</strong> *name)
{
<strong class="hl-keyword">if</strong> (rt_hw_touch_register(touch_device, name, RT_DEVICE_FLAG_INT_RX, RT_NULL) != RT_EOK) {
LOG_E(<span class="hl-string">"touch device cst826 register failed !!!"</span>);
} <strong class="hl-keyword">else</strong> {
LOG_I(<span class="hl-string">"touch device cst826 register success"</span>);
}
}
<strong class="hl-keyword">static</strong> <strong class="hl-keyword">int</strong> cst826_gpio_cfg()
{
<strong class="hl-keyword">unsigned</strong> <strong class="hl-keyword">int</strong> g, p;
<strong class="hl-keyword">long</strong> pin;
pin = drv_pin_get(AIC_TOUCH_PANEL_RST_PIN);
g = GPIO_GROUP(pin);
p = GPIO_GROUP_PIN(pin);
hal_gpio_direction_input(g, p);
pin = drv_pin_get(AIC_TOUCH_PANEL_INT_PIN);
g = GPIO_GROUP(pin);
p = GPIO_GROUP_PIN(pin);
hal_gpio_direction_input(g, p);
hal_gpio_set_irq_mode(g, p, <span class="hl-number">0</span>);
<strong class="hl-keyword">return</strong> <span class="hl-number">0</span>;
}
<strong class="hl-keyword">static</strong> <strong class="hl-keyword">int</strong> cst826_hw_init(<strong class="hl-keyword">struct</strong> rt_touch_config *cfg)
{
<strong class="hl-keyword">struct</strong> rt_touch_device *touch_device;
touch_device = (<strong class="hl-keyword">struct</strong> rt_touch_device *)rt_malloc(<strong class="hl-keyword">sizeof</strong>(<strong class="hl-keyword">struct</strong> rt_touch_device));
<strong class="hl-keyword">if</strong> (touch_device == RT_NULL) {
LOG_E(<span class="hl-string">"touch device malloc fail"</span>);
<strong class="hl-keyword">return</strong> -RT_ENOMEM;
}
rt_memset((<strong class="hl-keyword">void</strong> *)touch_device, <span class="hl-number">0x00</span>, <strong class="hl-keyword">sizeof</strong>(<strong class="hl-keyword">struct</strong> rt_touch_device));
touch_device-&gt;info = cst826_info; <em class="hl-comment">// 如果不需要手动获取信息,可以在这里赋值手动填写的信息</em>
touch_device-&gt;ops = &amp;cst826_touch_ops;
cst826_touch_device_register(touch_device, AIC_TOUCH_PANEL_NAME);
<strong class="hl-keyword">return</strong> RT_EOK;
}
<strong class="hl-keyword">static</strong> <strong class="hl-keyword">int</strong> cst826_port(<strong class="hl-keyword">void</strong>)
{
<strong class="hl-keyword">struct</strong> rt_touch_config cfg;
rt_uint8_t rst_pin;
cst826_gpio_cfg();
rst_pin = drv_pin_get(AIC_TOUCH_PANEL_RST_PIN);
cfg.dev_name = AIC_TOUCH_PANEL_I2C_CHAN;
cfg.irq_pin.pin = drv_pin_get(AIC_TOUCH_PANEL_INT_PIN);
cfg.irq_pin.mode = PIN_MODE_INPUT;
cfg.user_data = &amp;rst_pin;
#ifdef AIC_PM_DEMO
rt_pm_set_pin_wakeup_source(cfg.irq_pin.pin);
#endif
cst826_hw_init(&amp;cfg);
<strong class="hl-keyword">return</strong> <span class="hl-number">0</span>;
}
INIT_DEVICE_EXPORT(cst826_port);
</pre></div>
<div class="- topic/note note tip note_tip" id="touch_revise_existing_gt911_drive__note_pqm_sp1_b2c" data-ofbid="touch_revise_existing_gt911_drive__note_pqm_sp1_b2c"><span class="note__title">提示:</span>
2025-04-23 17:54:31 +08:00
<ul class="- topic/ul ul" id="touch_revise_existing_gt911_drive__ol_f4h_tp1_b2c" data-ofbid="touch_revise_existing_gt911_drive__ol_f4h_tp1_b2c">
<li class="- topic/li li" data-ofbid="d55816e181__20250409171035"><strong class="+ topic/ph hi-d/b ph b">寄存器配置</strong>:根据 CST826 的数据手册确认每个寄存器的地址和功能,并相应地调整代码中的寄存器配置。</li>
<li class="- topic/li li" data-ofbid="d55816e186__20250409171035"><strong class="+ topic/ph hi-d/b ph b">触摸点数</strong>:如果 CST826 支持多点触控,确保<code class="+ topic/ph pr-d/codeph ph codeph">info-&gt;point_num</code>
2025-01-23 16:37:00 +08:00
<code class="+ topic/ph pr-d/codeph ph codeph">info-&gt;x</code><code class="+ topic/ph pr-d/codeph ph codeph">info-&gt;y</code><code class="+ topic/ph pr-d/codeph ph codeph">info-&gt;weight</code>
2025-04-23 17:54:31 +08:00
数组的大小足够大以存储所有可能的触摸点。</li>
<li class="- topic/li li" data-ofbid="d55816e203__20250409171035"><strong class="+ topic/ph hi-d/b ph b">权重Weight</strong>:如果 CST826
不支持触摸点的权重,可以将<code class="+ topic/ph pr-d/codeph ph codeph">info-&gt;weight</code> 设置为固定值或忽略该字段。</li>
</ul>
2025-01-23 16:37:00 +08:00
</div>
2025-04-23 17:54:31 +08:00
</li>
<li class="- topic/li li" data-ofbid="d55816e214__20250409171035">
<p class="- topic/p p" data-ofbid="d55816e216__20250409171035"><strong class="+ topic/ph hi-d/b ph b">修改源代码中的 <span class="+ topic/ph sw-d/filepath ph filepath">.h</span> 文件</strong></p>
<div class="- topic/p p" data-ofbid="d55816e223__20250409171035">根据 CST826 规格书,确保所有相关的宏定义和寄存器地址正确无误。<div class="table-container"><table class="- topic/table table frame-all" id="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c" data-ofbid="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c" data-cols="5"><caption class="- topic/title title tablecap" data-caption-side="top" data-is-repeated="true"><span class="table--title-label"><span class="table--title-label-number"> 1</span><span class="table--title-label-punctuation">. </span></span><span class="table--title"><span class="+ topic/ph sw-d/filepath ph filepath">.h</span> 文件修改示例说明</span></caption><colgroup><col style="width:13.717421124828533%"/><col style="width:27.434842249657066%"/><col style="width:16.59807956104252%"/><col style="width:27.023319615912207%"/><col style="width:15.22633744855967%"/></colgroup><thead class="- topic/thead thead">
<tr class="- topic/row">
<th class="- topic/entry entry colsep-1 rowsep-1" id="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__1" rowspan="2"><p class="- topic/p p" data-ofbid="d55816e250__20250409171035">功能</p></th>
<th class="- topic/entry entry colsep-1 rowsep-1" id="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2" colspan="2"><p class="- topic/p p" data-ofbid="d55816e254__20250409171035">GT911</p></th>
<th class="- topic/entry entry colsep-0 rowsep-1" id="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3" colspan="2"><p class="- topic/p p" data-ofbid="d55816e258__20250409171035">CST826</p></th>
</tr>
<tr class="- topic/row">
<th class="- topic/entry entry colsep-1 rowsep-1" id="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__4"><p class="- topic/p p" data-ofbid="d55816e265__20250409171035">参数</p></th>
<th class="- topic/entry entry colsep-1 rowsep-1" id="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__5"><p class="- topic/p p" data-ofbid="d55816e269__20250409171035">配置</p></th>
<th class="- topic/entry entry colsep-1 rowsep-1" id="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__6"><p class="- topic/p p" data-ofbid="d55816e273__20250409171035">参数</p></th>
<th class="- topic/entry entry colsep-0 rowsep-1" id="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__7"><p class="- topic/p p" data-ofbid="d55816e277__20250409171035">配置</p></th>
</tr>
</thead><tbody class="- topic/tbody tbody">
<tr class="- topic/row">
<td class="- topic/entry entry colsep-0 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__1 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__4 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__5 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__6 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__7" colspan="5"><p class="- topic/p p" data-ofbid="d55816e287__20250409171035">寄存器</p></td>
</tr>
<tr class="- topic/row">
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__1" rowspan="2">
<p class="- topic/p p" data-ofbid="d55816e295__20250409171035">设置 I<sup class="+ topic/ph hi-d/sup ph sup">2</sup>C 地址</p>
</td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__4"><p class="- topic/p p" data-ofbid="d55816e303__20250409171035">GT911_ADDRESS_HIGH</p></td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__5"><p class="- topic/p p" data-ofbid="d55816e307__20250409171035">0x5D</p></td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__6"><p class="- topic/p p" data-ofbid="d55816e311__20250409171035">CST826_SALVE_ADDR</p></td>
<td class="- topic/entry entry colsep-0 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__7"><p class="- topic/p p" data-ofbid="d55816e315__20250409171035">0x15</p></td>
</tr>
<tr class="- topic/row">
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__4"><p class="- topic/p p" data-ofbid="d55816e322__20250409171035">GT911_ADDRESS_LOW</p></td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__5"><p class="- topic/p p" data-ofbid="d55816e326__20250409171035">0x14</p></td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__6"><p class="- topic/p p" data-ofbid="d55816e330__20250409171035">-</p></td>
<td class="- topic/entry entry colsep-0 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__7"><p class="- topic/p p" data-ofbid="d55816e334__20250409171035">-</p></td>
</tr>
<tr class="- topic/row">
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__1" rowspan="3">
<p class="- topic/p p" data-ofbid="d55816e342__20250409171035">配置和控制触摸控制器</p>
</td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__4"><p class="- topic/p p" data-ofbid="d55816e347__20250409171035">GT911_COMMAND_REG</p></td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__5"><p class="- topic/p p" data-ofbid="d55816e351__20250409171035">0x8040</p></td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__6"><p class="- topic/p p" data-ofbid="d55816e355__20250409171035">CST826_WORK_MODE</p></td>
<td class="- topic/entry entry colsep-0 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__7"><p class="- topic/p p" data-ofbid="d55816e359__20250409171035">0x00</p></td>
</tr>
<tr class="- topic/row">
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__4"><p class="- topic/p p" data-ofbid="d55816e366__20250409171035">GT911_CONFIG_REG</p></td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__5"><p class="- topic/p p" data-ofbid="d55816e370__20250409171035">0x8047</p></td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__6"><p class="- topic/p p" data-ofbid="d55816e374__20250409171035">CST826_PROX_STATE</p></td>
<td class="- topic/entry entry colsep-0 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__7"><p class="- topic/p p" data-ofbid="d55816e378__20250409171035">0x01</p></td>
</tr>
<tr class="- topic/row">
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__4"><p class="- topic/p p" data-ofbid="d55816e386__20250409171035">GT911_MOD_SWT_REG</p></td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__5"><p class="- topic/p p" data-ofbid="d55816e390__20250409171035">0x804D</p></td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__6"><p class="- topic/p p" data-ofbid="d55816e394__20250409171035">CST826_TOUCH_NUM</p></td>
<td class="- topic/entry entry colsep-0 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__7"><p class="- topic/p p" data-ofbid="d55816e398__20250409171035">0x02</p></td>
</tr>
<tr class="- topic/row">
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__1">
<p class="- topic/p p" data-ofbid="d55816e406__20250409171035">读取触摸点的信息</p>
</td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__4">
<p class="- topic/p p" data-ofbid="d55816e412__20250409171035">T911_POINT1_REG 到 GT911_POINT5_REG</p>
</td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__5"><p class="- topic/p p" data-ofbid="d55816e417__20250409171035">分别为从 0x814F 到 0x816F 的值</p></td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__6"><p class="- topic/p p" data-ofbid="d55816e421__20250409171035">CST826_TOUCH1_XH 到 CST826_TOUCH1_AREA </p></td>
<td class="- topic/entry entry colsep-0 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__7"><p class="- topic/p p" data-ofbid="d55816e425__20250409171035">分别为从 0x02 到 0x08 的值</p></td>
</tr>
<tr class="- topic/row">
<td class="- topic/entry entry colsep-0 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__1 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__4 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__5 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__6 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__7" colspan="5">
<p class="- topic/p p" data-ofbid="d55816e433__20250409171035">宏定义</p>
</td>
</tr>
<tr class="- topic/row">
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__1">
<p class="- topic/p p" data-ofbid="d55816e442__20250409171035">最大支持的触摸点数</p>
</td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__4"><p class="- topic/p p" data-ofbid="d55816e447__20250409171035">GT911_MAX_TOUCH</p></td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__5"><p class="- topic/p p" data-ofbid="d55816e451__20250409171035">5</p></td>
<td class="- topic/entry entry colsep-1 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__6"><p class="- topic/p p" data-ofbid="d55816e455__20250409171035">CST826_MAX_TOUCH </p></td>
<td class="- topic/entry entry colsep-0 rowsep-1" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__7"><p class="- topic/p p" data-ofbid="d55816e459__20250409171035">2</p></td>
</tr>
<tr class="- topic/row">
<td class="- topic/entry entry colsep-1 rowsep-0" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__1"><p class="- topic/p p" data-ofbid="d55816e466__20250409171035">每个触摸点的信息长度</p></td>
<td class="- topic/entry entry colsep-1 rowsep-0" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__4"><p class="- topic/p p" data-ofbid="d55816e470__20250409171035">GT911_POINT_INFO_NUM</p></td>
<td class="- topic/entry entry colsep-1 rowsep-0" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__2 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__5"><p class="- topic/p p" data-ofbid="d55816e474__20250409171035">8</p></td>
<td class="- topic/entry entry colsep-1 rowsep-0" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__6"><p class="- topic/p p" data-ofbid="d55816e478__20250409171035">CST826_POINT_LEN </p></td>
<td class="- topic/entry entry colsep-0 rowsep-0" headers="touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__3 touch_revise_existing_gt911_drive__table_g4k_tq1_b2c__entry__7"><p class="- topic/p p" data-ofbid="d55816e482__20250409171035">6</p></td>
</tr>
</tbody></table></div><ul class="- topic/ul ul" id="touch_revise_existing_gt911_drive__ul_aph_hq1_b2c" data-ofbid="touch_revise_existing_gt911_drive__ul_aph_hq1_b2c">
<li class="- topic/li li" data-ofbid="d55816e490__20250409171035">
<p class="- topic/p p" data-ofbid="d55816e492__20250409171035">GT911 寄存器地址和功能修改前的代码示例如下:</p>
2025-01-23 16:37:00 +08:00
<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="touch_revise_existing_gt911_drive__codeblock_zsr_lq1_b2c" data-ofbid="touch_revise_existing_gt911_drive__codeblock_zsr_lq1_b2c">#ifndef __GT911_H__
#<span class="hl-directive">define</span> __GT911_H__
#include <span class="hl-string">"drivers/touch.h"</span>
#include &lt;aic_hal_gpio.h&gt;
#include &lt;aic_drv_gpio.h&gt;
#<span class="hl-directive">define</span> GT911_ADDR_LEN <span class="hl-number">2</span>
#<span class="hl-directive">define</span> GT911_REGITER_LEN <span class="hl-number">2</span>
#<span class="hl-directive">define</span> GT911_MAX_TOUCH <span class="hl-number">5</span>
#<span class="hl-directive">define</span> GT911_POINT_INFO_NUM <span class="hl-number">8</span>
#<span class="hl-directive">define</span> GT911_ADDRESS_HIGH <span class="hl-number">0x5D</span>
#<span class="hl-directive">define</span> GT911_ADDRESS_LOW <span class="hl-number">0x14</span>
#<span class="hl-directive">define</span> GT911_COMMAND_REG <span class="hl-number">0x8040</span>
#<span class="hl-directive">define</span> GT911_CONFIG_REG <span class="hl-number">0x8047</span>
#<span class="hl-directive">define</span> GT911_MOD_SWT_REG <span class="hl-number">0x804D</span>
#<span class="hl-directive">define</span> GT911_PRODUCT_ID <span class="hl-number">0x8140</span>
#<span class="hl-directive">define</span> GT911_VENDOR_ID <span class="hl-number">0x814A</span>
#<span class="hl-directive">define</span> GT911_READ_STATUS <span class="hl-number">0x814E</span>
#<span class="hl-directive">define</span> GT911_POINT1_REG <span class="hl-number">0x814F</span>
#<span class="hl-directive">define</span> GT911_POINT2_REG <span class="hl-number">0x8157</span>
#<span class="hl-directive">define</span> GT911_POINT3_REG <span class="hl-number">0x815F</span>
#<span class="hl-directive">define</span> GT911_POINT4_REG <span class="hl-number">0x8167</span>
#<span class="hl-directive">define</span> GT911_POINT5_REG <span class="hl-number">0x816F</span>
#<span class="hl-directive">define</span> GT911_CHECK_SUM <span class="hl-number">0x80FF</span>
#endif <em class="hl-comment">/* gt911.h */</em></pre>
2025-04-23 17:54:31 +08:00
</li>
<li class="- topic/li li" data-ofbid="d55816e499__20250409171035">
<div class="- topic/p p" data-ofbid="d55816e501__20250409171035">CST826
2025-01-23 16:37:00 +08:00
寄存器地址和功能修改后的代码示例:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="touch_revise_existing_gt911_drive__codeblock_tgp_mq1_b2c" data-ofbid="touch_revise_existing_gt911_drive__codeblock_tgp_mq1_b2c">#ifndef __CST826_H__
#<span class="hl-directive">define</span> __CST826_H__
#include &lt;aic_hal_gpio.h&gt;
#include &lt;aic_drv_gpio.h&gt;
#include <span class="hl-string">"drivers/touch.h"</span>
#<span class="hl-directive">define</span> CST826_MAX_TOUCH <span class="hl-number">2</span>
#<span class="hl-directive">define</span> CST826_POINT_LEN <span class="hl-number">6</span>
#<span class="hl-directive">define</span> CST826_SALVE_ADDR <span class="hl-number">0x15</span>
<em class="hl-comment">/* cst826 reg */</em>
#<span class="hl-directive">define</span> CST826_WORK_MODE <span class="hl-number">0x00</span>
#<span class="hl-directive">define</span> CST826_PROX_STATE <span class="hl-number">0x01</span>
#<span class="hl-directive">define</span> CST826_TOUCH_NUM <span class="hl-number">0x02</span>
#<span class="hl-directive">define</span> CST826_TOUCH1_XH <span class="hl-number">0x03</span>
#<span class="hl-directive">define</span> CST826_TOUCH1_XL <span class="hl-number">0x04</span>
#<span class="hl-directive">define</span> CST826_TOUCH1_YH <span class="hl-number">0x05</span>
#<span class="hl-directive">define</span> CST826_TOUCH1_YL <span class="hl-number">0x06</span>
#<span class="hl-directive">define</span> CST826_TOUCH1_PRES <span class="hl-number">0x07</span>
#<span class="hl-directive">define</span> CST826_TOUCH1_AREA <span class="hl-number">0x08</span>
#<span class="hl-directive">define</span> CST826_SLEEP_MODE <span class="hl-number">0xA5</span>
#<span class="hl-directive">define</span> CST826_FW_VERSION1 <span class="hl-number">0xA6</span>
#<span class="hl-directive">define</span> CST826_FW_VERSION2 <span class="hl-number">0xA7</span>
#<span class="hl-directive">define</span> CST826_MODULE_ID <span class="hl-number">0xA8</span>
#<span class="hl-directive">define</span> CST826_PROJECT_NAME <span class="hl-number">0xA9</span>
#<span class="hl-directive">define</span> CST826_CHIP_TYPE1 <span class="hl-number">0xAA</span>
#<span class="hl-directive">define</span> CST826_CHIP_TYPE2 <span class="hl-number">0xAB</span>
#<span class="hl-directive">define</span> CST826_CHECKSUM1 <span class="hl-number">0xAC</span>
#<span class="hl-directive">define</span> CST826_CHECKSUM2 <span class="hl-number">0xAD</span>
#<span class="hl-directive">define</span> CST826_PROX_MODE <span class="hl-number">0xB0</span>
#<span class="hl-directive">define</span> CST826_GES_MODE <span class="hl-number">0xD0</span>
#<span class="hl-directive">define</span> CST826_GESTURE_ID <span class="hl-number">0xD3</span>
#<span class="hl-directive">define</span> AIC_TOUCH_PANEL_CST826_X_RANGE <span class="hl-number">480</span>
#<span class="hl-directive">define</span> AIC_TOUCH_PANEL_CST826_Y_RANGE <span class="hl-number">272</span>
#endif</pre></div>
2025-04-23 17:54:31 +08:00
</li>
</ul></div>
</li>
</ol></div>
</div>
</article></main></div>
2025-01-23 16:37:00 +08:00
</div>
</div>
</div>
</div>
<footer class="navbar navbar-default wh_footer">
<div class=" footer-container mx-auto ">
<title>footer def</title>
2025-04-23 17:54:31 +08:00
<style>
2025-01-23 16:37:00 +08:00
.p1 {
font-family: FangZhengShuSong, Times, serif;
}
.p2 {
font-family: Arial, Helvetica, sans-serif;
}
.p3 {
font-family: "Lucida Console", "Courier New", monospace;
}
2025-04-23 17:54:31 +08:00
</style>
2025-01-23 16:37:00 +08:00
<div class="webhelp.fragment.footer">
2025-04-23 17:54:31 +08:00
<p class="p1">Copyright © 2019-2025 广东匠芯创科技有限公司. All rights reserved.</p>
</div>
<div>
2025-01-23 16:37:00 +08:00
<div class="generation_time">
2025-04-23 17:54:31 +08:00
Update Time: 2025-04-09
2025-01-23 16:37:00 +08:00
</div>
2025-04-23 17:54:31 +08:00
</div>
2025-01-23 16:37:00 +08:00
</div>
</footer>
<div id="go2top" class="d-print-none">
<span class="oxy-icon oxy-icon-up"></span>
</div>
<div id="modal_img_large" class="modal">
<span class="close oxy-icon oxy-icon-remove"></span>
<div id="modal_img_container"></div>
<div id="caption"></div>
</div>
<script src="${pd}/publishing/publishing-styles-AIC-template/js/custom.js" defer="defer"></script>
</body>
</html>