add doc v1.1.2

This commit is contained in:
刘可亮
2025-01-23 16:37:00 +08:00
parent ba327e0931
commit b4033d8696
1883 changed files with 417094 additions and 0 deletions

View File

@@ -0,0 +1,161 @@
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn" data-whc_version="26.0">
<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="GPTimer 通过计数器来实现定时功能。可通过自动触发或者输入信号来启动定时器,其中定时器可以配置为单次模式或循环模式,同时还支持引脚输出功能。 GPTimer 被用作 Linux Clock Event 子系统。 表 1 . 术语定义 术语/缩略语 定义及说明 GPT/GPTimer General Purpose Timer通用定时器 图 1 . GPTimer 模块的硬件框图"/><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.contributor" content="yan.wang"/><meta name="DC.date.modified" content="2024-11-26"/><meta name="DC.format" content="HTML5"/><meta name="DC.identifier" content="id"/><title>GPTimer 使用指南</title><!-- Build number 2023110923. --><meta name="wh-path2root" content="../../../"/><meta name="wh-toc-id" content=""/><meta name="wh-source-relpath" content="topics/sdk/gptimer/gptimer-user-guide.dita"/><meta name="wh-out-relpath" content="topics/sdk/gptimer/gptimer-user-guide.html"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/commons.css?buildId=2023110923"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/topic.css?buildId=2023110923"/>
<script src="../../../webhelp/app/options/properties.js?buildId=20250121171154"></script>
<script src="../../../webhelp/app/localization/strings.js?buildId=2023110923"></script>
<script src="../../../webhelp/app/search/index/keywords.js?buildId=20250121171154"></script>
<script defer="defer" src="../../../webhelp/app/commons.js?buildId=2023110923"></script>
<script defer="defer" src="../../../webhelp/app/topic.js?buildId=2023110923"></script>
<link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-styles-web.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/notes.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-common.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-images.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/footnote.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-web-watermark.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/topic-body-list.css?buildId=2023110923"/></head>
<body id="id" 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">
<div class="wh_header_flex_container navbar-nav navbar-expand-md navbar-dark">
<div class="wh_logo_and_publication_title_container">
<div class="wh_logo_and_publication_title">
<a href="http://www.artinchip.com" class=" wh_logo d-none d-sm-block "><img src="../../../company-logo-white.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>
</div>
</div>
<div class="wh_top_menu_and_indexterms_link collapse navbar-collapse" id="wh_top_menu_and_indexterms_link">
</div>
</div>
</div>
</header>
<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>
</div>
<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 "></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_print_link print d-none d-md-inline-block "><button onClick="window.print()" title="打印此页" aria-label="打印此页"></button></div>
</div>
</nav>
</div>
<div class="wh_content_area">
<div class="row">
<div class="col-12" id="wh_topic_body">
<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://172.16.35.88/tasks/jdssno1uvvbf2mltu9kb9v3if05d5gopuakboe8hlud18rma/edit/F:/aicdita/aicdita-cn/topics/sdk/gptimer/gptimer-user-guide.dita">Edit online</a></span><h1 class="- topic/title title topictitle1" id="ariaid-title1">GPTimer 使用指南</h1><div class="date inPage">26 Nov 2024</div><div style="color: gray;"></div><div class="- topic/body body"><p class="- topic/p p" data-ofbid="d290685e17__20250121171756">GPTimer 通过计数器来实现定时功能。可通过自动触发或者输入信号来启动定时器,其中定时器可以配置为单次模式或循环模式,同时还支持引脚输出功能。</p><p class="- topic/p p" data-ofbid="d290685e19__20250121171756">GPTimer 被用作 Linux Clock Event 子系统。</p><div class="table-container"><table class="- topic/table table docutils align-default frame-all" id="id__table_sph_t3s_gdc" data-ofbid="id__table_sph_t3s_gdc" data-cols="2"><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></caption><colgroup><col style="width:46.948356807511736%"/><col style="width:53.051643192488264%"/></colgroup><thead class="- topic/thead thead"><tr class="- topic/row row-odd"><th class="- topic/entry entry head colsep-1 rowsep-1" id="id__table_sph_t3s_gdc__entry__1">术语/缩略语</th><th class="- topic/entry entry head colsep-0 rowsep-1" id="id__table_sph_t3s_gdc__entry__2">定义及说明</th></tr></thead><tbody class="- topic/tbody tbody"><tr class="- topic/row row-even"><td class="- topic/entry entry colsep-1 rowsep-0" headers="id__table_sph_t3s_gdc__entry__1">GPT/GPTimer</td><td class="- topic/entry entry colsep-0 rowsep-0" headers="id__table_sph_t3s_gdc__entry__2">General Purpose Timer通用定时器</td></tr></tbody></table></div><figure class="- topic/fig fig fignone" id="id__fig_dqc_x3s_gdc" data-ofbid="id__fig_dqc_x3s_gdc"><br/><div class="imagecenter"><img class="- topic/image image imagecenter" id="id__image_bhn_k3d_bdc" src="../../../images/gptimer/gpt_overview_block.png" alt="gptblock"/></div><br/><figcaption data-caption-side="bottom" class="- topic/title title figcapcenter"><span class="figtitleprefix fig--title-label"><span class="fig--title-label-number"> 1</span><span class="fig--title-label-punctuation">. </span></span><span class="fig--title">GPTimer 模块的硬件框图</span></figcaption></figure></div></article></main></div>
</div>
</div>
</div>
</div>
<footer class="navbar navbar-default wh_footer">
<div class=" footer-container mx-auto ">
<title>footer def</title>
<style><!--
.p1 {
font-family: FangZhengShuSong, Times, serif;
}
.p2 {
font-family: Arial, Helvetica, sans-serif;
}
.p3 {
font-family: "Lucida Console", "Courier New", monospace;
}
--></style>
<div class="webhelp.fragment.footer">
<p class="p1">Copyright © 2019-2024 广东匠芯创科技有限公司. All rights reserved.</p>
</div><div>
<div class="generation_time">
Update Time: 2025-01-21
</div>
</div>
</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>

View File

@@ -0,0 +1,194 @@
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn" data-whc_version="26.0">
<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="在 Luban-Lite 根目录下执行 scons --menuconfig ,进入 menuconfig 的功能配置界面,选择需要打开的 GPTimer。 以下输出示例中,配置只打开了 GPTimer0 Board options ---&gt; [*] Using GPTIMER0 [ ] Using GPTIMER1 [ ] Using GPTIMER2 [ ] Using GPTIMER3 [ ..."/><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.contributor" content="yan.wang"/><meta name="DC.date.modified" content="2024-12-04"/><meta name="DC.format" content="HTML5"/><meta name="DC.identifier" content="id"/><meta name="DC.language" content="zh-CN"/><title>GPTimer 配置</title><!-- Build number 2023110923. --><meta name="wh-path2root" content="../../../"/><meta name="wh-toc-id" content=""/><meta name="wh-source-relpath" content="topics/sdk/gptimer/gptimer_config_guide.dita"/><meta name="wh-out-relpath" content="topics/sdk/gptimer/gptimer_config_guide.html"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/commons.css?buildId=2023110923"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/topic.css?buildId=2023110923"/>
<script src="../../../webhelp/app/options/properties.js?buildId=20250121171154"></script>
<script src="../../../webhelp/app/localization/strings.js?buildId=2023110923"></script>
<script src="../../../webhelp/app/search/index/keywords.js?buildId=20250121171154"></script>
<script defer="defer" src="../../../webhelp/app/commons.js?buildId=2023110923"></script>
<script defer="defer" src="../../../webhelp/app/topic.js?buildId=2023110923"></script>
<link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-styles-web.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/notes.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-common.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-images.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/footnote.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-web-watermark.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/topic-body-list.css?buildId=2023110923"/></head>
<body id="id" 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">
<div class="wh_header_flex_container navbar-nav navbar-expand-md navbar-dark">
<div class="wh_logo_and_publication_title_container">
<div class="wh_logo_and_publication_title">
<a href="http://www.artinchip.com" class=" wh_logo d-none d-sm-block "><img src="../../../company-logo-white.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>
</div>
</div>
<div class="wh_top_menu_and_indexterms_link collapse navbar-collapse" id="wh_top_menu_and_indexterms_link">
</div>
</div>
</div>
</header>
<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>
</div>
<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 "></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_print_link print d-none d-md-inline-block "><button onClick="window.print()" title="打印此页" aria-label="打印此页"></button></div>
</div>
</nav>
</div>
<div class="wh_content_area">
<div class="row">
<div class="col-12" id="wh_topic_body">
<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://172.16.35.88/tasks/jdssno1uvvbf2mltu9kb9v3if05d5gopuakboe8hlud18rma/edit/F:/aicdita/aicdita-cn/topics/sdk/gptimer/gptimer_config_guide.dita">Edit online</a></span><h1 class="- topic/title title topictitle1" id="ariaid-title1">GPTimer 配置</h1><div class="date inPage">4 Dec 2024</div><div style="color: gray;">
Read time: 1 minute(s)
</div><div class="- topic/body body"><p class="- topic/p p" data-ofbid="d275889e17__20250121171747"><span class="- topic/ph ph">Luban-Lite</span> 根目录下执行 <span class="+ topic/keyword sw-d/cmdname keyword cmdname">scons
--menuconfig</span>,进入 menuconfig
的功能配置界面,选择需要打开的
GPTimer。</p><div class="- topic/p p" data-ofbid="d275889e25__20250121171747">以下输出示例中,配置只打开了
GPTimer0<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_qlb_rfs_cdc" data-ofbid="id__codeblock_qlb_rfs_cdc">Board options ---&gt;
[*] Using GPTIMER0
[ ] Using GPTIMER1
[ ] Using GPTIMER2
[ ] Using GPTIMER3
[ ] Using GPTIMER4
[ ] Using GPTIMER5
[ ] Using GPTIMER6
[ ] Using GPTIMER7
[ ] Using GPTIMER8
[ ] Using GPTIMER9</pre></div><p class="- topic/p p" data-ofbid="d275889e29__20250121171747">如需使用
RT-Thread
内核,还需要在
menuconfig 界面中打开
hwtimer
设备驱动框架:</p><p class="- topic/p p" data-ofbid="d275889e31__20250121171747">GPTimer
驱动需要依赖 RT-Thread 的 hwtimer
设备驱动框架。打开
hwtimer 设备驱动框架的输出示例如下:</p><div class="- topic/p p" data-ofbid="d275889e33__20250121171747">
<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_dcn_rfs_cdc" data-ofbid="id__codeblock_dcn_rfs_cdc">Rt-Thread options ---&gt;
RT-Thread Components ---&gt;
Device Drivers ---&gt;
[*] Using hardware timer device drivers</pre>
</div><div class="- topic/note note tip note_tip" id="id__note_jpd_5j5_cdc" data-ofbid="id__note_jpd_5j5_cdc"><span class="note__title">提示:</span>
<p class="- topic/p p" data-ofbid="d275889e40__20250121171747">为了简化使用,<span class="+ topic/ph ui-d/uicontrol ph uicontrol">Using
GPTimerx</span> 会自动打开 RT-Thread 的 hwtimer 设备驱动框架。</p>
</div></div></article></main></div>
</div>
</div>
</div>
</div>
<footer class="navbar navbar-default wh_footer">
<div class=" footer-container mx-auto ">
<title>footer def</title>
<style><!--
.p1 {
font-family: FangZhengShuSong, Times, serif;
}
.p2 {
font-family: Arial, Helvetica, sans-serif;
}
.p3 {
font-family: "Lucida Console", "Courier New", monospace;
}
--></style>
<div class="webhelp.fragment.footer">
<p class="p1">Copyright © 2019-2024 广东匠芯创科技有限公司. All rights reserved.</p>
</div><div>
<div class="generation_time">
Update Time: 2025-01-21
</div>
</div>
</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>

