diff --git a/benches/b15f.rs b/benches/b15f.rs index a4c4060..91a63f3 100644 --- a/benches/b15f.rs +++ b/benches/b15f.rs @@ -11,4 +11,18 @@ mod tests { fn bench_create_instance(b: &mut Bencher) { b.iter(|| B15F::new()); } + + #[bench] + fn bench_digital_write(b: &mut Bencher) { + let mut drv = B15F::new().unwrap(); + + b.iter(move || drv.digital_write::<0>(0xAB).unwrap()); + } + + #[bench] + fn bench_digital_read(b: &mut Bencher) { + let mut drv = B15F::new().unwrap(); + + b.iter(move || drv.digital_read::<0>().unwrap()); + } } \ No newline at end of file diff --git a/doc/b15f/b15f/index.html b/doc/b15f/b15f/index.html index 00afab9..970e2d0 100644 --- a/doc/b15f/b15f/index.html +++ b/doc/b15f/b15f/index.html @@ -1,4 +1,4 @@ -<!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="This module contains all the structures and functions related to interacting with the B15 on a high level. If you are writing code for the B15, this is the module you want to use."><meta name="keywords" content="rust, rustlang, rust-lang, b15f"><title>b15f::b15f - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../../normalize.css"><link rel="stylesheet" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../ayu.css" disabled><link rel="stylesheet" href="../../dark.css" disabled><link rel="stylesheet" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc mod"><!--[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">☰</button><a class="sidebar-logo" href="../../b15f/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../b15f/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Module b15f</a></h2><div class="sidebar-elems"><section><ul class="block"><li><a href="#structs">Structs</a></li></ul></section></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Module <a href="../index.html">b15f</a>::<wbr><a class="mod" href="#">b15f</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../../src/b15f/b15f.rs.html#1-316">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>This module contains all the structures and functions related to +<!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="This module contains all the structures and functions related to interacting with the B15 on a high level. If you are writing code for the B15, this is the module you want to use."><meta name="keywords" content="rust, rustlang, rust-lang, b15f"><title>b15f::b15f - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../../normalize.css"><link rel="stylesheet" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../ayu.css" disabled><link rel="stylesheet" href="../../dark.css" disabled><link rel="stylesheet" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc mod"><!--[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">☰</button><a class="sidebar-logo" href="../../b15f/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../b15f/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Module b15f</a></h2><div class="sidebar-elems"><section><ul class="block"><li><a href="#structs">Structs</a></li></ul></section></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Module <a href="../index.html">b15f</a>::<wbr><a class="mod" href="#">b15f</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../../src/b15f/b15f.rs.html#1-374">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>This module contains all the structures and functions related to interacting with the B15 on a high level. If you are writing code for the B15, this is the module you want to use.</p> </div></details><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.B15F.html" title="b15f::b15f::B15F struct">B15F</a></div><div class="item-right docblock-short">Structure representing the driver for the board 15</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="b15f" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0 (69f9c33d7 2022-12-12)" ></div></body></html> \ No newline at end of file diff --git a/doc/b15f/b15f/struct.B15F.html b/doc/b15f/b15f/struct.B15F.html index 9d095ad..895d93e 100644 --- a/doc/b15f/b15f/struct.B15F.html +++ b/doc/b15f/b15f/struct.B15F.html @@ -1,5 +1,5 @@ -<!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="Structure representing the driver for the board 15"><meta name="keywords" content="rust, rustlang, rust-lang, B15F"><title>B15F in b15f::b15f - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../../normalize.css"><link rel="stylesheet" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../ayu.css" disabled><link rel="stylesheet" href="../../dark.css" disabled><link rel="stylesheet" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc struct"><!--[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">☰</button><a class="sidebar-logo" href="../../b15f/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../b15f/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">B15F</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block"><li><a href="#method.digital_write">digital_write</a></li><li><a href="#method.discard">discard</a></li><li><a href="#method.get_board_info">get_board_info</a></li><li><a href="#method.new">new</a></li><li><a href="#method.test_connection">test_connection</a></li><li><a href="#method.test_int_conv">test_int_conv</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block"><li><a href="#impl-Debug-for-B15F">Debug</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block"><li><a href="#impl-RefUnwindSafe-for-B15F">!RefUnwindSafe</a></li><li><a href="#impl-Send-for-B15F">Send</a></li><li><a href="#impl-Sync-for-B15F">!Sync</a></li><li><a href="#impl-Unpin-for-B15F">Unpin</a></li><li><a href="#impl-UnwindSafe-for-B15F">!UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block"><li><a href="#impl-Any-for-B15F">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-B15F">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-B15F">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-B15F">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-B15F">Into<U></a></li><li><a href="#impl-TryFrom%3CU%3E-for-B15F">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-B15F">TryInto<U></a></li><li><a href="#impl-VZip%3CV%3E-for-B15F">VZip<V></a></li></ul></section><h2><a href="index.html">In b15f::b15f</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Struct <a href="../index.html">b15f</a>::<wbr><a href="index.html">b15f</a>::<wbr><a class="struct" href="#">B15F</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../../src/b15f/b15f.rs.html#28-30">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="item-decl"><pre class="rust struct"><code>pub struct B15F { /* private fields */ }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Structure representing the driver for the board 15</p> -</div></details><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><div id="implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-B15F" class="impl has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#32-308">source</a><a href="#impl-B15F" class="anchor"></a><h3 class="code-header">impl <a class="struct" href="struct.B15F.html" title="struct b15f::b15f::B15F">B15F</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.new" class="method has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#56-97">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fnname">new</a>() -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="struct.B15F.html" title="struct b15f::b15f::B15F">B15F</a>, Error></h4></section></summary><div class="docblock"><p>Creates a new instance of the B15</p> +<!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="Structure representing the driver for the board 15"><meta name="keywords" content="rust, rustlang, rust-lang, B15F"><title>B15F in b15f::b15f - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../../normalize.css"><link rel="stylesheet" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../ayu.css" disabled><link rel="stylesheet" href="../../dark.css" disabled><link rel="stylesheet" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc struct"><!--[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">☰</button><a class="sidebar-logo" href="../../b15f/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../b15f/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">B15F</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block"><li><a href="#method.digital_read">digital_read</a></li><li><a href="#method.digital_write">digital_write</a></li><li><a href="#method.discard">discard</a></li><li><a href="#method.get_board_info">get_board_info</a></li><li><a href="#method.new">new</a></li><li><a href="#method.test_connection">test_connection</a></li><li><a href="#method.test_int_conv">test_int_conv</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block"><li><a href="#impl-Debug-for-B15F">Debug</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block"><li><a href="#impl-RefUnwindSafe-for-B15F">!RefUnwindSafe</a></li><li><a href="#impl-Send-for-B15F">Send</a></li><li><a href="#impl-Sync-for-B15F">!Sync</a></li><li><a href="#impl-Unpin-for-B15F">Unpin</a></li><li><a href="#impl-UnwindSafe-for-B15F">!UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block"><li><a href="#impl-Any-for-B15F">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-B15F">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-B15F">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-B15F">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-B15F">Into<U></a></li><li><a href="#impl-TryFrom%3CU%3E-for-B15F">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-B15F">TryInto<U></a></li><li><a href="#impl-VZip%3CV%3E-for-B15F">VZip<V></a></li></ul></section><h2><a href="index.html">In b15f::b15f</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Struct <a href="../index.html">b15f</a>::<wbr><a href="index.html">b15f</a>::<wbr><a class="struct" href="#">B15F</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../../src/b15f/b15f.rs.html#27-29">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="item-decl"><pre class="rust struct"><code>pub struct B15F { /* private fields */ }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Structure representing the driver for the board 15</p> +</div></details><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><div id="implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-B15F" class="impl has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#31-366">source</a><a href="#impl-B15F" class="anchor"></a><h3 class="code-header">impl <a class="struct" href="struct.B15F.html" title="struct b15f::b15f::B15F">B15F</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.new" class="method has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#55-96">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fnname">new</a>() -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="struct.B15F.html" title="struct b15f::b15f::B15F">B15F</a>, Error></h4></section></summary><div class="docblock"><p>Creates a new instance of the B15</p> <p>This function will establish a connection to a connected B15 and return a handle to interact with it. Only one such instance should exist per program; calling <code>B15F::new()</code> more than once might lead to unexpected @@ -14,21 +14,52 @@ established, or if testing of that connection fails.</p> <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>b15f::B15F; <span class="kw">let </span>drv = B15F::new().unwrap();</code></pre></div> -</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.digital_write" class="method has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#128-144">source</a><h4 class="code-header">pub fn <a href="#method.digital_write" class="fnname">digital_write</a><const port: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.u8.html">u8</a>>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.u8.html">u8</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.unit.html">()</a>, Error></h4></section></summary><div class="docblock"><p>Sets the value of the specified port</p> +</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.digital_write" class="method has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#141-161">source</a><h4 class="code-header">pub fn <a href="#method.digital_write" class="fnname">digital_write</a><const PORT: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.usize.html">usize</a>>(<br> &mut self,<br> value: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.u8.html">u8</a><br>) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.unit.html">()</a>, Error></h4></section></summary><div class="docblock"><p>Sets the value of the specified port</p> <h5 id="errors-1"><a href="#errors-1">Errors</a></h5> -<p><code>port</code> can either be 0 or 1, other values will cause a compile-time +<p><code>PORT</code> can either be 0 or 1, other values will cause a compile-time error. Otherwise an <code>error::Error</code> is generated if communication with the B15 fails.</p> -<h5 id="examples-1"><a href="#examples-1">Examples</a></h5></div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_board_info" class="method has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#171-204">source</a><h4 class="code-header">pub fn <a href="#method.get_board_info" class="fnname">get_board_info</a>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.66.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="struct" href="https://doc.rust-lang.org/1.66.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, Error></h4></section></summary><div class="docblock"><p>Yields information about the installed firmware on the B15</p> +<h5 id="examples-1"><a href="#examples-1">Examples</a></h5> +<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>b15f::B15F; + +<span class="kw">fn </span>main() -> <span class="prelude-ty">Result</span><(), String> { + <span class="kw">let </span><span class="kw-2">mut </span>drv = B15F::new()<span class="question-mark">?</span>; + + drv.digital_write::<<span class="number">0</span>>(<span class="number">0xFF</span>)<span class="question-mark">?</span>; <span class="comment">// Turn on all bits of port 0 + </span>drv.digital_write::<<span class="number">1</span>>(<span class="number">0x0F</span>)<span class="question-mark">?</span>; <span class="comment">// Turn on bits 0-4 of port 1 + + // drv.digital_write::<2>(0xFF); // Compiler error + + </span><span class="prelude-val">Ok</span>(()) +}</code></pre></div> +</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.digital_read" class="method has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#186-202">source</a><h4 class="code-header">pub fn <a href="#method.digital_read" class="fnname">digital_read</a><const PORT: <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.usize.html">usize</a>>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.u8.html">u8</a>, Error></h4></section></summary><div class="docblock"><p>Reads the value of the specified port</p> +<h5 id="errors-2"><a href="#errors-2">Errors</a></h5> +<p><code>PORT</code> can either be 0 or 1, other values will cause a compile-time +error. Otherwise an <code>error::Error</code> is generated if communication +with the B15 fails.</p> +<h5 id="examples-2"><a href="#examples-2">Examples</a></h5> +<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>b15f::B15F; + +<span class="kw">fn </span>main() -> <span class="prelude-ty">Result</span><(), String> { + <span class="kw">let </span><span class="kw-2">mut </span>drv = B15F::new()<span class="question-mark">?</span>; + + <span class="kw">let _ </span>= drv.digital_read::<<span class="number">0</span>>()<span class="question-mark">?</span>; <span class="comment">// Read inputs of port 0 + </span><span class="kw">let _ </span>= drv.digital_read::<<span class="number">1</span>>()<span class="question-mark">?</span>; <span class="comment">// Read inputs of port 1 + + // drv.digital_read::<2>(); // Compiler error + + </span><span class="prelude-val">Ok</span>(()) +}</code></pre></div> +</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.get_board_info" class="method has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#229-262">source</a><h4 class="code-header">pub fn <a href="#method.get_board_info" class="fnname">get_board_info</a>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.66.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="struct" href="https://doc.rust-lang.org/1.66.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, Error></h4></section></summary><div class="docblock"><p>Yields information about the installed firmware on the B15</p> <p>Returns an array of strings, where each string contains a piece of information stored on the B15</p> <h5 id="returns-1"><a href="#returns-1">Returns</a></h5> <p>A list of strings where each string contains a piece of information about the board. What string contains what information is determined, but not explicitly listed.</p> -<h5 id="errors-2"><a href="#errors-2">Errors</a></h5> +<h5 id="errors-3"><a href="#errors-3">Errors</a></h5> <p>An <code>error::Error</code> is generated if the communication with the board fails.</p> -<h5 id="examples-2"><a href="#examples-2">Examples</a></h5> +<h5 id="examples-3"><a href="#examples-3">Examples</a></h5> <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>b15f::B15F; <span class="kw">let </span><span class="kw-2">mut </span>drv = B15F::new().unwrap(); @@ -38,19 +69,19 @@ but not explicitly listed.</p> .unwrap() .iter() .for_each(|info| <span class="macro">println!</span>(<span class="string">"{info}"</span>));</code></pre></div> -</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.discard" class="method has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#207-218">source</a><h4 class="code-header">pub fn <a href="#method.discard" class="fnname">discard</a>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.unit.html">()</a>, Error></h4></section></summary><div class="docblock"><p>Clears data in the USART buffers on this device and on the B15</p> -</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.test_int_conv" class="method has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#225-239">source</a><h4 class="code-header">pub fn <a href="#method.test_int_conv" class="fnname">test_int_conv</a>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.unit.html">()</a>, Error></h4></section></summary><div class="docblock"><p>Test the integer conversion of the USART connection</p> -<h5 id="errors-3"><a href="#errors-3">Errors</a></h5> +</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.discard" class="method has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#265-276">source</a><h4 class="code-header">pub fn <a href="#method.discard" class="fnname">discard</a>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.unit.html">()</a>, Error></h4></section></summary><div class="docblock"><p>Clears data in the USART buffers on this device and on the B15</p> +</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.test_int_conv" class="method has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#283-297">source</a><h4 class="code-header">pub fn <a href="#method.test_int_conv" class="fnname">test_int_conv</a>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.unit.html">()</a>, Error></h4></section></summary><div class="docblock"><p>Test the integer conversion of the USART connection</p> +<h5 id="errors-4"><a href="#errors-4">Errors</a></h5> <p>If an error occurs in the conversion or the communication with the board, an <code>error::Error</code> will be returned.</p> -</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.test_connection" class="method has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#263-276">source</a><h4 class="code-header">pub fn <a href="#method.test_connection" class="fnname">test_connection</a>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.unit.html">()</a>, Error></h4></section></summary><div class="docblock"><p>Tests the connetion to the B15</p> +</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.test_connection" class="method has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#321-334">source</a><h4 class="code-header">pub fn <a href="#method.test_connection" class="fnname">test_connection</a>(&mut self) -> <a class="enum" href="https://doc.rust-lang.org/1.66.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.unit.html">()</a>, Error></h4></section></summary><div class="docblock"><p>Tests the connetion to the B15</p> <p>To test the connection a <code>Request::Test</code> request will be sent to the board together with a randomly generated value. If the board returns that value the connection is working correctly.</p> -<h5 id="errors-4"><a href="#errors-4">Errors</a></h5> +<h5 id="errors-5"><a href="#errors-5">Errors</a></h5> <p>An <code>error::Error</code> is returned if the test fails, or if the communication itself fails.</p> -<h5 id="examples-3"><a href="#examples-3">Examples</a></h5> +<h5 id="examples-4"><a href="#examples-4">Examples</a></h5> <div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>b15f::B15F; <span class="kw">fn </span>main() { @@ -60,7 +91,7 @@ communication itself fails.</p> <span class="macro">panic!</span>(<span class="string">"Connection is not working: {err}"</span>); } }</code></pre></div> -</div></details></div></details></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Debug-for-B15F" class="impl has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#310-316">source</a><a href="#impl-Debug-for-B15F" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.B15F.html" title="struct b15f::b15f::B15F">B15F</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#311-315">source</a><a href="#method.fmt" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.66.0/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/1.66.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.66.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.66.0/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><section id="impl-RefUnwindSafe-for-B15F" class="impl has-srclink"><a href="#impl-RefUnwindSafe-for-B15F" class="anchor"></a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.B15F.html" title="struct b15f::b15f::B15F">B15F</a></h3></section><section id="impl-Send-for-B15F" class="impl has-srclink"><a href="#impl-Send-for-B15F" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.B15F.html" title="struct b15f::b15f::B15F">B15F</a></h3></section><section id="impl-Sync-for-B15F" class="impl has-srclink"><a href="#impl-Sync-for-B15F" class="anchor"></a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.B15F.html" title="struct b15f::b15f::B15F">B15F</a></h3></section><section id="impl-Unpin-for-B15F" class="impl has-srclink"><a href="#impl-Unpin-for-B15F" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.B15F.html" title="struct b15f::b15f::B15F">B15F</a></h3></section><section id="impl-UnwindSafe-for-B15F" class="impl has-srclink"><a href="#impl-UnwindSafe-for-B15F" class="anchor"></a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.B15F.html" title="struct b15f::b15f::B15F">B15F</a></h3></section></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Any-for-B15F" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.66.0/src/core/any.rs.html#200">source</a><a href="#impl-Any-for-B15F" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.66.0/src/core/any.rs.html#201">source</a><a href="#method.type_id" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.66.0/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.66.0/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.66.0/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-B15F" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.66.0/src/core/borrow.rs.html#211">source</a><a href="#impl-Borrow%3CT%3E-for-B15F" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.66.0/src/core/borrow.rs.html#213">source</a></span><a href="#method.borrow" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.66.0/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&</a>T</h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.66.0/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-B15F" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.66.0/src/core/borrow.rs.html#220">source</a><a href="#impl-BorrowMut%3CT%3E-for-B15F" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.66.0/src/core/borrow.rs.html#221">source</a></span><a href="#method.borrow_mut" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.66.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>T</h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.66.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-B15F" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.66.0/src/core/convert/mod.rs.html#733">source</a><a href="#impl-From%3CT%3E-for-B15F" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.66.0/src/core/convert/mod.rs.html#736">source</a></span><a href="#method.from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.66.0/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p> +</div></details></div></details></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Debug-for-B15F" class="impl has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#368-374">source</a><a href="#impl-Debug-for-B15F" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.B15F.html" title="struct b15f::b15f::B15F">B15F</a></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/b15f/b15f.rs.html#369-373">source</a><a href="#method.fmt" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.66.0/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/1.66.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/1.66.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.66.0/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><section id="impl-RefUnwindSafe-for-B15F" class="impl has-srclink"><a href="#impl-RefUnwindSafe-for-B15F" class="anchor"></a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.B15F.html" title="struct b15f::b15f::B15F">B15F</a></h3></section><section id="impl-Send-for-B15F" class="impl has-srclink"><a href="#impl-Send-for-B15F" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.B15F.html" title="struct b15f::b15f::B15F">B15F</a></h3></section><section id="impl-Sync-for-B15F" class="impl has-srclink"><a href="#impl-Sync-for-B15F" class="anchor"></a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.B15F.html" title="struct b15f::b15f::B15F">B15F</a></h3></section><section id="impl-Unpin-for-B15F" class="impl has-srclink"><a href="#impl-Unpin-for-B15F" class="anchor"></a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.B15F.html" title="struct b15f::b15f::B15F">B15F</a></h3></section><section id="impl-UnwindSafe-for-B15F" class="impl has-srclink"><a href="#impl-UnwindSafe-for-B15F" class="anchor"></a><h3 class="code-header">impl !<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.B15F.html" title="struct b15f::b15f::B15F">B15F</a></h3></section></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Any-for-B15F" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.66.0/src/core/any.rs.html#200">source</a><a href="#impl-Any-for-B15F" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<span class="where fmt-newline">where<br> T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.66.0/src/core/any.rs.html#201">source</a><a href="#method.type_id" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.66.0/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.66.0/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.66.0/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-B15F" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.66.0/src/core/borrow.rs.html#211">source</a><a href="#impl-Borrow%3CT%3E-for-B15F" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.66.0/src/core/borrow.rs.html#213">source</a></span><a href="#method.borrow" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.66.0/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&</a>T</h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.66.0/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-B15F" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.66.0/src/core/borrow.rs.html#220">source</a><a href="#impl-BorrowMut%3CT%3E-for-B15F" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<span class="where fmt-newline">where<br> T: ?<a class="trait" href="https://doc.rust-lang.org/1.66.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/91522" title="Tracking issue for const_borrow">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.66.0/src/core/borrow.rs.html#221">source</a></span><a href="#method.borrow_mut" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.66.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.66.0/std/primitive.reference.html">&mut </a>T</h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.66.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-B15F" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.66.0/src/core/convert/mod.rs.html#733">source</a><a href="#impl-From%3CT%3E-for-B15F" class="anchor"></a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.from" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.66.0/src/core/convert/mod.rs.html#736">source</a></span><a href="#method.from" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.66.0/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p> </div></details></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-B15F" class="impl has-srclink"><a class="srclink rightside" href="https://doc.rust-lang.org/1.66.0/src/core/convert/mod.rs.html#717">source</a><a href="#impl-Into%3CU%3E-for-B15F" class="anchor"></a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<span class="where fmt-newline">where<br> U: <a class="trait" href="https://doc.rust-lang.org/1.66.0/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</span></h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.into" class="method trait-impl has-srclink"><span class="rightside"><span class="since" title="const unstable">const: <a href="https://github.com/rust-lang/rust/issues/88674" title="Tracking issue for const_convert">unstable</a></span> · <a class="srclink" href="https://doc.rust-lang.org/1.66.0/src/core/convert/mod.rs.html#725">source</a></span><a href="#method.into" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.66.0/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p> <p>That is, this conversion is whatever the implementation of <code><a href="https://doc.rust-lang.org/1.66.0/core/convert/trait.From.html" title="From">From</a><T> for U</code> chooses to do.</p> diff --git a/doc/b15f/index.html b/doc/b15f/index.html index d764cff..cdd9c19 100644 --- a/doc/b15f/index.html +++ b/doc/b15f/index.html @@ -1,4 +1,4 @@ -<!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="Driver code for the board 15"><meta name="keywords" content="rust, rustlang, rust-lang, b15f"><title>b15f - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="../crates.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.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">☰</button><a class="sidebar-logo" href="../b15f/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../b15f/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Crate b15f</a></h2><div class="sidebar-elems"><ul class="block"><li class="version">Version 0.1.0</li><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#reexports">Re-exports</a></li><li><a href="#modules">Modules</a></li><li><a href="#macros">Macros</a></li></ul></section></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Crate <a class="mod" href="#">b15f</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/b15f/lib.rs.html#1-20">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Driver code for the board 15</p> +<!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="Driver code for the board 15"><meta name="keywords" content="rust, rustlang, rust-lang, b15f"><title>b15f - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="../crates.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.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">☰</button><a class="sidebar-logo" href="../b15f/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../b15f/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Crate b15f</a></h2><div class="sidebar-elems"><ul class="block"><li class="version">Version 0.1.0</li><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#reexports">Re-exports</a></li><li><a href="#modules">Modules</a></li><li><a href="#macros">Macros</a></li></ul></section></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Crate <a class="mod" href="#">b15f</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/b15f/lib.rs.html#1-21">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Driver code for the board 15</p> <p>It aims to be syntactically similar to the <a href="https://github.com/devfix/b15f"><code>original</code></a> implementation. The original repository is no longer maintained, and this library doesn’t maintain it either, it simply provides the same functionality in another language.</p> diff --git a/doc/search-index.js b/doc/search-index.js index 0903a4e..f8ad1b4 100644 --- a/doc/search-index.js +++ b/doc/search-index.js @@ -1,5 +1,5 @@ var searchIndex = JSON.parse('{\ -"b15f":{"doc":"Driver code for the board 15","t":[2,0,14,3,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11],"n":["B15F","b15f","build_request","B15F","borrow","borrow_mut","digital_write","discard","fmt","from","get_board_info","into","new","test_connection","test_int_conv","try_from","try_into","type_id","vzip"],"q":["b15f","","","b15f::b15f","","","","","","","","","","","","","","",""],"d":["","This module contains all the structures and functions …","Builds a new request buffer from the given data","Structure representing the driver for the board 15","","","Sets the value of the specified port","Clears data in the USART buffers on this device and on the …","","Returns the argument unchanged.","Yields information about the installed firmware on the B15","Calls <code>U::from(self)</code>.","Creates a new instance of the B15","Tests the connetion to the B15","Test the integer conversion of the USART connection","","","",""],"i":[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],"f":[0,0,0,0,[[]],[[]],[[1,2],[[3,[0]]]],[1,[[3,[0]]]],[[1,4],5],[[]],[1,[[3,[[7,[6]],0]]]],[[]],[[],[[3,[1,0]]]],[1,[[3,[0]]]],[1,[[3,[0]]]],[[],3],[[],3],[[],8],[[]]],"p":[[3,"B15F"],[15,"u8"],[4,"Result"],[3,"Formatter"],[6,"Result"],[3,"String"],[3,"Vec"],[3,"TypeId"]]}\ +"b15f":{"doc":"Driver code for the board 15","t":[2,0,14,3,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11],"n":["B15F","b15f","build_request","B15F","borrow","borrow_mut","digital_read","digital_write","discard","fmt","from","get_board_info","into","new","test_connection","test_int_conv","try_from","try_into","type_id","vzip"],"q":["b15f","","","b15f::b15f","","","","","","","","","","","","","","","",""],"d":["","This module contains all the structures and functions …","Builds a new request buffer from the given data","Structure representing the driver for the board 15","","","Reads the value of the specified port","Sets the value of the specified port","Clears data in the USART buffers on this device and on the …","","Returns the argument unchanged.","Yields information about the installed firmware on the B15","Calls <code>U::from(self)</code>.","Creates a new instance of the B15","Tests the connetion to the B15","Test the integer conversion of the USART connection","","","",""],"i":[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],"f":[0,0,0,0,[[]],[[]],[1,[[3,[2,0]]]],[[1,2],[[3,[0]]]],[1,[[3,[0]]]],[[1,4],5],[[]],[1,[[3,[[7,[6]],0]]]],[[]],[[],[[3,[1,0]]]],[1,[[3,[0]]]],[1,[[3,[0]]]],[[],3],[[],3],[[],8],[[]]],"p":[[3,"B15F"],[15,"u8"],[4,"Result"],[3,"Formatter"],[6,"Result"],[3,"String"],[3,"Vec"],[3,"TypeId"]]}\ }'); if (typeof window !== 'undefined' && window.initSearch) {window.initSearch(searchIndex)}; if (typeof exports !== 'undefined') {exports.searchIndex = searchIndex}; diff --git a/doc/source-files.js b/doc/source-files.js index 5669024..b008575 100644 --- a/doc/source-files.js +++ b/doc/source-files.js @@ -1,4 +1,4 @@ var sourcesIndex = JSON.parse('{\ -"b15f":["",[],["b15f.rs","error.rs","lib.rs","request.rs"]]\ +"b15f":["",[],["assert.rs","b15f.rs","error.rs","lib.rs","request.rs"]]\ }'); createSourceSidebar(); diff --git a/doc/src/b15f/assert.rs.html b/doc/src/b15f/assert.rs.html new file mode 100644 index 0000000..d8dbe2c --- /dev/null +++ b/doc/src/b15f/assert.rs.html @@ -0,0 +1,19 @@ +<!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="Source of the Rust file `src/assert.rs`."><meta name="keywords" content="rust, rustlang, rust-lang"><title>assert.rs - source</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../../normalize.css"><link rel="stylesheet" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../ayu.css" disabled><link rel="stylesheet" href="../../dark.css" disabled><link rel="stylesheet" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="../../source-script.js"></script><script defer src="../../source-files.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc source"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"></nav><main><div class="width-limiter"><nav class="sub"><a class="sub-logo-container" href="../../b15f/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><form class="search-form"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></form></nav><section id="main-content" class="content"><div class="example-wrap"><pre class="src-line-numbers"><span id="1">1</span> +<span id="2">2</span> +<span id="3">3</span> +<span id="4">4</span> +<span id="5">5</span> +<span id="6">6</span> +<span id="7">7</span> +<span id="8">8</span> +<span id="9">9</span> +</pre><pre class="rust"><code><span class="kw">struct </span>AssertInRange<<span class="kw">const </span>VALUE: usize, <span class="kw">const </span>MIN: usize, <span class="kw">const </span>MAX: usize>; + +<span class="kw">impl</span><<span class="kw">const </span>VALUE: usize, <span class="kw">const </span>MIN: usize, <span class="kw">const </span>MAX: usize> AssertInRange<VALUE, MIN, MAX> { + <span class="kw">const </span>OK: () = <span class="macro">assert!</span>(MIN <= VALUE && VALUE <= MAX); +} + +<span class="kw">pub fn </span>assert_in_range<<span class="kw">const </span>VALUE: usize, <span class="kw">const </span>MIN: usize, <span class="kw">const </span>MAX: usize> () { + <span class="kw">let </span>() = AssertInRange::<VALUE, MIN, MAX>::OK; +}</code></pre></div> +</section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="b15f" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0 (69f9c33d7 2022-12-12)" ></div></body></html> \ No newline at end of file diff --git a/doc/src/b15f/b15f.rs.html b/doc/src/b15f/b15f.rs.html index 004a9f0..173dca6 100644 --- a/doc/src/b15f/b15f.rs.html +++ b/doc/src/b15f/b15f.rs.html @@ -314,6 +314,64 @@ <span id="314">314</span> <span id="315">315</span> <span id="316">316</span> +<span id="317">317</span> +<span id="318">318</span> +<span id="319">319</span> +<span id="320">320</span> +<span id="321">321</span> +<span id="322">322</span> +<span id="323">323</span> +<span id="324">324</span> +<span id="325">325</span> +<span id="326">326</span> +<span id="327">327</span> +<span id="328">328</span> +<span id="329">329</span> +<span id="330">330</span> +<span id="331">331</span> +<span id="332">332</span> +<span id="333">333</span> +<span id="334">334</span> +<span id="335">335</span> +<span id="336">336</span> +<span id="337">337</span> +<span id="338">338</span> +<span id="339">339</span> +<span id="340">340</span> +<span id="341">341</span> +<span id="342">342</span> +<span id="343">343</span> +<span id="344">344</span> +<span id="345">345</span> +<span id="346">346</span> +<span id="347">347</span> +<span id="348">348</span> +<span id="349">349</span> +<span id="350">350</span> +<span id="351">351</span> +<span id="352">352</span> +<span id="353">353</span> +<span id="354">354</span> +<span id="355">355</span> +<span id="356">356</span> +<span id="357">357</span> +<span id="358">358</span> +<span id="359">359</span> +<span id="360">360</span> +<span id="361">361</span> +<span id="362">362</span> +<span id="363">363</span> +<span id="364">364</span> +<span id="365">365</span> +<span id="366">366</span> +<span id="367">367</span> +<span id="368">368</span> +<span id="369">369</span> +<span id="370">370</span> +<span id="371">371</span> +<span id="372">372</span> +<span id="373">373</span> +<span id="374">374</span> </pre><pre class="rust"><code><span class="doccomment">//! This module contains all the structures and functions related to //! interacting with the B15 on a high level. If you are writing code //! for the B15, this is the module you want to use. @@ -321,9 +379,8 @@ </span><span class="kw">use </span>std::{process::Command, time::Duration, fmt::Debug, thread::sleep}; <span class="kw">use </span>rand::Rng; <span class="kw">use </span>serialport::SerialPort; -<span class="kw">use </span><span class="kw">crate</span>::error::Error; -<span class="kw">use crate</span>::{request::Request, build_request}; +<span class="kw">use crate</span>::{assert::assert_in_range, error::Error, request::Request, build_request}; <span class="macro">macro_rules! </span>log { (<span class="macro-nonterminal">$text</span>: literal, $(<span class="macro-nonterminal">$arg</span>:tt)<span class="kw-2">*</span>) => (<span class="macro">println!</span>(<span class="macro">concat!</span>(<span class="string">"[B15F] "</span>, <span class="macro-nonterminal">$text</span>), $(<span class="macro-nonterminal">$arg</span>)<span class="kw-2">*</span>)); @@ -435,30 +492,89 @@ <span class="doccomment">/// Sets the value of the specified port /// /// # Errors - /// `port` can either be 0 or 1, other values will cause a compile-time + /// `PORT` can either be 0 or 1, other values will cause a compile-time /// error. Otherwise an `error::Error` is generated if communication /// with the B15 fails. /// /// # Examples + /// ``` + /// use b15f::B15F; /// - </span><span class="kw">pub fn </span>digital_write<<span class="kw">const </span>port: u8> (<span class="kw-2">&mut </span><span class="self">self</span>, value: u8) -> <span class="prelude-ty">Result</span><(), Error> { - <span class="macro">assert!</span>(port == <span class="number">0 </span>|| port == <span class="number">1</span>); + /// fn main() -> Result<(), String> { + /// let mut drv = B15F::new()?; + /// + /// drv.digital_write::<0>(0xFF)?; // Turn on all bits of port 0 + /// drv.digital_write::<1>(0x0F)?; // Turn on bits 0-4 of port 1 + /// + /// // drv.digital_write::<2>(0xFF); // Compiler error + /// + /// Ok(()) + /// } + /// ``` + /// + </span><span class="kw">pub fn </span>digital_write<<span class="kw">const </span>PORT: usize> (<span class="kw-2">&mut </span><span class="self">self</span>, value: u8) -> <span class="prelude-ty">Result</span><(), Error> { + assert_in_range::<PORT, <span class="number">0</span>, <span class="number">1</span>>(); <span class="kw">let </span>reversed = value.reverse_bits(); - <span class="kw">let </span>request = <span class="kw">if </span>port == <span class="number">0 </span>{ Request::DigitalWrite0 } <span class="kw">else </span>{ Request::DigitalWrite1 }; - + <span class="kw">let </span>request = <span class="kw">match </span>PORT { + <span class="number">0 </span>=> Request::DigitalWrite0, + <span class="number">1 </span>=> Request::DigitalWrite1, + <span class="kw">_ </span>=> <span class="macro">panic!</span>(<span class="string">"Report this issue to someone, this should not ever be visible."</span>) + }; + <span class="self">self</span>.usart.write(<span class="macro">build_request!</span>[request, reversed])<span class="question-mark">?</span>; <span class="kw">let </span><span class="kw-2">mut </span>aw: [u8; <span class="number">1</span>] = [<span class="number">0</span>; <span class="number">1</span>]; <span class="self">self</span>.usart.read(<span class="kw-2">&mut </span>aw)<span class="question-mark">?</span>; <span class="kw">if </span>aw[<span class="number">0</span>] != B15F::MSG_OK { - <span class="kw">return </span><span class="prelude-val">Err</span>(<span class="macro">format!</span>(<span class="string">"Setting Port {} failed"</span>, port).into()); + <span class="kw">return </span><span class="prelude-val">Err</span>(<span class="macro">format!</span>(<span class="string">"Setting Port {} failed"</span>, PORT).into()); } <span class="prelude-val">Ok</span>(()) } + <span class="doccomment">/// Reads the value of the specified port + /// + /// # Errors + /// `PORT` can either be 0 or 1, other values will cause a compile-time + /// error. Otherwise an `error::Error` is generated if communication + /// with the B15 fails. + /// + /// # Examples + /// ``` + /// use b15f::B15F; + /// + /// fn main() -> Result<(), String> { + /// let mut drv = B15F::new()?; + /// + /// let _ = drv.digital_read::<0>()?; // Read inputs of port 0 + /// let _ = drv.digital_read::<1>()?; // Read inputs of port 1 + /// + /// // drv.digital_read::<2>(); // Compiler error + /// + /// Ok(()) + /// } + /// ``` + /// + </span><span class="kw">pub fn </span>digital_read<<span class="kw">const </span>PORT: usize> (<span class="kw-2">&mut </span><span class="self">self</span>) -> <span class="prelude-ty">Result</span><u8, Error> { + assert_in_range::<PORT, <span class="number">0</span>, <span class="number">1</span>>(); + + <span class="kw">let </span>request = <span class="kw">match </span>PORT { + <span class="number">0 </span>=> Request::DigitalRead0, + <span class="number">1 </span>=> Request::DigitalRead1, + <span class="kw">_ </span>=> <span class="macro">panic!</span>(<span class="string">"Report this issue to someone, this should not ever be visible."</span>) + }; + + <span class="self">self</span>.usart.clear(serialport::ClearBuffer::Input)<span class="question-mark">?</span>; + <span class="self">self</span>.usart.write(<span class="macro">build_request!</span>[request])<span class="question-mark">?</span>; + + <span class="kw">let </span><span class="kw-2">mut </span>aw: [u8; <span class="number">1</span>] = [<span class="number">0</span>; <span class="number">1</span>]; + <span class="self">self</span>.usart.read(<span class="kw-2">&mut </span>aw)<span class="question-mark">?</span>; + + <span class="prelude-val">Ok</span>(u8::reverse_bits(aw[<span class="number">0</span>])) + } + <span class="doccomment">/// Yields information about the installed firmware on the B15 /// /// Returns an array of strings, where each string contains a piece diff --git a/doc/src/b15f/error.rs.html b/doc/src/b15f/error.rs.html index 1310124..775510a 100644 --- a/doc/src/b15f/error.rs.html +++ b/doc/src/b15f/error.rs.html @@ -40,6 +40,12 @@ <span id="40">40</span> <span id="41">41</span> <span id="42">42</span> +<span id="43">43</span> +<span id="44">44</span> +<span id="45">45</span> +<span id="46">46</span> +<span id="47">47</span> +<span id="48">48</span> </pre><pre class="rust"><code><span class="kw">use </span>std::fmt::Display; <span class="attribute">#[derive(Debug)] @@ -77,6 +83,12 @@ } } +<span class="kw">impl </span>From<Error> <span class="kw">for </span>String { + <span class="kw">fn </span>from(err: Error) -> <span class="self">Self </span>{ + err.message + } +} + <span class="kw">impl </span>Display <span class="kw">for </span>Error { <span class="kw">fn </span>fmt(<span class="kw-2">&</span><span class="self">self</span>, f: <span class="kw-2">&mut </span>std::fmt::Formatter<<span class="lifetime">'_</span>>) -> std::fmt::Result { <span class="macro">write!</span>(f, <span class="string">"{}"</span>, <span class="self">self</span>.message) diff --git a/doc/src/b15f/lib.rs.html b/doc/src/b15f/lib.rs.html index c99c952..7dc4593 100644 --- a/doc/src/b15f/lib.rs.html +++ b/doc/src/b15f/lib.rs.html @@ -18,6 +18,7 @@ <span id="18">18</span> <span id="19">19</span> <span id="20">20</span> +<span id="21">21</span> </pre><pre class="rust"><code><span class="attribute">#![deny(missing_docs, missing_debug_implementations, trivial_casts, @@ -36,6 +37,7 @@ </span><span class="kw">pub mod </span>b15f; <span class="kw">mod </span>request; <span class="kw">mod </span>error; +<span class="kw">mod </span>assert; <span class="kw">pub use </span><span class="kw">crate</span>::b15f::B15F;</code></pre></div> </section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="b15f" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0 (69f9c33d7 2022-12-12)" ></div></body></html> \ No newline at end of file diff --git a/doc/src/b15f/request.rs.html b/doc/src/b15f/request.rs.html index 49544b3..cd90f5c 100644 --- a/doc/src/b15f/request.rs.html +++ b/doc/src/b15f/request.rs.html @@ -25,6 +25,8 @@ <span id="25">25</span> <span id="26">26</span> <span id="27">27</span> +<span id="28">28</span> +<span id="29">29</span> </pre><pre class="rust"><code><span class="doccomment">//! This module contains the request data used to communicate //! with the B15 via USART. //! @@ -51,5 +53,7 @@ DigitalWrite0 = <span class="number">5</span>, DigitalWrite1 = <span class="number">6</span>, -}</code></pre></div> + DigitalRead0 = <span class="number">7</span>, + DigitalRead1 = <span class="number">8 +</span>}</code></pre></div> </section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="b15f" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0 (69f9c33d7 2022-12-12)" ></div></body></html> \ No newline at end of file diff --git a/examples/nightrider.rs b/examples/nightrider.rs index 8972314..df75f47 100644 --- a/examples/nightrider.rs +++ b/examples/nightrider.rs @@ -2,14 +2,14 @@ use std::{thread::sleep, time::Duration}; use b15f::b15f::B15F; -fn main() { - let mut drv = B15F::new().unwrap(); +fn main() -> Result<(), String> { + let mut drv = B15F::new()?; let mut position = 0; let mut direction = 1; loop { - drv.digital_write::<0>(1 << position); + drv.digital_write::<0>(1 << position)?; position += direction; if position >= 7 || position <= 0 { diff --git a/examples/read.rs b/examples/read.rs new file mode 100644 index 0000000..87e2434 --- /dev/null +++ b/examples/read.rs @@ -0,0 +1,8 @@ +use b15f::b15f::B15F; + +fn main() -> Result<(), String> { + let mut drv = B15F::new()?; + + println!("{}", drv.digital_read::<0>().unwrap()); + Ok(()) +} \ No newline at end of file diff --git a/src/b15f.rs b/src/b15f.rs index 1a1955c..e23f560 100644 --- a/src/b15f.rs +++ b/src/b15f.rs @@ -118,18 +118,36 @@ impl B15F { /// Sets the value of the specified port /// /// # Errors - /// `port` can either be 0 or 1, other values will cause a compile-time + /// `PORT` can either be 0 or 1, other values will cause a compile-time /// error. Otherwise an `error::Error` is generated if communication /// with the B15 fails. /// /// # Examples + /// ``` + /// use b15f::B15F; + /// + /// fn main() -> Result<(), String> { + /// let mut drv = B15F::new()?; + /// + /// drv.digital_write::<0>(0xFF)?; // Turn on all bits of port 0 + /// drv.digital_write::<1>(0x0F)?; // Turn on bits 0-4 of port 1 + /// + /// // drv.digital_write::<2>(0xFF); // Compiler error + /// + /// Ok(()) + /// } + /// ``` /// pub fn digital_write<const PORT: usize> (&mut self, value: u8) -> Result<(), Error> { assert_in_range::<PORT, 0, 1>(); let reversed = value.reverse_bits(); - let request = if PORT == 0 { Request::DigitalWrite0 } else { Request::DigitalWrite1 }; - + let request = match PORT { + 0 => Request::DigitalWrite0, + 1 => Request::DigitalWrite1, + _ => panic!("Report this issue to someone, this should not ever be visible.") + }; + self.usart.write(build_request![request, reversed])?; let mut aw: [u8; 1] = [0; 1]; @@ -142,6 +160,47 @@ impl B15F { Ok(()) } + /// Reads the value of the specified port + /// + /// # Errors + /// `PORT` can either be 0 or 1, other values will cause a compile-time + /// error. Otherwise an `error::Error` is generated if communication + /// with the B15 fails. + /// + /// # Examples + /// ``` + /// use b15f::B15F; + /// + /// fn main() -> Result<(), String> { + /// let mut drv = B15F::new()?; + /// + /// let _ = drv.digital_read::<0>()?; // Read inputs of port 0 + /// let _ = drv.digital_read::<1>()?; // Read inputs of port 1 + /// + /// // drv.digital_read::<2>(); // Compiler error + /// + /// Ok(()) + /// } + /// ``` + /// + pub fn digital_read<const PORT: usize> (&mut self) -> Result<u8, Error> { + assert_in_range::<PORT, 0, 1>(); + + let request = match PORT { + 0 => Request::DigitalRead0, + 1 => Request::DigitalRead1, + _ => panic!("Report this issue to someone, this should not ever be visible.") + }; + + self.usart.clear(serialport::ClearBuffer::Input)?; + self.usart.write(build_request![request])?; + + let mut aw: [u8; 1] = [0; 1]; + self.usart.read(&mut aw)?; + + Ok(u8::reverse_bits(aw[0])) + } + /// Yields information about the installed firmware on the B15 /// /// Returns an array of strings, where each string contains a piece diff --git a/src/error.rs b/src/error.rs index 9efc9e3..8619d98 100644 --- a/src/error.rs +++ b/src/error.rs @@ -35,6 +35,12 @@ impl From<String> for Error { } } +impl From<Error> for String { + fn from(err: Error) -> Self { + err.message + } +} + impl Display for Error { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{}", self.message) diff --git a/src/request.rs b/src/request.rs index d268c91..dd66cf8 100644 --- a/src/request.rs +++ b/src/request.rs @@ -24,4 +24,6 @@ pub enum Request { DigitalWrite0 = 5, DigitalWrite1 = 6, + DigitalRead0 = 7, + DigitalRead1 = 8 } \ No newline at end of file