From 4274134812e1887d1703b9bca7912029dc9ccc27 Mon Sep 17 00:00:00 2001 From: Felipe Balbi Date: Wed, 29 Apr 2026 06:20:04 -0700 Subject: [PATCH] Bump device-driver to 1.0.9 Updates the `device-driver` dependency from 1.0.7 to 1.0.9 and refreshes Cargo.lock. No `supply-chain/` config in this repo, so no cargo-vet certification was needed. While at that also bump MSRV to 1.90 because of the new device-driver update. Assisted-by: Claude:claude-opus-4.7 --- .github/workflows/check.yml | 18 +-- Cargo.lock | 118 ++++------------ Cargo.toml | 4 +- src/inner.rs | 266 +++++++----------------------------- src/lib.rs | 6 +- 5 files changed, 78 insertions(+), 334 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 13153ab..cee50d6 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -158,23 +158,7 @@ jobs: strategy: fail-fast: false matrix: - msrv: ["1.85"] # We're relying on namespaced-features, which - # was released in 1.60 - # - # We also depend on `fixed' which requires rust - # 1.71 - # - # Additionally, we depend on embedded-hal-async - # which requires 1.75 - # - # embassy-time requires 1.79 due to - # collapse_debuginfo - # - # embassy upstream switched to rust 1.83 - # - # f32::abs moved to core from std - # - # need edition 2024 + msrv: ["1.90"] name: ubuntu / ${{ matrix.msrv }} steps: diff --git a/Cargo.lock b/Cargo.lock index 6a67544..c5b2bb8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,7 +51,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d6ab5630b3d5eaf232620167977f95eb51f3432fc76852328774afbd242d4358" dependencies = [ "memchr", - "winnow 0.7.13", + "winnow", ] [[package]] @@ -107,9 +107,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.10.1" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" [[package]] name = "cc" @@ -188,9 +188,9 @@ dependencies = [ [[package]] name = "device-driver" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af0e43acfcbb0bb3b7435cc1b1dbb33596cacfec1eb243336b74a398e0bd6cbf" +checksum = "c2e4547bd66511372d2a38ac3c1b2892c7ebf83cf0d5411c3406e496c85a1d96" dependencies = [ "device-driver-macros", "embedded-io 0.6.1", @@ -199,9 +199,9 @@ dependencies = [ [[package]] name = "device-driver-generation" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3935aec9cf5bb2ab927f59ca69faecf976190390b0ce34c6023889e9041040c0" +checksum = "7f0170a2ef7fb5a74029c3edcaff07a0d44dbfac3d9dcfbb06fc696f890bb877" dependencies = [ "anyhow", "askama", @@ -209,7 +209,7 @@ dependencies = [ "convert_case", "dd-manifest-tree", "itertools", - "kdl", + "prettyplease", "proc-macro2", "quote", "syn 2.0.108", @@ -217,9 +217,9 @@ dependencies = [ [[package]] name = "device-driver-macros" -version = "1.0.7" +version = "1.0.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4fdc68ed515c4eddff2e95371185b4becba066085bf36d50f07f09782af98e17" +checksum = "176dbf719ece32afb641bf50d2d1881411ad1677aec6c8bf42011a7c279d97ff" dependencies = [ "device-driver-generation", "proc-macro2", @@ -325,7 +325,7 @@ version = "0.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d7a4b4d10ac48d08bfe3db7688c402baadb244721f30a77ce360bd24c3dffe58" dependencies = [ - "num 0.3.1", + "num", ] [[package]] @@ -465,17 +465,6 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" -[[package]] -name = "kdl" -version = "6.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81a29e7b50079ff44549f68c0becb1c73d7f6de2a4ea952da77966daf3d4761e" -dependencies = [ - "miette", - "num 0.4.3", - "winnow 0.6.24", -] - [[package]] name = "lazy_static" version = "1.5.0" @@ -596,16 +585,6 @@ version = "2.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" -[[package]] -name = "miette" -version = "7.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f98efec8807c63c752b5bd61f862c165c115b0a35685bdcfd9238c7aeb592b7" -dependencies = [ - "cfg-if", - "unicode-width", -] - [[package]] name = "mycelium-bitfield" version = "0.1.5" @@ -642,34 +621,10 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b7a8e9be5e039e2ff869df49155f1c06bd01ade2117ec783e56ab0932b67a8f" dependencies = [ - "num-complex 0.3.1", - "num-integer", - "num-iter", - "num-rational 0.3.2", - "num-traits", -] - -[[package]] -name = "num" -version = "0.4.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35bd024e8b2ff75562e5f34e7f4905839deb4b22955ef5e73d2fea1b9813cb23" -dependencies = [ - "num-bigint", - "num-complex 0.4.6", + "num-complex", "num-integer", "num-iter", - "num-rational 0.4.2", - "num-traits", -] - -[[package]] -name = "num-bigint" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" -dependencies = [ - "num-integer", + "num-rational", "num-traits", ] @@ -682,15 +637,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-complex" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" -dependencies = [ - "num-traits", -] - [[package]] name = "num-integer" version = "0.1.46" @@ -722,17 +668,6 @@ dependencies = [ "num-traits", ] -[[package]] -name = "num-rational" -version = "0.4.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" -dependencies = [ - "num-bigint", - "num-integer", - "num-traits", -] - [[package]] name = "num-traits" version = "0.2.19" @@ -901,6 +836,16 @@ dependencies = [ "serde", ] +[[package]] +name = "prettyplease" +version = "0.2.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b" +dependencies = [ + "proc-macro2", + "syn 2.0.108", +] + [[package]] name = "proc-macro-utils" version = "0.10.0" @@ -1255,7 +1200,7 @@ dependencies = [ "serde_spanned", "toml_datetime", "toml_write", - "winnow 0.7.13", + "winnow", ] [[package]] @@ -1354,12 +1299,6 @@ version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" -[[package]] -name = "unicode-width" -version = "0.1.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" - [[package]] name = "valuable" version = "0.1.1" @@ -1637,15 +1576,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" -[[package]] -name = "winnow" -version = "0.6.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c8d71a593cc5c42ad7876e2c1fda56f314f3754c084128833e64f1345ff8a03a" -dependencies = [ - "memchr", -] - [[package]] name = "winnow" version = "0.7.13" diff --git a/Cargo.toml b/Cargo.toml index 9de7b2f..ec02c87 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,10 +17,10 @@ include = [ "/LICENSE", ] edition = "2024" -rust-version = "1.85.0" +rust-version = "1.90.0" [dependencies] -device-driver = { version = "1.0.7", default-features = false, features = ["toml"] } +device-driver = { version = "1.0.9", default-features = false, features = ["toml"] } embedded-hal = "1.0.0" embedded-hal-async = { version = "1.0.0", optional = true } embedded-sensors-hal = { version = "0.1.0", optional = true } diff --git a/src/inner.rs b/src/inner.rs index 3ce5410..b233f9b 100644 --- a/src/inner.rs +++ b/src/inner.rs @@ -1,13 +1,10 @@ /// Root block of the Inner driver - #[derive(Debug)] pub struct Inner { pub(crate) interface: I, - #[doc(hidden)] base_address: u8, } - impl Inner { /// Create a new instance of the block based on device interface pub const fn new(interface: I) -> Self { @@ -16,12 +13,10 @@ impl Inner { base_address: 0, } } - /// A reference to the interface used to communicate with the device pub(crate) fn interface(&mut self) -> &mut I { &mut self.interface } - /// Read all readable register values in this block from the device. /// The callback is called for each of them. /// Any registers in child blocks are not included. @@ -33,7 +28,7 @@ impl Inner { /// - The read value from the register /// /// This is useful for e.g. debug printing all values. - /// The given [`field_sets::FieldSetValue`] has a Debug and Format implementation that forwards to the concrete type + /// The given [field_sets::FieldSetValue] has a Debug and Format implementation that forwards to the concrete type /// the lies within so it can be printed without matching on it. #[allow(unused_mut)] #[allow(unused_variables)] @@ -45,24 +40,15 @@ impl Inner { I: ::device_driver::RegisterInterface, { let reg = self.temperature().read()?; - - callback(0, "temperature", reg.into()); - + callback(0 + 0 * 0, "temperature", reg.into()); let reg = self.configuration().read()?; - - callback(1, "configuration", reg.into()); - + callback(1 + 0 * 0, "configuration", reg.into()); let reg = self.t_low().read()?; - - callback(2, "t_low", reg.into()); - + callback(2 + 0 * 0, "t_low", reg.into()); let reg = self.t_high().read()?; - - callback(3, "t_high", reg.into()); - + callback(3 + 0 * 0, "t_high", reg.into()); Ok(()) } - /// Read all readable register values in this block from the device. /// The callback is called for each of them. /// Any registers in child blocks are not included. @@ -74,7 +60,7 @@ impl Inner { /// - The read value from the register /// /// This is useful for e.g. debug printing all values. - /// The given [`field_sets::FieldSetValue`] has a Debug and Format implementation that forwards to the concrete type + /// The given [field_sets::FieldSetValue] has a Debug and Format implementation that forwards to the concrete type /// the lies within so it can be printed without matching on it. #[allow(unused_mut)] #[allow(unused_variables)] @@ -86,85 +72,66 @@ impl Inner { I: ::device_driver::AsyncRegisterInterface, { let reg = self.temperature().read_async().await?; - - callback(0, "temperature", reg.into()); - + callback(0 + 0 * 0, "temperature", reg.into()); let reg = self.configuration().read_async().await?; - - callback(1, "configuration", reg.into()); - + callback(1 + 0 * 0, "configuration", reg.into()); let reg = self.t_low().read_async().await?; - - callback(2, "t_low", reg.into()); - + callback(2 + 0 * 0, "t_low", reg.into()); let reg = self.t_high().read_async().await?; - - callback(3, "t_high", reg.into()); - + callback(3 + 0 * 0, "t_high", reg.into()); Ok(()) } - /// Temperature register pub fn temperature( &mut self, ) -> ::device_driver::RegisterOperation<'_, I, u8, field_sets::Temperature, ::device_driver::RO> { - let address = self.base_address; - + let address = self.base_address + 0; ::device_driver::RegisterOperation::<'_, I, u8, field_sets::Temperature, ::device_driver::RO>::new( self.interface(), - address, + address as u8, field_sets::Temperature::new, ) } - /// Configuration register pub fn configuration( &mut self, ) -> ::device_driver::RegisterOperation<'_, I, u8, field_sets::Configuration, ::device_driver::RW> { let address = self.base_address + 1; - ::device_driver::RegisterOperation::<'_, I, u8, field_sets::Configuration, ::device_driver::RW>::new( self.interface(), - address, + address as u8, field_sets::Configuration::new, ) } - /// Temperature low register pub fn t_low(&mut self) -> ::device_driver::RegisterOperation<'_, I, u8, field_sets::TLow, ::device_driver::RW> { let address = self.base_address + 2; - ::device_driver::RegisterOperation::<'_, I, u8, field_sets::TLow, ::device_driver::RW>::new( self.interface(), - address, + address as u8, field_sets::TLow::new, ) } - /// Temperature high register pub fn t_high(&mut self) -> ::device_driver::RegisterOperation<'_, I, u8, field_sets::THigh, ::device_driver::RW> { let address = self.base_address + 3; - ::device_driver::RegisterOperation::<'_, I, u8, field_sets::THigh, ::device_driver::RW>::new( self.interface(), - address, + address as u8, field_sets::THigh::new, ) } } - /// Module containing the generated fieldsets of the registers and commands pub mod field_sets { #[allow(unused_imports)] use super::*; - /// Temperature register #[derive(Copy, Clone, Eq, PartialEq)] pub struct Temperature { /// The internal bits bits: [u8; 2], } - impl ::device_driver::FieldSet for Temperature { const SIZE_BITS: u32 = 16; fn new_with_zero() -> Self { @@ -177,13 +144,6 @@ pub mod field_sets { &mut self.bits } } - - impl Default for Temperature { - fn default() -> Self { - Self::new() - } - } - impl Temperature { /// Create a new instance, loaded with the reset value (if any) pub const fn new() -> Self { @@ -194,27 +154,22 @@ pub mod field_sets { Self { bits: [0; 2] } } } - impl From<[u8; 2]> for Temperature { fn from(bits: [u8; 2]) -> Self { Self { bits } } } - impl From for [u8; 2] { fn from(val: Temperature) -> Self { val.bits } } - impl core::fmt::Debug for Temperature { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> { let mut d = f.debug_struct("Temperature"); - d.finish() } } - impl core::ops::BitAnd for Temperature { type Output = Self; fn bitand(mut self, rhs: Self) -> Self::Output { @@ -222,7 +177,6 @@ pub mod field_sets { self } } - impl core::ops::BitAndAssign for Temperature { fn bitand_assign(&mut self, rhs: Self) { for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { @@ -230,7 +184,6 @@ pub mod field_sets { } } } - impl core::ops::BitOr for Temperature { type Output = Self; fn bitor(mut self, rhs: Self) -> Self::Output { @@ -238,7 +191,6 @@ pub mod field_sets { self } } - impl core::ops::BitOrAssign for Temperature { fn bitor_assign(&mut self, rhs: Self) { for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { @@ -246,7 +198,6 @@ pub mod field_sets { } } } - impl core::ops::BitXor for Temperature { type Output = Self; fn bitxor(mut self, rhs: Self) -> Self::Output { @@ -254,7 +205,6 @@ pub mod field_sets { self } } - impl core::ops::BitXorAssign for Temperature { fn bitxor_assign(&mut self, rhs: Self) { for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { @@ -262,24 +212,21 @@ pub mod field_sets { } } } - impl core::ops::Not for Temperature { type Output = Self; fn not(mut self) -> Self::Output { - for val in &mut self.bits { + for val in self.bits.iter_mut() { *val = !*val; } self } } - /// Configuration register #[derive(Copy, Clone, Eq, PartialEq)] pub struct Configuration { /// The internal bits bits: [u8; 2], } - impl ::device_driver::FieldSet for Configuration { const SIZE_BITS: u32 = 16; fn new_with_zero() -> Self { @@ -292,185 +239,141 @@ pub mod field_sets { &mut self.bits } } - - impl Default for Configuration { - fn default() -> Self { - Self::new() - } - } - impl Configuration { /// Create a new instance, loaded with the reset value (if any) pub const fn new() -> Self { Self { bits: [34, 16] } } - /// Create a new instance, loaded with all zeroes pub const fn new_zero() -> Self { Self { bits: [0; 2] } } - - /// Read the `m` field of the register. + ///Read the `m` field of the register. /// /// Device functional mode - pub fn m(self) -> Result>::Error> { + pub fn m(&self) -> Result>::Error> { let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 0, 2) }; - raw.try_into() } - - /// Read the `tm` field of the register. + ///Read the `tm` field of the register. /// /// Thermostat mode - pub fn tm(self) -> super::Thermostat { + pub fn tm(&self) -> super::Thermostat { let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 2, 3) }; - unsafe { raw.try_into().unwrap_unchecked() } } - - /// Read the `fl` field of the register. + ///Read the `fl` field of the register. /// /// Temperature watchdog low flag - pub fn fl(self) -> bool { + pub fn fl(&self) -> bool { let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 3, 4) }; - raw > 0 } - - /// Read the `fh` field of the register. + ///Read the `fh` field of the register. /// /// Temperature watchdog high flag - pub fn fh(self) -> bool { + pub fn fh(&self) -> bool { let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 4, 5) }; - raw > 0 } - - /// Read the `cr` field of the register. + ///Read the `cr` field of the register. /// /// Conversion rate - pub fn cr(self) -> super::ConversionRate { + pub fn cr(&self) -> super::ConversionRate { let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 5, 7) }; - unsafe { raw.try_into().unwrap_unchecked() } } - - /// Read the `id` field of the register. + ///Read the `id` field of the register. /// /// ID - pub fn id(self) -> bool { + pub fn id(&self) -> bool { let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 7, 8) }; - raw > 0 } - - /// Read the `hys` field of the register. + ///Read the `hys` field of the register. /// /// Hysteresis control - pub fn hys(self) -> super::Hysteresis { + pub fn hys(&self) -> super::Hysteresis { let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 12, 14) }; - unsafe { raw.try_into().unwrap_unchecked() } } - - /// Read the `pol` field of the register. + ///Read the `pol` field of the register. /// /// ALERT pin polarity - pub fn pol(self) -> super::Polarity { + pub fn pol(&self) -> super::Polarity { let raw = unsafe { ::device_driver::ops::load_lsb0::(&self.bits, 15, 16) }; - unsafe { raw.try_into().unwrap_unchecked() } } - - /// Write the `m` field of the register. + ///Write the `m` field of the register. /// /// Device functional mode pub fn set_m(&mut self, value: super::Mode) { let raw = value.into(); - unsafe { ::device_driver::ops::store_lsb0::(raw, 0, 2, &mut self.bits) }; } - - /// Write the `tm` field of the register. + ///Write the `tm` field of the register. /// /// Thermostat mode pub fn set_tm(&mut self, value: super::Thermostat) { let raw = value.into(); - unsafe { ::device_driver::ops::store_lsb0::(raw, 2, 3, &mut self.bits) }; } - - /// Write the `fl` field of the register. + ///Write the `fl` field of the register. /// /// Temperature watchdog low flag pub fn set_fl(&mut self, value: bool) { - let raw = value.into(); - + let raw = value as _; unsafe { ::device_driver::ops::store_lsb0::(raw, 3, 4, &mut self.bits) }; } - - /// Write the `fh` field of the register. + ///Write the `fh` field of the register. /// /// Temperature watchdog high flag pub fn set_fh(&mut self, value: bool) { - let raw = value.into(); - + let raw = value as _; unsafe { ::device_driver::ops::store_lsb0::(raw, 4, 5, &mut self.bits) }; } - - /// Write the `cr` field of the register. + ///Write the `cr` field of the register. /// /// Conversion rate pub fn set_cr(&mut self, value: super::ConversionRate) { let raw = value.into(); - unsafe { ::device_driver::ops::store_lsb0::(raw, 5, 7, &mut self.bits) }; } - - /// Write the `id` field of the register. + ///Write the `id` field of the register. /// /// ID pub fn set_id(&mut self, value: bool) { - let raw = value.into(); - + let raw = value as _; unsafe { ::device_driver::ops::store_lsb0::(raw, 7, 8, &mut self.bits) }; } - - /// Write the `hys` field of the register. + ///Write the `hys` field of the register. /// /// Hysteresis control pub fn set_hys(&mut self, value: super::Hysteresis) { let raw = value.into(); - unsafe { ::device_driver::ops::store_lsb0::(raw, 12, 14, &mut self.bits) }; } - - /// Write the `pol` field of the register. + ///Write the `pol` field of the register. /// /// ALERT pin polarity pub fn set_pol(&mut self, value: super::Polarity) { let raw = value.into(); - unsafe { ::device_driver::ops::store_lsb0::(raw, 15, 16, &mut self.bits) }; } } - impl From<[u8; 2]> for Configuration { fn from(bits: [u8; 2]) -> Self { Self { bits } } } - impl From for [u8; 2] { fn from(val: Configuration) -> Self { val.bits } } - impl core::fmt::Debug for Configuration { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> { let mut d = f.debug_struct("Configuration"); - d.field("m", &self.m()); d.field("tm", &self.tm()); d.field("fl", &self.fl()); @@ -479,11 +382,9 @@ pub mod field_sets { d.field("id", &self.id()); d.field("hys", &self.hys()); d.field("pol", &self.pol()); - d.finish() } } - impl core::ops::BitAnd for Configuration { type Output = Self; fn bitand(mut self, rhs: Self) -> Self::Output { @@ -491,7 +392,6 @@ pub mod field_sets { self } } - impl core::ops::BitAndAssign for Configuration { fn bitand_assign(&mut self, rhs: Self) { for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { @@ -499,7 +399,6 @@ pub mod field_sets { } } } - impl core::ops::BitOr for Configuration { type Output = Self; fn bitor(mut self, rhs: Self) -> Self::Output { @@ -507,7 +406,6 @@ pub mod field_sets { self } } - impl core::ops::BitOrAssign for Configuration { fn bitor_assign(&mut self, rhs: Self) { for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { @@ -515,7 +413,6 @@ pub mod field_sets { } } } - impl core::ops::BitXor for Configuration { type Output = Self; fn bitxor(mut self, rhs: Self) -> Self::Output { @@ -523,7 +420,6 @@ pub mod field_sets { self } } - impl core::ops::BitXorAssign for Configuration { fn bitxor_assign(&mut self, rhs: Self) { for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { @@ -531,24 +427,21 @@ pub mod field_sets { } } } - impl core::ops::Not for Configuration { type Output = Self; fn not(mut self) -> Self::Output { - for val in &mut self.bits { + for val in self.bits.iter_mut() { *val = !*val; } self } } - /// Temperature low register #[derive(Copy, Clone, Eq, PartialEq)] pub struct TLow { /// The internal bits bits: [u8; 2], } - impl ::device_driver::FieldSet for TLow { const SIZE_BITS: u32 = 16; fn new_with_zero() -> Self { @@ -561,13 +454,6 @@ pub mod field_sets { &mut self.bits } } - - impl Default for TLow { - fn default() -> Self { - Self::new() - } - } - impl TLow { /// Create a new instance, loaded with the reset value (if any) pub const fn new() -> Self { @@ -578,27 +464,22 @@ pub mod field_sets { Self { bits: [0; 2] } } } - impl From<[u8; 2]> for TLow { fn from(bits: [u8; 2]) -> Self { Self { bits } } } - impl From for [u8; 2] { fn from(val: TLow) -> Self { val.bits } } - impl core::fmt::Debug for TLow { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> { let mut d = f.debug_struct("TLow"); - d.finish() } } - impl core::ops::BitAnd for TLow { type Output = Self; fn bitand(mut self, rhs: Self) -> Self::Output { @@ -606,7 +487,6 @@ pub mod field_sets { self } } - impl core::ops::BitAndAssign for TLow { fn bitand_assign(&mut self, rhs: Self) { for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { @@ -614,7 +494,6 @@ pub mod field_sets { } } } - impl core::ops::BitOr for TLow { type Output = Self; fn bitor(mut self, rhs: Self) -> Self::Output { @@ -622,7 +501,6 @@ pub mod field_sets { self } } - impl core::ops::BitOrAssign for TLow { fn bitor_assign(&mut self, rhs: Self) { for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { @@ -630,7 +508,6 @@ pub mod field_sets { } } } - impl core::ops::BitXor for TLow { type Output = Self; fn bitxor(mut self, rhs: Self) -> Self::Output { @@ -638,7 +515,6 @@ pub mod field_sets { self } } - impl core::ops::BitXorAssign for TLow { fn bitxor_assign(&mut self, rhs: Self) { for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { @@ -646,24 +522,21 @@ pub mod field_sets { } } } - impl core::ops::Not for TLow { type Output = Self; fn not(mut self) -> Self::Output { - for val in &mut self.bits { + for val in self.bits.iter_mut() { *val = !*val; } self } } - /// Temperature high register #[derive(Copy, Clone, Eq, PartialEq)] pub struct THigh { /// The internal bits bits: [u8; 2], } - impl ::device_driver::FieldSet for THigh { const SIZE_BITS: u32 = 16; fn new_with_zero() -> Self { @@ -676,13 +549,6 @@ pub mod field_sets { &mut self.bits } } - - impl Default for THigh { - fn default() -> Self { - Self::new() - } - } - impl THigh { /// Create a new instance, loaded with the reset value (if any) pub const fn new() -> Self { @@ -693,27 +559,22 @@ pub mod field_sets { Self { bits: [0; 2] } } } - impl From<[u8; 2]> for THigh { fn from(bits: [u8; 2]) -> Self { Self { bits } } } - impl From for [u8; 2] { fn from(val: THigh) -> Self { val.bits } } - impl core::fmt::Debug for THigh { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> Result<(), core::fmt::Error> { let mut d = f.debug_struct("THigh"); - d.finish() } } - impl core::ops::BitAnd for THigh { type Output = Self; fn bitand(mut self, rhs: Self) -> Self::Output { @@ -721,7 +582,6 @@ pub mod field_sets { self } } - impl core::ops::BitAndAssign for THigh { fn bitand_assign(&mut self, rhs: Self) { for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { @@ -729,7 +589,6 @@ pub mod field_sets { } } } - impl core::ops::BitOr for THigh { type Output = Self; fn bitor(mut self, rhs: Self) -> Self::Output { @@ -737,7 +596,6 @@ pub mod field_sets { self } } - impl core::ops::BitOrAssign for THigh { fn bitor_assign(&mut self, rhs: Self) { for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { @@ -745,7 +603,6 @@ pub mod field_sets { } } } - impl core::ops::BitXor for THigh { type Output = Self; fn bitxor(mut self, rhs: Self) -> Self::Output { @@ -753,7 +610,6 @@ pub mod field_sets { self } } - impl core::ops::BitXorAssign for THigh { fn bitxor_assign(&mut self, rhs: Self) { for (l, r) in self.bits.iter_mut().zip(&rhs.bits) { @@ -761,28 +617,23 @@ pub mod field_sets { } } } - impl core::ops::Not for THigh { type Output = Self; fn not(mut self) -> Self::Output { - for val in &mut self.bits { + for val in self.bits.iter_mut() { *val = !*val; } self } } - /// Enum containing all possible field set types pub enum FieldSetValue { /// Temperature register Temperature(Temperature), - /// Configuration register Configuration(Configuration), - /// Temperature low register TLow(TLow), - /// Temperature high register THigh(THigh), } @@ -790,44 +641,35 @@ pub mod field_sets { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { match self { Self::Temperature(val) => core::fmt::Debug::fmt(val, f), - Self::Configuration(val) => core::fmt::Debug::fmt(val, f), - Self::TLow(val) => core::fmt::Debug::fmt(val, f), - Self::THigh(val) => core::fmt::Debug::fmt(val, f), - #[allow(unreachable_patterns)] _ => unreachable!(), } } } - impl From for FieldSetValue { fn from(val: Temperature) -> Self { Self::Temperature(val) } } - impl From for FieldSetValue { fn from(val: Configuration) -> Self { Self::Configuration(val) } } - impl From for FieldSetValue { fn from(val: TLow) -> Self { Self::TLow(val) } } - impl From for FieldSetValue { fn from(val: THigh) -> Self { Self::THigh(val) } } } - /// Device functional mode #[repr(u8)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] @@ -836,7 +678,6 @@ pub enum Mode { OneShot = 1, Continuous = 2, } - impl core::convert::TryFrom for Mode { type Error = ::device_driver::ConversionError; fn try_from(val: u8) -> Result { @@ -851,7 +692,6 @@ impl core::convert::TryFrom for Mode { } } } - impl From for u8 { fn from(val: Mode) -> Self { match val { @@ -861,7 +701,6 @@ impl From for u8 { } } } - /// Thermostat mode #[repr(u8)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] @@ -869,7 +708,6 @@ pub enum Thermostat { Comparator = 0, Interrupt = 1, } - impl core::convert::TryFrom for Thermostat { type Error = ::device_driver::ConversionError; fn try_from(val: u8) -> Result { @@ -883,7 +721,6 @@ impl core::convert::TryFrom for Thermostat { } } } - impl From for u8 { fn from(val: Thermostat) -> Self { match val { @@ -892,18 +729,15 @@ impl From for u8 { } } } - /// Conversion rate #[repr(u8)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] -#[allow(clippy::enum_variant_names)] pub enum ConversionRate { _0_25Hz = 0, _1Hz = 1, _4Hz = 2, _16Hz = 3, } - impl core::convert::TryFrom for ConversionRate { type Error = ::device_driver::ConversionError; fn try_from(val: u8) -> Result { @@ -919,7 +753,6 @@ impl core::convert::TryFrom for ConversionRate { } } } - impl From for u8 { fn from(val: ConversionRate) -> Self { match val { @@ -930,7 +763,6 @@ impl From for u8 { } } } - #[repr(u8)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub enum Hysteresis { @@ -939,7 +771,6 @@ pub enum Hysteresis { _2C = 2, _4C = 3, } - impl core::convert::TryFrom for Hysteresis { type Error = ::device_driver::ConversionError; fn try_from(val: u8) -> Result { @@ -955,7 +786,6 @@ impl core::convert::TryFrom for Hysteresis { } } } - impl From for u8 { fn from(val: Hysteresis) -> Self { match val { @@ -966,15 +796,12 @@ impl From for u8 { } } } - #[repr(u8)] #[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub enum Polarity { ActiveLow = 0, - ActiveHigh = 1, } - impl core::convert::TryFrom for Polarity { type Error = ::device_driver::ConversionError; fn try_from(val: u8) -> Result { @@ -988,7 +815,6 @@ impl core::convert::TryFrom for Polarity { } } } - impl From for u8 { fn from(val: Polarity) -> Self { match val { diff --git a/src/lib.rs b/src/lib.rs index ff70f80..ed3dad2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,7 +24,11 @@ use embedded_hal::{delay::DelayNs, i2c::I2c}; #[cfg(feature = "async")] use embedded_hal_async::{delay::DelayNs as AsyncDelayNs, i2c::I2c as AsyncI2c}; -#[allow(unused, unsafe_code)] +#[allow(clippy::all)] +#[allow(clippy::pedantic)] +#[allow(missing_docs)] +#[allow(unsafe_code)] +#[allow(unused)] mod inner; use crate::inner::field_sets::{THigh, TLow};