View File

@@ -0,0 +1,161 @@
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn" data-whc_version="26.0">
<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=""/><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.contributor" content="yan.wang"/><meta name="DC.date.modified" content="2024-10-15"/><meta name="DC.format" content="HTML5"/><meta name="DC.identifier" content="id"/><meta name="DC.language" content="zh-CN"/><title>调试指南</title><!-- Build number 2023110923. --><meta name="wh-path2root" content="../../../"/><meta name="wh-toc-id" content=""/><meta name="wh-source-relpath" content="topics/sdk/gptimer/gptimer_debug_guide.dita"/><meta name="wh-out-relpath" content="topics/sdk/gptimer/gptimer_debug_guide.html"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/commons.css?buildId=2023110923"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/topic.css?buildId=2023110923"/>
<script src="../../../webhelp/app/options/properties.js?buildId=20250121171154"></script>
<script src="../../../webhelp/app/localization/strings.js?buildId=2023110923"></script>
<script src="../../../webhelp/app/search/index/keywords.js?buildId=20250121171154"></script>
<script defer="defer" src="../../../webhelp/app/commons.js?buildId=2023110923"></script>
<script defer="defer" src="../../../webhelp/app/topic.js?buildId=2023110923"></script>
<link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-styles-web.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/notes.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-common.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-images.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/footnote.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-web-watermark.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/topic-body-list.css?buildId=2023110923"/></head>
<body id="id" 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">
<div class="wh_header_flex_container navbar-nav navbar-expand-md navbar-dark">
<div class="wh_logo_and_publication_title_container">
<div class="wh_logo_and_publication_title">
<a href="http://www.artinchip.com" class=" wh_logo d-none d-sm-block "><img src="../../../company-logo-white.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>
</div>
</div>
<div class="wh_top_menu_and_indexterms_link collapse navbar-collapse" id="wh_top_menu_and_indexterms_link">
</div>
</div>
</div>
</header>
<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>
</div>
<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 "></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_print_link print d-none d-md-inline-block "><button onClick="window.print()" title="打印此页" aria-label="打印此页"></button></div>
</div>
</nav>
</div>
<div class="wh_content_area">
<div class="row">
<div class="col-12" id="wh_topic_body">
<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://172.16.35.88/tasks/jdssno1uvvbf2mltu9kb9v3if05d5gopuakboe8hlud18rma/edit/F:/aicdita/aicdita-cn/topics/sdk/gptimer/gptimer_debug_guide.dita">Edit online</a></span><h1 class="- topic/title title topictitle1" id="ariaid-title1">调试指南</h1><div class="date inPage">15 Oct 2024</div><div style="color: gray;"></div><div class="- topic/body body"></div></article></main></div>
</div>
</div>
</div>
</div>
<footer class="navbar navbar-default wh_footer">
<div class=" footer-container mx-auto ">
<title>footer def</title>
<style><!--
.p1 {
font-family: FangZhengShuSong, Times, serif;
}
.p2 {
font-family: Arial, Helvetica, sans-serif;
}
.p3 {
font-family: "Lucida Console", "Courier New", monospace;
}
--></style>
<div class="webhelp.fragment.footer">
<p class="p1">Copyright © 2019-2024 广东匠芯创科技有限公司. All rights reserved.</p>
</div><div>
<div class="generation_time">
Update Time: 2025-01-21
</div>
</div>
</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>

View File

