From a7b33ebc1d1e38644a96e66fc261d02901528819 Mon Sep 17 00:00:00 2001 From: Robert Zieba Date: Thu, 9 Jan 2025 11:56:18 -0700 Subject: [PATCH] Add initial PD controller trait --- Cargo.toml | 5 ++--- src/asynchronous/controller.rs | 9 +++++++++ src/asynchronous/mod.rs | 1 + src/lib.rs | 6 +++++- 4 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 src/asynchronous/controller.rs create mode 100644 src/asynchronous/mod.rs diff --git a/Cargo.toml b/Cargo.toml index 6816972..6ba0aec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,9 +5,8 @@ edition = "2021" [dependencies] defmt = { version = "0.3", optional = true } +embedded-hal-async = "1.0.0" [features] default = ["defmt"] -defmt = [ - "dep:defmt" -] \ No newline at end of file +defmt = ["dep:defmt"] diff --git a/src/asynchronous/controller.rs b/src/asynchronous/controller.rs new file mode 100644 index 0000000..58f1b18 --- /dev/null +++ b/src/asynchronous/controller.rs @@ -0,0 +1,9 @@ +use core::future::Future; + +use embedded_hal_async::delay::DelayNs; + +use crate::Error; + +pub trait PdController { + fn reset(&mut self, delay: &mut impl DelayNs) -> impl Future>>; +} diff --git a/src/asynchronous/mod.rs b/src/asynchronous/mod.rs new file mode 100644 index 0000000..cb9e0ac --- /dev/null +++ b/src/asynchronous/mod.rs @@ -0,0 +1 @@ +pub mod controller; diff --git a/src/lib.rs b/src/lib.rs index 3efbe73..8a20cb9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,7 @@ #![no_std] +pub mod asynchronous; + /// Port ID new type #[derive(Copy, Clone, Debug, PartialEq, Eq)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] @@ -41,6 +43,8 @@ pub enum PdError { ReverseCurrent, /// Set sink path rejected SetSinkPath, + /// The requested action has not yet completed + InProgress, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -62,4 +66,4 @@ impl Into> for PdError { fn into(self) -> Error { Error::Pd(self) } -} \ No newline at end of file +}