Update dependencies and do necessary migrations
This commit is contained in:
+28
-17
@@ -16,8 +16,8 @@ members = [
|
||||
]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.4.6"
|
||||
edition = "2021"
|
||||
version = "0.5.0"
|
||||
edition = "2024"
|
||||
repository = "https://git.bfpower.io/BFPOWER/physical"
|
||||
readme = "README.md"
|
||||
license = "MIT"
|
||||
@@ -30,14 +30,14 @@ default-features = false
|
||||
[workspace.dependencies.libm]
|
||||
version = "0.2.*"
|
||||
[workspace.dependencies.float-cmp]
|
||||
version = "0.9.*"
|
||||
version = "0.10.*"
|
||||
# Logging
|
||||
[workspace.dependencies.tracing]
|
||||
version = "0.1.*"
|
||||
[workspace.dependencies.defmt]
|
||||
version = "0.3.*"
|
||||
version = "1.0.*"
|
||||
[workspace.dependencies.defmt-rtt]
|
||||
version = "0.4.*"
|
||||
version = "1.1.*"
|
||||
# Embedded-HAL
|
||||
[workspace.dependencies.embedded-hal]
|
||||
version = "1.0.*"
|
||||
@@ -46,7 +46,7 @@ version = "1.0.*"
|
||||
# Memory
|
||||
[workspace.dependencies.static_cell]
|
||||
version = "2.1.*"
|
||||
# Serioalization
|
||||
# Serialization
|
||||
[workspace.dependencies.serde]
|
||||
version = "1.0.*"
|
||||
default-features = false
|
||||
@@ -57,34 +57,45 @@ version = "0.7.*"
|
||||
[workspace.dependencies.cortex-m-rt]
|
||||
version = "0.7.*"
|
||||
[workspace.dependencies.panic-probe]
|
||||
version = "0.3.*"
|
||||
version = "1.0.*"
|
||||
features = ["print-defmt"]
|
||||
# Embassy
|
||||
[workspace.dependencies.embassy-futures]
|
||||
version = "0.1.*"
|
||||
[workspace.dependencies.embassy-time]
|
||||
version = "0.3.*"
|
||||
version = "0.5.*"
|
||||
features = ["defmt", "defmt-timestamp-uptime"]
|
||||
[workspace.dependencies.embassy-sync]
|
||||
version = "0.6.*"
|
||||
version = "0.8.*"
|
||||
features = ["defmt"]
|
||||
[workspace.dependencies.embassy-embedded-hal]
|
||||
version = "0.1.*"
|
||||
version = "0.6.*"
|
||||
[workspace.dependencies.embassy-executor]
|
||||
version = "0.5.*"
|
||||
features = ["defmt", "arch-cortex-m", "integrated-timers", "executor-interrupt", "executor-thread"]
|
||||
version = "0.10.*"
|
||||
features = ["defmt", "platform-cortex-m", "executor-interrupt", "executor-thread"]
|
||||
[workspace.dependencies.embassy-usb]
|
||||
version = "0.2.*"
|
||||
version = "0.6.*"
|
||||
features = ["defmt"]
|
||||
[workspace.dependencies.embassy-stm32]
|
||||
version = "0.1.*"
|
||||
features = ["defmt", "unstable-pac"]
|
||||
version = "0.6.*"
|
||||
features = ["defmt", "unstable-pac", "gpio-init-analog"]
|
||||
[workspace.dependencies.embassy-nrf]
|
||||
version = "0.1.*"
|
||||
version = "0.10.*"
|
||||
features = ["defmt"]
|
||||
# Meta
|
||||
[workspace.dependencies.cfg-if]
|
||||
version = "1.0.*"
|
||||
[workspace.dependencies.derive_more]
|
||||
version = "0.99.*"
|
||||
version = "2.1.*"
|
||||
default-features = false
|
||||
features = ["add", "add_assign", "display"]
|
||||
[workspace.dependencies.thiserror]
|
||||
version = "2.0.*"
|
||||
default-features = false
|
||||
[workspace.dependencies.bitfields]
|
||||
version = "1.0.3"
|
||||
[workspace.dependencies.enumflags2]
|
||||
version = "0.7.12"
|
||||
[workspace.dependencies.syn]
|
||||
version = "2.0.*"
|
||||
features = ["extra-traits", "parsing"]
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::{
|
||||
drate, mux, opcodes, status, AdControl, Ads1256, BlockingDelay, CalibrationCommand, Conversion,
|
||||
DataRate, Gain, Multiplexer, Status,
|
||||
DataRate, Multiplexer, Status,
|
||||
};
|
||||
use embedded_hal::digital::OutputPin;
|
||||
use embedded_hal::spi;
|
||||
|
||||
@@ -6,10 +6,13 @@ mod io;
|
||||
#[cfg(feature = "embassy-sync")]
|
||||
mod mutex;
|
||||
|
||||
#[allow(unused_imports)]
|
||||
pub use crate::adc::*;
|
||||
pub use crate::delay::*;
|
||||
#[allow(unused_imports)]
|
||||
pub use crate::io::*;
|
||||
#[cfg(feature = "embassy-sync")]
|
||||
#[allow(unused_imports)]
|
||||
pub use crate::mutex::*;
|
||||
pub use ads1256_types::adcon::{ClockOut, Gain, Sdcs};
|
||||
pub use ads1256_types::drate::DataRate;
|
||||
|
||||
@@ -157,7 +157,7 @@ impl Status {
|
||||
#[inline(always)]
|
||||
pub const fn data_ready(self) -> bool {
|
||||
const MASK: u8 = 0b1;
|
||||
unsafe { mem::transmute::<u8, bool>(self.0 & MASK) }
|
||||
unsafe { !mem::transmute::<u8, bool>(self.0 & MASK) }
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
pub mod input {
|
||||
use crate::{Buffer, Config, DataRate, Gain, Multiplexer, MuxInput};
|
||||
use crate::{Multiplexer, MuxInput};
|
||||
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
|
||||
|
||||
@@ -34,4 +34,4 @@ features = ["tick-hz-16_000_000"]
|
||||
[dependencies.panic-probe]
|
||||
workspace = true
|
||||
[dependencies]
|
||||
log = "0.4.20"
|
||||
log = "0.4.*"
|
||||
|
||||
@@ -1,27 +1,25 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use cortex_m::prelude::{_embedded_hal_blocking_delay_DelayMs, _embedded_hal_blocking_delay_DelayUs};
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
use {embassy_executor as executor, embassy_stm32 as stm32};
|
||||
|
||||
use ads1256::{
|
||||
AdControl, Ads1256, AutoCal, BitOrder, Buffer, ClockOut, Config, DState, DataRate, DigitalIo,
|
||||
DigitalIoDirection, DigitalIoState, DioDirection, Gain, Multiplexer, MuxInput, OutputPin, Sdcs,
|
||||
SpiBus, Status, Wait, BlockingDelay
|
||||
AdControl, Ads1256, AutoCal, BitOrder, Buffer, ClockOut, Config,
|
||||
DataRate, DigitalIo, DigitalIoDirection, DigitalIoState, Gain, Multiplexer,
|
||||
MuxInput, OutputPin, Sdcs, SpiBus, Status, Wait,
|
||||
};
|
||||
use embassy_time::{Delay, Timer};
|
||||
use embassy_time::Delay;
|
||||
use executor::Spawner;
|
||||
use physical::quantity::Quantity;
|
||||
use stm32::dma::NoDma;
|
||||
use stm32::exti::ExtiInput;
|
||||
use stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||
use stm32::gpio::{Level, Output, Pull, Speed};
|
||||
use stm32::spi::Spi;
|
||||
use stm32::time::Hertz;
|
||||
use stm32::{pac, spi};
|
||||
|
||||
use defmt::{debug, error, info, trace, unwrap};
|
||||
use defmt::info;
|
||||
|
||||
const AUTOCAL_CONF: Config = Config {
|
||||
status: Status::setting(Buffer::Enabled, AutoCal::Enabled, BitOrder::MostSigFirst),
|
||||
@@ -33,15 +31,17 @@ const AUTOCAL_CONF: Config = Config {
|
||||
|
||||
const ADS1256_DELAY: ads1256::DefaultDelay<Delay> = ads1256::DefaultDelay::new(Delay);
|
||||
|
||||
stm32::bind_interrupts!(struct Irqs {
|
||||
EXTI3 => stm32::exti::InterruptHandler<stm32::interrupt::typelevel::EXTI3>;
|
||||
});
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(spawner: Spawner) {
|
||||
unsafe {
|
||||
pac::FLASH.acr().modify(|v| {
|
||||
v.set_prften(true);
|
||||
v.set_icen(true);
|
||||
v.set_dcen(true);
|
||||
});
|
||||
}
|
||||
async fn main(_spawner: Spawner) {
|
||||
pac::FLASH.acr().modify(|v| {
|
||||
v.set_prften(true);
|
||||
v.set_icen(true);
|
||||
v.set_dcen(true);
|
||||
});
|
||||
|
||||
let p = embassy_stm32::init(Default::default());
|
||||
|
||||
@@ -50,18 +50,10 @@ async fn main(spawner: Spawner) {
|
||||
spi_conf.bit_order = spi::BitOrder::MsbFirst;
|
||||
spi_conf.frequency = Hertz(ads1256::defaults::SPI_CLK_HZ);
|
||||
|
||||
let ads1256_data_ready = ExtiInput::new(Input::new(p.PA3, Pull::Up), p.EXTI3);
|
||||
let ads1256_data_ready = ExtiInput::new(p.PA3, p.EXTI3, Pull::Up, Irqs);
|
||||
let select_ads1256 = Output::new(p.PA1, Level::High, Speed::VeryHigh);
|
||||
|
||||
let mut spi = Spi::new(
|
||||
p.SPI1,
|
||||
p.PA5,
|
||||
p.PA7,
|
||||
p.PA6,
|
||||
NoDma,
|
||||
NoDma,
|
||||
spi_conf,
|
||||
);
|
||||
let mut spi = Spi::new_blocking(p.SPI1, p.PA5, p.PA7, p.PA6, spi_conf);
|
||||
|
||||
let mut ads_1256 = Ads1256::new(ADS1256_DELAY, select_ads1256, ads1256_data_ready);
|
||||
// single_conversion(&mut spi, &mut ads_1256).await;
|
||||
@@ -70,6 +62,7 @@ async fn main(spawner: Spawner) {
|
||||
cycle_multiplexer(&mut spi, &mut ads_1256).await;
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
async fn single_conversion<DelayerT: ads1256::BlockingDelay, SST: OutputPin, DrdyT: Wait>(
|
||||
spi: &mut impl SpiBus,
|
||||
ads_1256: &mut Ads1256<DelayerT, SST, DrdyT>,
|
||||
@@ -78,9 +71,14 @@ async fn single_conversion<DelayerT: ads1256::BlockingDelay, SST: OutputPin, Drd
|
||||
ads_1256.delayer.t11_1_delay();
|
||||
ads_1256.conversion_init(spi).unwrap();
|
||||
let data = ads_1256.cmd_read_data(spi).await.unwrap();
|
||||
info!("data: {}, volts: {}", data, data.to_voltage(AUTOCAL_CONF.ad_control.gain()).fmt(Some(5)));
|
||||
info!(
|
||||
"data: {}, volts: {}",
|
||||
data,
|
||||
data.to_voltage(AUTOCAL_CONF.ad_control.gain()).fmt(Some(5))
|
||||
);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
async fn read_continuous<DelayerT: ads1256::BlockingDelay, SST: OutputPin, DrdyT: Wait>(
|
||||
spi: &mut impl SpiBus,
|
||||
ads_1256: &mut Ads1256<DelayerT, SST, DrdyT>,
|
||||
@@ -90,7 +88,11 @@ async fn read_continuous<DelayerT: ads1256::BlockingDelay, SST: OutputPin, DrdyT
|
||||
ads_1256.start_rdatac(spi).await.unwrap();
|
||||
loop {
|
||||
let data = ads_1256.read_data(spi).await.unwrap();
|
||||
info!("data: {}, volts: {}", data, data.to_voltage(AUTOCAL_CONF.ad_control.gain()).fmt(Some(5)));
|
||||
info!(
|
||||
"data: {}, volts: {}",
|
||||
data,
|
||||
data.to_voltage(AUTOCAL_CONF.ad_control.gain()).fmt(Some(5))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,7 +105,6 @@ async fn cycle_multiplexer<DelayerT: ads1256::BlockingDelay, SST: OutputPin, Drd
|
||||
const INPUT_3: Multiplexer = Multiplexer::setting(MuxInput::AIn3, MuxInput::Common);
|
||||
|
||||
let ad_control = AUTOCAL_CONF.ad_control;
|
||||
let status = AUTOCAL_CONF.status;
|
||||
|
||||
ads_1256.write_config(spi, AUTOCAL_CONF).unwrap();
|
||||
ads_1256.delayer.t11_1_delay();
|
||||
@@ -113,19 +114,30 @@ async fn cycle_multiplexer<DelayerT: ads1256::BlockingDelay, SST: OutputPin, Drd
|
||||
.autocal_convert(spi, INPUT_1, None, Some(ad_control.with_gain(Gain::X4)), None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
info!("Input 1: data: {}, volts: {}", data, data.to_voltage(ad_control.gain()).fmt(Some(5)));
|
||||
info!(
|
||||
"Input 1: data: {}, volts: {}",
|
||||
data,
|
||||
data.to_voltage(ad_control.gain()).fmt(Some(5))
|
||||
);
|
||||
let ad_control = ad_control.with_gain(Gain::X8);
|
||||
let data = ads_1256
|
||||
.autocal_convert(spi, INPUT_2, None, Some(ad_control.with_gain(Gain::X8)), None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
info!("Input 2: data: {}, volts: {}", data, data.to_voltage(ad_control.gain()).fmt(Some(5)));
|
||||
info!(
|
||||
"Input 2: data: {}, volts: {}",
|
||||
data,
|
||||
data.to_voltage(ad_control.gain()).fmt(Some(5))
|
||||
);
|
||||
let ad_control = ad_control.with_gain(Gain::X16);
|
||||
let data = ads_1256
|
||||
.autocal_convert(spi, INPUT_3, None, Some(ad_control.with_gain(Gain::X16)), None, false)
|
||||
.await
|
||||
.unwrap();
|
||||
info!("Input 3: data: {}, volts: {}", data, data.to_voltage(ad_control.gain()).fmt(Some(5)));
|
||||
info!(
|
||||
"Input 3: data: {}, volts: {}",
|
||||
data,
|
||||
data.to_voltage(ad_control.gain()).fmt(Some(5))
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
use cortex_m::prelude::_embedded_hal_blocking_delay_DelayUs;
|
||||
use {defmt_rtt as _, panic_probe as _};
|
||||
|
||||
use embassy_stm32::bind_interrupts;
|
||||
use {embassy_executor as executor, embassy_stm32 as stm32};
|
||||
|
||||
use ads1256::{
|
||||
@@ -13,26 +13,28 @@ use ads1256::{
|
||||
};
|
||||
use embassy_time::Delay;
|
||||
use executor::Spawner;
|
||||
use stm32::dma::NoDma;
|
||||
|
||||
use stm32::exti::ExtiInput;
|
||||
use stm32::gpio::{Input, Level, Output, Pull, Speed};
|
||||
use stm32::gpio::{Level, Output, Pull, Speed};
|
||||
use stm32::spi::Spi;
|
||||
use stm32::time::Hertz;
|
||||
use stm32::{pac, spi};
|
||||
|
||||
use defmt::{debug, error, info, trace, unwrap};
|
||||
use defmt::info;
|
||||
|
||||
const ADS1256_DELAY: ads1256::DefaultDelay<Delay> = ads1256::DefaultDelay::new(Delay);
|
||||
|
||||
bind_interrupts!(struct Irqs {
|
||||
EXTI3 => stm32::exti::InterruptHandler<stm32::interrupt::typelevel::EXTI3>;
|
||||
});
|
||||
|
||||
#[embassy_executor::main]
|
||||
async fn main(spawner: Spawner) {
|
||||
unsafe {
|
||||
pac::FLASH.acr().modify(|v| {
|
||||
v.set_prften(true);
|
||||
v.set_icen(true);
|
||||
v.set_dcen(true);
|
||||
});
|
||||
}
|
||||
async fn main(_spawner: Spawner) {
|
||||
pac::FLASH.acr().modify(|v| {
|
||||
v.set_prften(true);
|
||||
v.set_icen(true);
|
||||
v.set_dcen(true);
|
||||
});
|
||||
|
||||
let p = embassy_stm32::init(Default::default());
|
||||
|
||||
@@ -41,18 +43,10 @@ async fn main(spawner: Spawner) {
|
||||
spi_conf.bit_order = spi::BitOrder::MsbFirst;
|
||||
spi_conf.frequency = Hertz(ads1256::defaults::SPI_CLK_HZ);
|
||||
|
||||
let ads1256_data_ready = ExtiInput::new(Input::new(p.PA3, Pull::Up), p.EXTI3);
|
||||
let ads1256_data_ready = ExtiInput::new(p.PA3, p.EXTI3, Pull::Up, Irqs);
|
||||
let select_ads1256 = Output::new(p.PA1, Level::High, Speed::VeryHigh);
|
||||
|
||||
let mut spi = Spi::new(
|
||||
p.SPI1,
|
||||
p.PA5,
|
||||
p.PA7,
|
||||
p.PA6,
|
||||
NoDma,
|
||||
NoDma,
|
||||
spi_conf,
|
||||
);
|
||||
let mut spi = Spi::new_blocking(p.SPI1, p.PA5, p.PA7, p.PA6, spi_conf);
|
||||
|
||||
let mut ads_1256 = Ads1256::new(ADS1256_DELAY, select_ads1256, ads1256_data_ready);
|
||||
// status(&mut spi, &mut ads_1256);
|
||||
@@ -60,9 +54,10 @@ async fn main(spawner: Spawner) {
|
||||
// ad_control(&mut spi, &mut ads_1256);
|
||||
// data_rate(&mut spi, &mut ads_1256);
|
||||
// gpio(&mut spi, &mut ads_1256);
|
||||
config(&mut spi, &mut ads_1256);
|
||||
config(&mut spi, &mut ads_1256);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn status<DelayerT: ads1256::BlockingDelay, SST: OutputPin, DrdyT: Wait>(
|
||||
spi: &mut impl SpiBus,
|
||||
ads_1256: &mut Ads1256<DelayerT, SST, DrdyT>,
|
||||
@@ -79,6 +74,7 @@ fn status<DelayerT: ads1256::BlockingDelay, SST: OutputPin, DrdyT: Wait>(
|
||||
info!("ADS1256 new status: {}", status);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn multiplexer<DelayerT: ads1256::BlockingDelay, SST: OutputPin, DrdyT: Wait>(
|
||||
spi: &mut impl SpiBus,
|
||||
ads_1256: &mut Ads1256<DelayerT, SST, DrdyT>,
|
||||
@@ -98,6 +94,7 @@ fn multiplexer<DelayerT: ads1256::BlockingDelay, SST: OutputPin, DrdyT: Wait>(
|
||||
info!("ADS1256 new ad_control: {}", multiplexer);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn ad_control<DelayerT: ads1256::BlockingDelay, SST: OutputPin, DrdyT: Wait>(
|
||||
spi: &mut impl SpiBus,
|
||||
ads_1256: &mut Ads1256<DelayerT, SST, DrdyT>,
|
||||
@@ -115,6 +112,7 @@ fn ad_control<DelayerT: ads1256::BlockingDelay, SST: OutputPin, DrdyT: Wait>(
|
||||
info!("ADS1256 new ad_control: {}", ad_control);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn data_rate<DelayerT: ads1256::BlockingDelay, SST: OutputPin, DrdyT: Wait>(
|
||||
spi: &mut impl SpiBus,
|
||||
ads_1256: &mut Ads1256<DelayerT, SST, DrdyT>,
|
||||
@@ -129,6 +127,7 @@ fn data_rate<DelayerT: ads1256::BlockingDelay, SST: OutputPin, DrdyT: Wait>(
|
||||
info!("ADS1256 new data rate: {}", data_rate);
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn gpio<DelayerT: ads1256::BlockingDelay, SST: OutputPin, DrdyT: Wait>(
|
||||
spi: &mut impl SpiBus,
|
||||
ads_1256: &mut Ads1256<DelayerT, SST, DrdyT>,
|
||||
|
||||
@@ -110,7 +110,7 @@ pub fn quantity_type(input: TokenStream) -> TokenStream {
|
||||
derive_more::SubAssign,
|
||||
derive_more::Display
|
||||
)]
|
||||
#[display(fmt = "{} {}", _0, "Self::symbol()")]
|
||||
#[display("{_0} {}", Self::symbol())]
|
||||
#[repr(transparent)]
|
||||
pub struct #struct_name<V: Value>(pub V);
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ stm32 = ["embassy-stm32", "physical/stm32"]
|
||||
|
||||
[dependencies.physical]
|
||||
path = ".."
|
||||
[dependencies.cfg-if]
|
||||
workspace = true
|
||||
[dependencies.embedded-hal]
|
||||
workspace = true
|
||||
[dependencies.embedded-hal-async]
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
#[allow(async_fn_in_trait)]
|
||||
pub trait Sender {
|
||||
async fn send(&mut self, msg: &[u8]) -> Result<(), Reset>;
|
||||
}
|
||||
|
||||
#[allow(async_fn_in_trait)]
|
||||
pub trait Receiver {
|
||||
async fn receive(&mut self, buffer: &mut [u8]) -> Result<(), Reset>;
|
||||
}
|
||||
|
||||
+11
-9
@@ -3,28 +3,30 @@
|
||||
|
||||
use crate::comms;
|
||||
use embassy_stm32::peripherals::USB_OTG_FS;
|
||||
use embassy_stm32::usb_otg::{Driver, Endpoint, In, Out};
|
||||
use embassy_usb::driver::{EndpointIn, EndpointOut};
|
||||
use embassy_stm32::usb::Driver as StmUsbDriver;
|
||||
use embassy_usb::driver::{Driver as UsbDriverTrait, EndpointIn, EndpointOut};
|
||||
use embassy_usb::UsbDevice;
|
||||
|
||||
pub type TypedUSB = UsbDevice<'static, Driver<'static, USB_OTG_FS>>;
|
||||
pub type TypedInterIn = Endpoint<'static, USB_OTG_FS, In>;
|
||||
pub type TypedInterOut = Endpoint<'static, USB_OTG_FS, Out>;
|
||||
type UsbDriver = StmUsbDriver<'static, USB_OTG_FS>;
|
||||
type InterIn = <UsbDriver as UsbDriverTrait<'static>>::EndpointIn;
|
||||
type InterOut = <UsbDriver as UsbDriverTrait<'static>>::EndpointOut;
|
||||
|
||||
pub type TypedUSB = UsbDevice<'static, UsbDriver>;
|
||||
|
||||
pub struct UsbIO {
|
||||
/// Send to master
|
||||
pub interrupt_in: TypedInterIn,
|
||||
pub interrupt_in: InterIn,
|
||||
/// Recieve from master
|
||||
pub interrupt_out: TypedInterOut,
|
||||
pub interrupt_out: InterOut,
|
||||
}
|
||||
|
||||
impl comms::Sender for TypedInterIn {
|
||||
impl<T: EndpointIn> comms::Sender for T {
|
||||
async fn send(&mut self, msg: &[u8]) -> Result<(), comms::Reset> {
|
||||
self.write(msg).await.map_err(|_| comms::Reset)
|
||||
}
|
||||
}
|
||||
|
||||
impl comms::Receiver for TypedInterOut {
|
||||
impl<T: EndpointOut> comms::Receiver for T {
|
||||
#[cfg(feature = "single-packet-msgs")]
|
||||
async fn receive(&mut self, buffer: &mut [u8]) -> Result<(), comms::Reset> {
|
||||
// This is OK when all our messages are smaller than a single packet.
|
||||
|
||||
+2
-2
@@ -1,8 +1,8 @@
|
||||
# Before upgrading check that everything is available on all tier1 targets here:
|
||||
# https://rust-lang.github.io/rustup-components-history
|
||||
[toolchain]
|
||||
channel = "1.82"
|
||||
components = [ "rust-src", "rustfmt", "llvm-tools" ]
|
||||
channel = "1.93.1"
|
||||
components = [ "rust-src", "rustfmt" ]
|
||||
targets = [
|
||||
"thumbv7em-none-eabi",
|
||||
"thumbv7m-none-eabi",
|
||||
|
||||
+2
-2
@@ -3,6 +3,6 @@ format_strings = true
|
||||
wrap_comments = true
|
||||
match_block_trailing_comma = true
|
||||
enum_discrim_align_threshold = 25
|
||||
fn_call_width = 100
|
||||
fn_call_width = 110
|
||||
single_line_if_else_max_width = 110
|
||||
comment_width = 120
|
||||
single_line_if_else_max_width = 100
|
||||
+10
-13
@@ -6,9 +6,6 @@ mod volume;
|
||||
mod volume_rate;
|
||||
mod pressure;
|
||||
|
||||
#[cfg(feature = "defmt")]
|
||||
pub use defmt_impl::*;
|
||||
|
||||
pub use irradiance::*;
|
||||
pub use resistance::*;
|
||||
pub use temperature::*;
|
||||
@@ -22,16 +19,16 @@ use core::marker::PhantomData;
|
||||
use core::ops::{Add, Sub};
|
||||
use num_traits::{FromPrimitive, Num, NumCast};
|
||||
|
||||
const DECA: u8 = 10;
|
||||
const DECI: u8 = 10;
|
||||
const HECTO: u8 = 100;
|
||||
const CENTI: u8 = 100;
|
||||
const KILO: u16 = 1_000;
|
||||
const MILLI: u16 = 1_000;
|
||||
const MEGA: u32 = 1_000_000;
|
||||
const MICRO: u32 = 1_000_000;
|
||||
const GIGA: u32 = 1_000_000_000;
|
||||
const NANO: u32 = 1_000_000_000;
|
||||
pub const DECA: u8 = 10;
|
||||
pub const DECI: u8 = 10;
|
||||
pub const HECTO: u8 = 100;
|
||||
pub const CENTI: u8 = 100;
|
||||
pub const KILO: u16 = 1_000;
|
||||
pub const MILLI: u16 = 1_000;
|
||||
pub const MEGA: u32 = 1_000_000;
|
||||
pub const MICRO: u32 = 1_000_000;
|
||||
pub const GIGA: u32 = 1_000_000_000;
|
||||
pub const NANO: u32 = 1_000_000_000;
|
||||
|
||||
pub trait Quantity<V: Value>: Copy + PartialEq + PartialOrd + Add + Sub {
|
||||
fn value(self) -> V;
|
||||
|
||||
@@ -19,9 +19,9 @@ quantity_type! {MilliLiters, "mL"}
|
||||
|
||||
impl<V: Value> MilliLiters<V> {
|
||||
#[inline]
|
||||
pub fn to_liters(self) -> MilliLiters<V> {
|
||||
pub fn to_liters(self) -> Liters<V> {
|
||||
let divisor = V::from_u16(MILLI).unwrap();
|
||||
MilliLiters(self.0 / divisor)
|
||||
Liters(self.0 / divisor)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
mod part;
|
||||
|
||||
#[allow(unused_imports)]
|
||||
pub use part::*;
|
||||
@@ -1,6 +1,6 @@
|
||||
//! Note - Thermocouple conversion uses [f64] arithmetic internally.
|
||||
|
||||
use libm::pow;
|
||||
use libm::exp;
|
||||
use crate::error::InvalidValue;
|
||||
use crate::quantity::{Celsius, MilliVolts, Quantity};
|
||||
|
||||
@@ -45,7 +45,7 @@ fn _convert(
|
||||
|
||||
Ok(Celsius(celsius as f32))
|
||||
} else if mv >= 20.644 && mv <= 54.886 {
|
||||
let celsius = 1.318058e2
|
||||
let celsius = -1.318058e2
|
||||
+ 4.830222E+1 * mv
|
||||
+ -1.646031 * mv_pow2
|
||||
+ 5.464731E-2 * mv_pow3
|
||||
@@ -136,8 +136,8 @@ pub fn temp_to_voltage_poly(
|
||||
Ok(MilliVolts(mv as f32))
|
||||
} else if celsius >= 0.0 && celsius <= 1372.0 {
|
||||
let base = celsius - 0.126968600000E+03;
|
||||
let exp = -0.118343200000E-03 * (base * base);
|
||||
let addition = pow(0.1185976, exp);
|
||||
let exponent = -0.118343200000E-03 * (base * base);
|
||||
let addition = 0.1185976 * exp(exponent);
|
||||
|
||||
let mv = -0.176004136860E-01
|
||||
+ 0.389212049750E-01 * celsius
|
||||
|
||||
Reference in New Issue
Block a user