blob: 60c1c3e8951223d867071efc5a291e0b23dc628c [file] [log] [blame]
<!--
Documentation/_templates/layout.html
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership. The
ASF licenses this file to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance with the
License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations
under the License.
-->
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>LED Support &mdash; NuttX latest documentation</title>
<link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../../_static/copybutton.css" type="text/css" />
<link rel="stylesheet" href="../../_static/tabs.css" type="text/css" />
<link rel="stylesheet" href="../../_static/custom.css" type="text/css" />
<link rel="shortcut icon" href="../../_static/favicon.ico"/>
<!--[if lt IE 9]>
<script src="../../_static/js/html5shiv.min.js"></script>
<![endif]-->
<script src="../../_static/jquery.js"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js"></script>
<script data-url_root="../../" id="documentation_options" src="../../_static/documentation_options.js"></script>
<script src="../../_static/doctools.js"></script>
<script src="../../_static/sphinx_highlight.js"></script>
<script src="../../_static/clipboard.min.js"></script>
<script src="../../_static/copybutton.js"></script>
<script src="../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
<link rel="next" title="Mutual Exclusion lock" href="mutex.html" />
<link rel="prev" title="I/O Buffer Management" href="iob.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../../index.html" class="icon icon-home"> NuttX
</a>
<!-- this version selector is quite ugly, should be probably replaced by something
more modern -->
<div class="version-selector">
<select onchange="javascript:location.href = this.value;">
<option value="../../../latest" selected="selected">latest</option>
<option value="../../../10.0.0" >10.0.0</option>
<option value="../../../10.0.1" >10.0.1</option>
<option value="../../../10.1.0" >10.1.0</option>
<option value="../../../10.2.0" >10.2.0</option>
<option value="../../../10.3.0" >10.3.0</option>
<option value="../../../11.0.0" >11.0.0</option>
<option value="../../../12.0.0" >12.0.0</option>
<option value="../../../12.1.0" >12.1.0</option>
<option value="../../../12.2.0" >12.2.0</option>
<option value="../../../12.2.1" >12.2.1</option>
<option value="../../../12.3.0" >12.3.0</option>
<option value="../../../12.4.0" >12.4.0</option>
<option value="../../../12.5.0" >12.5.0</option>
<option value="../../../12.5.1" >12.5.1</option>
</select>
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Table of Contents</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../index.html">Home</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../introduction/index.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../quickstart/index.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../contributing/index.html">Contributing</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../introduction/inviolables.html">The Inviolable Principles of NuttX</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../platforms/index.html">Supported Platforms</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../components/index.html">OS Components</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../applications/index.html">Applications</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../implementation/index.html">Implementation Details</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="../index.html">API Reference</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="../user/index.html">Userspace API</a></li>
<li class="toctree-l2 current"><a class="reference internal" href="index.html">Architecture APIs</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="addrenv.html">Address Environments</a></li>
<li class="toctree-l3"><a class="reference internal" href="app_vs_os.html">Application OS vs. Internal OS Interfaces</a></li>
<li class="toctree-l3"><a class="reference internal" href="arch.html">APIs Exported by Architecture-Specific Logic to NuttX</a></li>
<li class="toctree-l3"><a class="reference internal" href="board.html">APIs Exported by Board-Specific Logic to NuttX</a></li>
<li class="toctree-l3"><a class="reference internal" href="conventions.html">Naming and Header File Conventions</a></li>
<li class="toctree-l3"><a class="reference internal" href="iob.html">I/O Buffer Management</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="#">LED Support</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#header-files">Header Files</a></li>
<li class="toctree-l4"><a class="reference internal" href="#led-definitions">LED Definitions</a></li>
<li class="toctree-l4"><a class="reference internal" href="#common-led-interfaces">Common LED interfaces</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="mutex.html">Mutual Exclusion lock</a></li>
<li class="toctree-l3"><a class="reference internal" href="nat.html">Network Address Translation (NAT)</a></li>
<li class="toctree-l3"><a class="reference internal" href="newreno.html">Congestion Control NewReno</a></li>
<li class="toctree-l3"><a class="reference internal" href="notifier.html">Notifier Chain</a></li>
<li class="toctree-l3"><a class="reference internal" href="nuttx.html">APIs Exported by NuttX to Architecture-Specific Logic</a></li>
<li class="toctree-l3"><a class="reference internal" href="paging.html">On-Demand Paging</a></li>
<li class="toctree-l3"><a class="reference internal" href="shm.html">Shared Memory</a></li>
<li class="toctree-l3"><a class="reference internal" href="smp.html">Symmetric Multiprocessing (SMP) Application</a></li>
<li class="toctree-l3"><a class="reference internal" href="time_clock.html">System Time and Clock</a></li>
<li class="toctree-l3"><a class="reference internal" href="wqueue.html">Work Queues</a></li>
<li class="toctree-l3"><a class="reference internal" href="netdev.html">Network Devices</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../faq/index.html">FAQ</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../guides/index.html">Guides</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../glossary.html">Glossary</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">NuttX</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../index.html">API Reference</a></li>
<li class="breadcrumb-item"><a href="index.html">Architecture APIs</a></li>
<li class="breadcrumb-item active">LED Support</li>
<li class="wy-breadcrumbs-aside">
<a href="../../_sources/reference/os/led.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="led-support">
<h1>LED Support<a class="headerlink" href="#led-support" title="Permalink to this heading"></a></h1>
<p>A board architecture may or may not have LEDs. If the board does
have LEDs, then most architectures provide similar LED support
that is enabled when <code class="docutils literal notranslate"><span class="pre">CONFIG_ARCH_LEDS</span></code> is selected in the NuttX
configuration file. This LED support is part of
architecture-specific logic and is not managed by the core NuttX
logic. However, the support provided by each architecture is
sufficiently similar that it can be documented here.</p>
<section id="header-files">
<h2>Header Files<a class="headerlink" href="#header-files" title="Permalink to this heading"></a></h2>
<p>LED-related definitions are provided in two header files:</p>
<ul class="simple">
<li><p>LED definitions are provided for each board in the <code class="docutils literal notranslate"><span class="pre">board.h</span></code>
that resides in the <code class="docutils literal notranslate"><span class="pre">&lt;board-name&gt;/include/board.h</span></code> file
(which is also linked to <code class="docutils literal notranslate"><span class="pre">include/arch/board/board.h</span></code> when
the RTOS is configured). Those definitions are discussed
<a class="reference external" href="#leddefinitions">below</a>.</p></li>
<li><p>The board-specific logic provides unique instances of the LED
interfaces. This is because the implementation of LED support
may be very different on different boards. Prototypes for these
board-specific implementations are, however, provided in
architecture-common header files. That header file is usually
at <code class="docutils literal notranslate"><span class="pre">&lt;arch-name&gt;/src/common/up_internal.h</span></code>, but could be at
other locations in particular architectures. These prototypes
are discussed <a class="reference external" href="#ledapis">below</a>.</p></li>
</ul>
</section>
<section id="led-definitions">
<h2>LED Definitions<a class="headerlink" href="#led-definitions" title="Permalink to this heading"></a></h2>
<p>The implementation of LED support is very specific to a board
architecture. Some boards have several LEDS, others have only one
or two. Some have none. Others LED matrices and show alphanumeric
data, etc. The NuttX logic does not refer to specific LEDS,
rather, it refers to an event to be shown on the LEDS in whatever
manner is appropriate for the board; the way that this event is
presented depends upon the hardware available on the board.</p>
<p>The model used by NuttX is that the board can show 8 events
defined as follows in <code class="docutils literal notranslate"><span class="pre">&lt;board-name&gt;/include/board.h</span></code>:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define LED_STARTED ??</span>
<span class="cp">#define LED_HEAPALLOCATE ??</span>
<span class="cp">#define LED_IRQSENABLED ??</span>
<span class="cp">#define LED_STACKCREATED ??</span>
<span class="cp">#define LED_INIRQ ??</span>
<span class="cp">#define LED_SIGNAL ??</span>
<span class="cp">#define LED_ASSERTION ??</span>
<span class="cp">#define LED_PANIC ??</span>
</pre></div>
</div>
<p>The specific value assigned to each pre-processor variable can be
whatever makes the implementation easiest for the board logic. The
<em>meaning</em> associated with each definition is as follows:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">LED_STARTED</span></code> is the value that describes the setting of the
LEDs when the LED logic is first initialized. This LED value is
set but never cleared.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">LED_HEAPALLOCATE</span></code> indicates that the NuttX heap has been
configured. This is an important place in the boot sequence
because if the memory is configured wrong, it will probably
crash leaving this LED setting. This LED value is set but never
cleared.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">LED_IRQSENABLED</span></code> indicates that interrupts have been
enabled. Again, during bring-up (or if there are hardware
problems), it is very likely that the system may crash just
when interrupts are enabled, leaving this setting on the LEDs.
This LED value is set but never cleared.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">LED_STACKCREATED</span></code> is set each time a new stack is created.
If set, it means that the system attempted to start at least
one new thread. This LED value is set but never cleared.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">LED_INIRQ</span></code> is set and cleared on entry and exit from each
interrupt. If interrupts are working okay, this LED will have a
dull glow.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">LED_SIGNAL</span></code> is set and cleared on entry and exit from a
signal handler. Signal handlers are tricky so this is
especially useful during bring-up or a new architecture.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">LED_ASSERTION</span></code> is set if an assertion occurs.</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">LED_PANIC</span></code> will blink at around 1Hz if the system panics and
hangs.</p></li>
</ul>
</section>
<section id="common-led-interfaces">
<h2>Common LED interfaces<a class="headerlink" href="#common-led-interfaces" title="Permalink to this heading"></a></h2>
<p>The <code class="docutils literal notranslate"><span class="pre">include/nuttx/board.h</span></code> includes the following declarations:</p>
<dl class="c function">
<dt class="sig sig-object c" id="c.board_autoled_initialize">
<span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">board_autoled_initialize</span></span></span><span class="sig-paren">(</span><span class="kt"><span class="pre">void</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.board_autoled_initialize" title="Permalink to this definition"></a><br /></dt>
<dd><p>Called early in power-up initialization to initialize the LED hardware.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>In most architectures,
<code class="docutils literal notranslate"><span class="pre">board_autoled_initialize()</span></code> is called from board-specific
initialization logic. But there are a few architectures
where this initialization function is still called from
common chip architecture logic. This interface is not,
however, a common board interface in any event.</p>
</div>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>This interface name will eventually be removed;
do not use it in new board ports. New implementations should
not use the naming convention for common board interfaces,
but should instead use the naming conventions for
microprocessor-specific interfaces or the board-specific
interfaces (such as <code class="docutils literal notranslate"><span class="pre">stm32_led_initialize()</span></code>).</p>
</div>
</dd></dl>
<dl class="c function">
<dt class="sig sig-object c" id="c.board_autoled_on">
<span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">board_autoled_on</span></span></span><span class="sig-paren">(</span><span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">led</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.board_autoled_on" title="Permalink to this definition"></a><br /></dt>
<dd><p>Called to instantiate the LED
presentation of the event. The <code class="docutils literal notranslate"><span class="pre">led</span></code> argument is one of the
definitions provided in <code class="docutils literal notranslate"><span class="pre">&lt;board-name&gt;/include/board.h</span></code>.</p>
</dd></dl>
<dl class="c function">
<dt class="sig sig-object c" id="c.board_autoled_off">
<span class="kt"><span class="pre">void</span></span><span class="w"> </span><span class="sig-name descname"><span class="n"><span class="pre">board_autoled_off</span></span></span><span class="sig-paren">(</span><span class="kt"><span class="pre">int</span></span><span class="w"> </span><span class="n"><span class="pre">led</span></span><span class="sig-paren">)</span><a class="headerlink" href="#c.board_autoled_off" title="Permalink to this definition"></a><br /></dt>
<dd><p>Called to terminate the LED
presentation of the event. The <code class="docutils literal notranslate"><span class="pre">led</span></code> argument is one of the
definitions provided in <code class="docutils literal notranslate"><span class="pre">&lt;board-name&gt;/include/board.h</span></code>. Note
that only <code class="docutils literal notranslate"><span class="pre">LED_INIRQ</span></code>, <code class="docutils literal notranslate"><span class="pre">LED_SIGNAL</span></code>, <code class="docutils literal notranslate"><span class="pre">LED_ASSERTION</span></code>, and
<code class="docutils literal notranslate"><span class="pre">LED_PANIC</span></code> indications are terminated.</p>
</dd></dl>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="iob.html" class="btn btn-neutral float-left" title="I/O Buffer Management" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="mutex.html" class="btn btn-neutral float-right" title="Mutual Exclusion lock" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>&#169; Copyright 2023, The Apache Software Foundation.</p>
</div>
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>