Merge remote-tracking branch 'origin/develop' into develop
# Conflicts: # Software/MainBoard/rust/src/hal/water.rs
This commit is contained in:
@@ -161,9 +161,11 @@ pub(crate) async fn create_v4(
|
|||||||
info!("Start v4");
|
info!("Start v4");
|
||||||
let mut awake = Output::new(peripherals.gpio21, Level::High, OutputConfig::default());
|
let mut awake = Output::new(peripherals.gpio21, Level::High, OutputConfig::default());
|
||||||
awake.set_high();
|
awake.set_high();
|
||||||
|
info!("v4: gpio21 awake ok");
|
||||||
|
|
||||||
let mut general_fault = Output::new(peripherals.gpio23, Level::Low, OutputConfig::default());
|
let mut general_fault = Output::new(peripherals.gpio23, Level::Low, OutputConfig::default());
|
||||||
general_fault.set_low();
|
general_fault.set_low();
|
||||||
|
info!("v4: gpio23 general_fault ok");
|
||||||
|
|
||||||
let twai_config = Some(TwaiConfiguration::new(
|
let twai_config = Some(TwaiConfiguration::new(
|
||||||
peripherals.twai,
|
peripherals.twai,
|
||||||
@@ -172,17 +174,24 @@ pub(crate) async fn create_v4(
|
|||||||
TWAI_BAUDRATE,
|
TWAI_BAUDRATE,
|
||||||
TwaiMode::Normal,
|
TwaiMode::Normal,
|
||||||
));
|
));
|
||||||
|
info!("v4: twai config ok");
|
||||||
|
|
||||||
let extra1 = Output::new(peripherals.gpio6, Level::Low, OutputConfig::default());
|
let extra1 = Output::new(peripherals.gpio6, Level::Low, OutputConfig::default());
|
||||||
|
info!("v4: gpio6 extra1 ok");
|
||||||
let extra2 = Output::new(peripherals.gpio15, Level::Low, OutputConfig::default());
|
let extra2 = Output::new(peripherals.gpio15, Level::Low, OutputConfig::default());
|
||||||
|
info!("v4: gpio15 extra2 ok");
|
||||||
|
|
||||||
let one_wire_pin = Flex::new(peripherals.gpio18);
|
let one_wire_pin = Flex::new(peripherals.gpio18);
|
||||||
|
info!("v4: gpio18 one_wire ok");
|
||||||
let tank_power_pin = Output::new(peripherals.gpio11, Level::Low, OutputConfig::default());
|
let tank_power_pin = Output::new(peripherals.gpio11, Level::Low, OutputConfig::default());
|
||||||
|
info!("v4: gpio11 tank_power ok");
|
||||||
let flow_sensor_pin = Input::new(
|
let flow_sensor_pin = Input::new(
|
||||||
peripherals.gpio4,
|
peripherals.gpio4,
|
||||||
InputConfig::default().with_pull(Pull::Up),
|
InputConfig::default().with_pull(Pull::Up),
|
||||||
);
|
);
|
||||||
|
info!("v4: gpio4 flow_sensor ok");
|
||||||
|
|
||||||
|
info!("v4: creating tank sensor");
|
||||||
let tank_sensor = TankSensor::create(
|
let tank_sensor = TankSensor::create(
|
||||||
one_wire_pin,
|
one_wire_pin,
|
||||||
peripherals.adc1,
|
peripherals.adc1,
|
||||||
@@ -191,12 +200,17 @@ pub(crate) async fn create_v4(
|
|||||||
flow_sensor_pin,
|
flow_sensor_pin,
|
||||||
peripherals.pcnt1,
|
peripherals.pcnt1,
|
||||||
)?;
|
)?;
|
||||||
|
info!("v4: tank sensor ok");
|
||||||
|
|
||||||
let can_power = Output::new(peripherals.gpio22, Level::Low, OutputConfig::default());
|
let can_power = Output::new(peripherals.gpio22, Level::Low, OutputConfig::default());
|
||||||
|
info!("v4: gpio22 can_power ok");
|
||||||
|
|
||||||
let solar_is_day = Input::new(peripherals.gpio7, InputConfig::default());
|
let solar_is_day = Input::new(peripherals.gpio7, InputConfig::default());
|
||||||
|
info!("v4: gpio7 solar_is_day ok");
|
||||||
let light = Output::new(peripherals.gpio10, Level::Low, Default::default());
|
let light = Output::new(peripherals.gpio10, Level::Low, Default::default());
|
||||||
|
info!("v4: gpio10 light ok");
|
||||||
let charge_indicator = Output::new(peripherals.gpio3, Level::Low, Default::default());
|
let charge_indicator = Output::new(peripherals.gpio3, Level::Low, Default::default());
|
||||||
|
info!("v4: gpio3 charge_indicator ok");
|
||||||
|
|
||||||
info!("Start pump expander");
|
info!("Start pump expander");
|
||||||
let pump_device = I2cDevice::new(I2C_DRIVER.get().await);
|
let pump_device = I2cDevice::new(I2C_DRIVER.get().await);
|
||||||
|
|||||||
@@ -44,25 +44,34 @@ impl<'a> TankSensor<'a> {
|
|||||||
one_wire_pin.set_high();
|
one_wire_pin.set_high();
|
||||||
one_wire_pin.set_input_enable(true);
|
one_wire_pin.set_input_enable(true);
|
||||||
one_wire_pin.set_output_enable(true);
|
one_wire_pin.set_output_enable(true);
|
||||||
|
info!("tank: one_wire pin config ok");
|
||||||
|
|
||||||
let mut adc1_config = AdcConfig::new();
|
let mut adc1_config = AdcConfig::new();
|
||||||
|
info!("tank: adc config created");
|
||||||
let tank_pin =
|
let tank_pin =
|
||||||
adc1_config.enable_pin_with_cal::<_, AdcCalLine<_>>(gpio5, Attenuation::_11dB);
|
adc1_config.enable_pin_with_cal::<_, AdcCalLine<_>>(gpio5, Attenuation::_11dB);
|
||||||
|
info!("tank: adc pin cal ok");
|
||||||
let tank_channel = Adc::new(adc1, adc1_config).into_async();
|
let tank_channel = Adc::new(adc1, adc1_config).into_async();
|
||||||
|
info!("tank: adc channel ok");
|
||||||
|
|
||||||
let one_wire_bus = OneWire::new(one_wire_pin, false);
|
let one_wire_bus = OneWire::new(one_wire_pin, false);
|
||||||
|
info!("tank: one_wire bus ok");
|
||||||
|
|
||||||
pcnt1.set_high_limit(Some(i16::MAX))?;
|
pcnt1.set_high_limit(Some(i16::MAX))?;
|
||||||
|
info!("tank: pcnt high limit ok");
|
||||||
// Reject pulses shorter than ~12.8 µs (1023 APB cycles @ 80 MHz) to suppress EMI noise
|
// Reject pulses shorter than ~12.8 µs (1023 APB cycles @ 80 MHz) to suppress EMI noise
|
||||||
// on the sensor cable. Real flow pulses are in the millisecond range.
|
// on the sensor cable. Real flow pulses are in the millisecond range.
|
||||||
pcnt1.set_filter(Some(1023)).unwrap();
|
pcnt1.set_filter(Some(1023)).unwrap();
|
||||||
|
|
||||||
let ch0 = &pcnt1.channel0;
|
let ch0 = &pcnt1.channel0;
|
||||||
ch0.set_edge_signal(flow_sensor.peripheral_input());
|
ch0.set_edge_signal(flow_sensor.peripheral_input());
|
||||||
|
info!("tank: pcnt edge signal ok");
|
||||||
ch0.set_input_mode(Hold, Increment);
|
ch0.set_input_mode(Hold, Increment);
|
||||||
ch0.set_ctrl_mode(Keep, Keep);
|
ch0.set_ctrl_mode(Keep, Keep);
|
||||||
|
info!("tank: pcnt input/ctrl mode ok");
|
||||||
|
|
||||||
pcnt1.listen();
|
pcnt1.listen();
|
||||||
|
info!("tank: pcnt listen ok");
|
||||||
|
|
||||||
Ok(TankSensor {
|
Ok(TankSensor {
|
||||||
one_wire_bus,
|
one_wire_bus,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
|
|||||||
use embassy_sync::blocking_mutex::Mutex as BlockingMutex;
|
use embassy_sync::blocking_mutex::Mutex as BlockingMutex;
|
||||||
use log::{LevelFilter, Log, Metadata, Record};
|
use log::{LevelFilter, Log, Metadata, Record};
|
||||||
|
|
||||||
const MAX_LIVE_LOG_ENTRIES: usize = 64;
|
const MAX_LIVE_LOG_ENTRIES: usize = 128;
|
||||||
|
|
||||||
struct LiveLogBuffer {
|
struct LiveLogBuffer {
|
||||||
entries: Vec<(u64, String)>,
|
entries: Vec<(u64, String)>,
|
||||||
|
|||||||
Reference in New Issue
Block a user