From af194a7342cd734ddb53528af3db321d1cb3668c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Thu, 1 Feb 2024 16:44:34 +0100 Subject: [PATCH] style, depth * clippy lints on comments and default * fixed tree depth --- .cargo/config | 5 +++-- src/hardware/dac.rs | 24 +++++++++++++----------- src/hardware/pwm.rs | 9 +++++---- src/hardware/system_timer.rs | 10 +++++----- src/main.rs | 4 ++-- src/net/mod.rs | 16 ++++++++-------- src/net/network_processor.rs | 10 +++++----- src/net/telemetry.rs | 26 +++++++++++++------------- src/output_channel.rs | 2 +- 9 files changed, 55 insertions(+), 51 deletions(-) diff --git a/.cargo/config b/.cargo/config index 014252e..475b76e 100644 --- a/.cargo/config +++ b/.cargo/config @@ -1,11 +1,12 @@ [target.'cfg(all(target_arch = "arm", target_os = "none"))'] -runner = "probe-run --chip STM32H743ZITx --speed 30000" +runner = "probe-rs run --chip STM32H743ZITx --log-file /dev/null" # runner = "gdb-multiarch -q -x openocd.gdb" rustflags = [ "-C", "link-arg=-Tlink.x", "-C", "link-arg=--nmagic", "-C", "target-cpu=cortex-m7", + #"-C", "target-feature=+fp-armv8d16", ] [build] -target = "thumbv7em-none-eabihf" \ No newline at end of file +target = "thumbv7em-none-eabihf" diff --git a/src/hardware/dac.rs b/src/hardware/dac.rs index cec3968..6506324 100644 --- a/src/hardware/dac.rs +++ b/src/hardware/dac.rs @@ -1,14 +1,16 @@ -/// Thermostat DAC driver -/// -/// This file contains the driver for the 4 Thermostat DAC output channels. -/// To convert a 18 bit word into an analog current Thermostat uses a DAC to -/// convert the word into a voltage and a subsequent TEC driver IC that produces -/// a current proportional to the DAC voltage. -/// -/// The 4 channel DAC ICs share an SPI bus and are addressed using individual "sync" -/// signals, similar to a chip select signal. -/// DAC datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/AD5680.pdf -/// TEC driver datasheet: https://datasheets.maximintegrated.com/en/ds/MAX1968-MAX1969.pdf +//! Thermostat DAC driver +//! +//! This file contains the driver for the 4 Thermostat DAC output channels. +//! To convert a 18 bit word into an analog current Thermostat uses a DAC to +//! convert the word into a voltage and a subsequent TEC driver IC that produces +//! a current proportional to the DAC voltage. +//! +//! The 4 channel DAC ICs share an SPI bus and are addressed using individual "sync" +//! signals, similar to a chip select signal. +//! DAC datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/AD5680.pdf +//! TEC driver datasheet: https://datasheets.maximintegrated.com/en/ds/MAX1968-MAX1969.pdf +//! + use super::hal::{ gpio::{self, gpioc}, hal::blocking::spi::Write, diff --git a/src/hardware/pwm.rs b/src/hardware/pwm.rs index 6a0ffe2..b38aae6 100644 --- a/src/hardware/pwm.rs +++ b/src/hardware/pwm.rs @@ -1,7 +1,8 @@ -/// Thermostat TEC driver IC voltage/current limits PWM driver. -/// -/// The Thermostat TEC driver ICs feature current limits controlled by an analog voltage input. -/// This voltage is controlled by the MCU using low-pass filtered PWM outputs. +//! Thermostat TEC driver IC voltage/current limits PWM driver. +//! +//! The Thermostat TEC driver ICs feature current limits controlled by an analog voltage input. +//! This voltage is controlled by the MCU using low-pass filtered PWM outputs. +//! use super::{ dac::{R_SENSE, VREF_TEC}, hal::{ diff --git a/src/hardware/system_timer.rs b/src/hardware/system_timer.rs index 5db2a65..3ff6c1d 100644 --- a/src/hardware/system_timer.rs +++ b/src/hardware/system_timer.rs @@ -1,8 +1,8 @@ -/// System timer used for non-RTIC compatibility -/// -/// # Design -/// `Clock` is implemented using the RTIC `app::monotonics::now()` default `Monotonic`. -/// That `Monotonic` must tick at 1 kHz. +//! System timer used for non-RTIC compatibility +//! +//! # Design +//! `Clock` is implemented using the RTIC `app::monotonics::now()` default `Monotonic`. +//! That `Monotonic` must tick at 1 kHz. use minimq::embedded_time::{clock::Error, fraction::Fraction, Clock, Instant}; #[derive(Copy, Clone, Debug)] diff --git a/src/main.rs b/src/main.rs index 9df43e1..4bee349 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,7 +53,7 @@ pub struct Settings { /// /// # Value /// See [output_channel::OutputChannel] - #[tree(depth(5))] + #[tree(depth(4))] output_channel: [output_channel::OutputChannel; 4], /// Alarm settings. @@ -63,7 +63,7 @@ pub struct Settings { /// /// # Value /// See [Alarm] - #[tree(depth(3))] + #[tree(depth(5))] alarm: Alarm, } diff --git a/src/net/mod.rs b/src/net/mod.rs index ecf174f..ae9a17e 100644 --- a/src/net/mod.rs +++ b/src/net/mod.rs @@ -1,10 +1,10 @@ -/// Stabilizer network management module -/// -/// # Design -/// The stabilizer network architecture supports numerous layers to permit transmission of -/// telemetry (via MQTT), configuration of run-time settings (via MQTT + Miniconf), and live data -/// streaming over raw UDP/TCP sockets. This module encompasses the main processing routines -/// related to Stabilizer networking operations. +//! Stabilizer network management module +//! +//! # Design +//! The stabilizer network architecture supports numerous layers to permit transmission of +//! telemetry (via MQTT), configuration of run-time settings (via MQTT + Miniconf), and live data +//! streaming over raw UDP/TCP sockets. This module encompasses the main processing routines +//! related to Stabilizer networking operations. pub use heapless; pub use miniconf; pub use serde; @@ -252,6 +252,6 @@ pub struct Alarm { /// /// # Value /// [f32, f32] - #[tree(depth(2))] + #[tree(depth(4))] pub temperature_limits: [[Option<[f32; 2]>; 4]; 4], } diff --git a/src/net/network_processor.rs b/src/net/network_processor.rs index abbdc66..a557387 100644 --- a/src/net/network_processor.rs +++ b/src/net/network_processor.rs @@ -1,8 +1,8 @@ -/// Task to process network hardware. -/// -/// # Design -/// The network processir is a small taks to regularly process incoming data over ethernet, handle -/// the ethernet PHY state, and reset the network as appropriate. +//! Task to process network hardware. +//! +//! # Design +//! The network processir is a small taks to regularly process incoming data over ethernet, handle +//! the ethernet PHY state, and reset the network as appropriate. use super::{NetworkReference, UpdateState}; use crate::hardware::EthernetPhy; diff --git a/src/net/telemetry.rs b/src/net/telemetry.rs index 6301541..04405a1 100644 --- a/src/net/telemetry.rs +++ b/src/net/telemetry.rs @@ -1,15 +1,15 @@ -/// Thermostat Telemetry Capabilities -/// -/// # Design -/// Telemetry is reported regularly using an MQTT client. All telemetry is reported in SI units -/// using standard JSON format. -/// -/// In order to report ADC/DAC codes generated during the DSP routines, a telemetry buffer is -/// employed to track the latest codes. Converting these codes to SI units would result in -/// repetitive and unnecessary calculations within the DSP routine, slowing it down and limiting -/// sampling frequency. Instead, the raw codes are stored and the telemetry is generated as -/// required immediately before transmission. This ensures that any slower computation required -/// for unit conversion can be off-loaded to lower priority tasks. +//! Thermostat Telemetry Capabilities +//! +//! # Design +//! Telemetry is reported regularly using an MQTT client. All telemetry is reported in SI units +//! using standard JSON format. +//! +//! In order to report ADC/DAC codes generated during the DSP routines, a telemetry buffer is +//! employed to track the latest codes. Converting these codes to SI units would result in +//! repetitive and unnecessary calculations within the DSP routine, slowing it down and limiting +//! sampling frequency. Instead, the raw codes are stored and the telemetry is generated as +//! required immediately before transmission. This ensures that any slower computation required +//! for unit conversion can be off-loaded to lower priority tasks. use heapless::String; use serde::Serialize; @@ -55,8 +55,8 @@ impl TelemetryClient { Self { mqtt, prefix: String::from(prefix), - metadata, meta_published: false, + metadata, _telemetry: core::marker::PhantomData, } } diff --git a/src/output_channel.rs b/src/output_channel.rs index 015611d..dbdcf4b 100644 --- a/src/output_channel.rs +++ b/src/output_channel.rs @@ -45,7 +45,7 @@ pub struct OutputChannel { /// /// # Value /// f32 - #[tree(depth(3))] + #[tree(depth(2))] pub weights: [[Option; 4]; 4], }