| <!-- |
| 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.19: https://docutils.sourceforge.io/" /> |
| |
| <meta name="viewport" content="width=device-width, initial-scale=1.0" /> |
| <title>i2c I2C Tool — NuttX latest documentation</title> |
| <link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" /> |
| <link rel="stylesheet" type="text/css" href="../../../_static/css/theme.css" /> |
| <link rel="stylesheet" type="text/css" href="../../../_static/copybutton.css" /> |
| <link rel="stylesheet" type="text/css" href="../../../_static/custom.css" /> |
| |
| |
| <link rel="shortcut icon" href="../../../_static/favicon.ico"/> |
| <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="input input tool" href="../input/index.html" /> |
| <link rel="prev" title="hostname “hostname” command" href="../hostname/index.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> |
| |
| <option value="../../../../12.6.0" >12.6.0</option> |
| |
| <option value="../../../../12.7.0" >12.7.0</option> |
| |
| <option value="../../../../12.8.0" >12.8.0</option> |
| |
| <option value="../../../../12.9.0" >12.9.0</option> |
| |
| <option value="../../../../12.10.0" >12.10.0</option> |
| |
| <option value="../../../../12.11.0" >12.11.0</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 current"><a class="reference internal" href="../../index.html">Applications</a><ul class="current"> |
| <li class="toctree-l2"><a class="reference internal" href="../../audioutils/index.html">Audio Utility libraries</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../boot/index.html">Bootloader Utilities</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../benchmarks/index.html">Benchmark Applications</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../canutils/index.html">CAN Utilities</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../crypto/index.html">Cryptography Library Support</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../fsutils/index.html">File System Utilities</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../games/index.html">Games</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../graphics/index.html">Graphics Support</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../industry/index.html">Industrial Applications</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../inertial/index.html">Inertial Libraries Support</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../interpreters/index.html">Interpreters</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../logging/index.html">Logging Utilities</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../lte/index.html">LTE Libraries and NSH Add-Ons</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../math/index.html">Math Library Support</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../mlearing/index.html">Machine Learning Support</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../netutils/index.html">Network Utilities</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../nsh/index.html">NuttShell (NSH)</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../sdr/index.html">Software Define Radio Libraries</a></li> |
| <li class="toctree-l2 current"><a class="reference internal" href="../index.html">System Libraries and NSH Add-Ons</a><ul class="current"> |
| <li class="toctree-l3"><a class="reference internal" href="../adb/index.html"><code class="docutils literal notranslate"><span class="pre">adb</span></code> ADB daemon application</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../argtable3/index.html"><code class="docutils literal notranslate"><span class="pre">argtable3</span></code> ARGTABLE3 library</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../cdcacm/index.html"><code class="docutils literal notranslate"><span class="pre">cdcacm</span></code> USB CDC/ACM Device Commands</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../cfgdata/index.html"><code class="docutils literal notranslate"><span class="pre">cfgdata</span></code> Cfgdata Command</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../cle/index.html"><code class="docutils literal notranslate"><span class="pre">cle</span></code> EMACS-like Command Line Editor</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../composite/index.html"><code class="docutils literal notranslate"><span class="pre">composite</span></code> USB Composite Device Commands</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../coredump/index.html"><code class="docutils literal notranslate"><span class="pre">coredump</span></code> Coredump tool capture system status</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../crimon/index.html"><code class="docutils literal notranslate"><span class="pre">critmon</span></code> Critcal Section Monitor</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../cu/index.html"><code class="docutils literal notranslate"><span class="pre">cu</span></code> CU minimal serial terminal</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../dd/index.html"><code class="docutils literal notranslate"><span class="pre">dd</span></code> system ‘dd’ command</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../debugpoint/index.html"><code class="docutils literal notranslate"><span class="pre">debugpoint</span></code> Debug Utility</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../dhcp6c/index.html"><code class="docutils literal notranslate"><span class="pre">dhcp6c</span></code> DHCP IPv6 Address Renewal</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../dhcpc/index.html"><code class="docutils literal notranslate"><span class="pre">dhcpc</span></code> DHCP Address Renewal</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../dumpstack/index.html"><code class="docutils literal notranslate"><span class="pre">dumpstack</span></code> dumpstack tool for show the task backtrace</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../fastboot/index.html"><code class="docutils literal notranslate"><span class="pre">fastboot</span></code> fastbootd</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../fdt/index.html"><code class="docutils literal notranslate"><span class="pre">fdt</span></code> fdt utility tools</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../flash_eraseall/index.html"><code class="docutils literal notranslate"><span class="pre">flash_eraseall</span></code> FLASH Erase-all Command</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gcov/index.html"><code class="docutils literal notranslate"><span class="pre">gcov</span></code> gcov tool</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gdbstub/index.html"><code class="docutils literal notranslate"><span class="pre">gdbstub</span></code> GDBSTUB</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../gprof/index.html"><code class="docutils literal notranslate"><span class="pre">gprof</span></code> GNU Profile tool</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../hex2bin/index.html"><code class="docutils literal notranslate"><span class="pre">hex2bin</span></code> Intel HEX to binary conversion</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../hexed/index.html"><code class="docutils literal notranslate"><span class="pre">hexed</span></code> Hex editor</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../hostname/index.html"><code class="docutils literal notranslate"><span class="pre">hostname</span></code> “hostname” command</a></li> |
| <li class="toctree-l3 current"><a class="current reference internal" href="#"><code class="docutils literal notranslate"><span class="pre">i2c</span></code> I2C Tool</a><ul> |
| <li class="toctree-l4"><a class="reference internal" href="#contents">Contents</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="#system-requirements">System Requirements</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="#configuration-options">Configuration Options</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l4"><a class="reference internal" href="#help">Help</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="#command-line-form">Command Line Form</a></li> |
| <li class="toctree-l4"><a class="reference internal" href="#common-command-options">Common Command Options</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="#sticky-options">“Sticky” Options</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="#environment-variables">Environment Variables</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="#common-option-summary">Common Option Summary</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l4"><a class="reference internal" href="#command-summary">Command Summary</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="#list-buses-bus-options">List buses: <code class="docutils literal notranslate"><span class="pre">bus</span> <span class="pre">[OPTIONS]</span></code></a></li> |
| <li class="toctree-l5"><a class="reference internal" href="#list-devices-dev-options-first-last">List devices: <code class="docutils literal notranslate"><span class="pre">dev</span> <span class="pre">[OPTIONS]</span> <span class="pre"><first></span> <span class="pre"><last></span></code></a></li> |
| <li class="toctree-l5"><a class="reference internal" href="#read-register-get-options">Read register: <code class="docutils literal notranslate"><span class="pre">get</span> <span class="pre">[OPTIONS]</span></code></a></li> |
| <li class="toctree-l5"><a class="reference internal" href="#write-register-set-options-value">Write register: <code class="docutils literal notranslate"><span class="pre">set</span> <span class="pre">[OPTIONS]</span> <span class="pre"><value></span></code></a></li> |
| <li class="toctree-l5"><a class="reference internal" href="#verify-access-verf-options-value-repetitions">Verify access: <code class="docutils literal notranslate"><span class="pre">verf</span> <span class="pre">[OPTIONS]</span> <span class="pre"><value></span> <span class="pre">[<repetitions>]</span></code></a></li> |
| </ul> |
| </li> |
| <li class="toctree-l4"><a class="reference internal" href="#i2c-build-configuration">I2C Build Configuration</a><ul> |
| <li class="toctree-l5"><a class="reference internal" href="#nuttx-configuration-requirements">NuttX Configuration Requirements</a></li> |
| <li class="toctree-l5"><a class="reference internal" href="#i2c-tool-configuration-options">I2C Tool Configuration Options</a></li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| <li class="toctree-l3"><a class="reference internal" href="../input/index.html"><code class="docutils literal notranslate"><span class="pre">input</span></code> input tool</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../iptables/index.html"><code class="docutils literal notranslate"><span class="pre">iptables</span></code> “iptables” command</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../libuv/index.html"><code class="docutils literal notranslate"><span class="pre">libuv</span></code> libuv asynchronous I/O Library</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../lm75/index.html"><code class="docutils literal notranslate"><span class="pre">lm75</span></code> LM75 Temperature</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../lzf/index.html"><code class="docutils literal notranslate"><span class="pre">lzf</span></code> LZF compression tool</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../mdio/index.html"><code class="docutils literal notranslate"><span class="pre">mdio</span></code> PHY MDIO tool</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../netdb/index.html"><code class="docutils literal notranslate"><span class="pre">netdb</span></code> netdb interface</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../nsh/index.html"><code class="docutils literal notranslate"><span class="pre">nsh</span></code> NuttShell (NSH) example</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ntpc/index.html"><code class="docutils literal notranslate"><span class="pre">ntpc</span></code> NTP Daemon Commands</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../nxcamera/index.html"><code class="docutils literal notranslate"><span class="pre">nxcamera</span></code> NxCamera video test application</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../nxcodec/index.html"><code class="docutils literal notranslate"><span class="pre">nxcodec</span></code> NxCodec video codec test application</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../nxdiag/index.html"><code class="docutils literal notranslate"><span class="pre">nxdiag</span></code> NuttX Diagnostic Tool</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../nxlooper/index.html"><code class="docutils literal notranslate"><span class="pre">nxlooper</span></code> NxLooper audio test application</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../nxplayer/index.html"><code class="docutils literal notranslate"><span class="pre">nxplayer</span></code> NxPlayer Media Player</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../nxrecorder/index.html"><code class="docutils literal notranslate"><span class="pre">nxrecorder</span></code> NxRecorder pcm raw data Recorder</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ofloader/index.html"><code class="docutils literal notranslate"><span class="pre">ofloader</span></code> Open flash loader</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ping/index.html"><code class="docutils literal notranslate"><span class="pre">ping</span></code> ICMP “ping” command</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ping6/index.html"><code class="docutils literal notranslate"><span class="pre">ping6</span></code> ICMPv6 “ping6” command</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../popen/index.html"><code class="docutils literal notranslate"><span class="pre">popen</span></code> popen()/pclose() Functions</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../psmq/index.html"><code class="docutils literal notranslate"><span class="pre">psmq</span></code> Publish Subscribe Message Queue</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ptpd/index.html"><code class="docutils literal notranslate"><span class="pre">ptpd</span></code> PTP daemon commands</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../readline/index.html"><code class="docutils literal notranslate"><span class="pre">readline</span></code> readline() Support</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../sched_note/index.html"><code class="docutils literal notranslate"><span class="pre">sched_note</span></code> Scheduler monitor</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../setlogmask/index.html"><code class="docutils literal notranslate"><span class="pre">setlogmask</span></code> “setlogmask” command</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../spi/index.html"><code class="docutils literal notranslate"><span class="pre">spi</span></code> SPI Tool</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../stackmonitor/index.html"><code class="docutils literal notranslate"><span class="pre">stackmonitor</span></code> Stack Monitor</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../system/index.html"><code class="docutils literal notranslate"><span class="pre">system</span></code> System Command</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../taskset/index.html"><code class="docutils literal notranslate"><span class="pre">taskset</span></code> Taskset Command</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../tcpdump/index.html"><code class="docutils literal notranslate"><span class="pre">tcpdump</span></code> tcpdump command</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../tee/index.html"><code class="docutils literal notranslate"><span class="pre">tee</span></code> Tee Command</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../telnet/index.html"><code class="docutils literal notranslate"><span class="pre">telnet</span></code> Telnet chat daemon</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../telnetd/index.html"><code class="docutils literal notranslate"><span class="pre">telnetd</span></code> Telnet daemon application</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../termcurses/index.html"><code class="docutils literal notranslate"><span class="pre">termcurses</span></code> Terminal Curses control support</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../trace/index.html"><code class="docutils literal notranslate"><span class="pre">trace</span></code> Trace command</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ubloxmodem/index.html"><code class="docutils literal notranslate"><span class="pre">ubloxmodem</span></code> u-blox modem configuration tool</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../uniqueid/index.html"><code class="docutils literal notranslate"><span class="pre">uniqueid</span></code> “uniqueid” command</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../uorb/index.html"><code class="docutils literal notranslate"><span class="pre">uorb</span></code> uorb(micro object request broker)</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../usbmsc/index.html"><code class="docutils literal notranslate"><span class="pre">usbmsc</span></code> USB Mass Storage Device Commands</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../vi/index.html"><code class="docutils literal notranslate"><span class="pre">vi</span></code> VI Work-Alike Text Editor</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../ymodem/index.html"><code class="docutils literal notranslate"><span class="pre">ymodem</span></code> YMODEM</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../zlib/index.html"><code class="docutils literal notranslate"><span class="pre">zlib</span></code> zlib data compression library</a></li> |
| <li class="toctree-l3"><a class="reference internal" href="../zmodem/index.html"><code class="docutils literal notranslate"><span class="pre">zmodem</span></code> Zmodem Commands</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l2"><a class="reference internal" href="../../testing/index.html">Testing</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../tools/index.html">Host Side Tools</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../wireless/index.html">Wireless Libraries and NSH Add-Ons</a></li> |
| <li class="toctree-l2"><a class="reference internal" href="../../examples/index.html">Examples</a></li> |
| </ul> |
| </li> |
| <li class="toctree-l1"><a class="reference internal" href="../../../implementation/index.html">Implementation Details</a></li> |
| <li class="toctree-l1"><a class="reference internal" href="../../../reference/index.html">API Reference</a></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> |
| <li class="toctree-l1"><a class="reference internal" href="../../../logos/index.html">NuttX Logos</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">Applications</a></li> |
| <li class="breadcrumb-item"><a href="../index.html">System Libraries and NSH Add-Ons</a></li> |
| <li class="breadcrumb-item active"><code class="docutils literal notranslate"><span class="pre">i2c</span></code> I2C Tool</li> |
| <li class="wy-breadcrumbs-aside"> |
| <a href="../../../_sources/applications/system/i2c/index.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="i2c-i2c-tool"> |
| <h1><code class="docutils literal notranslate"><span class="pre">i2c</span></code> I2C Tool<a class="headerlink" href="#i2c-i2c-tool" title="Permalink to this heading"></a></h1> |
| <p>The I2C tool provides a way to debug I2C related problems. This README file will |
| provide usage information for the I2C tools.</p> |
| <section id="contents"> |
| <h2>Contents<a class="headerlink" href="#contents" title="Permalink to this heading"></a></h2> |
| <ul class="simple"> |
| <li><p>System Requirements |
| - I2C Driver |
| - Configuration Options</p></li> |
| <li><p>Help</p></li> |
| <li><p>Common Line Form</p></li> |
| <li><p>Common Command Options |
| - _Sticky_ Options |
| - Environment variables |
| - Common Option Summary</p></li> |
| <li><p>Command summary |
| - <code class="docutils literal notranslate"><span class="pre">bus</span></code> |
| - <code class="docutils literal notranslate"><span class="pre">dev</span></code> |
| - <code class="docutils literal notranslate"><span class="pre">get</span></code> |
| - <code class="docutils literal notranslate"><span class="pre">set</span></code> |
| - <code class="docutils literal notranslate"><span class="pre">verf</span></code></p></li> |
| <li><p>I2C Build Configuration |
| - NuttX Configuration Requirements |
| - I2C Tool Configuration Options</p></li> |
| </ul> |
| </section> |
| <section id="system-requirements"> |
| <h2>System Requirements<a class="headerlink" href="#system-requirements" title="Permalink to this heading"></a></h2> |
| <p>The I2C tool is designed to be implemented as a NuttShell (NSH) add-on. Read the |
| <code class="docutils literal notranslate"><span class="pre">apps/nshlib/README.md</span></code> file for information about add-ons.</p> |
| <section id="configuration-options"> |
| <h3>Configuration Options<a class="headerlink" href="#configuration-options" title="Permalink to this heading"></a></h3> |
| <ul class="simple"> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_NSH_BUILTIN_APPS</span></code> – Build the tools as an NSH built-in command.</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_MINBUS</span></code> – Smallest bus index supported by the hardware |
| (default <code class="docutils literal notranslate"><span class="pre">0</span></code>).</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_MAXBUS</span></code> – Largest bus index supported by the hardware |
| (default <code class="docutils literal notranslate"><span class="pre">3</span></code>).</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_MINADDR</span></code> – Minimum device address (default: <code class="docutils literal notranslate"><span class="pre">0x03</span></code>).</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_MAXADDR</span></code> – Largest device address (default: <code class="docutils literal notranslate"><span class="pre">0x77</span></code>).</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_MAXREGADDR</span></code> – Largest register address (default: <code class="docutils literal notranslate"><span class="pre">0xff</span></code>).</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_DEFFREQ</span></code> – Default frequency (default: <code class="docutils literal notranslate"><span class="pre">4000000</span></code>).</p></li> |
| </ul> |
| </section> |
| </section> |
| <section id="help"> |
| <h2>Help<a class="headerlink" href="#help" title="Permalink to this heading"></a></h2> |
| <p>First of all, the I2C tools supports a pretty extensive help output. That help |
| output can be view by entering either:</p> |
| <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>nsh> i2c help |
| </pre></div> |
| </div> |
| <p>or:</p> |
| <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>nsh> i2c ? |
| </pre></div> |
| </div> |
| <p>Here is an example of the help output. I shows the general form of the command |
| line, the various I2C commands supported with their unique command line options, |
| and a more detailed summary of the command I2C command options:</p> |
| <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>nsh> i2c help |
| |
| Usage: i2c <cmd> [arguments] |
| Where <cmd> is one of: |
| |
| Show help : ? |
| List buses : bus |
| List devices : dev [OPTIONS] <first> <last> |
| Read register : get [OPTIONS] [<repetitions>] |
| Show help : help |
| Write register: set [OPTIONS] <value> [<repetitions>] |
| Verify access : verf [OPTIONS] <value> [<repetitions>] |
| |
| Where common _sticky_ OPTIONS include: |
| [-a addr] is the I2C device address (hex). Default: 03 Current: 03 |
| [-b bus] is the I2C bus number (decimal). Default: 1 Current: 1 |
| [-r regaddr] is the I2C device register address (hex). Default: 00 Current: 00 |
| [-w width] is the data width (8 or 16 decimal). Default: 8 Current: 8 |
| [-s|n], send/don't send start between command and data. Default: -n Current: -n |
| [-i|j], Auto increment|don't increment regaddr on repetitions. Default: NO Current: NO |
| [-f freq] I2C frequency. Default: 100000 Current: 100000 |
| </pre></div> |
| </div> |
| <p><strong>Notes</strong>:</p> |
| <ul class="simple"> |
| <li><p>An environment variable like <code class="docutils literal notranslate"><span class="pre">$PATH</span></code> may be used for any argument.</p></li> |
| <li><p>Arguments are _sticky_. For example, once the I2C address is specified, that |
| address will be re-used until it is changed.</p></li> |
| </ul> |
| <p><strong>Warning</strong>:</p> |
| <ul class="simple"> |
| <li><p>The I2C dev command may have bad side effects on your I2C devices. Use only at |
| your own risk.</p></li> |
| </ul> |
| </section> |
| <section id="command-line-form"> |
| <h2>Command Line Form<a class="headerlink" href="#command-line-form" title="Permalink to this heading"></a></h2> |
| <p>The I2C is started from NSH by invoking the <code class="docutils literal notranslate"><span class="pre">i2c</span></code> command from the NSH command |
| line. The general form of the <code class="docutils literal notranslate"><span class="pre">i2c</span></code> command is:</p> |
| <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>i2c <cmd> [arguments] |
| </pre></div> |
| </div> |
| <p>Where <code class="docutils literal notranslate"><span class="pre"><cmd></span></code> is a sub-command and identifies one I2C operations supported by |
| the tool. <code class="docutils literal notranslate"><span class="pre">[arguments]</span></code> represents the list of arguments needed to perform the |
| I2C operation. Those arguments vary from command to command as described below. |
| However, there is also a core set of common <code class="docutils literal notranslate"><span class="pre">OPTIONS</span></code> supported by all commands. |
| So perhaps a better representation of the general I2C command would be:</p> |
| <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>i2c <cmd> [OPTIONS] [arguments] |
| </pre></div> |
| </div> |
| <p>Where <code class="docutils literal notranslate"><span class="pre">[OPTIONS]</span></code> represents the common options and and arguments represent the |
| operation-specific arguments.</p> |
| </section> |
| <section id="common-command-options"> |
| <h2>Common Command Options<a class="headerlink" href="#common-command-options" title="Permalink to this heading"></a></h2> |
| <section id="sticky-options"> |
| <h3>“Sticky” Options<a class="headerlink" href="#sticky-options" title="Permalink to this heading"></a></h3> |
| <p>In order to interact with I2C devices, there are a number of I2C parameters that |
| must be set correctly. One way to do this would be to provide to set the value |
| of each separate command for each I2C parameter. The I2C tool takes a different |
| approach, instead: The I2C configuration can be specified as a (potentially |
| long) sequence of command line arguments.</p> |
| <p>These arguments, however, are _sticky_. They are sticky in the sense that once |
| you set the I2C parameter, that value will remain until it is reset with a new |
| value (or until you reset the board).</p> |
| </section> |
| <section id="environment-variables"> |
| <h3>Environment Variables<a class="headerlink" href="#environment-variables" title="Permalink to this heading"></a></h3> |
| <p><strong>Note</strong> also that if environment variables are not disabled (by |
| <code class="docutils literal notranslate"><span class="pre">CONFIG_DISABLE_ENVIRON=y</span></code>), then these options may also be environment |
| variables. Environment variables must be preceded with the special character |
| <code class="docutils literal notranslate"><span class="pre">$</span></code>. For example, <code class="docutils literal notranslate"><span class="pre">PWD</span></code> is the variable that holds the current working directory |
| and so <code class="docutils literal notranslate"><span class="pre">$PWD</span></code> could be used as a command line argument. The use of environment |
| variables on the I2C tools command is really only useful if you wish to write |
| NSH scripts to execute a longer, more complex series of I2C commands.</p> |
| </section> |
| <section id="common-option-summary"> |
| <h3>Common Option Summary<a class="headerlink" href="#common-option-summary" title="Permalink to this heading"></a></h3> |
| <ul> |
| <li><p><code class="docutils literal notranslate"><span class="pre">[-a</span> <span class="pre">addr]</span></code> is the I2C device address (hex). Default: <code class="docutils literal notranslate"><span class="pre">03</span></code> Current: <code class="docutils literal notranslate"><span class="pre">03</span></code></p> |
| <p>The <code class="docutils literal notranslate"><span class="pre">[-a</span> <span class="pre">addr]</span></code> sets the I2C device address. The valid range is <code class="docutils literal notranslate"><span class="pre">0x03</span></code> through |
| <code class="docutils literal notranslate"><span class="pre">0x77</span></code> (this valid range is controlled by the configuration settings |
| <code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_MINADDR</span></code> and <code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_MAXADDR</span></code>). If you are working |
| with the same device, the address needs to be set only once.</p> |
| <p>All I2C address are 7-bit, hexadecimal values.</p> |
| <p><strong>Note 1</strong>: Notice in the <code class="docutils literal notranslate"><span class="pre">help</span></code> output above it shows both default value of the |
| I2C address (<code class="docutils literal notranslate"><span class="pre">03</span></code> hex) and the current address value (also <code class="docutils literal notranslate"><span class="pre">03</span></code> hex).</p> |
| <p><strong>Note 2</strong>: Sometimes I2C addresses are represented as 8-bit values (with bit zero |
| indicating a read or write operation). The I2C tool uses a 7-bit |
| representation of the address with bit 7 unused and no read/write indication |
| in bit 0. Essentially, the 7-bit address is like the 8-bit address shifted |
| right by 1.</p> |
| <p><strong>Note 3</strong>: Most I2C bus controllers will also support 10-bit addressing. That |
| capability has not been integrated into the I2C tool as of this writing.</p> |
| </li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">[-b</span> <span class="pre">bus]</span></code> is the I2C bus number (decimal). Default: <code class="docutils literal notranslate"><span class="pre">1</span></code> Current: <code class="docutils literal notranslate"><span class="pre">1</span></code></p> |
| <p>Most devices support multiple I2C devices and also have unique bus numbering. |
| This option identifies which bus you are working with now. The valid range of |
| bus numbers is controlled by the configuration settings |
| <code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_MINBUS</span></code> and <code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_MAXBUS</span></code>.</p> |
| <p>The bus numbers are small, decimal numbers.</p> |
| </li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">[-r</span> <span class="pre">regaddr]</span></code> is the I2C device register address (hex). Default: <code class="docutils literal notranslate"><span class="pre">00</span></code> |
| Current: <code class="docutils literal notranslate"><span class="pre">00</span></code></p> |
| <p>The I2C set and get commands will access registers on the I2C device. This |
| option selects the device register address (sometimes called the sub-address). |
| This is an 8-bit hexadecimal value. The maximum value is determined by the |
| configuration setting <code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_MAXREGADDR</span></code>.</p> |
| </li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">[-w</span> <span class="pre">width]</span></code> is the data width (8 or 16 decimal). Default: <code class="docutils literal notranslate"><span class="pre">8</span></code> Current: <code class="docutils literal notranslate"><span class="pre">8</span></code></p> |
| <p>Device register data may be 8-bit or 16-bit. This options selects one of those |
| two data widths.</p> |
| </li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">[-s|n]</span></code>, send/don’t send start between command and data. Default: <code class="docutils literal notranslate"><span class="pre">-n</span></code> |
| Current: <code class="docutils literal notranslate"><span class="pre">-n</span></code></p> |
| <p>This determines whether or not there should be a new I2C START between sending |
| of the register address and sending/receiving of the register data.</p> |
| </li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">[-i|j]</span></code>, Auto increment|don’t increment <code class="docutils literal notranslate"><span class="pre">regaddr</span></code> on repetitions. Default: |
| <code class="docutils literal notranslate"><span class="pre">NO</span></code> Current: <code class="docutils literal notranslate"><span class="pre">NO</span></code></p> |
| <p>On commands that take a optional number of repetitions, the option can be used |
| to temporarily increment the <code class="docutils literal notranslate"><span class="pre">regaddr</span></code> value by one on each repetition.</p> |
| </li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">[-f</span> <span class="pre">freq]</span></code> I2C frequency. Default: <code class="docutils literal notranslate"><span class="pre">400000</span></code> Current: <code class="docutils literal notranslate"><span class="pre">400000</span></code></p> |
| <p>The <code class="docutils literal notranslate"><span class="pre">[-f</span> <span class="pre">freq]</span></code> sets the frequency of the I2C device.</p> |
| </li> |
| </ul> |
| </section> |
| </section> |
| <section id="command-summary"> |
| <h2>Command Summary<a class="headerlink" href="#command-summary" title="Permalink to this heading"></a></h2> |
| <p>We have already seen the I2C help (or <code class="docutils literal notranslate"><span class="pre">?</span></code>) commands above. This section will |
| discuss the remaining commands.</p> |
| <section id="list-buses-bus-options"> |
| <h3>List buses: <code class="docutils literal notranslate"><span class="pre">bus</span> <span class="pre">[OPTIONS]</span></code><a class="headerlink" href="#list-buses-bus-options" title="Permalink to this heading"></a></h3> |
| <p>This command will simply list all of the configured I2C buses and indicate which |
| are supported by the driver and which are not:</p> |
| <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>BUS EXISTS? |
| Bus 1: YES |
| Bus 2: NO |
| </pre></div> |
| </div> |
| <p>The valid range of bus numbers is controlled by the configuration settings |
| <code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_MINBUS</span></code> and <code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_MAXBUS</span></code>.</p> |
| </section> |
| <section id="list-devices-dev-options-first-last"> |
| <h3>List devices: <code class="docutils literal notranslate"><span class="pre">dev</span> <span class="pre">[OPTIONS]</span> <span class="pre"><first></span> <span class="pre"><last></span></code><a class="headerlink" href="#list-devices-dev-options-first-last" title="Permalink to this heading"></a></h3> |
| <p>The <code class="docutils literal notranslate"><span class="pre">dev</span></code> command will attempt to identify all of the I2C devices on the |
| selected bus. The <code class="docutils literal notranslate"><span class="pre"><first></span></code> and <code class="docutils literal notranslate"><span class="pre"><last></span></code> arguments are 7-bit, hexadecimal I2C |
| addresses. This command will examine a range of addresses beginning with |
| <code class="docutils literal notranslate"><span class="pre"><first></span></code> and continuing through <code class="docutils literal notranslate"><span class="pre"><last></span></code>. It will request the value of register |
| address zero from each device.</p> |
| <p>The register address of zero is always used by default. The previous _sticky_ |
| register address is ignored. Some devices may not respond to ergister address |
| zero, however. To work around this, you can provide a new _sticky_ register |
| address on the command as an option to the ‘dev’ command. Then that new _sticky_ |
| register address will be used instead of the address zero.</p> |
| <p>If the device at an I2C address responds to the read request, then the <code class="docutils literal notranslate"><span class="pre">dev</span></code> |
| command will display the I2C address of the device. If the device does not |
| respond, this command will display <code class="docutils literal notranslate"><span class="pre">--</span></code>. The resulting display looks like:</p> |
| <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>nsh> i2c dev 03 77 |
| |
| 0 1 2 3 4 5 6 7 8 9 a b c d e f |
| 00: -- -- -- -- -- -- -- -- -- -- -- -- -- |
| 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
| 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
| 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
| 40: -- -- -- -- -- -- -- -- -- 49 -- -- -- -- -- -- |
| 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- |
| 70: -- -- -- -- -- -- -- -- |
| </pre></div> |
| </div> |
| <p>Warnings:</p> |
| <ul class="simple"> |
| <li><p>The I2C dev command may have bad side effects on certain I2C devices. For |
| example, if could cause data loss in an EEPROM device.</p></li> |
| <li><p>The I2C dev command also depends upon the underlying behavior of the I2C |
| driver. How does the driver respond to addressing failures?</p></li> |
| </ul> |
| </section> |
| <section id="read-register-get-options"> |
| <h3>Read register: <code class="docutils literal notranslate"><span class="pre">get</span> <span class="pre">[OPTIONS]</span></code><a class="headerlink" href="#read-register-get-options" title="Permalink to this heading"></a></h3> |
| <p>This command will read the value of the I2C register using the selected I2C |
| parameters in the common options. No other arguments are required.</p> |
| <p>This command with write the 8-bit address value then read an 8- or 16-bit data |
| value from the device. Optionally, it may re-start the transfer before obtaining |
| the data.</p> |
| <p>An optional <code class="docutils literal notranslate"><span class="pre"><repetitions></span></code> argument can be supplied to repeat the read |
| operation an arbitrary number of times (up to 2 billion). If auto-increment is |
| select (<code class="docutils literal notranslate"><span class="pre">-i</span></code>), then the register address will be temporarily incremented on each |
| repetitions. The increment is temporary in the since that it will not alter the |
| _sticky_ value of the register address.</p> |
| <p>On success, the output will look like the following (the data value read will be |
| shown as a 4-character hexadecimal number if the 16-bit data width option is |
| selected):</p> |
| <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>READ Bus: 1 Addr: 49 Subaddr: 04 Value: 96 |
| </pre></div> |
| </div> |
| <p>All values (except the bus numbers) are hexadecimal.</p> |
| </section> |
| <section id="write-register-set-options-value"> |
| <h3>Write register: <code class="docutils literal notranslate"><span class="pre">set</span> <span class="pre">[OPTIONS]</span> <span class="pre"><value></span></code><a class="headerlink" href="#write-register-set-options-value" title="Permalink to this heading"></a></h3> |
| <p>This command will write a value to an I2C register using the selected I2C |
| parameters in the common options. The value to write must be provided as the |
| final, hexadecimal value. This value may be an 8-bit value (in the range |
| <code class="docutils literal notranslate"><span class="pre">00</span></code>-<code class="docutils literal notranslate"><span class="pre">ff</span></code>) or a 16-bit value (in the range <code class="docutils literal notranslate"><span class="pre">0000</span></code>-<code class="docutils literal notranslate"><span class="pre">ffff</span></code>), depending upon the |
| selected data width.</p> |
| <p>This command will write the 8-bit address value then write the 8- or 16-bit data |
| value to the device. Optionally, it may re-start the transfer before writing the |
| data.</p> |
| <p>An optional <code class="docutils literal notranslate"><span class="pre"><repetitions></span></code> argument can be supplied to repeat the write |
| operation an arbitrary number of times (up to 2 billion). If auto-increment is |
| select (<code class="docutils literal notranslate"><span class="pre">-i</span></code>), then the register address will be temporarily incremented on each |
| repetitions. The increment is temporary in the since that it will not alter the |
| _sticky_ value of the register address.</p> |
| <p>On success, the output will look like the following (the data value written will |
| be shown as a 4-character hexadecimal number if the 16-bit data width option is |
| selected):</p> |
| <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>WROTE Bus: 1 Addr: 49 Subaddr: 04 Value: 96 |
| </pre></div> |
| </div> |
| <p>All values (except the bus numbers) are hexadecimal.</p> |
| </section> |
| <section id="verify-access-verf-options-value-repetitions"> |
| <h3>Verify access: <code class="docutils literal notranslate"><span class="pre">verf</span> <span class="pre">[OPTIONS]</span> <span class="pre"><value></span> <span class="pre">[<repetitions>]</span></code><a class="headerlink" href="#verify-access-verf-options-value-repetitions" title="Permalink to this heading"></a></h3> |
| <p>This command combines writing and reading from an I2C device register. It will |
| write a value to an will write a value to an I2C register using the selected I2C |
| parameters in the common options just as described for tie <code class="docutils literal notranslate"><span class="pre">set</span></code> command. Then |
| this command will read the value back just as described with the <code class="docutils literal notranslate"><span class="pre">get</span></code> command. |
| Finally, this command will compare the value read and against the value written |
| and emit an error message if they do not match.</p> |
| <p>If no value is provided, then this command will use the register address itself |
| as the data, providing for a address-in-address test.</p> |
| <p>An optional <code class="docutils literal notranslate"><span class="pre"><repetitions></span></code> argument can be supplied to repeat the verify |
| operation an arbitrary number of times (up to 2 billion). If auto-increment is |
| select (<code class="docutils literal notranslate"><span class="pre">-i</span></code>), then the register address will be temporarily incremented on each |
| repetitions. The increment is temporary in the since that it will not alter the |
| <code class="docutils literal notranslate"><span class="pre">sticky</span></code> value of the register address.</p> |
| <p>On success, the output will look like the following (the data value written will |
| be shown as a 4-character hexadecimal number if the 16-bit data width option is |
| selected):</p> |
| <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>VERIFY Bus: 1 Addr: 49 Subaddr: 04 Wrote: 96 Read: 92 FAILURE |
| </pre></div> |
| </div> |
| <p>All values (except the bus numbers) are hexadecimal.</p> |
| </section> |
| </section> |
| <section id="i2c-build-configuration"> |
| <h2>I2C Build Configuration<a class="headerlink" href="#i2c-build-configuration" title="Permalink to this heading"></a></h2> |
| <section id="nuttx-configuration-requirements"> |
| <h3>NuttX Configuration Requirements<a class="headerlink" href="#nuttx-configuration-requirements" title="Permalink to this heading"></a></h3> |
| <p>The I2C tools requires the following in your NuttX configuration:</p> |
| <ol class="arabic"> |
| <li><p>Application configuration.</p> |
| <p>Using <code class="docutils literal notranslate"><span class="pre">make</span> <span class="pre">menuconfig</span></code>, select the i2c tool. The following definition should |
| appear in your <code class="docutils literal notranslate"><span class="pre">.config</span></code> file:</p> |
| <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>CONFIG_SYSTEM_I2C=y |
| </pre></div> |
| </div> |
| </li> |
| <li><p>Device-specific I2C driver support must be enabled:</p> |
| <div class="highlight-none notranslate"><div class="highlight"><pre><span></span>CONFIG_I2C_DRIVER=y |
| </pre></div> |
| </div> |
| <p>The I2C tool will then use the I2C character driver to access the I2C bus. |
| These devices will reside at <code class="docutils literal notranslate"><span class="pre">/dev/i2cN</span></code> where <code class="docutils literal notranslate"><span class="pre">N</span></code> is the I2C bus number.</p> |
| <p><strong>Note</strong>: The I2C driver <code class="docutils literal notranslate"><span class="pre">ioctl</span></code> interface is defined in |
| <code class="docutils literal notranslate"><span class="pre">include/nuttx/i2c/i2c_master.h</span></code>.</p> |
| </li> |
| </ol> |
| </section> |
| <section id="i2c-tool-configuration-options"> |
| <h3>I2C Tool Configuration Options<a class="headerlink" href="#i2c-tool-configuration-options" title="Permalink to this heading"></a></h3> |
| <p>The default behavior of the I2C tool can be modified by the setting the options |
| in the NuttX configuration. This configuration is the <code class="docutils literal notranslate"><span class="pre">defconfig</span></code> file in your |
| configuration directory that is copied to the NuttX top-level directory as |
| <code class="docutils literal notranslate"><span class="pre">.config</span></code> when NuttX is configured.</p> |
| <ul class="simple"> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_NSH_BUILTIN_APPS</span></code> – Build the tools as an NSH built-in command.</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_MINBUS</span></code> – Smallest bus index supported by the hardware |
| (default <code class="docutils literal notranslate"><span class="pre">0</span></code>).</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_MAXBUS</span></code> – Largest bus index supported by the hardware |
| (default <code class="docutils literal notranslate"><span class="pre">3</span></code>).</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_MINADDR</span></code> – Minimum device address (default: <code class="docutils literal notranslate"><span class="pre">0x03</span></code>).</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_MAXADDR</span></code> – Largest device address (default: <code class="docutils literal notranslate"><span class="pre">0x77</span></code>).</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_MAXREGADDR</span></code> – Largest register address (default: <code class="docutils literal notranslate"><span class="pre">0xff</span></code>).</p></li> |
| <li><p><code class="docutils literal notranslate"><span class="pre">CONFIG_I2CTOOL_DEFFREQ</span></code> – Default frequency (default: <code class="docutils literal notranslate"><span class="pre">4000000</span></code>).</p></li> |
| </ul> |
| </section> |
| </section> |
| </section> |
| |
| |
| </div> |
| </div> |
| <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer"> |
| <a href="../hostname/index.html" class="btn btn-neutral float-left" title="hostname “hostname” command" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a> |
| <a href="../input/index.html" class="btn btn-neutral float-right" title="input input tool" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a> |
| </div> |
| |
| <hr/> |
| |
| <div role="contentinfo"> |
| <p>© Copyright 2023, The Apache Software Foundation.</p> |
| </div> |
| |
| |
| |
| </footer> |
| </div> |
| </div> |
| </section> |
| </div> |
| <script> |
| jQuery(function () { |
| SphinxRtdTheme.Navigation.enable(true); |
| }); |
| </script> |
| |
| </body> |
| </html> |