From 93efdd247f6dc2c64d2d7bc0badacdc745586901 Mon Sep 17 00:00:00 2001 From: Zachary Sunforge Date: Wed, 19 Jul 2023 11:30:57 -0700 Subject: [PATCH 1/2] Readme updates. --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f84712c..67a396e 100644 --- a/README.md +++ b/README.md @@ -12,14 +12,15 @@ The main concepts of Physical are: * Peripheral: A peripheral is a board that hosts physical I/O and usually does analog to digital conversion or digital to analog conversion. A peripheral cannot function on its own, it must be connected to a node. This is more - narrow than the definition of a peripheral in embedded systems generally. Peripheral support is done on the basis - of complete boards, not individual components like an ADC. Abstractions for individual components should be made - separately, such as in BFPOWER drivers. + narrow than the definition of a peripheral in embedded systems generally. Peripheral support is focused on complete + boards, not individual components like an ADC. Although common abstractions for components specific to physical + can be provided in this repository, general component abstractions / drivers should be made separately, such as in + BFPOWER drivers. * Node: A node hosts peripherals. A node can have a commander but does not need one. A node can ignore or even override commands from the commander. In a complex system, nodes are intended to be kept simple, less likely to encounter an error than the commander, and in some cases should check for obvious problems in commands from the commander. * Commander: A commander hosts nodes. It is possible for a device to be both a node and a commander at the same time, although it may not be the best idea to make such a setup. There is no concept of nesting commanders built into - Physical. If some kind of abstraction for a computer that commands multiple commanders, which command nodes, is + Physical. If some kind of abstraction for a computer that commands multiple commanders, which command nodes, is necessary, it should be made for that specific application. \ No newline at end of file -- 2.43.0 From b299f59d9fe742e134a28a29ac5c1edbb7d7a0f1 Mon Sep 17 00:00:00 2001 From: Zachary Sunforge Date: Thu, 20 Jul 2023 06:49:53 -0700 Subject: [PATCH 2/2] Example cleanup --- examples/ads1256/src/bin/multiplex.rs | 13 +++++------- examples/ads1256/src/bin/poll.rs | 13 +++++------- examples/ads1256/src/bin/thermocouple.rs | 26 ++++++++++++------------ 3 files changed, 23 insertions(+), 29 deletions(-) diff --git a/examples/ads1256/src/bin/multiplex.rs b/examples/ads1256/src/bin/multiplex.rs index 91f9bb9..8f48021 100644 --- a/examples/ads1256/src/bin/multiplex.rs +++ b/examples/ads1256/src/bin/multiplex.rs @@ -3,20 +3,17 @@ #![feature(type_alias_impl_trait, async_fn_in_trait)] use core::cell::Cell; -use cortex_m::prelude::{ - _embedded_hal_blocking_delay_DelayMs, _embedded_hal_blocking_delay_DelayUs, -}; +use cortex_m::prelude::_embedded_hal_blocking_delay_DelayUs; use {defmt_rtt as _, panic_probe as _}; use {embassy_executor as executor, embassy_stm32 as stm32}; use ads1256::standard::input::SingleEnded; use ads1256::{ - AdControl, Ads1256, AutoCal, BitOrder, BlockingDelay, Buffer, ClockOut, Config, DState, - DataRate, DigitalIo, DigitalIoDirection, DigitalIoState, DioDirection, Gain, Multiplexer, - MuxInput, OutputPin, Sdcs, SpiBus, Status, Wait, + AdControl, Ads1256, AutoCal, BitOrder, Buffer, ClockOut, Config, DataRate, DigitalIo, + DigitalIoDirection, DigitalIoState, Gain, Multiplexer, MuxInput, Sdcs, Status, }; -use embassy_time::{Delay, Duration, Timer}; +use embassy_time::Delay; use executor::Spawner; use stm32::dma::NoDma; use stm32::exti::ExtiInput; @@ -30,7 +27,7 @@ use uom::si::f32; use defmt::{debug, error, info, trace, unwrap}; use embassy_executor::_export::StaticCell; -use embassy_stm32::peripherals::{EXTI6, PF6, PF7, SPI3}; +use embassy_stm32::peripherals::{PF6, PF7, SPI3}; use embassy_sync::blocking_mutex::raw::NoopRawMutex; use embassy_sync::pubsub::PubSubChannel; use physical_node::transducer::{Publish, StatefulPublisher}; diff --git a/examples/ads1256/src/bin/poll.rs b/examples/ads1256/src/bin/poll.rs index 5c2cfd1..f161f7c 100644 --- a/examples/ads1256/src/bin/poll.rs +++ b/examples/ads1256/src/bin/poll.rs @@ -3,19 +3,16 @@ #![feature(type_alias_impl_trait, async_fn_in_trait)] use core::cell::Cell; -use core::ops::DerefMut; -use cortex_m::prelude::{ - _embedded_hal_blocking_delay_DelayMs, _embedded_hal_blocking_delay_DelayUs, -}; + +use cortex_m::prelude::_embedded_hal_blocking_delay_DelayUs; use {defmt_rtt as _, panic_probe as _}; use {embassy_executor as executor, embassy_stm32 as stm32}; use ads1256::standard::input::SingleEnded; use ads1256::{ - AdControl, Ads1256, AutoCal, BitOrder, BlockingDelay, Buffer, ClockOut, Config, DState, - DataRate, DigitalIo, DigitalIoDirection, DigitalIoState, DioDirection, Gain, Multiplexer, - MuxInput, OutputPin, Sdcs, SpiBus, Status, Wait, + AdControl, Ads1256, AutoCal, BitOrder, Buffer, ClockOut, Config, DState, DataRate, DigitalIo, + DigitalIoDirection, DigitalIoState, Gain, Multiplexer, MuxInput, Sdcs, Status, }; use embassy_time::{Delay, Duration, Timer}; use executor::Spawner; @@ -29,7 +26,7 @@ use stm32::{pac, spi}; use uom::si::electric_potential::volt; use uom::si::f32; -use defmt::{debug, error, info, trace, unwrap}; +use defmt::info; use embassy_executor::_export::StaticCell; use embassy_stm32::peripherals::{EXTI6, PF6, PF7, SPI3}; use embassy_sync::blocking_mutex::raw::NoopRawMutex; diff --git a/examples/ads1256/src/bin/thermocouple.rs b/examples/ads1256/src/bin/thermocouple.rs index 5fe194f..b96bb02 100644 --- a/examples/ads1256/src/bin/thermocouple.rs +++ b/examples/ads1256/src/bin/thermocouple.rs @@ -2,21 +2,18 @@ #![no_main] #![feature(type_alias_impl_trait, async_fn_in_trait)] -use core::cell::Cell; -use cortex_m::prelude::{ - _embedded_hal_blocking_delay_DelayMs, _embedded_hal_blocking_delay_DelayUs, -}; +use cortex_m::prelude::_embedded_hal_blocking_delay_DelayUs; +// Necessary unused import. use {defmt_rtt as _, panic_probe as _}; use {embassy_executor as executor, embassy_stm32 as stm32}; use ads1256::standard::input::{Differential, SingleEnded}; use ads1256::{ - AdControl, Ads1256, AutoCal, BitOrder, BlockingDelay, Buffer, ClockOut, Config, DState, - DataRate, DigitalIo, DigitalIoDirection, DigitalIoState, DioDirection, Gain, Multiplexer, - MuxInput, OutputPin, Sdcs, SpiBus, Status, Wait, + AdControl, Ads1256, AutoCal, BitOrder, Buffer, ClockOut, Config, DataRate, DigitalIo, + DigitalIoDirection, DigitalIoState, Gain, Multiplexer, MuxInput, Sdcs, Status, }; -use embassy_time::{Delay, Duration, Timer}; +use embassy_time::Delay; use executor::Spawner; use stm32::dma::NoDma; use stm32::exti::ExtiInput; @@ -26,9 +23,8 @@ use stm32::time::Hertz; use stm32::{pac, spi}; use uom::si::electric_potential::{millivolt, volt}; -use uom::si::f32; -use defmt::{debug, error, info, trace, unwrap}; +use defmt::info; use physical::transducer::{lm35, thermocouple_k}; use uom::si::thermodynamic_temperature::degree_celsius; @@ -88,7 +84,7 @@ async fn main(spawner: Spawner) { ads_1256.self_calibrate(&mut spi).await.unwrap(); loop { - let gain = Gain::X4; + let gain = Gain::X2; let reference = ads_1256 .autocal_convert( &mut spi, @@ -101,9 +97,13 @@ async fn main(spawner: Spawner) { .await .unwrap() .to_voltage(gain); + let reference_volts = reference.get::(); let reference = lm35::convert(reference).unwrap(); let reference_celsius = reference.get::(); - info!("Reference junction temperature: {}°C", reference_celsius); + info!( + "Reference junction temperature: {}°C, from voltage reading: {}V", + reference_celsius, reference_volts + ); let gain = Gain::X64; let voltage = ads_1256 @@ -121,6 +121,6 @@ async fn main(spawner: Spawner) { let mv = voltage.get::(); let temperature = thermocouple_k::convert_direct(voltage, reference).unwrap(); let celsius = temperature.get::(); - info!("Thermocouple temperature: {}°C, millivolts: {}", celsius, mv); + info!("Thermocouple temperature: {}°C, from reading: {}mV", celsius, mv); } } -- 2.43.0