diff --git a/Cargo.toml b/Cargo.toml index 1ea032e3..42ee9bba 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -165,10 +165,8 @@ esp-wifi = { git = "https://github.com/esp-rs/esp-wifi", rev = "d200a167237f03cf [features] default = ["defmt"] -battery_adc = [] battery_max17055 = ["dep:max17055"] -hw_v1 = ["battery_adc", "esp32s3"] hw_v2 = ["battery_max17055", "esp32s3"] # skipped v3 hw_v4 = ["battery_max17055", "esp32s3"] hw_v6 = ["battery_max17055"] # skipped v5, v6 has S3 and C6 options diff --git a/build.rs b/build.rs index d574b004..b2f0b967 100644 --- a/build.rs +++ b/build.rs @@ -84,14 +84,13 @@ fn main() { // Ensure that only a single HW version let hw_features = [ - (cfg!(feature = "hw_v1"), HwVersion::V1), (cfg!(feature = "hw_v2"), HwVersion::V2), (cfg!(feature = "hw_v4"), HwVersion::V4), (cfg!(feature = "hw_v6"), HwVersion::V6), ]; let Some(hw_version) = get_unique(hw_features) else { - panic!("Exactly 1 hardware version must be selected via its Cargo feature (hw_v1, hw_v2, hw_v4, hw_v6)"); + panic!("Exactly 1 hardware version must be selected via its Cargo feature (hw_v2, hw_v4, hw_v6)"); }; let build_config = BuildConfig { mcu, hw_version }; diff --git a/src/board/drivers/battery_monitor/battery_adc.rs b/src/board/drivers/battery_monitor/battery_adc.rs deleted file mode 100644 index 451027a6..00000000 --- a/src/board/drivers/battery_monitor/battery_adc.rs +++ /dev/null @@ -1,145 +0,0 @@ -use crate::{ - board::hal::{ - adc::{ - AdcCalEfuse, AdcCalLine, AdcConfig, AdcHasLineCal, AdcPin, Attenuation, - CalibrationAccess, ADC, - }, - peripheral::Peripheral, - prelude::*, - }, - task_control::TaskControlToken, - Shared, -}; -use embassy_futures::yield_now; -use embassy_time::{Duration, Ticker}; -use embedded_hal_old::adc::{Channel, OneShot}; - -#[derive(Clone, Copy, Debug, defmt::Format)] -pub struct BatteryAdcData { - pub voltage: u16, - pub charge_current: u16, -} - -pub struct BatteryAdc { - pub voltage_in: AdcPin>, - pub current_in: AdcPin>, - pub enable: EN, - pub adc: ADC<'static, ADCI>, -} - -fn raw_to_mv(raw: u16) -> u16 { - (raw as u32 * Attenuation::Attenuation11dB.ref_mv() as u32 / 4096) as u16 -} - -impl BatteryAdc -where - ADCI: CalibrationAccess + AdcCalEfuse + AdcHasLineCal + 'static + Peripheral

, - ADC<'static, ADCI>: OneShot>, - ADC<'static, ADCI>: OneShot>, - V: Channel, - A: Channel, -{ - pub fn new( - adc: ADCI, - voltage_in: impl Into, - current_in: impl Into, - enable: impl Into, - ) -> Self { - let mut adc_config = AdcConfig::new(); - - Self { - voltage_in: adc_config - .enable_pin_with_cal(voltage_in.into(), Attenuation::Attenuation11dB), - current_in: adc_config - .enable_pin_with_cal(current_in.into(), Attenuation::Attenuation11dB), - enable: enable.into(), - adc: unwrap!(ADC::adc(adc, adc_config)), - } - } - - pub async fn read_battery_voltage(&mut self) -> Result { - loop { - match self.adc.read(&mut self.voltage_in) { - Ok(out) => { - return Ok(2 * raw_to_mv(out)); // 2x voltage divider - } - Err(nb::Error::Other(_e)) => return Err(()), - Err(nb::Error::WouldBlock) => yield_now().await, - } - } - } - - pub async fn read_charge_current(&mut self) -> Result { - loop { - match self.adc.read(&mut self.current_in) { - Ok(out) => return Ok(raw_to_mv(out)), - Err(nb::Error::Other(_e)) => return Err(()), - Err(nb::Error::WouldBlock) => yield_now().await, - } - } - } - - pub async fn read_data(&mut self) -> Result { - Ok(BatteryAdcData { - voltage: self.read_battery_voltage().await?, - charge_current: self.read_charge_current().await?, - }) - } -} - -#[embassy_executor::task] -pub async fn monitor_task_adc( - battery: Shared, - mut task_control: TaskControlToken<()>, -) { - task_control - .run_cancellable(|_| async { - let mut timer = Ticker::every(Duration::from_millis(10)); - info!("ADC monitor started"); - - unwrap!(battery.lock().await.enable.set_high().ok()); - - let mut voltage_accumulator = 0; - let mut current_accumulator = 0; - - let mut sample_count = 0; - - const AVG_SAMPLE_COUNT: u32 = 128; - - loop { - { - let mut sensor = battery.lock().await; - if let Ok(data) = sensor.read_data().await { - voltage_accumulator += data.voltage as u32; - current_accumulator += data.charge_current as u32; - - if sample_count == AVG_SAMPLE_COUNT { - let average = BatteryAdcData { - voltage: (voltage_accumulator / AVG_SAMPLE_COUNT) as u16, - charge_current: (current_accumulator / AVG_SAMPLE_COUNT) as u16, - }; - sensor.update_data(average); - - debug!("Battery data: {:?}", average); - - sample_count = 0; - - voltage_accumulator = 0; - current_accumulator = 0; - } else { - sample_count += 1; - } - } else { - error!("Failed to read battery data"); - } - } - - timer.next().await; - } - }) - .await; - - unwrap!(battery.lock().await.enable.set_low().ok()); - - info!("Monitor exited"); -} diff --git a/src/board/drivers/battery_monitor/mod.rs b/src/board/drivers/battery_monitor/mod.rs index 0c1890b0..45a807bd 100644 --- a/src/board/drivers/battery_monitor/mod.rs +++ b/src/board/drivers/battery_monitor/mod.rs @@ -6,19 +6,9 @@ use embassy_sync::mutex::Mutex; use embedded_hal::digital::InputPin; use gui::screens::{BatteryInfo, ChargingState}; -#[cfg(feature = "battery_adc")] -pub mod battery_adc; #[cfg(feature = "battery_max17055")] pub mod battery_fg; -#[cfg(feature = "battery_adc")] -use crate::board::{ - drivers::battery_monitor::battery_adc::{ - monitor_task_adc as monitor_task, BatteryAdcData as BatteryData, - }, - BatteryAdc as BatterySensorImpl, -}; - #[cfg(feature = "battery_max17055")] use crate::board::{ drivers::battery_monitor::battery_fg::{ @@ -27,10 +17,10 @@ use crate::board::{ BatteryFg as BatterySensorImpl, }; -#[cfg(any(feature = "battery_adc", feature = "battery_max17055"))] +#[cfg(feature = "battery_max17055")] use crate::board::LOW_BATTERY_PERCENTAGE; -#[cfg(any(feature = "battery_adc", feature = "battery_max17055"))] +#[cfg(feature = "battery_max17055")] use embassy_executor::Spawner; #[derive(Default, Clone, Copy)] @@ -142,33 +132,6 @@ impl BatteryMonitor { } } -#[cfg(feature = "battery_adc")] -impl BatteryMonitor { - fn convert_battery_data(&self, data: BatteryData) -> BatteryInfo { - use signal_processing::battery::BatteryModel; - - let battery_model = BatteryModel { - voltage: (2750, 4200), - charge_current: (0, 1000), - }; - - let charge_current = if self.is_charging() { - None - } else { - Some(data.charge_current) - }; - - let percentage = battery_model.estimate(data.voltage, charge_current); - - BatteryInfo { - voltage: data.voltage, - charging_state: self.charging_state(), - percentage, - is_low: percentage < LOW_BATTERY_PERCENTAGE, - } - } -} - #[cfg(feature = "battery_max17055")] impl BatteryMonitor { pub fn convert_battery_data(&mut self, data: BatteryData) -> BatteryInfo { diff --git a/src/board/hardware/v1.rs b/src/board/hardware/v1.rs deleted file mode 100644 index 79081d46..00000000 --- a/src/board/hardware/v1.rs +++ /dev/null @@ -1,145 +0,0 @@ -use crate::board::{ - drivers::{ - battery_monitor::{battery_adc::BatteryAdc as BatteryAdcType, BatteryMonitor}, - display::Display as DisplayType, - frontend::{Frontend, PoweredFrontend}, - }, - hal::{ - self, - adc::ADC2, - clock::ClockControl, - dma::*, - embassy, - gpio::{Analog, Floating, GpioPin, Input, Output, PullUp, PushPull}, - peripherals::{self, Peripherals}, - prelude::*, - spi::{master::dma::SpiDma, FullDuplexMode}, - systimer::SystemTimer, - timer::TimerGroup, - Rtc, IO, - }, - utils::DummyOutputPin, - wifi::WifiDriver, -}; -use embassy_time::Delay; -use embedded_hal_bus::spi::ExclusiveDevice; - -use display_interface_spi::SPIInterface; - -pub type DisplaySpiInstance = hal::peripherals::SPI2; -pub type DisplayDmaChannel = ChannelCreator0; -pub type DisplayDataCommand = GpioPin, 13>; -pub type DisplayChipSelect = GpioPin, 10>; -pub type DisplayReset = GpioPin, 9>; -pub type DisplaySclk = GpioPin, 12>; -pub type DisplayMosi = GpioPin, 11>; - -pub type DisplayInterface<'a> = SPIInterface, DisplayDataCommand>; -pub type DisplaySpi<'d> = ExclusiveDevice< - SpiDma<'d, DisplaySpiInstance, Channel0, FullDuplexMode>, - DummyOutputPin, - Delay, ->; - -pub type AdcDmaChannel = ChannelCreator1; -pub type AdcSpiInstance = hal::peripherals::SPI3; -pub type AdcSclk = GpioPin, 6>; -pub type AdcMosi = GpioPin, 7>; -pub type AdcMiso = GpioPin, 5>; -pub type AdcChipSelect = GpioPin, 18>; -pub type AdcClockEnable = DummyOutputPin; -pub type AdcDrdy = GpioPin, 4>; -pub type AdcReset = GpioPin, 2>; -pub type TouchDetect = GpioPin, 1>; -pub type AdcSpi = ExclusiveDevice< - SpiDma<'static, AdcSpiInstance, Channel1, FullDuplexMode>, - AdcChipSelect, - Delay, ->; - -pub type BatteryAdcInput = GpioPin; -pub type BatteryAdcEnable = GpioPin, 8>; -pub type VbusDetect = GpioPin, 47>; -pub type ChargeCurrentInput = GpioPin; -pub type ChargerStatus = GpioPin, 21>; - -pub type EcgFrontend = Frontend; -pub type PoweredEcgFrontend = - PoweredFrontend; - -pub type Display = DisplayType; - -pub type BatteryAdc = BatteryAdcType; - -impl super::startup::StartupResources { - pub async fn initialize() -> Self { - Self::common_init(); - - let peripherals = Peripherals::take(); - - let system = peripherals.SYSTEM.split(); - let clocks = ClockControl::max(system.clock_control).freeze(); - - embassy::init(&clocks, SystemTimer::new(peripherals.SYSTIMER)); - - let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); - - let dma = Dma::new(peripherals.DMA); - - let display = Self::create_display_driver( - dma.channel0, - peripherals::Interrupt::DMA_IN_CH0, - peripherals::Interrupt::DMA_OUT_CH0, - peripherals.SPI2, - io.pins.gpio9, - io.pins.gpio13, - io.pins.gpio10, - io.pins.gpio12, - io.pins.gpio11, - &clocks, - ); - - let adc = Self::create_frontend_driver( - Self::create_frontend_spi( - dma.channel1, - peripherals::Interrupt::DMA_IN_CH1, - peripherals::Interrupt::DMA_OUT_CH1, - peripherals.SPI3, - io.pins.gpio6, - io.pins.gpio7, - io.pins.gpio5, - io.pins.gpio18, - &clocks, - ), - io.pins.gpio4, - io.pins.gpio2, - DummyOutputPin, - io.pins.gpio1, - ); - - // Battery ADC - let analog = peripherals.SENS.split(); - let battery_monitor = BatteryMonitor::start( - io.pins.gpio47.into(), - io.pins.gpio21.into(), - BatteryAdc::new(analog.adc2, io.pins.gpio17, io.pins.gpio14, io.pins.gpio8), - ) - .await; - - Self { - display, - frontend: adc, - battery_monitor, - wifi: static_cell::make_static! { - WifiDriver::new( - peripherals.WIFI, - TimerGroup::new(peripherals.TIMG1, &clocks).timer0, - peripherals.RNG, - system.radio_clock_control, - ) - }, - clocks, - rtc: Rtc::new(peripherals.LPWR), - } - } -} diff --git a/src/board/hardware/v2.rs b/src/board/hardware/v2.rs deleted file mode 100644 index 83fc21c9..00000000 --- a/src/board/hardware/v2.rs +++ /dev/null @@ -1,190 +0,0 @@ -#[cfg(feature = "battery_adc")] -use crate::board::{ - drivers::battery_monitor::{battery_adc::BatteryAdc as BatteryAdcType, BatteryMonitor}, - hal::{adc::ADC1, gpio::Analog}, -}; - -#[cfg(feature = "battery_max17055")] -use crate::board::{ - drivers::battery_monitor::battery_fg::BatteryFg as BatteryFgType, - hal::{gpio::Unknown, i2c::I2C}, -}; - -use crate::board::{ - drivers::{ - display::Display as DisplayType, - frontend::{Frontend, PoweredFrontend}, - }, - hal::{ - self, - clock::ClockControl, - dma::*, - embassy, - gpio::{Floating, GpioPin, Input, Output, PullUp, PushPull}, - peripherals::{self, Peripherals}, - prelude::*, - spi::{master::dma::SpiDma, FullDuplexMode}, - systimer::SystemTimer, - timer::TimerGroup, - Rtc, IO, - }, - utils::DummyOutputPin, - wifi::WifiDriver, -}; -use embassy_time::Delay; -use embedded_hal_bus::spi::ExclusiveDevice; - -use display_interface_spi::SPIInterface; - -pub type DisplaySpiInstance = hal::peripherals::SPI2; -pub type DisplayDmaChannel = ChannelCreator0; -pub type DisplayDataCommand = GpioPin, 13>; -pub type DisplayChipSelect = GpioPin, 11>; -pub type DisplayReset = GpioPin, 12>; -pub type DisplaySclk = GpioPin, 14>; -pub type DisplayMosi = GpioPin, 21>; - -pub type DisplayInterface<'a> = SPIInterface, DisplayDataCommand>; -pub type DisplaySpi<'d> = ExclusiveDevice< - SpiDma<'d, DisplaySpiInstance, Channel0, FullDuplexMode>, - DummyOutputPin, - Delay, ->; - -pub type AdcDmaChannel = ChannelCreator1; -pub type AdcSpiInstance = hal::peripherals::SPI3; -pub type AdcSclk = GpioPin, 6>; -pub type AdcMosi = GpioPin, 7>; -pub type AdcMiso = GpioPin, 5>; -pub type AdcChipSelect = GpioPin, 18>; -pub type AdcClockEnable = GpioPin, 38>; -pub type AdcDrdy = GpioPin, 4>; -pub type AdcReset = GpioPin, 2>; -pub type TouchDetect = GpioPin, 1>; -pub type AdcSpi = ExclusiveDevice< - SpiDma<'static, AdcSpiInstance, Channel1, FullDuplexMode>, - AdcChipSelect, - Delay, ->; - -pub type VbusDetect = GpioPin, 17>; -pub type ChargerStatus = GpioPin, 47>; - -pub type EcgFrontend = Frontend; -pub type PoweredEcgFrontend = - PoweredFrontend; - -pub type Display = DisplayType; - -#[cfg(feature = "battery_max17055")] -mod battery_monitor_types { - use super::*; - pub type BatteryFgI2cInstance = hal::peripherals::I2C0; - pub type I2cSda = GpioPin; - pub type I2cScl = GpioPin; - pub type BatteryFgI2c = I2C<'static, BatteryFgI2cInstance>; - pub type BatteryAdcEnable = GpioPin, 8>; - pub type BatteryFg = BatteryFgType; -} - -#[cfg(feature = "battery_adc")] -mod battery_monitor_types { - use super::*; - pub type ChargeCurrentInput = GpioPin; - pub type BatteryAdcInput = GpioPin; - pub type BatteryAdcEnable = GpioPin, 8>; - - pub type BatteryAdc = - BatteryAdcType; -} - -pub use battery_monitor_types::*; - -impl super::startup::StartupResources { - pub async fn initialize() -> Self { - Self::common_init(); - - let peripherals = Peripherals::take(); - - let system = peripherals.SYSTEM.split(); - let clocks = ClockControl::max(system.clock_control).freeze(); - - embassy::init(&clocks, SystemTimer::new(peripherals.SYSTIMER)); - - let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); - - let dma = Dma::new(peripherals.DMA); - - let display = Self::create_display_driver( - dma.channel0, - peripherals::Interrupt::DMA_IN_CH0, - peripherals::Interrupt::DMA_OUT_CH0, - peripherals.SPI2, - io.pins.gpio12, - io.pins.gpio13, - io.pins.gpio11, - io.pins.gpio14, - io.pins.gpio21, - &clocks, - ); - - let adc = Self::create_frontend_driver( - Self::create_frontend_spi( - dma.channel1, - peripherals::Interrupt::DMA_IN_CH1, - peripherals::Interrupt::DMA_OUT_CH1, - peripherals.SPI3, - io.pins.gpio6, - io.pins.gpio7, - io.pins.gpio5, - io.pins.gpio18, - &clocks, - ), - io.pins.gpio4, - io.pins.gpio2, - io.pins.gpio38, - io.pins.gpio1, - ); - - // Battery ADC - #[cfg(feature = "battery_adc")] - let battery_monitor = { - let analog = peripherals.SENS.split(); - BatteryMonitor::start( - io.pins.gpio17.into(), - io.pins.gpio47.into(), - BatteryAdc::new(analog.adc1, io.pins.gpio9, io.pins.gpio10, io.pins.gpio8), - ) - .await - }; - - #[cfg(feature = "battery_max17055")] - let battery_monitor = Self::setup_battery_monitor_fg( - peripherals.I2C0, - peripherals::Interrupt::I2C_EXT0, - io.pins.gpio35, - io.pins.gpio36, - io.pins.gpio17, - io.pins.gpio47, - io.pins.gpio8, - &clocks, - ) - .await; - - Self { - display, - frontend: adc, - battery_monitor, - wifi: static_cell::make_static! { - WifiDriver::new( - peripherals.WIFI, - TimerGroup::new(peripherals.TIMG1, &clocks).timer0, - peripherals.RNG, - system.radio_clock_control, - ) - }, - clocks, - rtc: Rtc::new(peripherals.LPWR), - } - } -} diff --git a/src/board/mod.rs b/src/board/mod.rs index 1e71156a..fcca7d15 100644 --- a/src/board/mod.rs +++ b/src/board/mod.rs @@ -1,11 +1,9 @@ -#[cfg_attr(feature = "hw_v1", path = "hardware/v1.rs")] #[cfg_attr(feature = "hw_v2", path = "hardware/v2.rs")] #[cfg_attr(feature = "hw_v4", path = "hardware/v4.rs")] #[cfg_attr(all(feature = "hw_v6", feature = "esp32s3"), path = "hardware/v6s3.rs")] #[cfg_attr(all(feature = "hw_v6", feature = "esp32c6"), path = "hardware/v6c6.rs")] #[cfg_attr( // We default to hw_v6/esp32c6 if no feature is selected to help rust-analyzer for example not(any( - feature = "hw_v1", feature = "hw_v2", feature = "hw_v4", all(feature = "hw_v6", feature = "esp32s3"), diff --git a/src/main.rs b/src/main.rs index bd0d2f5f..557ceaf9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -60,9 +60,6 @@ use crate::{ }, }; -#[cfg(feature = "hw_v1")] -use crate::{board::ChargerStatus, sleep::disable_gpio_wakeup, states::adc_setup::adc_setup}; - use crate::board::{ hal::rtc_cntl::{sleep, sleep::WakeupLevel}, TouchDetect, @@ -80,8 +77,6 @@ use crate::board::hal::gpio::RTCPinWithResistors as RtcWakeupPin; mod board; mod heap; pub mod human_readable; -#[cfg(feature = "hw_v1")] -mod sleep; mod stack_protection; mod states; mod task_control; @@ -120,8 +115,6 @@ pub type SharedGuard<'a, T> = MutexGuard<'a, NoopRawMutex, T>; #[derive(Debug)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] pub enum AppState { - #[cfg(feature = "hw_v1")] - AdcSetup, PreInitialize, Initialize, Measure, @@ -220,9 +213,6 @@ where async fn main(_spawner: Spawner) { let resources = StartupResources::initialize().await; - #[cfg(feature = "hw_v1")] - info!("Hardware version: v1"); - #[cfg(feature = "hw_v2")] info!("Hardware version: v2"); @@ -260,17 +250,11 @@ async fn main(_spawner: Spawner) { board.apply_hw_config_changes().await; board.config_changed = false; - #[cfg(feature = "hw_v1")] - let mut state = AppState::AdcSetup; - - #[cfg(not(feature = "hw_v1"))] let mut state = AppState::PreInitialize; loop { info!("New app state: {:?}", state); state = match state { - #[cfg(feature = "hw_v1")] - AppState::AdcSetup => adc_setup(&mut board).await, AppState::PreInitialize => { if board.battery_monitor.is_plugged() { AppState::Charging @@ -314,10 +298,6 @@ async fn main(_spawner: Spawner) { let mut rtc = resources.rtc; let is_charging = battery_monitor.is_plugged(); - #[cfg(feature = "hw_v1")] - let (_, mut charger_pin) = battery_monitor.stop().await; - - #[cfg(not(feature = "hw_v1"))] let (mut charger_pin, _) = battery_monitor.stop().await; let (_, _, _, mut touch) = board.frontend.split(); @@ -331,34 +311,6 @@ async fn main(_spawner: Spawner) { // will have nothing else to do. Not ideal, but again, we shouldn't reach this. } -#[cfg(feature = "hw_v1")] -fn setup_wakeup_pins<'a, 'b, const N: usize>( - wakeup_pins: &'a mut heapless::Vec<(&'b mut dyn RtcWakeupPin, WakeupLevel), N>, - touch: &'b mut TouchDetect, - charger_pin: &'b mut ChargerStatus, - is_charging: bool, -) -> sleep::RtcioWakeupSource<'a, 'b> { - unwrap!(wakeup_pins.push((touch, WakeupLevel::Low)).ok()); - - if is_charging { - // This is a bit awkward as unplugging then replugging will not wake the - // device. Ideally, we'd use the VBUS detect pin, but it's not connected to RTCIO. - disable_gpio_wakeup(charger_pin); - } else { - // We want to wake up when the charger is connected, or the electrodes are touched. - - // v1 uses the charger status pin, which is open drain - // and the board does not have a pullup resistor. A low signal means the battery is - // charging. This means we can watch for low level to detect a charger connection. - charger_pin.rtcio_pad_hold(true); - charger_pin.rtcio_pullup(true); - - unwrap!(wakeup_pins.push((charger_pin, WakeupLevel::Low)).ok()); - } - - sleep::RtcioWakeupSource::new(wakeup_pins) -} - #[cfg(any( feature = "hw_v2", feature = "hw_v4", diff --git a/src/sleep.rs b/src/sleep.rs deleted file mode 100644 index b5ee20f3..00000000 --- a/src/sleep.rs +++ /dev/null @@ -1,25 +0,0 @@ -use crate::board::hal::{gpio::GpioPin, peripherals}; - -enum RtcioWakeupType { - Disable = 0, - LowLevel = 4, - HighLevel = 5, -} - -fn enable_gpio_wakeup(_pin: &GpioPin, level: RtcioWakeupType) { - let sens = unsafe { &*peripherals::SENS::PTR }; - - // TODO: disable clock when not in use - sens.sar_peri_clk_gate_conf - .modify(|_, w| w.iomux_clk_en().set_bit()); - - let rtcio = unsafe { &*peripherals::RTC_IO::PTR }; - - rtcio.pin[PIN as usize] - .modify(|_, w| w.wakeup_enable().set_bit().int_type().variant(level as u8)); -} - -// Wakeup remains enabled after waking from deep sleep, so we need to disable it manually. -pub fn disable_gpio_wakeup(pin: &GpioPin) { - enable_gpio_wakeup(pin, RtcioWakeupType::Disable) -} diff --git a/src/states/adc_setup.rs b/src/states/adc_setup.rs deleted file mode 100644 index 7831d1a6..00000000 --- a/src/states/adc_setup.rs +++ /dev/null @@ -1,33 +0,0 @@ -use crate::{ - board::{ - initialized::{Context, InnerContext}, - EcgFrontend, - }, - AppState, -}; - -/// Ensures that the ADC does not keep the touch detector circuit disabled. -/// This state is expected to go away once the ADC can be properly placed into powerdown mode. -pub async fn adc_setup(context: &mut Context) -> AppState { - unsafe { - let frontend = core::ptr::read(&context.frontend); - - let (next_state, frontend) = adc_setup_impl(&mut context.inner, frontend).await; - - core::ptr::write(&mut context.frontend, frontend); - next_state - } -} - -async fn adc_setup_impl( - context: &mut InnerContext, - frontend: EcgFrontend, -) -> (AppState, EcgFrontend) { - match frontend.enable_async().await { - Ok(frontend) => (AppState::PreInitialize, frontend.shut_down().await), - Err((frontend, _err)) => { - context.display_message("ADC error").await; - (AppState::Shutdown, frontend) - } - } -} diff --git a/src/states/mod.rs b/src/states/mod.rs index 1ad4b285..25e7bb72 100644 --- a/src/states/mod.rs +++ b/src/states/mod.rs @@ -1,5 +1,3 @@ -#[cfg(feature = "hw_v1")] -pub mod adc_setup; pub mod charging; pub mod display_serial; pub mod firmware_update; diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 87445b93..9fe38a5d 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -76,7 +76,6 @@ pub enum Subcommands { #[derive(Default, Debug, Clone, Copy, PartialEq, Eq, ValueEnum)] pub enum HardwareVersion { - V1, V2, V4, V6S3, @@ -87,7 +86,6 @@ pub enum HardwareVersion { impl HardwareVersion { fn feature(&self) -> &str { match self { - HardwareVersion::V1 => "hw_v1", HardwareVersion::V2 => "hw_v2", HardwareVersion::V4 => "hw_v4", HardwareVersion::V6S3 => "hw_v6,esp32s3",