mirror of
https://github.com/rtic-rs/rtic.git
synced 2024-12-26 11:59:33 +01:00
70 lines
No EOL
21 KiB
HTML
70 lines
No EOL
21 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 device trait."><title>SpiDevice 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-b0742ba02757f159.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.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="sidebar-items.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 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><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">SpiDevice</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.transaction" title="transaction">transaction</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.read" title="read">read</a></li><li><a href="#method.transfer" title="transfer">transfer</a></li><li><a href="#method.transfer_in_place" title="transfer_in_place">transfer_in_place</a></li><li><a href="#method.write" title="write">write</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-SpiDevice%3CWord%3E-for-%26mut+T" title="&mut T">&mut T</a></li></ul><h3><a href="#object-safety">Object Safety</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In embedded_<wbr>hal_<wbr>async::<wbr>spi</a></h2></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"><span class="rustdoc-breadcrumbs"><a href="../index.html">embedded_hal_async</a>::<wbr><a href="index.html">spi</a></span><h1>Trait <span class="trait">SpiDevice</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_async/spi.rs.html#13-75">source</a> </span></div><pre class="rust item-decl"><code>pub trait SpiDevice<Word: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + 'static = <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.u8.html">u8</a>>: <a class="trait" href="trait.ErrorType.html" title="trait embedded_hal_async::spi::ErrorType">ErrorType</a> {
|
|
// Required method
|
|
async fn <a href="#tymethod.transaction" class="fn">transaction</a>(
|
|
&mut self,
|
|
operations: &mut [<a class="enum" href="enum.Operation.html" title="enum embedded_hal_async::spi::Operation">Operation</a><'_, Word>],
|
|
) -> <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.83.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>>;
|
|
|
|
// Provided methods
|
|
async fn <a href="#method.read" class="fn">read</a>(&mut self, buf: &mut <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.slice.html">[Word]</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.83.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>> { ... }
|
|
<span class="item-spacer"></span> async fn <a href="#method.write" class="fn">write</a>(&mut self, buf: &<a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.slice.html">[Word]</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.83.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>> { ... }
|
|
<span class="item-spacer"></span> async fn <a href="#method.transfer" class="fn">transfer</a>(
|
|
&mut self,
|
|
read: &mut <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.slice.html">[Word]</a>,
|
|
write: &<a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.slice.html">[Word]</a>,
|
|
) -> <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.83.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>> { ... }
|
|
<span class="item-spacer"></span> async fn <a href="#method.transfer_in_place" class="fn">transfer_in_place</a>(
|
|
&mut self,
|
|
buf: &mut <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.slice.html">[Word]</a>,
|
|
) -> <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.83.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>> { ... }
|
|
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>SPI device trait.</p>
|
|
<p><code>SpiDevice</code> represents ownership over a single SPI device on a (possibly shared) bus, selected
|
|
with a CS (Chip Select) pin.</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.transaction" class="method"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#29-32">source</a><h4 class="code-header">async fn <a href="#tymethod.transaction" class="fn">transaction</a>(
|
|
&mut self,
|
|
operations: &mut [<a class="enum" href="enum.Operation.html" title="enum embedded_hal_async::spi::Operation">Operation</a><'_, Word>],
|
|
) -> <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.83.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>></h4></section></summary><div class="docblock"><p>Perform a transaction against the device.</p>
|
|
<ul>
|
|
<li>Locks the bus</li>
|
|
<li>Asserts the CS (Chip Select) pin.</li>
|
|
<li>Performs all the operations.</li>
|
|
<li><a href="trait.SpiBus.html#tymethod.flush" title="method embedded_hal_async::spi::SpiBus::flush">Flushes</a> the bus.</li>
|
|
<li>Deasserts the CS pin.</li>
|
|
<li>Unlocks the bus.</li>
|
|
</ul>
|
|
<p>The locking mechanism is implementation-defined. The only requirement is it must prevent two
|
|
transactions from executing concurrently against the same bus. Examples of implementations are:
|
|
critical sections, blocking mutexes, returning an error or panicking if the bus is already busy.</p>
|
|
<p>On bus errors the implementation should try to deassert CS.
|
|
If an error occurs while deasserting CS the bus error should take priority as the return value.</p>
|
|
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.read" class="method"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#40-42">source</a><h4 class="code-header">async fn <a href="#method.read" class="fn">read</a>(&mut self, buf: &mut <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.slice.html">[Word]</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.83.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>></h4></section></summary><div class="docblock"><p>Do a read within a transaction.</p>
|
|
<p>This is a convenience method equivalent to <code>device.read_transaction(&mut [buf])</code>.</p>
|
|
<p>See also: <a href="trait.SpiDevice.html#tymethod.transaction" title="method embedded_hal_async::spi::SpiDevice::transaction"><code>SpiDevice::transaction</code></a>, <a href="trait.SpiDevice.html#method.read" title="method embedded_hal_async::spi::SpiDevice::read"><code>SpiDevice::read</code></a></p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write" class="method"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#50-52">source</a><h4 class="code-header">async fn <a href="#method.write" class="fn">write</a>(&mut self, buf: &<a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.slice.html">[Word]</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.83.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>></h4></section></summary><div class="docblock"><p>Do a write within a transaction.</p>
|
|
<p>This is a convenience method equivalent to <code>device.write_transaction(&mut [buf])</code>.</p>
|
|
<p>See also: <a href="trait.SpiDevice.html#tymethod.transaction" title="method embedded_hal_async::spi::SpiDevice::transaction"><code>SpiDevice::transaction</code></a>, <a href="trait.SpiDevice.html#method.write" title="method embedded_hal_async::spi::SpiDevice::write"><code>SpiDevice::write</code></a></p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.transfer" class="method"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#60-63">source</a><h4 class="code-header">async fn <a href="#method.transfer" class="fn">transfer</a>(
|
|
&mut self,
|
|
read: &mut <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.slice.html">[Word]</a>,
|
|
write: &<a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.slice.html">[Word]</a>,
|
|
) -> <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.83.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>></h4></section></summary><div class="docblock"><p>Do a transfer within a transaction.</p>
|
|
<p>This is a convenience method equivalent to <code>device.transaction(&mut [Operation::Transfer(read, write)])</code>.</p>
|
|
<p>See also: <a href="trait.SpiDevice.html#tymethod.transaction" title="method embedded_hal_async::spi::SpiDevice::transaction"><code>SpiDevice::transaction</code></a>, <a href="trait.SpiBus.html#tymethod.transfer" title="method embedded_hal_async::spi::SpiBus::transfer"><code>SpiBus::transfer</code></a></p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.transfer_in_place" class="method"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#71-74">source</a><h4 class="code-header">async fn <a href="#method.transfer_in_place" class="fn">transfer_in_place</a>(
|
|
&mut self,
|
|
buf: &mut <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.slice.html">[Word]</a>,
|
|
) -> <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.83.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>></h4></section></summary><div class="docblock"><p>Do an in-place transfer within a transaction.</p>
|
|
<p>This is a convenience method equivalent to <code>device.transaction(&mut [Operation::TransferInPlace(buf)])</code>.</p>
|
|
<p>See also: <a href="trait.SpiDevice.html#tymethod.transaction" title="method embedded_hal_async::spi::SpiDevice::transaction"><code>SpiDevice::transaction</code></a>, <a href="trait.SpiBus.html#tymethod.transfer_in_place" title="method embedded_hal_async::spi::SpiBus::transfer_in_place"><code>SpiBus::transfer_in_place</code></a></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.83.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-SpiDevice%3CWord%3E-for-%26mut+T" class="impl"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#77-105">source</a><a href="#impl-SpiDevice%3CWord%3E-for-%26mut+T" class="anchor">§</a><h3 class="code-header">impl<Word: <a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + 'static, T: <a class="trait" href="trait.SpiDevice.html" title="trait embedded_hal_async::spi::SpiDevice">SpiDevice</a><Word> + ?<a class="trait" href="https://doc.rust-lang.org/1.83.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>> <a class="trait" href="trait.SpiDevice.html" title="trait embedded_hal_async::spi::SpiDevice">SpiDevice</a><Word> for <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.reference.html">&mut T</a></h3></section></summary><div class="impl-items"><section id="method.transaction" class="method trait-impl"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#79-84">source</a><a href="#method.transaction" class="anchor">§</a><h4 class="code-header">async fn <a href="#tymethod.transaction" class="fn">transaction</a>(
|
|
&mut self,
|
|
operations: &mut [<a class="enum" href="enum.Operation.html" title="enum embedded_hal_async::spi::Operation">Operation</a><'_, Word>],
|
|
) -> <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.83.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>></h4></section><section id="method.read-1" class="method trait-impl"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#87-89">source</a><a href="#method.read-1" class="anchor">§</a><h4 class="code-header">async fn <a href="#method.read" class="fn">read</a>(&mut self, buf: &mut <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.slice.html">[Word]</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.83.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>></h4></section><section id="method.write-1" class="method trait-impl"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#92-94">source</a><a href="#method.write-1" class="anchor">§</a><h4 class="code-header">async fn <a href="#method.write" class="fn">write</a>(&mut self, buf: &<a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.slice.html">[Word]</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.83.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>></h4></section><section id="method.transfer-1" class="method trait-impl"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#97-99">source</a><a href="#method.transfer-1" class="anchor">§</a><h4 class="code-header">async fn <a href="#method.transfer" class="fn">transfer</a>(
|
|
&mut self,
|
|
read: &mut <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.slice.html">[Word]</a>,
|
|
write: &<a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.slice.html">[Word]</a>,
|
|
) -> <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.83.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>></h4></section><section id="method.transfer_in_place-1" class="method trait-impl"><a class="src rightside" href="../../src/embedded_hal_async/spi.rs.html#102-104">source</a><a href="#method.transfer_in_place-1" class="anchor">§</a><h4 class="code-header">async fn <a href="#method.transfer_in_place" class="fn">transfer_in_place</a>(
|
|
&mut self,
|
|
buf: &mut <a class="primitive" href="https://doc.rust-lang.org/1.83.0/core/primitive.slice.html">[Word]</a>,
|
|
) -> <a class="enum" href="https://doc.rust-lang.org/1.83.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.83.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>></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.SpiDevice.js" async></script></section></div></main></body></html> |