rtic/2/api/embedded_hal_async/spi/trait.SpiBus.html
github-merge-queue[bot] 5b32b958a3 deploy: f17915842f
2024-11-27 19:34:22 +00:00

56 lines
No EOL
19 KiB
HTML

<!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="SPI bus."><title>SpiBus in embedded_hal_async::spi - 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-492a78a4a87dcc01.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="embedded_hal_async" data-themes="" data-resource-suffix="" data-rustdoc-version="1.82.0 (f6e511eec 2024-10-15)" data-channel="1.82.0" data-search-js="search-a99f1315e7cc5121.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-921df33f47b8780c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-3b12f09e550e0385.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 trait"><!--[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_async/index.html">embedded_<wbr>hal_<wbr>async</a><span class="version">1.0.0</span></h2></div><h2 class="location"><a href="#">SpiBus</a></h2><div class="sidebar-elems"><section><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.flush">flush</a></li><li><a href="#tymethod.read">read</a></li><li><a href="#tymethod.transfer">transfer</a></li><li><a href="#tymethod.transfer_in_place">transfer_in_place</a></li><li><a href="#tymethod.write">write</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-SpiBus%3CWord%3E-for-%26mut+T">&#38;mut T</a></li></ul><h3><a href="#object-safety">Object Safety</a></h3><h3><a href="#implementors">Implementors</a></h3></section><h2><a href="index.html">In embedded_<wbr>hal_<wbr>async::<wbr>spi</a></h2></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>Trait <a href="../index.html">embedded_hal_async</a>::<wbr><a href="index.html">spi</a>::<wbr><a class="trait" href="#">SpiBus</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><a class="src" href="../../src/embedded_hal_async/spi.rs.html#112-153">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>pub trait SpiBus&lt;Word: 'static + <a class="trait" href="https://doc.rust-lang.org/1.82.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> = <a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.u8.html">u8</a>&gt;: <a class="trait" href="trait.ErrorType.html" title="trait embedded_hal_async::spi::ErrorType">ErrorType</a> {
// Required methods
async fn <a href="#tymethod.read" class="fn">read</a>(&amp;mut self, words: &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.slice.html">[Word]</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.82.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.ErrorType.html#associatedtype.Error" title="type embedded_hal_async::spi::ErrorType::Error">Error</a>&gt;;
<span class="item-spacer"></span> async fn <a href="#tymethod.write" class="fn">write</a>(&amp;mut self, words: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.slice.html">[Word]</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.82.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.ErrorType.html#associatedtype.Error" title="type embedded_hal_async::spi::ErrorType::Error">Error</a>&gt;;
<span class="item-spacer"></span> async fn <a href="#tymethod.transfer" class="fn">transfer</a>(
&amp;mut self,
read: &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.slice.html">[Word]</a>,
write: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.slice.html">[Word]</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.82.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.ErrorType.html#associatedtype.Error" title="type embedded_hal_async::spi::ErrorType::Error">Error</a>&gt;;
<span class="item-spacer"></span> async fn <a href="#tymethod.transfer_in_place" class="fn">transfer_in_place</a>(
&amp;mut self,
words: &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.slice.html">[Word]</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.82.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.ErrorType.html#associatedtype.Error" title="type embedded_hal_async::spi::ErrorType::Error">Error</a>&gt;;
<span class="item-spacer"></span> async fn <a href="#tymethod.flush" class="fn">flush</a>(&amp;mut self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.82.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.ErrorType.html#associatedtype.Error" title="type embedded_hal_async::spi::ErrorType::Error">Error</a>&gt;;
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>SPI bus.</p>
<p><code>SpiBus</code> represents <strong>exclusive ownership</strong> over the whole SPI bus, with SCK, MOSI and MISO pins.</p>
<p>See <a href="../../embedded_hal/spi/index.html" title="mod embedded_hal::spi">the docs on embedded-hal</a> for important information on SPI Bus vs Device traits.</p>
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.read" class="method"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#120">source</a><h4 class="code-header">async fn <a href="#tymethod.read" class="fn">read</a>(&amp;mut self, words: &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.slice.html">[Word]</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.82.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.ErrorType.html#associatedtype.Error" title="type embedded_hal_async::spi::ErrorType::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Read <code>words</code> from the slave.</p>
<p>The word value sent on MOSI during reading is implementation-defined,
typically <code>0x00</code>, <code>0xFF</code>, or configurable.</p>
<p>Implementations are allowed to return before the operation is
complete. See <a href="../../embedded_hal/spi/index.html" title="mod embedded_hal::spi">the docs on embedded-hal</a> for details on flushing.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.write" class="method"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#126">source</a><h4 class="code-header">async fn <a href="#tymethod.write" class="fn">write</a>(&amp;mut self, words: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.slice.html">[Word]</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.82.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.ErrorType.html#associatedtype.Error" title="type embedded_hal_async::spi::ErrorType::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Write <code>words</code> to the slave, ignoring all the incoming words.</p>
<p>Implementations are allowed to return before the operation is
complete. See <a href="../../embedded_hal/spi/index.html" title="mod embedded_hal::spi">the docs on embedded-hal</a> for details on flushing.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.transfer" class="method"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#139">source</a><h4 class="code-header">async fn <a href="#tymethod.transfer" class="fn">transfer</a>(
&amp;mut self,
read: &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.slice.html">[Word]</a>,
write: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.slice.html">[Word]</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.82.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.ErrorType.html#associatedtype.Error" title="type embedded_hal_async::spi::ErrorType::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Write and read simultaneously. <code>write</code> is written to the slave on MOSI and
words received on MISO are stored in <code>read</code>.</p>
<p>It is allowed for <code>read</code> and <code>write</code> to have different lengths, even zero length.
The transfer runs for <code>max(read.len(), write.len())</code> words. If <code>read</code> is shorter,
incoming words after <code>read</code> has been filled will be discarded. If <code>write</code> is shorter,
the value of words sent in MOSI after all <code>write</code> has been sent is implementation-defined,
typically <code>0x00</code>, <code>0xFF</code>, or configurable.</p>
<p>Implementations are allowed to return before the operation is
complete. See <a href="../../embedded_hal/spi/index.html" title="mod embedded_hal::spi">the docs on embedded-hal</a> for details on flushing.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.transfer_in_place" class="method"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#147">source</a><h4 class="code-header">async fn <a href="#tymethod.transfer_in_place" class="fn">transfer_in_place</a>(
&amp;mut self,
words: &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.slice.html">[Word]</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.82.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.ErrorType.html#associatedtype.Error" title="type embedded_hal_async::spi::ErrorType::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Write and read simultaneously. The contents of <code>words</code> are
written to the slave, and the received words are stored into the same
<code>words</code> buffer, overwriting it.</p>
<p>Implementations are allowed to return before the operation is
complete. See <a href="../../embedded_hal/spi/index.html" title="mod embedded_hal::spi">the docs on embedded-hal</a> for details on flushing.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.flush" class="method"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#152">source</a><h4 class="code-header">async fn <a href="#tymethod.flush" class="fn">flush</a>(&amp;mut self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.82.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.ErrorType.html#associatedtype.Error" title="type embedded_hal_async::spi::ErrorType::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Wait until all operations have completed and the bus is idle.</p>
<p>See <a href="../../embedded_hal/spi/index.html" title="mod embedded_hal::spi">the docs on embedded-hal</a> for information on flushing.</p>
</div></details></div><h2 id="object-safety" class="section-header">Object Safety<a href="#object-safety" class="anchor">§</a></h2><div class="object-safety-info">This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.82.0/reference/items/traits.html#object-safety">object safe</a>.</div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-SpiBus%3CWord%3E-for-%26mut+T" class="impl"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#155-180">source</a><a href="#impl-SpiBus%3CWord%3E-for-%26mut+T" class="anchor">§</a><h3 class="code-header">impl&lt;T: <a class="trait" href="trait.SpiBus.html" title="trait embedded_hal_async::spi::SpiBus">SpiBus</a>&lt;Word&gt; + ?<a class="trait" href="https://doc.rust-lang.org/1.82.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, Word: 'static + <a class="trait" href="https://doc.rust-lang.org/1.82.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a>&gt; <a class="trait" href="trait.SpiBus.html" title="trait embedded_hal_async::spi::SpiBus">SpiBus</a>&lt;Word&gt; for <a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.reference.html">&amp;mut T</a></h3></section></summary><div class="impl-items"><section id="method.read" class="method trait-impl"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#157-159">source</a><a href="#method.read" class="anchor">§</a><h4 class="code-header">async fn <a href="#tymethod.read" class="fn">read</a>(&amp;mut self, words: &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.slice.html">[Word]</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.82.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.ErrorType.html#associatedtype.Error" title="type embedded_hal_async::spi::ErrorType::Error">Error</a>&gt;</h4></section><section id="method.write" class="method trait-impl"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#162-164">source</a><a href="#method.write" class="anchor">§</a><h4 class="code-header">async fn <a href="#tymethod.write" class="fn">write</a>(&amp;mut self, words: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.slice.html">[Word]</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.82.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.ErrorType.html#associatedtype.Error" title="type embedded_hal_async::spi::ErrorType::Error">Error</a>&gt;</h4></section><section id="method.transfer" class="method trait-impl"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#167-169">source</a><a href="#method.transfer" class="anchor">§</a><h4 class="code-header">async fn <a href="#tymethod.transfer" class="fn">transfer</a>(
&amp;mut self,
read: &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.slice.html">[Word]</a>,
write: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.slice.html">[Word]</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.82.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.ErrorType.html#associatedtype.Error" title="type embedded_hal_async::spi::ErrorType::Error">Error</a>&gt;</h4></section><section id="method.transfer_in_place" class="method trait-impl"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#172-174">source</a><a href="#method.transfer_in_place" class="anchor">§</a><h4 class="code-header">async fn <a href="#tymethod.transfer_in_place" class="fn">transfer_in_place</a>(
&amp;mut self,
words: &amp;mut <a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.slice.html">[Word]</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.82.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.ErrorType.html#associatedtype.Error" title="type embedded_hal_async::spi::ErrorType::Error">Error</a>&gt;</h4></section><section id="method.flush" class="method trait-impl"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#177-179">source</a><a href="#method.flush" class="anchor">§</a><h4 class="code-header">async fn <a href="#tymethod.flush" class="fn">flush</a>(&amp;mut self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.82.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.82.0/core/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.ErrorType.html#associatedtype.Error" title="type embedded_hal_async::spi::ErrorType::Error">Error</a>&gt;</h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../../trait.impl/embedded_hal_async/spi/trait.SpiBus.js" async></script></section></div></main></body></html>