rtic/dev/api/embedded_hal_bus/index.html

44 lines
8.3 KiB
HTML
Raw Normal View History

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="crates.io crates.io Documentation Minimum Supported Rust Version"><title>embedded_hal_bus - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-b0742ba02757f159.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="embedded_hal_bus" data-themes="" data-resource-suffix="" data-rustdoc-version="1.83.0 (90b35a623 2024-11-26)" data-channel="1.83.0" data-search-js="search-f0d225181b97f9a4.js" data-settings-js="settings-805db61a62df4bd2.js" ><script src="../static.files/storage-1d39b6787ed640ff.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-f070b9041d14864c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-0111fcff984fae8f.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../embedded_hal_bus/index.html">embedded_<wbr>hal_<wbr>bus</a><span class="version">0.2.0</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#embedded-hal-bus" title="`embedded-hal-bus`"><code>embedded-hal-bus</code></a><ul><li><a href="#spi" title="SPI">SPI</a></li><li><a href="#i2c" title="I2C">I2C</a></li><li><a href="#optional-cargo-features" title="Optional Cargo features">Optional Cargo features</a></li><li><a href="#minimum-supported-rust-version-msrv" title="Minimum Supported Rust Version (MSRV)">Minimum Supported Rust Version (MSRV)</a></li><li><a href="#license" title="License">License</a></li></ul></li></ul><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>embedded_hal_bus</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/embedded_hal_bus/lib.rs.html#1-21">source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p><a href="https://crates.io/crates/embedded-hal-bus"><img src="https://img.shields.io/crates/d/embedded-hal-bus.svg" alt="crates.io" /></a>
<a href="https://crates.io/crates/embedded-hal-bus"><img src="https://img.shields.io/crates/v/embedded-hal-bus.svg" alt="crates.io" /></a>
<a href="https://docs.rs/embedded-hal-bus"><img src="https://docs.rs/embedded-hal-bus/badge.svg" alt="Documentation" /></a>
<img src="https://img.shields.io/badge/rustc-1.60+-blue.svg" alt="Minimum Supported Rust Version" /></p>
<h2 id="embedded-hal-bus"><a class="doc-anchor" href="#embedded-hal-bus">§</a><code>embedded-hal-bus</code></h2>
<p>Bus sharing utilities for <a href="https://crates.io/crates/embedded-hal"><code>embedded-hal</code></a>, a Hardware Abstraction Layer (HAL) for embedded systems.</p>
<p><code>embedded-hal</code> provides traits for SPI and I2C buses and devices. This crate provides hardware-independent adapters for sharing a single bus between multiple devices, compatible with the traits.</p>
<p>This project is developed and maintained by the <a href="https://github.com/rust-embedded/wg#the-hal-team">HAL team</a>.</p>
<h3 id="spi"><a class="doc-anchor" href="#spi">§</a>SPI</h3>
<p>To support bus sharing, <code>embedded-hal</code> provides the <code>SpiBus</code> and <code>SpiDevice</code> traits. <code>SpiBus</code> represents an entire bus,
while <code>SpiDevice</code> represents a device on that bus. For further details on these traits, please consult the
<a href="https://docs.rs/embedded-hal/latest/embedded_hal/spi/index.html"><code>embedded-hal</code> documentation</a>.</p>
<p><code>embedded-hal</code> trait implementations for microcontrollers should implement the <code>SpiBus</code> trait.
However, device drivers should use the <code>SpiDevice</code> traits, <em>not the <code>SpiBus</code> traits</em> if at all possible
in order to allow for sharing of the bus they are connected to.</p>
<p>This crate provides mechanisms to connect a <code>SpiBus</code> and a <code>SpiDevice</code>.</p>
<h3 id="i2c"><a class="doc-anchor" href="#i2c">§</a>I2C</h3>
<p>In the case of I2C, the same <code>I2c</code> <code>embedded-hal</code> trait represents either an entire bus, or a device on a bus. This crate
provides mechanisms to obtain multiple <code>I2c</code> instances out of a single <code>I2c</code> instance, sharing the bus.</p>
<h3 id="optional-cargo-features"><a class="doc-anchor" href="#optional-cargo-features">§</a>Optional Cargo features</h3>
<ul>
<li><strong><code>std</code></strong>: enable shared bus implementations using <code>std::sync::Mutex</code>, and implement
<code>std::error::Error</code> for <code>DeviceError</code>.</li>
<li><strong><code>async</code></strong>: enable <code>embedded-hal-async</code> support.</li>
<li><strong><code>defmt-03</code></strong>: Derive <code>defmt::Format</code> from <code>defmt</code> 0.3 for enums and structs.</li>
</ul>
<h3 id="minimum-supported-rust-version-msrv"><a class="doc-anchor" href="#minimum-supported-rust-version-msrv">§</a>Minimum Supported Rust Version (MSRV)</h3>
<p>This crate is guaranteed to compile on stable Rust 1.60 and up. It <em>might</em>
compile with older versions but that may change in any new patch release.</p>
<p>See <a href="../docs/msrv.md">here</a> for details on how the MSRV may be upgraded.</p>
<p>Enabling the <code>async</code> Cargo features requires Rust 1.75 or higher.</p>
<h3 id="license"><a class="doc-anchor" href="#license">§</a>License</h3>
<p>Licensed under either of</p>
<ul>
<li>Apache License, Version 2.0 (<a href="LICENSE-APACHE">LICENSE-APACHE</a> or
<a href="http://www.apache.org/licenses/LICENSE-2.0">http://www.apache.org/licenses/LICENSE-2.0</a>)</li>
<li>MIT license (<a href="LICENSE-MIT">LICENSE-MIT</a> or <a href="http://opensource.org/licenses/MIT">http://opensource.org/licenses/MIT</a>)</li>
</ul>
<p>at your option.</p>
<h4 id="contribution"><a class="doc-anchor" href="#contribution">§</a>Contribution</h4>
<p>Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.</p>
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="i2c/index.html" title="mod embedded_hal_bus::i2c">i2c</a></div><div class="desc docblock-short"><code>I2c</code> shared bus implementations.</div></li><li><div class="item-name"><a class="mod" href="spi/index.html" title="mod embedded_hal_bus::spi">spi</a></div><div class="desc docblock-short"><code>SpiDevice</code> implementations.</div></li><li><div class="item-name"><a class="mod" href="util/index.html" title="mod embedded_hal_bus::util">util</a></div><div class="desc docblock-short">Utilities shared by all bus types.</div></li></ul></section></div></main></body></html>