Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/asynchronous/embassy/fw_update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use embassy_sync::blocking_mutex::raw::RawMutex;
use embassy_time::{with_timeout, Delay, Duration};
use embedded_hal_async::delay::DelayNs;
use embedded_hal_async::i2c::I2c;
use embedded_usb_pd::asynchronous::controller::PdController;
use embedded_usb_pd::{Error, PdError};

use super::Tps6699x;
Expand Down Expand Up @@ -44,7 +43,7 @@ impl<M: RawMutex, B: I2c> UpdateTarget for Tps6699x<'_, M, B> {
}

/// Attempt to exit fw update mode
async fn fw_update_mode_exit(&mut self, _delay: &mut impl DelayNs) -> Result<(), Error<Self::BusError>> {
async fn fw_update_mode_exit(&mut self, delay: &mut impl DelayNs) -> Result<(), Error<Self::BusError>> {
// Reset the controller if we failed to exit fw update mode
if let Ok(ret) = self
.execute_command(PORT0, Command::Tfue, TFUE_TIMEOUT_MS, None, None)
Expand All @@ -59,7 +58,7 @@ impl<M: RawMutex, B: I2c> UpdateTarget for Tps6699x<'_, M, B> {

// Reset to return to normal operating mode
info!("Resetting controller");
self.reset(&mut Delay).await?;
self.reset(delay).await?;

Ok(())
}
Expand Down
18 changes: 7 additions & 11 deletions src/asynchronous/embassy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ use embassy_time::{with_timeout, Delay, Duration};
use embedded_hal::digital::InputPin;
use embedded_hal_async::delay::DelayNs;
use embedded_hal_async::i2c::I2c;
use embedded_usb_pd::asynchronous::controller::PdController;
use embedded_usb_pd::{Error, PdError, PortId};

use super::interrupt::{self, InterruptController};
Expand Down Expand Up @@ -278,6 +277,13 @@ impl<'a, M: RawMutex, B: I2c> Tps6699x<'a, M, B> {

Ok(())
}

/// Reset the device.
async fn reset(&mut self, delay: &mut impl DelayNs) -> Result<(), Error<B::Error>> {
let _guard = self.disable_all_interrupts_guarded().await;
let mut inner = self.lock_inner().await;
inner.reset(delay, &Default::default()).await
}
}

impl<'a, M: RawMutex, B: I2c> interrupt::InterruptController for Tps6699x<'a, M, B> {
Expand All @@ -296,16 +302,6 @@ impl<'a, M: RawMutex, B: I2c> interrupt::InterruptController for Tps6699x<'a, M,
}
}

impl<M: RawMutex, B: I2c> PdController for Tps6699x<'_, M, B> {
type BusError = B::Error;

async fn reset(&mut self, delay: &mut impl DelayNs) -> Result<(), Error<Self::BusError>> {
let _guard = self.disable_all_interrupts_guarded().await;
let mut inner = self.lock_inner().await;
inner.reset(delay, &Default::default()).await
}
}

pub struct Interrupt<'a, M: RawMutex, B: I2c> {
controller: &'a controller::Controller<M, B>,
}
Expand Down