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 27, 2025
1 parent f22443c commit bd3f45c
Show file tree
Hide file tree
Showing 4 changed files with 18 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"]
11 changes: 11 additions & 0 deletions src/asynchronous/controller.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use core::future::Future;

use embedded_hal_async::delay::DelayNs;

use crate::Error;

pub trait PdController {
type BusError;

fn reset(&mut self, delay: &mut impl DelayNs) -> impl Future<Output = Result<(), Error<Self::BusError>>>;
}
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;
5 changes: 4 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 @@ -51,6 +53,7 @@ pub enum PdError {
InvalidMode,
/// Data serialization error
Serialize,
InProgress,
}

/// Top-level error type
Expand All @@ -73,4 +76,4 @@ impl<BE> Into<Error<BE>> for PdError {
fn into(self) -> Error<BE> {
Error::Pd(self)
}
}
}

0 comments on commit bd3f45c

Please sign in to comment.