Skip to content

Commit

Permalink
Add initial PD controller trait
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertZ2011 committed Jan 9, 2025
1 parent 45fa9f2 commit a7b33eb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
defmt = ["dep:defmt"]
9 changes: 9 additions & 0 deletions src/asynchronous/controller.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
use core::future::Future;

use embedded_hal_async::delay::DelayNs;

use crate::Error;

pub trait PdController<BE> {
fn reset(&mut self, delay: &mut impl DelayNs) -> impl Future<Output = Result<(), Error<BE>>>;
}
1 change: 1 addition & 0 deletions src/asynchronous/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod controller;
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -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))]
Expand Down Expand Up @@ -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)]
Expand All @@ -62,4 +66,4 @@ impl<BE> Into<Error<BE>> for PdError {
fn into(self) -> Error<BE> {
Error::Pd(self)
}
}
}

0 comments on commit a7b33eb

Please sign in to comment.