Merge remote-tracking branch 'origin/master' into rj/log

* origin/master:
  remove unused dependencies
  remove unused dependencies
This commit is contained in:
Robert Jördens 2021-05-13 18:27:11 +02:00
commit 5d37963ec2
4 changed files with 40 additions and 30 deletions

42
Cargo.lock generated
View File

@ -180,6 +180,17 @@ dependencies = [
"syn",
]
[[package]]
name = "derivative"
version = "2.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "derive_miniconf"
version = "0.1.0"
@ -195,7 +206,6 @@ name = "dsp"
version = "0.1.0"
dependencies = [
"easybench",
"libm",
"miniconf",
"ndarray",
"num",
@ -354,12 +364,6 @@ version = "0.2.93"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9385f66bf6105b241aa65a61cb923ef20efc665cb9f9bb50ac2f0c4b7f378d41"
[[package]]
name = "libm"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a"
[[package]]
name = "log"
version = "0.4.14"
@ -517,6 +521,27 @@ dependencies = [
"autocfg",
]
[[package]]
name = "num_enum"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "226b45a5c2ac4dd696ed30fa6b94b057ad909c7b7fc2e0d0808192bced894066"
dependencies = [
"derivative",
"num_enum_derive",
]
[[package]]
name = "num_enum_derive"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c0fd9eba1d5db0994a239e09c1be402d35622277e35468ba891aa5e3188ce7e"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "paste"
version = "1.0.5"
@ -740,14 +765,13 @@ dependencies = [
"cortex-m-rtic",
"dsp",
"embedded-hal",
"enum-iterator",
"generic-array 0.14.4",
"heapless 0.6.1",
"log",
"mcp23017",
"miniconf",
"minimq",
"nb 1.0.0",
"num_enum",
"paste",
"rtt-logger",
"rtt-target",

View File

@ -39,11 +39,10 @@ cortex-m-rtic = "0.5.6"
embedded-hal = "0.2.4"
nb = "1.0.0"
asm-delay = "0.9.0"
enum-iterator = "0.6.0"
num_enum = { version = "0.5.1", default-features = false }
paste = "1"
dsp = { path = "dsp" }
ad9959 = { path = "ad9959" }
generic-array = "0.14"
miniconf = "0.1.0"
shared-bus = {version = "0.2.2", features = ["cortex-m"] }
serde-json-core = "0.3"

View File

@ -5,7 +5,6 @@ authors = ["Robert Jördens <rj@quartiq.de>"]
edition = "2018"
[dependencies]
libm = "0.2.1"
serde = { version = "1.0", features = ["derive"], default-features = false }
num = { version = "0.4.0", default-features = false }
miniconf = "0.1"

View File

@ -2,11 +2,12 @@ use miniconf::Miniconf;
use serde::{Deserialize, Serialize};
use core::convert::TryFrom;
use enum_iterator::IntoEnumIterator;
use num_enum::TryFromPrimitive;
#[derive(
Copy, Clone, Debug, Serialize, Deserialize, IntoEnumIterator, Miniconf,
Copy, Clone, Debug, Serialize, Deserialize, TryFromPrimitive, Miniconf,
)]
#[repr(u8)]
pub enum Gain {
G1 = 0b00,
G2 = 0b01,
@ -32,20 +33,6 @@ impl Gain {
}
}
impl TryFrom<u8> for Gain {
type Error = ();
fn try_from(value: u8) -> Result<Self, Self::Error> {
for gain in Gain::into_enum_iter() {
if value == gain as u8 {
return Ok(gain);
}
}
Err(())
}
}
impl<A0, A1> ProgrammableGainAmplifier<A0, A1>
where
A0: embedded_hal::digital::v2::StatefulOutputPin,
@ -82,7 +69,7 @@ where
}
/// Get the programmed gain of the analog front-end.
pub fn get_gain(&self) -> Result<Gain, ()> {
pub fn get_gain(&self) -> Gain {
let mut code: u8 = 0;
if self.a0.is_set_high().unwrap() {
code |= 0b1;
@ -91,6 +78,7 @@ where
code |= 0b10;
}
Gain::try_from(code)
// NOTE(unwrap): All possibilities covered.
Gain::try_from(code).unwrap()
}
}