blob: c7f24fc235c3e675c5633c9c9c691c58973f283c [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Timer &mdash; Apache Mynewt latest documentation</title>
<link rel="shortcut icon" href="../../../../_static/mynewt-logo-only-newt32x32.png"/>
<link rel="stylesheet" href="../../../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../../../_static/css/sphinx_theme.css" type="text/css" />
<link rel="stylesheet" href="../../../../_static/css/bootstrap-3.0.3.min.css" type="text/css" />
<link rel="stylesheet" href="../../../../_static/css/v2.css" type="text/css" />
<link rel="stylesheet" href="../../../../_static/css/custom.css" type="text/css" />
<link rel="stylesheet" href="../../../../_static/css/restructuredtext.css" type="text/css" />
<link rel="stylesheet" href="../../../../_static/css/overrides.css" type="text/css" />
<link rel="index" title="Index"
href="../../../../genindex.html"/>
<link rel="search" title="Search" href="../../../../search.html"/>
<link rel="top" title="Apache Mynewt latest documentation" href="../../../../index.html"/>
<link rel="up" title="Hardware Abstraction Layer" href="../hal.html"/>
<link rel="next" title="GPIO" href="../hal_gpio/hal_gpio.html"/>
<link rel="prev" title="Hardware Abstraction Layer" href="../hal.html"/>
<script src="../../../../_static/js/modernizr.min.js"></script>
<script>
(function(i, s, o, g, r, a, m) {
i["GoogleAnalyticsObject"] = r;
(i[r] =
i[r] ||
function() {
(i[r].q = i[r].q || []).push(arguments);
}),
(i[r].l = 1 * new Date());
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m);
})(window, document, "script", "//www.google-analytics.com/analytics.js", "ga");
ga("create", "UA-72162311-1", "auto");
ga("send", "pageview");
</script>
</head>
<body class="not-front page-documentation" role="document" >
<div id="wrapper">
<div class="container">
<div id="banner" class="row v2-main-banner">
<a class="logo-cell" href="/">
<img class="logo" src="../../../../_static/img/logo.png">
</a>
<div class="tagline-cell">
<h4 class="tagline">An OS to build, deploy and securely manage billions of devices</h4>
</div>
<div class="news-cell">
<div class="well">
<h4>Latest News:</h4> <a href="/download">Apache Mynewt 1.12.0, Apache NimBLE 1.7.0 </a> released April 4, 2024)
</div>
</div>
</div>
</div>
<header>
<nav id="navbar" class="navbar navbar-inverse" role="navigation">
<div class="container">
<!-- Collapsed navigation -->
<div class="navbar-header">
<!-- Expander button -->
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<!-- Expanded navigation -->
<div class="navbar-collapse collapse">
<!-- Main navigation -->
<ul class="nav navbar-nav navbar-right">
<li>
<a href="/"><i class="fa fa-home" style="font-size: larger;"></i></a>
</li>
<li class="important">
<a href="/quick-start/">Quick Start</a>
</li>
<li>
<a href="/about/">About</a>
</li>
<li>
<a href="/talks/">Talks</a>
</li>
<li class="active">
<a href="/documentation/">Documentation</a>
</li>
<li>
<a href="/download/">Download</a>
</li>
<li>
<a href="/community/">Community</a>
</li>
<li>
<a href="/events/">Events</a>
</li>
</ul>
<!-- Search, Navigation and Repo links -->
<ul class="nav navbar-nav navbar-right">
</ul>
</div>
</div>
</nav>
</header>
<!-- STARTS MAIN CONTENT -->
<div id="main-content">
<div id="breadcrumb">
<div class="container">
<a href="/documentation/">Docs</a> /
<a href="../../../os_user_guide.html">OS User Guide</a> /
<a href="../hal.html">Hardware Abstraction Layer</a> /
Timer
<div class="sourcelink">
<a href="https://github.com/apache/mynewt-core/edit/master/docs/os/modules/hal/hal_timer/hal_timer.rst" class="icon icon-github"
rel="nofollow"> Edit on GitHub</a>
</div>
</div>
</div>
<!-- STARTS CONTAINER -->
<div class="container">
<!-- STARTS .content -->
<div id="content" class="row">
<!-- STARTS .container-sidebar -->
<div class="container-sidebar col-xs-12 col-sm-3">
<div id="docSidebar" class="sticky-container">
<div role="search" class="sphinx-search">
<form id="rtd-search-form" class="wy-form" action="../../../../search.html" method="get">
<input type="text" name="q" placeholder="Search documentation" class="search-documentation" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
<!-- Note: only works when deployed -->
<select class="form-control" onchange="if (this.value) window.location.href=this.value">
<option value="/latest" selected>
Version: latest
</option>
<option value="/v1_12_0" >
Version: 1.12.0
</option>
<option value="/v1_11_0" >
Version: 1.11.0
</option>
<option value="/v1_10_0" >
Version: 1.10.0
</option>
<option value="/v1_9_0" >
Version: 1.9.0
</option>
<option value="/v1_8_0" >
Version: 1.8.0
</option>
<option value="/v1_7_0" >
Version: 1.7.0
</option>
<option value="/v1_6_0" >
Version: 1.6.0
</option>
<option value="/v1_5_0" >
Version: 1.5.0
</option>
<option value="/v1_4_0" >
Version: 1.4.0
</option>
<option value="/v1_3_0/os/introduction" >
Version: 1.3.0
</option>
<option value="/v1_2_0/os/introduction" >
Version: 1.2.0
</option>
<option value="/v1_1_0/os/introduction" >
Version: 1.1.0
</option>
<option value="/v1_0_0/os/introduction" >
Version: 1.0.0
</option>
<option value="/v0_9_0/os/introduction" >
Version: 0.9.0
</option>
</select>
<div class="region region-sidebar">
<div class="docs-menu">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../../../index.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../get_started/index.html">Setup &amp; Get Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../concepts.html">Concepts</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../tutorials/tutorials.html">Tutorials</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../external_links.html">Third-party Resources</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../../../os_user_guide.html">OS User Guide</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../../../core_os/mynewt_os.html">Kernel</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../system_modules.html">System</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="../hal.html">Hardware Abstraction</a><ul class="current">
<li class="toctree-l3 current"><a class="current reference internal" href="#">Timer</a></li>
<li class="toctree-l3"><a class="reference internal" href="../hal_gpio/hal_gpio.html">GPIO</a></li>
<li class="toctree-l3"><a class="reference internal" href="../hal_uart/hal_uart.html">UART</a></li>
<li class="toctree-l3"><a class="reference internal" href="../hal_spi/hal_spi.html">SPI</a></li>
<li class="toctree-l3"><a class="reference internal" href="../hal_i2c/hal_i2c.html">I2C</a></li>
<li class="toctree-l3"><a class="reference internal" href="../hal_flash/hal_flash.html">Flash</a></li>
<li class="toctree-l3"><a class="reference internal" href="../hal_system/hal_sys.html">System</a></li>
<li class="toctree-l3"><a class="reference internal" href="../hal_watchdog/hal_watchdog.html">Watchdog</a></li>
<li class="toctree-l3"><a class="reference internal" href="../hal_bsp/hal_bsp.html">BSP</a></li>
<li class="toctree-l3"><a class="reference internal" href="../hal_os_tick/hal_os_tick.html">OS Tick</a></li>
<li class="toctree-l3"><a class="reference internal" href="../hal_creation.html">Creating New HAL Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="../hal_in_libraries.html">Using HAL in Your Libraries</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../../bootloader/bootloader.html">Secure Bootloader</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../split/split.html">Split Images</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../core_os/porting/port_os.html">Porting Guide</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../baselibc.html">Baselibc</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../drivers/driver.html">Drivers</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../devmgmt/newtmgr.html">Device Management with Newt Manager</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../mcumgr/mcumgr.html">Device Management with MCUmgr</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../imgmgr/imgmgr.html">Image Manager</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../sysinitconfig/sysinitconfig.html">Compile-Time Configuration</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../sysinitdown/sysinitdown.html">System Initialization and Shutdown</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../extcmd/extcmd.html">Build-Time Hooks</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../fs/fs.html">File System</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../fcb/fcb.html">Flash Circular Buffer</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../sensor_framework/sensor_framework.html">Sensor Framework</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../testutil/testutil.html">Test Utilities</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../json/json.html">JSON</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../mfg/mfg.html">Manufacturing support</a></li>
<li class="toctree-l2"><a class="reference internal" href="../../../bsp/index.html">Board support</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../../../network/index.html">BLE User Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../newt/index.html">Newt Tool Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../newtmgr/index.html">Newt Manager Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../mynewt_faq/index.html">Mynewt FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../../misc/index.html">Appendix</a></li>
</ul>
</div>
</div>
</div>
<!-- ENDS STICKY CONTAINER -->
</div>
<!-- ENDS .container-sidebar -->
<div class="col-xs-12 col-sm-9">
<div class="">
<div class="rst-content">
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="timer">
<h1>Timer<a class="headerlink" href="#timer" title="Permalink to this headline"></a></h1>
<p>The hardware independent timer structure and API to configure,
initialize, and run timers.</p>
<div class="section" id="description">
<h2>Description<a class="headerlink" href="#description" title="Permalink to this headline"></a></h2>
<p>The HAL timer structure is shown below. The user can declare as many of
these structures as required. They are enqueued on a particular HW timer
queue when the user calls the hal_timer_start or hal_timer_start_at
API. The user must have called hal_timer_set_cb before starting a
timer.</p>
<p>NOTE: the user should not have to modify/examine the contents of this
structure; the hal timer API should be used.</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">struct</span><span class="w"> </span><span class="nc">hal_timer</span>
<span class="p">{</span>
<span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="o">*</span><span class="n">bsp_timer</span><span class="p">;</span><span class="w"> </span><span class="cm">/* Internal platform specific pointer */</span>
<span class="w"> </span><span class="n">hal_timer_cb</span><span class="w"> </span><span class="n">cb_func</span><span class="p">;</span><span class="w"> </span><span class="cm">/* Callback function */</span>
<span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="o">*</span><span class="n">cb_arg</span><span class="p">;</span><span class="w"> </span><span class="cm">/* Callback argument */</span>
<span class="w"> </span><span class="kt">uint32_t</span><span class="w"> </span><span class="n">expiry</span><span class="p">;</span><span class="w"> </span><span class="cm">/* Tick at which timer should expire */</span>
<span class="w"> </span><span class="n">TAILQ_ENTRY</span><span class="p">(</span><span class="n">hal_timer</span><span class="p">)</span><span class="w"> </span><span class="n">link</span><span class="p">;</span><span class="w"> </span><span class="cm">/* Queue linked list structure */</span>
<span class="p">};</span>
</pre></div>
</div>
</div>
<div class="section" id="api">
<h2>API<a class="headerlink" href="#api" title="Permalink to this headline"></a></h2>
<dl class="c type">
<dt id="c.hal_timer_cb">
<span class="target" id="group___h_a_l_timer_1gaf6b777c97781df4e860d4eadba407ec4"></span><em class="property"><span class="pre">typedef</span> </em><span class="pre">void</span> <span class="pre">(</span><span class="pre">*</span><code class="sig-name descname"><span class="pre">hal_timer_cb</span></code><span class="pre">)</span><span class="sig-paren">(</span><span class="pre">void</span> <span class="pre">*</span><span class="pre">arg</span><span class="sig-paren">)</span><a class="headerlink" href="#c.hal_timer_cb" title="Permalink to this definition"></a><br /></dt>
<dd></dd></dl>
<dl class="c function">
<dt id="c.hal_timer_init">
<span class="target" id="group___h_a_l_timer_1gae008bd575e17e5c0d6fab7cd20429505"></span><span class="pre">int</span> <code class="sig-name descname"><span class="pre">hal_timer_init</span></code><span class="sig-paren">(</span><span class="pre">int</span> <em><span class="pre">timer_num</span></em>, <span class="pre">void</span> <span class="pre">*</span><em><span class="pre">cfg</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.hal_timer_init" title="Permalink to this definition"></a><br /></dt>
<dd><p>Initialize a HW timer. </p>
<p><dl class="simple">
<dt><strong>Parameters</strong></dt><dd><ul class="breatheparameterlist simple">
<li><p><code class="docutils literal notranslate"><span class="pre">timer_num</span></code>: The number of the HW timer to initialize </p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">cfg</span></code>: Hardware specific timer configuration. This is passed from BSP directly to the MCU specific driver. </p></li>
</ul>
</dd>
</dl>
</p>
</dd></dl>
<dl class="c function">
<dt id="c.hal_timer_deinit">
<span class="target" id="group___h_a_l_timer_1gab484bcc8f328f16a467ba74473bc4e67"></span><span class="pre">int</span> <code class="sig-name descname"><span class="pre">hal_timer_deinit</span></code><span class="sig-paren">(</span><span class="pre">int</span> <em><span class="pre">timer_num</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.hal_timer_deinit" title="Permalink to this definition"></a><br /></dt>
<dd><p>Un-initialize a HW timer. </p>
<p><dl class="simple">
<dt><strong>Parameters</strong></dt><dd><ul class="breatheparameterlist simple">
<li><p><code class="docutils literal notranslate"><span class="pre">timer_num</span></code>: The number of the HW timer to un-initialize </p></li>
</ul>
</dd>
</dl>
</p>
</dd></dl>
<dl class="c function">
<dt id="c.hal_timer_config">
<span class="target" id="group___h_a_l_timer_1gafc13bd55373f7b105c1f09a319876c86"></span><span class="pre">int</span> <code class="sig-name descname"><span class="pre">hal_timer_config</span></code><span class="sig-paren">(</span><span class="pre">int</span> <em><span class="pre">timer_num</span></em>, <span class="pre">uint32_t</span> <em><span class="pre">freq_hz</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.hal_timer_config" title="Permalink to this definition"></a><br /></dt>
<dd><p>Config a HW timer at the given frequency and start it. </p>
<p>If the exact frequency is not obtainable the closest obtainable frequency is set.</p>
<p><dl class="simple">
<dt><strong>Return</strong></dt><dd><p>0 on success, non-zero error code on failure </p>
</dd>
<dt><strong>Parameters</strong></dt><dd><ul class="breatheparameterlist simple">
<li><p><code class="docutils literal notranslate"><span class="pre">timer_num</span></code>: The number of the HW timer to configure </p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">freq_hz</span></code>: The frequency in Hz to configure the timer at</p></li>
</ul>
</dd>
</dl>
</p>
</dd></dl>
<dl class="c function">
<dt id="c.hal_timer_get_resolution">
<span class="target" id="group___h_a_l_timer_1ga09972cb40f65bbf75add4a745bb6f171"></span><span class="pre">uint32_t</span> <code class="sig-name descname"><span class="pre">hal_timer_get_resolution</span></code><span class="sig-paren">(</span><span class="pre">int</span> <em><span class="pre">timer_num</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.hal_timer_get_resolution" title="Permalink to this definition"></a><br /></dt>
<dd><p>Returns the resolution of the HW timer. </p>
<p>NOTE: the frequency may not be obtainable so the caller can use this to determine the resolution. Returns resolution in nanoseconds. A return value of 0 indicates an invalid timer was used.</p>
<p><dl class="simple">
<dt><strong>Return</strong></dt><dd><p>The resolution of the timer </p>
</dd>
<dt><strong>Parameters</strong></dt><dd><ul class="breatheparameterlist simple">
<li><p><code class="docutils literal notranslate"><span class="pre">timer_num</span></code>: The number of the HW timer to get resolution for</p></li>
</ul>
</dd>
</dl>
</p>
</dd></dl>
<dl class="c function">
<dt id="c.hal_timer_read">
<span class="target" id="group___h_a_l_timer_1ga399c1ad97a20ab9a4edb445ea6253b59"></span><span class="pre">uint32_t</span> <code class="sig-name descname"><span class="pre">hal_timer_read</span></code><span class="sig-paren">(</span><span class="pre">int</span> <em><span class="pre">timer_num</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.hal_timer_read" title="Permalink to this definition"></a><br /></dt>
<dd><p>Returns the HW timer current tick value. </p>
<p><dl class="simple">
<dt><strong>Return</strong></dt><dd><p>The current tick value </p>
</dd>
<dt><strong>Parameters</strong></dt><dd><ul class="breatheparameterlist simple">
<li><p><code class="docutils literal notranslate"><span class="pre">timer_num</span></code>: The HW timer to read the tick value from</p></li>
</ul>
</dd>
</dl>
</p>
</dd></dl>
<dl class="c function">
<dt id="c.hal_timer_delay">
<span class="target" id="group___h_a_l_timer_1ga8921d021217ad28b7c399dfac948072d"></span><span class="pre">int</span> <code class="sig-name descname"><span class="pre">hal_timer_delay</span></code><span class="sig-paren">(</span><span class="pre">int</span> <em><span class="pre">timer_num</span></em>, <span class="pre">uint32_t</span> <em><span class="pre">ticks</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.hal_timer_delay" title="Permalink to this definition"></a><br /></dt>
<dd><p>Perform a blocking delay for a number of ticks. </p>
<p><dl class="simple">
<dt><strong>Return</strong></dt><dd><p>0 on success, non-zero error code on failure </p>
</dd>
<dt><strong>Parameters</strong></dt><dd><ul class="breatheparameterlist simple">
<li><p><code class="docutils literal notranslate"><span class="pre">timer_num</span></code>: The timer number to use for the blocking delay </p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ticks</span></code>: The number of ticks to delay for</p></li>
</ul>
</dd>
</dl>
</p>
</dd></dl>
<dl class="c function">
<dt id="c.hal_timer_set_cb">
<span class="target" id="group___h_a_l_timer_1ga565e77630c3548207bb1cde8545230fd"></span><span class="pre">int</span> <code class="sig-name descname"><span class="pre">hal_timer_set_cb</span></code><span class="sig-paren">(</span><span class="pre">int</span> <em><span class="pre">timer_num</span></em>, <em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.hal_timer" title="hal_timer"><span class="pre">hal_timer</span></a> <span class="pre">*</span><em><span class="pre">tmr</span></em>, <a class="reference internal" href="#c.hal_timer_cb" title="hal_timer_cb"><span class="pre">hal_timer_cb</span></a> <em><span class="pre">cb_func</span></em>, <span class="pre">void</span> <span class="pre">*</span><em><span class="pre">arg</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.hal_timer_set_cb" title="Permalink to this definition"></a><br /></dt>
<dd><p>Set the timer structure prior to use. </p>
<p>Should not be called if the timer is running. Must be called at least once prior to using timer.</p>
<p><dl class="simple">
<dt><strong>Return</strong></dt><dd><p>0 on success, non-zero error code on failure. </p>
</dd>
<dt><strong>Parameters</strong></dt><dd><ul class="breatheparameterlist simple">
<li><p><code class="docutils literal notranslate"><span class="pre">timer_num</span></code>: The number of the HW timer to configure the callback on </p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">tmr</span></code>: The timer structure to use for this timer </p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">cb_func</span></code>: The timer callback to call when the timer fires </p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">arg</span></code>: An opaque argument to provide the timer callback</p></li>
</ul>
</dd>
</dl>
</p>
</dd></dl>
<dl class="c function">
<dt id="c.hal_timer_start">
<span class="target" id="group___h_a_l_timer_1ga108e679ed0440ac830631fc662a04fa6"></span><span class="pre">int</span> <code class="sig-name descname"><span class="pre">hal_timer_start</span></code><span class="sig-paren">(</span><em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.hal_timer" title="hal_timer"><span class="pre">hal_timer</span></a> <span class="pre">*</span><em><span class="pre">tmr</span></em>, <span class="pre">uint32_t</span> <em><span class="pre">ticks</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.hal_timer_start" title="Permalink to this definition"></a><br /></dt>
<dd><p>Start a timer that will expire in ‘ticks’ ticks. </p>
<p>Ticks cannot be 0</p>
<p><dl class="simple">
<dt><strong>Return</strong></dt><dd><p>0 on success, non-zero error code on failure. </p>
</dd>
<dt><strong>Parameters</strong></dt><dd><ul class="breatheparameterlist simple">
<li><p><code class="docutils literal notranslate"><span class="pre">tmr</span></code>: The timer to start </p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ticks</span></code>: The number of ticks to expire the timer in</p></li>
</ul>
</dd>
</dl>
</p>
</dd></dl>
<dl class="c function">
<dt id="c.hal_timer_start_at">
<span class="target" id="group___h_a_l_timer_1ga7cfacab8052286bcb9ebcf09fe4ba842"></span><span class="pre">int</span> <code class="sig-name descname"><span class="pre">hal_timer_start_at</span></code><span class="sig-paren">(</span><em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.hal_timer" title="hal_timer"><span class="pre">hal_timer</span></a> <span class="pre">*</span><em><span class="pre">tmr</span></em>, <span class="pre">uint32_t</span> <em><span class="pre">tick</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.hal_timer_start_at" title="Permalink to this definition"></a><br /></dt>
<dd><p>Start a timer that will expire when the timer reaches ‘tick’. </p>
<p>If tick has already passed the timer callback will be called “immediately” (at interrupt context).</p>
<p><dl class="simple">
<dt><strong>Return</strong></dt><dd><p>0 on success, non-zero error code on failure. </p>
</dd>
<dt><strong>Parameters</strong></dt><dd><ul class="breatheparameterlist simple">
<li><p><code class="docutils literal notranslate"><span class="pre">tmr</span></code>: The timer to start </p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">tick</span></code>: The absolute tick value to fire the timer at</p></li>
</ul>
</dd>
</dl>
</p>
</dd></dl>
<dl class="c function">
<dt id="c.hal_timer_stop">
<span class="target" id="group___h_a_l_timer_1ga948dc3fdc14f840fe713ffc1f9508dab"></span><span class="pre">int</span> <code class="sig-name descname"><span class="pre">hal_timer_stop</span></code><span class="sig-paren">(</span><em class="property"><span class="pre">struct</span></em> <a class="reference internal" href="#c.hal_timer" title="hal_timer"><span class="pre">hal_timer</span></a> <span class="pre">*</span><em><span class="pre">tmr</span></em><span class="sig-paren">)</span><a class="headerlink" href="#c.hal_timer_stop" title="Permalink to this definition"></a><br /></dt>
<dd><p>Stop a currently running timer; associated callback will NOT be called. </p>
<p><dl class="simple">
<dt><strong>Parameters</strong></dt><dd><ul class="breatheparameterlist simple">
<li><p><code class="docutils literal notranslate"><span class="pre">tmr</span></code>: The timer to stop </p></li>
</ul>
</dd>
</dl>
</p>
</dd></dl>
<dl class="c struct">
<dt id="c.hal_timer">
<span class="target" id="structhal__timer"></span><em class="property"><span class="pre">struct</span> </em><code class="sig-name descname"><span class="pre">hal_timer</span></code><a class="headerlink" href="#c.hal_timer" title="Permalink to this definition"></a><br /></dt>
<dd><em>#include &lt;hal_timer.h&gt;</em><p>The HAL timer structure. </p>
<p>The user can declare as many of these structures as desired. They are enqueued on a particular HW timer queue when the user calls the :c:func:<code class="docutils literal notranslate"><a class="reference internal" href="#group___h_a_l_timer_1ga108e679ed0440ac830631fc662a04fa6"><span class="std std-ref"><span class="pre">hal_timer_start()</span></span></a></code> or :c:func:<code class="docutils literal notranslate"><a class="reference internal" href="#group___h_a_l_timer_1ga7cfacab8052286bcb9ebcf09fe4ba842"><span class="std std-ref"><span class="pre">hal_timer_start_at()</span></span></a></code> API. The user must have called :c:func:<code class="docutils literal notranslate"><a class="reference internal" href="#group___h_a_l_timer_1ga565e77630c3548207bb1cde8545230fd"><span class="std std-ref"><span class="pre">hal_timer_set_cb()</span></span></a></code> before starting a timer.</p>
<p>NOTE: the user should not have to modify/examine the contents of this structure; the hal timer API should be used. </p>
<div class="breathe-sectiondef docutils container">
<p class="breathe-sectiondef-title rubric" id="breathe-section-title-public-members">Public Members</p>
<dl class="c var">
<dt id="c.hal_timer.bsp_timer">
<span class="target" id="structhal__timer_1a6d7bba13d02c0192adb00dee4588216b"></span><span class="pre">void</span> <span class="pre">*</span><code class="sig-name descname"><span class="pre">bsp_timer</span></code><a class="headerlink" href="#c.hal_timer.bsp_timer" title="Permalink to this definition"></a><br /></dt>
<dd><p>Internal platform specific pointer. </p>
</dd></dl>
<dl class="c var">
<dt id="c.hal_timer.cb_func">
<span class="target" id="structhal__timer_1aa6b82b412ede70f5c580e20e5eb99aee"></span><a class="reference internal" href="#c.hal_timer_cb" title="hal_timer_cb"><span class="pre">hal_timer_cb</span></a> <code class="sig-name descname"><span class="pre">cb_func</span></code><a class="headerlink" href="#c.hal_timer.cb_func" title="Permalink to this definition"></a><br /></dt>
<dd><p>Callback function. </p>
</dd></dl>
<dl class="c var">
<dt id="c.hal_timer.cb_arg">
<span class="target" id="structhal__timer_1a315d7a2737f930cb664b21deb0886a3c"></span><span class="pre">void</span> <span class="pre">*</span><code class="sig-name descname"><span class="pre">cb_arg</span></code><a class="headerlink" href="#c.hal_timer.cb_arg" title="Permalink to this definition"></a><br /></dt>
<dd><p>Callback argument. </p>
</dd></dl>
<dl class="c var">
<dt id="c.hal_timer.expiry">
<span class="target" id="structhal__timer_1ab4edba6c830706a49097ffe86a8d73d9"></span><span class="pre">uint32_t</span> <code class="sig-name descname"><span class="pre">expiry</span></code><a class="headerlink" href="#c.hal_timer.expiry" title="Permalink to this definition"></a><br /></dt>
<dd><p>Tick at which timer should expire. </p>
</dd></dl>
</div>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="rst-footer-buttons row" role="navigation" aria-label="footer navigation">
<a href="../hal_gpio/hal_gpio.html" class="btn btn-neutral float-right" title="GPIO" accesskey="n">Next: GPIO <span class="fa fa-arrow-circle-right"></span></a>
<a href="../hal.html" class="btn btn-neutral" title="Hardware Abstraction Layer" accesskey="p"><span class="fa fa-arrow-circle-left"></span> Previous: Hardware Abstraction Layer</a>
</div>
</div>
</div>
</div>
<!-- ENDS CONTENT SECTION -->
</div>
<!-- ENDS .content -->
</div>
</div>
<footer>
<div class="container">
<div class="row">
<div class="col-xs-12">
<p class="copyright">Apache Mynewt is available under Apache License, version 2.0.</p>
</div>
<div class="col-xs-12">
<div class="logos">
<img src="../../../../_static/img/asf_logo_wide_small.png" alt="Apache" title="Apache">
<small class="footnote">
Apache Mynewt, Mynewt, Apache, the Apache feather logo, and the Apache Mynewt project logo are either
registered trademarks or trademarks of the Apache Software Foundation in the United States and other countries.
</small>
<a href="">
<img src="../../../../_static/img/add_to_slack.png" alt="Slack Icon" title="Join our Slack Community" />
</a>
</div>
</div>
</div>
</div>
</footer>
</div>
<!-- ENDS #wrapper -->
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'../../../../',
VERSION:'latest',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt',
LINK_SUFFIX: '.html'
};
</script>
<script type="text/javascript" src="../../../../_static/jquery.js"></script>
<script type="text/javascript" src="../../../../_static/underscore.js"></script>
<script type="text/javascript" src="../../../../_static/doctools.js"></script>
<script type="text/javascript" src="../../../../_static/js/bootstrap-3.0.3.min.js"></script>
<script type="text/javascript" src="../../../../_static/js/affix.js"></script>
<script type="text/javascript" src="../../../../_static/js/main.js"></script>
</body>
</html>