@@ -0,0 +1,511 @@
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn" data-whc_version="26.0">
<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="GPTimer 的源代码位于 bsp/artinchip/ bsp/artinchip/drv/gpt/drv_gpt.c GPTimer Driver 层实现 bsp/artinchip/include/drv/drv_gptimer.h GPTimer Driver 层接口 bsp/artinchip/hal/gpt/hal_gpt.c GTPimer 模块的 HAL 层实现 ..."/><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.contributor" content="yan.wang"/><meta name="DC.date.modified" content="2024-12-04"/><meta name="DC.format" content="HTML5"/><meta name="DC.identifier" content="id"/><meta name="DC.language" content="zh-CN"/><title>设计说明</title><!-- Build number 2023110923. --><meta name="wh-path2root" content="../../../"/><meta name="wh-toc-id" content=""/><meta name="wh-source-relpath" content="topics/sdk/gptimer/gptimer_design_guide.dita"/><meta name="wh-out-relpath" content="topics/sdk/gptimer/gptimer_design_guide.html"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/commons.css?buildId=2023110923"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/topic.css?buildId=2023110923"/>
<script src="../../../webhelp/app/options/properties.js?buildId=20250121171154"></script>
<script src="../../../webhelp/app/localization/strings.js?buildId=2023110923"></script>
<script src="../../../webhelp/app/search/index/keywords.js?buildId=20250121171154"></script>
<script defer="defer" src="../../../webhelp/app/commons.js?buildId=2023110923"></script>
<script defer="defer" src="../../../webhelp/app/topic.js?buildId=2023110923"></script>
<link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-styles-web.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/notes.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-common.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-images.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/footnote.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-web-watermark.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/topic-body-list.css?buildId=2023110923"/></head>
<body id="id" 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">
<div class="wh_header_flex_container navbar-nav navbar-expand-md navbar-dark">
<div class="wh_logo_and_publication_title_container">
<div class="wh_logo_and_publication_title">
<a href="http://www.artinchip.com" class=" wh_logo d-none d-sm-block "><img src="../../../company-logo-white.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>
</div>
</div>
<div class="wh_top_menu_and_indexterms_link collapse navbar-collapse" id="wh_top_menu_and_indexterms_link">
</div>
</div>
</div>
</header>
<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>
</div>
<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 "></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_print_link print d-none d-md-inline-block "><button onClick="window.print()" title="打印此页" aria-label="打印此页"></button></div>
</div>
</nav>
</div>
<div class="wh_content_area">
<div class="row">
<div class="col-lg-10 col-md-10 col-sm-10 col-xs-12" id="wh_topic_body">
<button id="wh_close_topic_toc_button" class="close-toc-button d-none" aria-label="Toggle topic table of content" aria-controls="wh_topic_toc" aria-expanded="true">
<span class="close-toc-icon-container">
<span class="close-toc-icon"></span>
</span>
</button>
<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://172.16.35.88/tasks/jdssno1uvvbf2mltu9kb9v3if05d5gopuakboe8hlud18rma/edit/F:/aicdita/aicdita-cn/topics/sdk/gptimer/gptimer_design_guide.dita">Edit online</a></span><h1 class="- topic/title title topictitle1" id="ariaid-title1">设计说明</h1><div class="date inPage">4 Dec 2024</div><div style="color: gray;">
Read time: 9 minute(s)
</div><div class="- topic/body body"><p class="- topic/p p" data-ofbid="d204928e17__20250121171637">GPTimer
的源代码位于
<span class="+ topic/ph sw-d/filepath ph filepath">bsp/artinchip/</span></p><ul class="- topic/ul ul simple" id="id__ul_emq_n3d_bdc" data-ofbid="id__ul_emq_n3d_bdc"><li class="- topic/li li" data-ofbid="d204928e23__20250121171637">
<p class="- topic/p p" data-ofbid="d204928e25__20250121171637"><span class="+ topic/ph sw-d/filepath ph filepath">bsp/artinchip/drv/gpt/drv_gpt.c</span>GPTimer
Driver 层实现</p>
</li><li class="- topic/li li" data-ofbid="d204928e30__20250121171637">
<p class="- topic/p p" data-ofbid="d204928e32__20250121171637"><span class="+ topic/ph sw-d/filepath ph filepath">bsp/artinchip/include/drv/drv_gptimer.h</span>GPTimer
Driver 层接口</p>
</li><li class="- topic/li li" data-ofbid="d204928e37__20250121171637">
<p class="- topic/p p" data-ofbid="d204928e39__20250121171637"><span class="+ topic/ph sw-d/filepath ph filepath">bsp/artinchip/hal/gpt/hal_gpt.c</span>GTPimer
模块的 HAL 层实现</p>
</li><li class="- topic/li li" data-ofbid="d204928e44__20250121171637">
<p class="- topic/p p" data-ofbid="d204928e46__20250121171637"><span class="+ topic/ph sw-d/filepath ph filepath">bsp/artinchip/include/hal/hal_gpt.h</span>GTPimer
模块的 HAL 层接口头文件</p>
</li></ul><section class="- topic/section section" id="id__id3" data-ofbid="id__id3"><h2 class="- topic/title title sectiontitle">模块架构</h2>
<p class="- topic/p p" data-ofbid="d204928e56__20250121171637">GPTimer 驱动 Driver 层采用 RT-Thread 的 hwtimer 设备驱动框架。HAL 层也可以支持 Baremetal
方式或配合自定义的设备驱动框架进行使用。</p><figure class="- topic/fig fig fignone" id="id__id7" data-ofbid="id__id7"><br/><div class="imagecenter"><img class="- topic/image image imagecenter" id="id__image_fmq_n3d_bdc" src="../../../images/gptimer/gptimer_sw_system.png" alt="sw_system"/></div><br/><figcaption data-caption-side="bottom" class="- topic/title title figcapcenter"><span class="figtitleprefix fig--title-label"><span class="fig--title-label-number"> 1</span><span class="fig--title-label-punctuation">. </span></span><span class="fig--title">GPTimer 驱动的软件架构图</span></figcaption></figure></section><section class="- topic/section section" id="id__id4" data-ofbid="id__id4"><h2 class="- topic/title title sectiontitle">关键流程设计</h2>
<div class="- topic/div div section" id="id__id5">
<p class="- topic/p p" data-ofbid="d204928e71__20250121171637">GPTimer 的初始化和配置过程是确保其能够正确工作的关键步骤。</p>
<p class="- topic/p p" data-ofbid="d204928e74__20250121171637">GPTimer
控制器的详细配置步骤如下:</p>
<ol class="- topic/ol ol arabic simple" id="id__ol_gmq_n3d_bdc" data-ofbid="id__ol_gmq_n3d_bdc"><li class="- topic/li li" data-ofbid="d204928e78__20250121171637">
<p class="- topic/p p" data-ofbid="d204928e80__20250121171637">初始化 GPTimer 模块的时钟 (clk),包括时钟源和分频器等参数,确保 GPTimer 以正确的频率运行。</p>
</li><li class="- topic/li li" data-ofbid="d204928e87__20250121171637">
<p class="- topic/p p" data-ofbid="d204928e89__20250121171637">设置 GPTimer
的计数值
(cnt)。</p>
</li><li class="- topic/li li" data-ofbid="d204928e92__20250121171637">
<p class="- topic/p p" data-ofbid="d204928e94__20250121171637">根据需求,设置
GPTimer
的工作模式,例如单次触发、周期性触发等。</p>
</li><li class="- topic/li li" data-ofbid="d204928e97__20250121171637">
<p class="- topic/p p" data-ofbid="d204928e99__20250121171637">使能 GPTimer
的中断。</p>
</li><li class="- topic/li li" data-ofbid="d204928e102__20250121171637">
<p class="- topic/p p" data-ofbid="d204928e104__20250121171637">启动 GPTimer
计数。</p>
</li><li class="- topic/li li" data-ofbid="d204928e107__20250121171637">
<p class="- topic/p p" data-ofbid="d204928e109__20250121171637">注册 hwtimer 设备。</p>
<p class="- topic/p p" data-ofbid="d204928e112__20250121171637">在 RT-Thread 中,通过 <span class="+ topic/keyword pr-d/apiname keyword apiname">rt_device_hwtimer_register()</span> 函数注册一个
hwtimer 设备。</p>
</li></ol>
</div>
</section><section class="- topic/section section" id="id__id6" data-ofbid="id__id6"><h2 class="- topic/title title sectiontitle">数据结构设计</h2>
<div class="- topic/div div section" id="id__struct-gptimer-info">
<strong class="+ topic/ph hi-d/b ph b">struct gptimer_info</strong>
<div class="- topic/p p" data-ofbid="d204928e130__20250121171637">属于 Driver 层接口,记录一个 GPTimer
设备的配置信息:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_jng_cqt_cdc" data-ofbid="id__codeblock_jng_cqt_cdc"><strong class="hl-keyword">struct</strong> gptimer_info {
<strong class="hl-keyword">char</strong> name[<span class="hl-number">12</span>];
u32 id;
<strong class="hl-keyword">struct</strong> irq_flag gptirq_flag;
rt_hwtimer_t gptimer;
};</pre></div></div><div class="- topic/div div section" id="id__struct-gptimer-para">
<strong class="+ topic/ph hi-d/b ph b">struct gptimer_para</strong>
<div class="- topic/p p" data-ofbid="d204928e139__20250121171637">属于 Driver 层接口,用于设置 GPTimer
的工作模式:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_wnv_cqt_cdc" data-ofbid="id__codeblock_wnv_cqt_cdc"><strong class="hl-keyword">struct</strong> gptimer_match_out
{
u8 is_en;
<strong class="hl-keyword">enum</strong> gpt_out_init out_init;
<strong class="hl-keyword">enum</strong> gpt_cmp_out cmpa_out;
<strong class="hl-keyword">enum</strong> gpt_cmp_out cmpb_out;
};
<strong class="hl-keyword">struct</strong> gptimer_match
{
<strong class="hl-keyword">enum</strong> gpt_cmp_act cmpa_act;
<strong class="hl-keyword">enum</strong> gpt_cmp_act cmpb_act;
<strong class="hl-keyword">struct</strong> gptimer_match_out outval[GPT_OUT_NUMS];
};
<strong class="hl-keyword">struct</strong> gptimer_para
{
<strong class="hl-keyword">enum</strong> gptimer_mode gptimer_mode;
<strong class="hl-keyword">enum</strong> gpt_trg_mode gptimer_trgmode;
<strong class="hl-keyword">struct</strong> gptimer_match matchval;
};</pre></div></div></section><section class="- topic/section section" id="id__driver" data-ofbid="id__driver"><h2 class="- topic/title title sectiontitle">Driver 层接口设计</h2>
<div class="- topic/p p" data-ofbid="d204928e148__20250121171637"><span class="+ topic/keyword pr-d/apiname keyword apiname">struct rt_hwtimer_ops</span> 是 RT-Thread 中定义的 hwtimer
设备驱动框架的标准接口,包含了一组函数指针,用于初始化、启动、停止、获取计数值和控制定时器等操作。<div class="- topic/note note note note_note" id="id__note_otz_zqt_cdc" data-ofbid="id__note_otz_zqt_cdc"><span class="note__title">注:</span> 各个操作参数的详细说明,可查看下列表格。</div></div>
<div class="- topic/p p" data-ofbid="d204928e155__20250121171637">以下示例展示了如何定义并实现 <span class="+ topic/keyword pr-d/apiname keyword apiname">rt_hwtimer_ops</span>
接口,并将其应用到一个定时器设备上。通过这种方式,可以方便地扩展和管理不同的定时器设备:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_it4_dqt_cdc" data-ofbid="id__codeblock_it4_dqt_cdc"><strong class="hl-keyword">struct</strong> rt_hwtimer_ops
{
<strong class="hl-keyword">void</strong> (*init)(<strong class="hl-keyword">struct</strong> rt_hwtimer_device *timer, rt_uint32_t state);
#ifdef AIC_GPTIMER_DRV
rt_err_t (*start)(<strong class="hl-keyword">struct</strong> rt_hwtimer_device *timer, rt_uint32_t cnt, rt_hwtimer_mode_t mode, <strong class="hl-keyword">void</strong> *args);
#<strong class="hl-keyword">else</strong>
rt_err_t (*start)(<strong class="hl-keyword">struct</strong> rt_hwtimer_device *timer, rt_uint32_t cnt, rt_hwtimer_mode_t mode);
#endif
<strong class="hl-keyword">void</strong> (*stop)(<strong class="hl-keyword">struct</strong> rt_hwtimer_device *timer);
rt_uint32_t (*count_get)(<strong class="hl-keyword">struct</strong> rt_hwtimer_device *timer);
rt_err_t (*control)(<strong class="hl-keyword">struct</strong> rt_hwtimer_device *timer, rt_uint32_t cmd, <strong class="hl-keyword">void</strong> *args);
};</pre></div>
<p class="- topic/p p" data-ofbid="d204928e166__20250121171637">为了拓展 GPTimer 的功能,<span class="+ topic/keyword pr-d/apiname keyword apiname">(*start)</span> 接口中新增了 <span class="+ topic/keyword pr-d/parmname keyword parmname">args</span> 参数,用于设置
GPTimer 的工作模式。</p>
<div class="- topic/div div section" id="id__drv-gptimer-init">
<div class="table-container"><table class="- topic/table table frame-all" id="id__table_kmq_n3d_bdc" data-ofbid="id__table_kmq_n3d_bdc" data-cols="2"><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">drv_gptimer_init</span></caption><colgroup><col style="width:16.666666666666664%"/><col style="width:83.33333333333334%"/></colgroup><thead class="- topic/thead thead"><tr class="- topic/row"><th class="- topic/entry entry colsep-1 rowsep-1" id="id__table_kmq_n3d_bdc__entry__1">函数原型</th><th class="- topic/entry entry colsep-0 rowsep-1" id="id__table_kmq_n3d_bdc__entry__2">static void drv_gptimer_init(rt_hwtimer_t *timer, rt_uint32_t
state)</th></tr></thead><tbody class="- topic/tbody tbody"><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="id__table_kmq_n3d_bdc__entry__1">功能说明</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="id__table_kmq_n3d_bdc__entry__2">初始化配置一路 Timer</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="id__table_kmq_n3d_bdc__entry__1">参数定义</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="id__table_kmq_n3d_bdc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">timer - 指向 rt_hwtimer_t 设备的指针</div>
<div class="- topic/div div">state - 1表示打开0表示关闭</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="id__table_kmq_n3d_bdc__entry__1">返回值</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="id__table_kmq_n3d_bdc__entry__2"></td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-0" headers="id__table_kmq_n3d_bdc__entry__1">注意事项</td><td class="- topic/entry entry colsep-0 rowsep-0" headers="id__table_kmq_n3d_bdc__entry__2">-</td></tr></tbody></table></div>
</div>
<div class="- topic/div div section" id="id__drv-hrtimer-start">
<div class="table-container"><table class="- topic/table table frame-all" id="id__table_lmq_n3d_bdc" data-ofbid="id__table_lmq_n3d_bdc" data-cols="2"><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"> 2</span><span class="table--title-label-punctuation">. </span></span><span class="table--title">drv_hrtimer_start</span></caption><colgroup><col style="width:16.666666666666664%"/><col style="width:83.33333333333334%"/></colgroup><thead class="- topic/thead thead"><tr class="- topic/row"><th class="- topic/entry entry colsep-1 rowsep-1" id="id__table_lmq_n3d_bdc__entry__1">函数原型</th><th class="- topic/entry entry colsep-0 rowsep-1" id="id__table_lmq_n3d_bdc__entry__2">static rt_err_t drv_gptimer_start(rt_hwtimer_t *timer,
rt_uint32_t cnt, rt_hwtimer_mode_t mode, void *args)</th></tr></thead><tbody class="- topic/tbody tbody"><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="id__table_lmq_n3d_bdc__entry__1">功能说明</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="id__table_lmq_n3d_bdc__entry__2">启动 Timer</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="id__table_lmq_n3d_bdc__entry__1">参数定义</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="id__table_lmq_n3d_bdc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">timer - 指向 rt_hwtimer_t 设备的指针</div>
<div class="- topic/div div">cnt - Timer 的超时计数,单位是:1/Freq 秒</div>
<div class="- topic/div div">mode - Oneshot、或 Period 类型</div>
<div class="- topic/div div">args - 指向 GPtimer 工作模式参数指针</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="id__table_lmq_n3d_bdc__entry__1">返回值</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="id__table_lmq_n3d_bdc__entry__2">0成功&lt;0失败</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-0" headers="id__table_lmq_n3d_bdc__entry__1">注意事项</td><td class="- topic/entry entry colsep-0 rowsep-0" headers="id__table_lmq_n3d_bdc__entry__2">输出模式下 CMPA 值默认为 cnt 值的四分之一CMPB 值默认为 cnt 值的二分之一</td></tr></tbody></table></div>
</div>
<div class="- topic/div div section" id="id__drv-hrtimer-stop">
<div class="table-container"><table class="- topic/table table frame-all" id="id__table_mmq_n3d_bdc" data-ofbid="id__table_mmq_n3d_bdc" data-cols="2"><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"> 3</span><span class="table--title-label-punctuation">. </span></span><span class="table--title">drv_hrtimer_stop</span></caption><colgroup><col style="width:16.666666666666664%"/><col style="width:83.33333333333334%"/></colgroup><thead class="- topic/thead thead"><tr class="- topic/row"><th class="- topic/entry entry colsep-1 rowsep-1" id="id__table_mmq_n3d_bdc__entry__1">函数原型</th><th class="- topic/entry entry colsep-0 rowsep-1" id="id__table_mmq_n3d_bdc__entry__2">static void drv_gptimer_stop(rt_hwtimer_t *timer)</th></tr></thead><tbody class="- topic/tbody tbody"><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="id__table_mmq_n3d_bdc__entry__1">功能说明</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="id__table_mmq_n3d_bdc__entry__2">停止 Timer</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="id__table_mmq_n3d_bdc__entry__1">参数定义</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="id__table_mmq_n3d_bdc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">timer - 指向 rt_hwtimer_t 设备的指针</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="id__table_mmq_n3d_bdc__entry__1">返回值</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="id__table_mmq_n3d_bdc__entry__2"></td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-0" headers="id__table_mmq_n3d_bdc__entry__1">注意事项</td><td class="- topic/entry entry colsep-0 rowsep-0" headers="id__table_mmq_n3d_bdc__entry__2">-</td></tr></tbody></table></div>
</div>
<div class="- topic/div div section" id="id__drv-hrtimer-ctrl">
<div class="table-container"><table class="- topic/table table frame-all" id="id__table_nmq_n3d_bdc" data-ofbid="id__table_nmq_n3d_bdc" data-cols="2"><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"> 4</span><span class="table--title-label-punctuation">. </span></span><span class="table--title">drv_hrtimer_ctrl</span></caption><colgroup><col style="width:16.666666666666664%"/><col style="width:83.33333333333334%"/></colgroup><thead class="- topic/thead thead"><tr class="- topic/row"><th class="- topic/entry entry colsep-1 rowsep-1" id="id__table_nmq_n3d_bdc__entry__1">函数原型</th><th class="- topic/entry entry colsep-0 rowsep-1" id="id__table_nmq_n3d_bdc__entry__2">static rt_err_t drv_gptimer_ctrl(rt_hwtimer_t *timer,
rt_uint32_t cmd, void *args)</th></tr></thead><tbody class="- topic/tbody tbody"><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="id__table_nmq_n3d_bdc__entry__1">功能说明</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="id__table_nmq_n3d_bdc__entry__2">GPTimer 驱动的 ioctl 接口</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="id__table_nmq_n3d_bdc__entry__1">参数定义</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="id__table_nmq_n3d_bdc__entry__2">
<div class="- topic/div div">
<div class="- topic/div div">timer - 指向 rt_hwtimer_t 设备的指针</div>
<div class="- topic/div div">cmd - ioctl 命令码</div>
<div class="- topic/div div">args - ioctl 命令相应的参数</div>
</div>
</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-1" headers="id__table_nmq_n3d_bdc__entry__1">返回值</td><td class="- topic/entry entry colsep-0 rowsep-1" headers="id__table_nmq_n3d_bdc__entry__2">0成功&lt;0失败</td></tr><tr class="- topic/row"><td class="- topic/entry entry colsep-1 rowsep-0" headers="id__table_nmq_n3d_bdc__entry__1">注意事项</td><td class="- topic/entry entry colsep-0 rowsep-0" headers="id__table_nmq_n3d_bdc__entry__2">目前仅支持设置 Timer 的 Freq 值</td></tr></tbody></table></div>
</div>
</section><section class="- topic/section section" id="id__hal" data-ofbid="id__hal"><h2 class="- topic/title title sectiontitle">HAL 层接口设计</h2>
<div class="- topic/p p" data-ofbid="d204928e371__20250121171637"><span class="+ topic/ph sw-d/filepath ph filepath">hal_gpt.h</span>
是一个头文件,其中声明了与通用定时器 (GPT) 相关的函数接口。HAL
层主要包含以下函数接口:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_j34_jvt_cdc" data-ofbid="id__codeblock_j34_jvt_cdc">u32 hal_gpt_int_stat(u32 i);
<strong class="hl-keyword">void</strong> hal_gpt_int_clr(u32 i, u32 mask);
<strong class="hl-keyword">void</strong> hal_gpt_clk_div_set(u32 i, u32 div);
<strong class="hl-keyword">void</strong> hal_gpt_ctl_set(u32 i, u32 trg_db, <strong class="hl-keyword">enum</strong> gpt_trg_mode trg_mode, <strong class="hl-keyword">enum</strong> gpt_run_mode run_mode);
<strong class="hl-keyword">void</strong> hal_gpt_en(u32 i, u32 enable);
<strong class="hl-keyword">void</strong> hal_gpt_clr(u32 i);
<strong class="hl-keyword">void</strong> hal_gpt_irq_en(u32 i, <strong class="hl-keyword">enum</strong> gpt_irq_mode irq_mode, u32 enable);
<strong class="hl-keyword">void</strong> hal_gpt_irq_disable(u32 i);
<strong class="hl-keyword">void</strong> hal_gpt_set_max(u32 i, u32 val);
<strong class="hl-keyword">void</strong> hal_gpt_out_init(u32 i, u32 out_num, <strong class="hl-keyword">struct</strong> gptimer_match cfg, u32 cmpa_val, u32 cmpb_val);
<strong class="hl-keyword">void</strong> hal_gpt_out_en(u32 i, u32 out_num, u32 enable);</pre></div>
</section><section class="- topic/section section" id="id__demo" data-ofbid="id__demo"><h2 class="- topic/title title sectiontitle">Demo</h2>
<div class="- topic/p p" data-ofbid="d204928e388__20250121171637">
Demo 是 test_gptimer
的部分源码(<span class="+ topic/ph sw-d/filepath ph filepath">bsp/examples/test-gptimer/test_gptimer.c</span><pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_sf2_smt_cdc" data-ofbid="id__codeblock_sf2_smt_cdc"><strong class="hl-keyword">struct</strong> test_gptimer_para {
rt_hwtimerval_t tm;
<strong class="hl-keyword">struct</strong> gptimer_para gpt_para;
};
<strong class="hl-keyword">struct</strong> gptimer_match_out g_outval[GPT_OUT_NUMS] = {
{<span class="hl-number">1</span>, OUT_INIT_LOW, CMP_OUT_HIGH, CMP_OUT_LOW},
{<span class="hl-number">1</span>, OUT_INIT_HIGH, CMP_OUT_LOW, CMP_OUT_HIGH},
{<span class="hl-number">0</span>, OUT_INIT_LOW, CMP_OUT_HIGH, CMP_OUT_LOW},
{<span class="hl-number">0</span>, OUT_INIT_LOW, CMP_OUT_HIGH, CMP_OUT_LOW},
};
<strong class="hl-keyword">enum</strong> gpt_cmp_act g_cmpa_act = GPTIMER_CNT_CONTINUE;
<strong class="hl-keyword">enum</strong> gpt_cmp_act g_cmpb_act = GPTIMER_CNT_CONTINUE;
<em class="hl-comment">/* Timer timeout callback function */</em>
<strong class="hl-keyword">static</strong> rt_err_t gptimer_cb(rt_device_t dev, rt_size_t size)
{
<strong class="hl-keyword">struct</strong> gptimer_info *info = (<strong class="hl-keyword">struct</strong> gptimer_info *)dev-&gt;user_data;
#ifdef ULOG_USING_ISR_LOG
<strong class="hl-keyword">if</strong> (g_debug)
printf(<span class="hl-string">"%d/%d gptimer%d timeout callback! Elapsed %ld us\n"</span>,
g_loop_cnt, g_loop_max,
info-&gt;id, aic_timer_get_us() - g_start_us);
#endif
g_start_us = aic_timer_get_us();
g_loop_cnt++;
<strong class="hl-keyword">if</strong> ((g_loop_max &gt; <span class="hl-number">1</span>) &amp;&amp; (g_loop_cnt &gt; g_loop_max))
rt_device_control(g_gptimer_dev[info-&gt;id], HWTIMER_CTRL_STOP, NULL);
<strong class="hl-keyword">return</strong> RT_EOK;
}
<strong class="hl-keyword">static</strong> <strong class="hl-keyword">void</strong> cmd_test_gptimer(<strong class="hl-keyword">int</strong> argc, <strong class="hl-keyword">char</strong> *argv[])
{
rt_err_t ret = RT_EOK;
u32 c, ch = <span class="hl-number">0</span>;
<strong class="hl-keyword">struct</strong> test_gptimer_para para = {<span class="hl-number">0</span>};
rt_hwtimer_mode_t mode = HWTIMER_MODE_ONESHOT;
<strong class="hl-keyword">enum</strong> gptimer_mode gpt_mode = GPTIMER_MODE_COUNT;
<strong class="hl-keyword">enum</strong> gpt_trg_mode trg_mode = GPT_TRG_MODE_AUTO;
u32 freq= <span class="hl-number">1000000</span>;
optind = <span class="hl-number">0</span>;
g_debug = <span class="hl-number">0</span>;
<strong class="hl-keyword">while</strong> ((c = getopt_long(argc, argv, sopts, lopts, NULL)) != -<span class="hl-number">1</span>) {
<strong class="hl-keyword">switch</strong> (c) {
<strong class="hl-keyword">case</strong> <span class="hl-string">'m'</span>:
<strong class="hl-keyword">if</strong> (strncasecmp(<span class="hl-string">"period"</span>, optarg, strlen(optarg)) == <span class="hl-number">0</span>)
mode = HWTIMER_MODE_PERIOD;
<strong class="hl-keyword">continue</strong>;
<strong class="hl-keyword">case</strong> <span class="hl-string">'c'</span>:
ch = atoi(optarg);
<strong class="hl-keyword">if</strong> (ch &gt; TIMER_NUM) {
pr_err(<span class="hl-string">"Channel number %s is invalid\n"</span>, optarg);
<strong class="hl-keyword">return</strong>;
}
<strong class="hl-keyword">continue</strong>;
<strong class="hl-keyword">case</strong> <span class="hl-string">'s'</span>:
para.tm.sec = atoi(optarg);
<strong class="hl-keyword">continue</strong>;
<strong class="hl-keyword">case</strong> <span class="hl-string">'u'</span>:
para.tm.usec = atoi(optarg);
<strong class="hl-keyword">continue</strong>;
<strong class="hl-keyword">case</strong> <span class="hl-string">'d'</span>:
g_debug = <span class="hl-number">1</span>;
<strong class="hl-keyword">continue</strong>;
<strong class="hl-keyword">case</strong> <span class="hl-string">'g'</span>:
<strong class="hl-keyword">if</strong> (strncasecmp(<span class="hl-string">"count"</span>, optarg, strlen(optarg)) == <span class="hl-number">0</span>)
gpt_mode = GPTIMER_MODE_COUNT;
<strong class="hl-keyword">else</strong> <strong class="hl-keyword">if</strong> (strncasecmp(<span class="hl-string">"match"</span>, optarg, strlen(optarg)) == <span class="hl-number">0</span>)
gpt_mode = GPTIMER_MODE_MATCH;
<strong class="hl-keyword">continue</strong>;
<strong class="hl-keyword">case</strong> <span class="hl-string">'a'</span>:
<strong class="hl-keyword">if</strong> (strncasecmp(<span class="hl-string">"auto"</span>, optarg, strlen(optarg)) == <span class="hl-number">0</span>)
trg_mode = GPT_TRG_MODE_AUTO;
<strong class="hl-keyword">else</strong> <strong class="hl-keyword">if</strong> (strncasecmp(<span class="hl-string">"rsi"</span>, optarg, strlen(optarg)) == <span class="hl-number">0</span>)
trg_mode = GPT_TRG_MODE_RSI;
<strong class="hl-keyword">else</strong> <strong class="hl-keyword">if</strong> (strncasecmp(<span class="hl-string">"fall"</span>, optarg, strlen(optarg)) == <span class="hl-number">0</span>)
trg_mode = GPT_TRG_MODE_FALL;
<strong class="hl-keyword">else</strong> <strong class="hl-keyword">if</strong> (strncasecmp(<span class="hl-string">"bil"</span>, optarg, strlen(optarg)) == <span class="hl-number">0</span>)
trg_mode = GPT_TRG_MODE_BILATERAL;
<strong class="hl-keyword">continue</strong>;
<strong class="hl-keyword">case</strong> <span class="hl-string">'f'</span>:
freq = atoi(optarg);
<strong class="hl-keyword">continue</strong>;
<strong class="hl-keyword">case</strong> <span class="hl-string">'h'</span>:
usage(argv[<span class="hl-number">0</span>]);
<strong class="hl-keyword">return</strong>;
<strong class="hl-keyword">default</strong>:
pr_err(<span class="hl-string">"Invalid argument\n"</span>);
usage(argv[<span class="hl-number">0</span>]);
<strong class="hl-keyword">return</strong>;
}
}
<strong class="hl-keyword">if</strong> ((para.tm.sec == <span class="hl-number">0</span>) &amp;&amp; (para.tm.usec == <span class="hl-number">0</span>)) {
pr_err(<span class="hl-string">"Invalid argument\n"</span>);
usage(argv[<span class="hl-number">0</span>]);
<strong class="hl-keyword">return</strong>;
}
<strong class="hl-keyword">if</strong> (!g_gptimer_dev[ch]) {
<strong class="hl-keyword">char</strong> name[<span class="hl-number">10</span>] = <span class="hl-string">""</span>;
snprintf(name, <span class="hl-number">10</span>, <span class="hl-string">"gptimer%d"</span>, ch);
<em class="hl-comment">/* find timer device */</em>
g_gptimer_dev[ch] = rt_device_find(name);
<strong class="hl-keyword">if</strong> (g_gptimer_dev[ch] == RT_NULL) {
pr_err(<span class="hl-string">"Can't find %s device!\n"</span>, name);
<strong class="hl-keyword">return</strong>;
}
<em class="hl-comment">/* Open the device in read-write mode */</em>
ret = rt_device_open(g_gptimer_dev[ch], RT_DEVICE_OFLAG_RDWR);
<strong class="hl-keyword">if</strong> (ret != RT_EOK) {
pr_err(<span class="hl-string">"Failed to open %s device!\n"</span>, name);
<strong class="hl-keyword">return</strong>;
}
}
para.gpt_para.gptimer_mode = gpt_mode;
para.gpt_para.gptimer_trgmode = trg_mode;
<strong class="hl-keyword">if</strong> (gpt_mode == GPTIMER_MODE_MATCH) {
para.gpt_para.matchval.cmpa_act = g_cmpa_act;
para.gpt_para.matchval.cmpb_act = g_cmpb_act;
memcpy(&amp;para.gpt_para.matchval.outval[<span class="hl-number">0</span>], g_outval, <strong class="hl-keyword">sizeof</strong>(<strong class="hl-keyword">struct</strong> gptimer_match_out) * <span class="hl-number">4</span>);
}
<em class="hl-comment">/* set timeout callback function */</em>
rt_device_set_rx_indicate(g_gptimer_dev[ch], gptimer_cb);
<em class="hl-comment">/* set the timer mode, oneshot or period */</em>
ret = rt_device_control(g_gptimer_dev[ch], HWTIMER_CTRL_MODE_SET, &amp;mode);
<strong class="hl-keyword">if</strong> (ret != RT_EOK) {
pr_err(<span class="hl-string">"Failed to set mode! ret is %d\n"</span>, ret);
<strong class="hl-keyword">return</strong>;
}
<em class="hl-comment">/* set the timer frequency to freqHz */</em>
ret = rt_device_control(g_gptimer_dev[ch], HWTIMER_CTRL_FREQ_SET, &amp;freq);
<strong class="hl-keyword">if</strong> (ret != RT_EOK) {
pr_err(<span class="hl-string">"Failed to set the freq! ret is %d\n"</span>, ret);
<strong class="hl-keyword">return</strong>;
}
printf(<span class="hl-string">"gptimer%d: Create a timer of %d.%06d sec, %s mode\n"</span>,
ch, (u32)para.tm.sec, (u32)para.tm.usec,
mode == HWTIMER_MODE_ONESHOT ? <span class="hl-string">"Oneshot"</span> : <span class="hl-string">"Period"</span>);
<strong class="hl-keyword">if</strong> (mode != HWTIMER_MODE_ONESHOT) {
g_loop_max = GPTIMER_MAX_ELAPSE / (para.tm.sec * USEC_PER_SEC + para.tm.usec);
printf(<span class="hl-string">"\tWill loop %d times\n"</span>, g_loop_max);
}
g_loop_cnt = <span class="hl-number">0</span>;
g_start_us = aic_timer_get_us();
<strong class="hl-keyword">if</strong> (!rt_device_write(g_gptimer_dev[ch], <span class="hl-number">0</span>, &amp;para, <strong class="hl-keyword">sizeof</strong>(<strong class="hl-keyword">struct</strong> test_gptimer_para))) {
pr_err(<span class="hl-string">"set timeout value failed\n"</span>);
<strong class="hl-keyword">return</strong>;
}
<em class="hl-comment">// rt_device_close(g_gptimer_dev[ch]);</em>
}
MSH_CMD_EXPORT_ALIAS(cmd_test_gptimer, test_gptimer, test gptimer);</pre></div>
</section></div></article></main></div>
</div>
<nav role="navigation" id="wh_topic_toc" aria-label="On this page" class="col-lg-2 d-none d-lg-block navbar d-print-none">
<div id="wh_topic_toc_content">
<div class=" wh_topic_toc "><div class="wh_topic_label">在本页上</div><ul><li class="section-item"><div class="section-title"><a href="#id__id3" data-tocid="id__id3">模块架构</a></div></li><li class="section-item"><div class="section-title"><a href="#id__id4" data-tocid="id__id4">关键流程设计</a></div></li><li class="section-item"><div class="section-title"><a href="#id__id6" data-tocid="id__id6">数据结构设计</a></div></li><li class="section-item"><div class="section-title"><a href="#id__driver" data-tocid="id__driver">Driver 层接口设计</a></div></li><li class="section-item"><div class="section-title"><a href="#id__hal" data-tocid="id__hal">HAL 层接口设计</a></div></li><li class="section-item"><div class="section-title"><a href="#id__demo" data-tocid="id__demo">Demo</a></div></li></ul></div>
</div>
</nav>
</div>
</div>
</div>
<footer class="navbar navbar-default wh_footer">
<div class=" footer-container mx-auto ">
<title>footer def</title>
<style><!--
.p1 {
font-family: FangZhengShuSong, Times, serif;
}
.p2 {
font-family: Arial, Helvetica, sans-serif;
}
.p3 {
font-family: "Lucida Console", "Courier New", monospace;
}
--></style>
<div class="webhelp.fragment.footer">
<p class="p1">Copyright © 2019-2024 广东匠芯创科技有限公司. All rights reserved.</p>
</div><div>
<div class="generation_time">
Update Time: 2025-01-21
</div>
</div>
</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>

View File

@@ -0,0 +1,161 @@
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn" data-whc_version="26.0">
<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=""/><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.contributor" content="yan.wang"/><meta name="DC.date.modified" content="2024-10-15"/><meta name="DC.format" content="HTML5"/><meta name="DC.identifier" content="id"/><meta name="DC.language" content="zh-CN"/><title>常见问题</title><!-- Build number 2023110923. --><meta name="wh-path2root" content="../../../"/><meta name="wh-toc-id" content=""/><meta name="wh-source-relpath" content="topics/sdk/gptimer/gptimer_faq.dita"/><meta name="wh-out-relpath" content="topics/sdk/gptimer/gptimer_faq.html"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/commons.css?buildId=2023110923"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/topic.css?buildId=2023110923"/>
<script src="../../../webhelp/app/options/properties.js?buildId=20250121171154"></script>
<script src="../../../webhelp/app/localization/strings.js?buildId=2023110923"></script>
<script src="../../../webhelp/app/search/index/keywords.js?buildId=20250121171154"></script>
<script defer="defer" src="../../../webhelp/app/commons.js?buildId=2023110923"></script>
<script defer="defer" src="../../../webhelp/app/topic.js?buildId=2023110923"></script>
<link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-styles-web.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/notes.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-common.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-images.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/footnote.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-web-watermark.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/topic-body-list.css?buildId=2023110923"/></head>
<body id="id" 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">
<div class="wh_header_flex_container navbar-nav navbar-expand-md navbar-dark">
<div class="wh_logo_and_publication_title_container">
<div class="wh_logo_and_publication_title">
<a href="http://www.artinchip.com" class=" wh_logo d-none d-sm-block "><img src="../../../company-logo-white.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>
</div>
</div>
<div class="wh_top_menu_and_indexterms_link collapse navbar-collapse" id="wh_top_menu_and_indexterms_link">
</div>
</div>
</div>
</header>
<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>
</div>
<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 "></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_print_link print d-none d-md-inline-block "><button onClick="window.print()" title="打印此页" aria-label="打印此页"></button></div>
</div>
</nav>
</div>
<div class="wh_content_area">
<div class="row">
<div class="col-12" id="wh_topic_body">
<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://172.16.35.88/tasks/jdssno1uvvbf2mltu9kb9v3if05d5gopuakboe8hlud18rma/edit/F:/aicdita/aicdita-cn/topics/sdk/gptimer/gptimer_faq.dita">Edit online</a></span><h1 class="- topic/title title topictitle1" id="ariaid-title1">常见问题</h1><div class="date inPage">15 Oct 2024</div><div style="color: gray;"></div><div class="- topic/body body"></div></article></main></div>
</div>
</div>
</div>
</div>
<footer class="navbar navbar-default wh_footer">
<div class=" footer-container mx-auto ">
<title>footer def</title>
<style><!--
.p1 {
font-family: FangZhengShuSong, Times, serif;
}
.p2 {
font-family: Arial, Helvetica, sans-serif;
}
.p3 {
font-family: "Lucida Console", "Courier New", monospace;
}
--></style>
<div class="webhelp.fragment.footer">
<p class="p1">Copyright © 2019-2024 广东匠芯创科技有限公司. All rights reserved.</p>
</div><div>
<div class="generation_time">
Update Time: 2025-01-21
</div>
</div>
</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>

View File

@@ -0,0 +1,308 @@
<!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn" lang="zh-cn" data-whc_version="26.0">
<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="测试环境 硬件 FPGA 验证版 USB 转串口的线缆 信号源(用于测试触发模式) 示波器(用于观察引脚输出) 软件 PC 端的串口终端软件,用于 PC 和 开发板进行串口通信 Luban-Lite 自带的 test_gptimer 命令行工具 软件配置 在 SDK 根目录下执行 scons --menuconfig ,进入 menuconfig 的功能配置界面。 按如下选择,打开 ..."/><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.contributor" content="yan.wang"/><meta name="DC.date.modified" content="2024-12-20"/><meta name="DC.format" content="HTML5"/><meta name="DC.identifier" content="id"/><meta name="DC.language" content="zh-CN"/><title>测试指南</title><!-- Build number 2023110923. --><meta name="wh-path2root" content="../../../"/><meta name="wh-toc-id" content=""/><meta name="wh-source-relpath" content="topics/sdk/gptimer/gptimer_test_guide.dita"/><meta name="wh-out-relpath" content="topics/sdk/gptimer/gptimer_test_guide.html"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/commons.css?buildId=2023110923"/>
<link rel="stylesheet" type="text/css" href="../../../webhelp/app/topic.css?buildId=2023110923"/>
<script src="../../../webhelp/app/options/properties.js?buildId=20250121171154"></script>
<script src="../../../webhelp/app/localization/strings.js?buildId=2023110923"></script>
<script src="../../../webhelp/app/search/index/keywords.js?buildId=20250121171154"></script>
<script defer="defer" src="../../../webhelp/app/commons.js?buildId=2023110923"></script>
<script defer="defer" src="../../../webhelp/app/topic.js?buildId=2023110923"></script>
<link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-styles-web.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/notes.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-common.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-images.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/footnote.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/aic-web-watermark.css?buildId=2023110923"/><link rel="stylesheet" type="text/css" href="../../../webhelp/template/topic-body-list.css?buildId=2023110923"/></head>
<body id="id" 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">
<div class="wh_header_flex_container navbar-nav navbar-expand-md navbar-dark">
<div class="wh_logo_and_publication_title_container">
<div class="wh_logo_and_publication_title">
<a href="http://www.artinchip.com" class=" wh_logo d-none d-sm-block "><img src="../../../company-logo-white.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>
</div>
</div>
<div class="wh_top_menu_and_indexterms_link collapse navbar-collapse" id="wh_top_menu_and_indexterms_link">
</div>
</div>
</div>
</header>
<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>
</div>
<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 "></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_print_link print d-none d-md-inline-block "><button onClick="window.print()" title="打印此页" aria-label="打印此页"></button></div>
</div>
</nav>
</div>
<div class="wh_content_area">
<div class="row">
<div class="col-lg-10 col-md-10 col-sm-10 col-xs-12" id="wh_topic_body">
<button id="wh_close_topic_toc_button" class="close-toc-button d-none" aria-label="Toggle topic table of content" aria-controls="wh_topic_toc" aria-expanded="true">
<span class="close-toc-icon-container">
<span class="close-toc-icon"></span>
</span>
</button>
<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://172.16.35.88/tasks/jdssno1uvvbf2mltu9kb9v3if05d5gopuakboe8hlud18rma/edit/F:/aicdita/aicdita-cn/topics/sdk/gptimer/gptimer_test_guide.dita">Edit online</a></span><h1 class="- topic/title title topictitle1" id="ariaid-title1">测试指南</h1><div class="date inPage">20 Dec 2024</div><div style="color: gray;">
Read time: 5 minute(s)
</div><div class="- topic/body body"><section class="- topic/section section" id="id__id2" data-ofbid="id__id2"><h2 class="- topic/title title sectiontitle">测试环境</h2>
<ul class="- topic/ul ul" data-ofbid="d324420e22__20250121171828"><li class="- topic/li li" data-ofbid="d324420e23__20250121171828"><strong class="+ topic/ph hi-d/b ph b">硬件</strong><ul class="- topic/ul ul simple" id="id__ul_ult_m3d_bdc" data-ofbid="id__ul_ult_m3d_bdc"><li class="- topic/li li" data-ofbid="d324420e27__20250121171828">
<p class="- topic/p p" data-ofbid="d324420e29__20250121171828">FPGA 验证版</p>
</li><li class="- topic/li li" data-ofbid="d324420e32__20250121171828">
<p class="- topic/p p" data-ofbid="d324420e34__20250121171828">USB 转串口的线缆</p>
</li><li class="- topic/li li" data-ofbid="d324420e37__20250121171828">
<p class="- topic/p p" data-ofbid="d324420e39__20250121171828">信号源(用于测试触发模式)</p>
</li><li class="- topic/li li" data-ofbid="d324420e42__20250121171828">
<p class="- topic/p p" data-ofbid="d324420e44__20250121171828">示波器(用于观察引脚输出)</p>
</li></ul></li><li class="- topic/li li" data-ofbid="d324420e47__20250121171828"><strong class="+ topic/ph hi-d/b ph b">软件</strong><ul class="- topic/ul ul simple" id="id__ul_vlt_m3d_bdc" data-ofbid="id__ul_vlt_m3d_bdc"><li class="- topic/li li" data-ofbid="d324420e51__20250121171828">
<p class="- topic/p p" data-ofbid="d324420e53__20250121171828">PC 端的串口终端软件,用于 PC 和 开发板进行串口通信</p>
</li><li class="- topic/li li" data-ofbid="d324420e56__20250121171828">
<p class="- topic/p p" data-ofbid="d324420e58__20250121171828"><span class="- topic/ph ph">Luban-Lite</span> 自带的 <code class="+ topic/ph pr-d/codeph ph codeph">test_gptimer</code> 命令行工具</p>
</li></ul></li></ul>
</section><section class="- topic/section section" id="id__id5" data-ofbid="id__id5"><h2 class="- topic/title title sectiontitle">软件配置</h2>
<ol class="- topic/ol ol" id="id__ul_xb3_rtn_tdc" data-ofbid="id__ul_xb3_rtn_tdc"><li class="- topic/li li" data-ofbid="d324420e73__20250121171828">
<p class="- topic/p p" data-ofbid="d324420e75__20250121171828">在 SDK 根目录下执行 <span class="+ topic/keyword sw-d/cmdname keyword cmdname">scons --menuconfig</span>,进入 menuconfig 的功能配置界面。</p>
</li><li class="- topic/li li" data-ofbid="d324420e81__20250121171828">
<div class="- topic/p p" data-ofbid="d324420e83__20250121171828">按如下选择,打开 <code class="+ topic/ph pr-d/codeph ph codeph">test_gptimer</code>
命令行工具:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_wlt_m3d_bdc" data-ofbid="id__codeblock_wlt_m3d_bdc">Drivers options ---&gt;
Drivers examples ---&gt;
[*] Enable GPTimer driver test command
</pre></div>
</li><li class="- topic/li li" data-ofbid="d324420e91__20250121171828">
<div class="- topic/p p" data-ofbid="d324420e93__20250121171828">同时,按如下选择,打开中断打印配置:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_xlt_m3d_bdc" data-ofbid="id__codeblock_xlt_m3d_bdc">Rt-Thread options ---&gt;
RT-Thread Components ---&gt;
Utilities ---&gt;
[*] Enable ISR log.
</pre></div>
</li></ol>
</section><section class="- topic/section section" id="id__section_zjd_1r4_tdc" data-ofbid="id__section_zjd_1r4_tdc"><h2 class="- topic/title title sectiontitle">GPTimer 常见测试</h2>
<div class="- topic/p p" data-ofbid="d324420e104__20250121171828"><span class="+ topic/keyword sw-d/cmdname keyword cmdname">test_gptimer</span> 的常见测试场景和流程如下所示:<div class="- topic/note note note note_note" id="id__note_fky_jt4_tdc" data-ofbid="id__note_fky_jt4_tdc"><span class="note__title">注:</span> 关于命令参数详细描述,可查看 <a class="- topic/xref xref" href="gptimer_test_guide.html#id__gptimer">test_gptimer 参数详解</a></div><ul class="- topic/ul ul simple" id="id__ul_zlt_m3d_bdc" data-ofbid="id__ul_zlt_m3d_bdc"><li class="- topic/li li" data-ofbid="d324420e115__20250121171828">
<p class="- topic/p p" data-ofbid="d324420e117__20250121171828">单次自动计数模式</p>
<div class="- topic/p p" data-ofbid="d324420e120__20250121171828">使用下列命令配置 GPTimer0 的单次自动计数模式,以设置一个超时时间是 1.000003 秒(即 1 秒 3
微秒)的定时器为例,并启用调试日志:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_amt_m3d_bdc" data-ofbid="id__codeblock_amt_m3d_bdc">test_gptimer -m oneshot -c <span class="hl-number">0</span> -s <span class="hl-number">1</span> -u <span class="hl-number">3</span> -g count -a <strong class="hl-keyword">auto</strong> -f <span class="hl-number">1000</span> -d</pre></div>
<div class="- topic/p p" data-ofbid="d324420e125__20250121171828">输出示例如下,表示创建成功:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_ukw_c5n_tdc" data-ofbid="id__codeblock_ukw_c5n_tdc">gptimer0: Create a timer of <span class="hl-number">1.000003</span> sec, Oneshot mode</pre></div>
<p class="- topic/p p" data-ofbid="d324420e130__20250121171828">当计时器超时时,可以看到如下调试日志输出:</p>
<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_bl3_d5n_tdc" data-ofbid="id__codeblock_bl3_d5n_tdc"><span class="hl-number">0</span>/<span class="hl-number">0</span> gptimer0 timeout callback! Elapsed <span class="hl-number">1001154</span> us</pre>
</li><li class="- topic/li li" data-ofbid="d324420e136__20250121171828">
<p class="- topic/p p" data-ofbid="d324420e138__20250121171828">循环自动计数模式 </p>
<div class="- topic/p p" data-ofbid="d324420e141__20250121171828">使用下列命令配置 GPTimer0 的循环自动计数模式,超时时间是 1 秒 3 微秒的定时器,并启用调试日志,会循环输出 59
次超时回调:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_cmt_m3d_bdc" data-ofbid="id__codeblock_cmt_m3d_bdc">test_gptimer -m period -c <span class="hl-number">0</span> -s <span class="hl-number">1</span> -u <span class="hl-number">3</span> -g count -a <strong class="hl-keyword">auto</strong> -f <span class="hl-number">1000</span> -d</pre></div>
<div class="- topic/p p" data-ofbid="d324420e146__20250121171828">输出示例如下,表示创建成功:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_wgc_hb4_tdc" data-ofbid="id__codeblock_wgc_hb4_tdc">gptimer0: Create a timer of <span class="hl-number">1.000003</span> sec, Period mode
Will loop <span class="hl-number">59</span>times</pre></div>
<div class="- topic/p p" data-ofbid="d324420e151__20250121171828">当计时器每次超时时,调试日志输出如下所示:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_s4z_xd4_tdc" data-ofbid="id__codeblock_s4z_xd4_tdc"><span class="hl-number">0</span>/<span class="hl-number">59</span> gptimer0 timeout callback! Elapsed <span class="hl-number">1001142</span> us
<span class="hl-number">1</span>/<span class="hl-number">59</span> gptimer0 timeout callback! Elapsed <span class="hl-number">995703</span> us
<span class="hl-number">2</span>/<span class="hl-number">59</span> gptimer0 timeout callback! Elapsed <span class="hl-number">995912</span> us
<span class="hl-number">3</span>/<span class="hl-number">59</span> gptimer0 timeout callback! Elapsed <span class="hl-number">995923</span> us
<span class="hl-number">4</span>/<span class="hl-number">59</span> gptimer0 timeout callback! Elapsed <span class="hl-number">995929</span> us
<span class="hl-number">5</span>/<span class="hl-number">59</span> gptimer0 timeout callback! Elapsed <span class="hl-number">995922</span> us
<span class="hl-number">6</span>/<span class="hl-number">59</span> gptimer0 timeout callback! Elapsed <span class="hl-number">995918</span> us
<span class="hl-number">7</span>/<span class="hl-number">59</span> gptimer0 timeout callback! Elapsed <span class="hl-number">995915</span> us
<span class="hl-number">8</span>/<span class="hl-number">59</span> gptimer0 timeout callback! Elapsed <span class="hl-number">995922</span> us
......
<span class="hl-number">59</span>/<span class="hl-number">59</span> gptimer0 timeout callback! Elapsed <span class="hl-number">995797</span> us</pre></div>
<p class="- topic/p p" data-ofbid="d324420e156__20250121171828">本循环计数模式示例仅供演示使用,在持续大约 60
秒后自动停止定时器。在实际使用过程中,如果配置了循环输出模式,则会不断输出直至配置为其他模式。</p>
</li><li class="- topic/li li" data-ofbid="d324420e159__20250121171828">
<p class="- topic/p p" data-ofbid="d324420e161__20250121171828">单次触发计数模式</p>
<p class="- topic/p p" data-ofbid="d324420e164__20250121171828">触发模式下日志打印的时间包含启动定时器到有信号触发的时间。</p>
<div class="- topic/p p" data-ofbid="d324420e167__20250121171828">使用下列命令配置 GPTimer0 的单次触发计数模式,超时时间是 1 秒 3
微秒的定时器,并启用双边沿触发模式和调试日志:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_emt_m3d_bdc" data-ofbid="id__codeblock_emt_m3d_bdc">test_gptimer -m oneshot -c <span class="hl-number">0</span> -s <span class="hl-number">1</span> -u <span class="hl-number">3</span> -g count -a bil -f <span class="hl-number">1000</span> -d</pre></div>
<div class="- topic/p p" data-ofbid="d324420e172__20250121171828">输出示例如下,表示创建成功:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_wjm_hb4_tdc" data-ofbid="id__codeblock_wjm_hb4_tdc">gptimer0: Create a timer of <span class="hl-number">1.000003</span> sec, Oneshot mode</pre></div>
<div class="- topic/p p" data-ofbid="d324420e177__20250121171828">当信号源或其他方式往 GPTimer
输入引脚产生一个信号变化时,定时器将被触发启动。输出示例如下:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_lpz_hb4_tdc" data-ofbid="id__codeblock_lpz_hb4_tdc"><span class="hl-number">0</span>/<span class="hl-number">59</span> gptimer0 timeout callback! Elapsed <span class="hl-number">25708887</span></pre></div>
</li><li class="- topic/li li" data-ofbid="d324420e182__20250121171828">
<p class="- topic/p p" data-ofbid="d324420e184__20250121171828">单次自动输出模式</p>
<div class="- topic/p p" data-ofbid="d324420e187__20250121171828">使用下列命令配置 GPTimer0 的单次自动输出模式,超时时间是 1 秒 3
微秒的定时器:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_gmt_m3d_bdc" data-ofbid="id__codeblock_gmt_m3d_bdc">test_gptimer -m oneshot -c <span class="hl-number">0</span> -s <span class="hl-number">1</span> -u <span class="hl-number">3</span> -g match -a <strong class="hl-keyword">auto</strong> -f <span class="hl-number">1000</span></pre></div>
<div class="- topic/p p" data-ofbid="d324420e192__20250121171828">输出示例如下,表示创建成功:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_c1q_3b4_tdc" data-ofbid="id__codeblock_c1q_3b4_tdc">gptimer0: Create a timer of <span class="hl-number">1.000003</span> sec, Oneshot mode</pre></div>
</li><li class="- topic/li li" data-ofbid="d324420e197__20250121171828">
<p class="- topic/p p" data-ofbid="d324420e199__20250121171828">自动输出模式</p>
<div class="- topic/p p" data-ofbid="d324420e202__20250121171828">使用下列命令配置 GPTimer0 的循环自动输出模式,超时时间是 1 秒 3
微秒的定时器:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_imt_m3d_bdc" data-ofbid="id__codeblock_imt_m3d_bdc">test_gptimer -m period -c <span class="hl-number">0</span> -s <span class="hl-number">1</span> -u <span class="hl-number">3</span> -g match -a <strong class="hl-keyword">auto</strong> -f <span class="hl-number">1000</span></pre></div>
<div class="- topic/p p" data-ofbid="d324420e207__20250121171828">输出示例如下,表示创建成功:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_fxy_3b4_tdc" data-ofbid="id__codeblock_fxy_3b4_tdc">gptimer0: Create a timer of <span class="hl-number">1.000003</span> sec, Period mode</pre></div>
</li></ul><div class="- topic/note note tip note_tip" id="id__note_rms_qn3_ddc" data-ofbid="id__note_rms_qn3_ddc"><span class="note__title">提示:</span>
<ul class="- topic/ul ul arabic simple" id="id__ol_jmt_m3d_bdc" data-ofbid="id__ol_jmt_m3d_bdc"><li class="- topic/li li" data-ofbid="d324420e215__20250121171828">
<p class="- topic/p p" data-ofbid="d324420e217__20250121171828">示例中的运行 log 出现了一些误差,属于合理现象。这是因为 GPTimer 的精度是微秒级RTOS
的调度和调试信息输出都会干扰到定时器的精度。</p>
</li><li class="- topic/li li" data-ofbid="d324420e220__20250121171828">
<p class="- topic/p p" data-ofbid="d324420e222__20250121171828">输出模式下可以使用示波器观察波形。</p>
</li><li class="- topic/li li" data-ofbid="d324420e225__20250121171828">
<p class="- topic/p p" data-ofbid="d324420e227__20250121171828">为了简化 <span class="+ topic/keyword sw-d/cmdname keyword cmdname">test_gptimer</span> 命令,可在
<span class="+ topic/ph sw-d/filepath ph filepath">test_gptimer.c</span> 文件的
<span class="+ topic/keyword pr-d/parmname keyword parmname">g_outval</span> 结构体中修改输出引脚的配置参数。</p>
</li><li class="- topic/li li" data-ofbid="d324420e239__20250121171828">
<p class="- topic/p p" data-ofbid="d324420e241__20250121171828">GPTimer 达到比较值后默认继续计数,可在 <span class="+ topic/ph sw-d/filepath ph filepath">test_gptimer.c</span> 中的
<span class="+ topic/keyword pr-d/parmname keyword parmname">g_cmpa(b)_act</span> 变量修改为停止计数或清零计数。</p>
</li></ul>
</div></div>
</section><section class="- topic/section section" id="id__gptimer" data-ofbid="id__gptimer"><h2 class="- topic/title title sectiontitle">test_gptimer 参数详解</h2>
<div class="- topic/p p" data-ofbid="d324420e257__20250121171828">以下是一个 <span class="+ topic/keyword sw-d/cmdname keyword cmdname">test_gptimer</span> 命令示例,配置 GPTimer0 为循环自动计数模式,并设置超时时间为 1 秒 3
微秒,同时启用调试日志:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_kbp_ng4_tdc" data-ofbid="id__codeblock_kbp_ng4_tdc">test_gptimer -m period -c <span class="hl-number">0</span> -s <span class="hl-number">1</span> -u <span class="hl-number">3</span> -g count -a <strong class="hl-keyword">auto</strong> -f <span class="hl-number">1000</span> -d</pre></div>
<div class="- topic/p p" data-ofbid="d324420e265__20250121171828"><span class="+ topic/keyword sw-d/cmdname keyword cmdname">test_gptimer</span>
命令参数解释及示例如下所示:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_crz_2p4_tdc" data-ofbid="id__codeblock_crz_2p4_tdc">test_gptimer <var class="+ topic/keyword sw-d/varname keyword varname">parameter</var></pre><ul class="- topic/ul ul" id="id__ul_ctz_qg4_tdc" data-ofbid="id__ul_ctz_qg4_tdc"><li class="- topic/li li" data-ofbid="d324420e274__20250121171828"><code class="+ topic/ph pr-d/codeph ph codeph">-m <var class="+ topic/keyword sw-d/varname keyword varname">mode</var></code><div class="- topic/p p" data-ofbid="d324420e279__20250121171828">创建定时器类型,支持创建两类 Timer<ul class="- topic/ul ul arabic simple" id="id__ol_mnc_s3d_bdc" data-ofbid="id__ol_mnc_s3d_bdc"><li class="- topic/li li" data-ofbid="d324420e282__20250121171828">
<div class="- topic/p p" data-ofbid="d324420e284__20250121171828"><code class="+ topic/ph pr-d/codeph ph codeph">oneshot</code>
类型定时器:单次触发,默认值。<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_rnd_jp4_tdc" data-ofbid="id__codeblock_rnd_jp4_tdc">-m oneshot</pre></div>
<p class="- topic/p p" data-ofbid="d324420e291__20250121171828">只触发一次超时,随后 Timer 会被注销。适用于需要一次性触发的任务,例如超时报警、单次事件等。</p>
</li><li class="- topic/li li" data-ofbid="d324420e294__20250121171828">
<div class="- topic/p p" data-ofbid="d324420e296__20250121171828"><code class="+ topic/ph pr-d/codeph ph codeph">period</code>
类型定时器:循环触发<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_rql_jp4_tdc" data-ofbid="id__codeblock_rql_jp4_tdc">-m period</pre></div>
<p class="- topic/p p" data-ofbid="d324420e303__20250121171828">循环触发超时,适用于需要周期性触发的任务,例如心跳包发送、定时数据采集等。</p>
</li></ul></div></li><li class="- topic/li li" data-ofbid="d324420e306__20250121171828"><code class="+ topic/ph pr-d/codeph ph codeph">-c <var class="+ topic/keyword sw-d/varname keyword varname">GPTimer channel number</var></code><p class="- topic/p p" data-ofbid="d324420e311__20250121171828">选择 GPTimer
通道编号,可选参数范围是 [0, 2]。</p><p class="- topic/p p" data-ofbid="d324420e313__20250121171828">示例:<code class="+ topic/ph pr-d/codeph ph codeph">-c 0</code><code class="+ topic/ph pr-d/codeph ph codeph">-c
2</code></p></li><li class="- topic/li li" data-ofbid="d324420e320__20250121171828"><code class="+ topic/ph pr-d/codeph ph codeph">-s <var class="+ topic/keyword sw-d/varname keyword varname">second</var></code>:
<p class="- topic/p p" data-ofbid="d324420e326__20250121171828">设置计数器的秒数,必须大于 0。</p><p class="- topic/p p" data-ofbid="d324420e328__20250121171828">示例:<code class="+ topic/ph pr-d/codeph ph codeph">-s 1</code></p></li><li class="- topic/li li" data-ofbid="d324420e333__20250121171828"><code class="+ topic/ph pr-d/codeph ph codeph">-u <var class="+ topic/keyword sw-d/varname keyword varname">microsecon</var></code><p class="- topic/p p" data-ofbid="d324420e338__20250121171828">设置计时器的微秒数,必须大于
0。</p><p class="- topic/p p" data-ofbid="d324420e340__20250121171828">示例:<code class="+ topic/ph pr-d/codeph ph codeph">-u 3</code></p></li><li class="- topic/li li" data-ofbid="d324420e344__20250121171828"><code class="+ topic/ph pr-d/codeph ph codeph">-g <var class="+ topic/keyword sw-d/varname keyword varname">gptmode</var></code><div class="- topic/p p" data-ofbid="d324420e349__20250121171828">设置计时器的模式,可选模式包括:<ul class="- topic/ul ul" id="id__ul_p44_mq4_tdc" data-ofbid="id__ul_p44_mq4_tdc"><li class="- topic/li li" data-ofbid="d324420e352__20250121171828">
<p class="- topic/p p" data-ofbid="d324420e354__20250121171828"><code class="+ topic/ph pr-d/codeph ph codeph">count</code>:计数</p>
</li><li class="- topic/li li" data-ofbid="d324420e359__20250121171828"><code class="+ topic/ph pr-d/codeph ph codeph">match</code>:匹配</li></ul></div></li><li class="- topic/li li" data-ofbid="d324420e363__20250121171828"><code class="+ topic/ph pr-d/codeph ph codeph">-a <var class="+ topic/keyword sw-d/varname keyword varname">triggermode</var></code><div class="- topic/p p" data-ofbid="d324420e368__20250121171828">设置 GPTimer
的触发模式,可选模式包括:<ul class="- topic/ul ul" id="id__ul_cmy_pq4_tdc" data-ofbid="id__ul_cmy_pq4_tdc"><li class="- topic/li li" data-ofbid="d324420e371__20250121171828"><code class="+ topic/ph pr-d/codeph ph codeph">auto</code>:自动</li><li class="- topic/li li" data-ofbid="d324420e375__20250121171828"><code class="+ topic/ph pr-d/codeph ph codeph">rsi</code>:上升沿</li><li class="- topic/li li" data-ofbid="d324420e379__20250121171828"><code class="+ topic/ph pr-d/codeph ph codeph">fall</code>:下降沿</li><li class="- topic/li li" data-ofbid="d324420e383__20250121171828">
<code class="+ topic/ph pr-d/codeph ph codeph">bil</code>:双边沿。</li></ul></div></li><li class="- topic/li li" data-ofbid="d324420e388__20250121171828"><code class="+ topic/ph pr-d/codeph ph codeph">-f <var class="+ topic/keyword sw-d/varname keyword varname">frequency</var></code><p class="- topic/p p" data-ofbid="d324420e393__20250121171828">设置 GPTimer 的频率,必须大于
0。</p><p class="- topic/p p" data-ofbid="d324420e395__20250121171828">示例:<code class="+ topic/ph pr-d/codeph ph codeph">-f 1000</code></p></li><li class="- topic/li li" data-ofbid="d324420e400__20250121171828"><code class="+ topic/ph pr-d/codeph ph codeph">-d</code>: 显示超时日志,用于调试目的。<p class="- topic/p p" data-ofbid="d324420e404__20250121171828"><span class="+ topic/keyword sw-d/cmdname keyword cmdname">test_gptimer</span>
命令默认不打印定时器的超时信息,需要使用 <code class="+ topic/ph pr-d/codeph ph codeph">-d</code> 参数打开日志。</p></li><li class="- topic/li li" data-ofbid="d324420e411__20250121171828">
<p class="- topic/p p" data-ofbid="d324420e413__20250121171828"><code class="+ topic/ph pr-d/codeph ph codeph">h</code></p>
<p class="- topic/p p" data-ofbid="d324420e417__20250121171828">显示帮助信息。</p>
<div class="- topic/p p" data-ofbid="d324420e420__20250121171828">
<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_sqm_xq4_tdc" data-ofbid="id__codeblock_sqm_xq4_tdc">test_gptimer -h</pre>
</div>
<div class="- topic/p p" data-ofbid="d324420e426__20250121171828">输出结果如下所示:<pre class="+ topic/pre pr-d/codeblock pre codeblock language-c" id="id__codeblock_vc1_vq4_tdc" data-ofbid="id__codeblock_vc1_vq4_tdc">Usage: test_gptimer [options]:
-m, --mode mode of timer, oneshot/period
-c, --channel the number of gptimer [<span class="hl-number">0</span>, <span class="hl-number">2</span>]
-s, --second the second of timer (must &gt; <span class="hl-number">0</span>)
-u, --microsecond the microsecond of timer (must &gt; <span class="hl-number">0</span>)
-g, --gptmode he mode of gptimer, count/match
-a, --triggermode the trigger mode of gptimer, <strong class="hl-keyword">auto</strong>/rsi/fall/bil
-f, --frequency the frequncy of the gptimer (must &gt; <span class="hl-number">0</span>)
-d, --debug show the timeout log
-h, --usage</pre></div>
</li></ul></div>
</section></div></article></main></div>
</div>
<nav role="navigation" id="wh_topic_toc" aria-label="On this page" class="col-lg-2 d-none d-lg-block navbar d-print-none">
<div id="wh_topic_toc_content">
<div class=" wh_topic_toc "><div class="wh_topic_label">在本页上</div><ul><li class="section-item"><div class="section-title"><a href="#id__id2" data-tocid="id__id2">测试环境</a></div></li><li class="section-item"><div class="section-title"><a href="#id__id5" data-tocid="id__id5">软件配置</a></div></li><li class="section-item"><div class="section-title"><a href="#id__section_zjd_1r4_tdc" data-tocid="id__section_zjd_1r4_tdc">GPTimer 常见测试</a></div></li><li class="section-item"><div class="section-title"><a href="#id__gptimer" data-tocid="id__gptimer">test_gptimer 参数详解</a></div></li></ul></div>
</div>
</nav>
</div>
</div>
</div>
<footer class="navbar navbar-default wh_footer">
<div class=" footer-container mx-auto ">
<title>footer def</title>
<style><!--
.p1 {
font-family: FangZhengShuSong, Times, serif;
}
.p2 {
font-family: Arial, Helvetica, sans-serif;
}
.p3 {
font-family: "Lucida Console", "Courier New", monospace;
}
--></style>
<div class="webhelp.fragment.footer">
<p class="p1">Copyright © 2019-2024 广东匠芯创科技有限公司. All rights reserved.</p>
</div><div>
<div class="generation_time">
Update Time: 2025-01-21
</div>
</div>
</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>