Added comms traits
This commit is contained in:
@ -9,7 +9,7 @@ members = [
|
||||
]
|
||||
|
||||
[workspace.package]
|
||||
version = "0.3.0"
|
||||
version = "0.3.1"
|
||||
edition = "2021"
|
||||
repository = "https://git.bfpower.io/BFPOWER/physical"
|
||||
readme = "README.md"
|
||||
@ -76,6 +76,9 @@ version = "0.1.*"
|
||||
[workspace.dependencies.embassy-executor]
|
||||
version = "0.5.*"
|
||||
features = ["defmt", "arch-cortex-m", "integrated-timers", "executor-interrupt", "executor-thread"]
|
||||
[workspace.dependencies.embassy-usb]
|
||||
version = "0.2.*"
|
||||
features = ["defmt"]
|
||||
[workspace.dependencies.embassy-stm32]
|
||||
version = "0.1.*"
|
||||
features = ["defmt", "unstable-pac"]
|
||||
|
@ -7,6 +7,10 @@ repository.workspace = true
|
||||
readme.workspace = true
|
||||
license.workspace = true
|
||||
|
||||
[features]
|
||||
comms = []
|
||||
stm32 = ["embassy-stm32", "physical/stm32"]
|
||||
|
||||
[dependencies.physical]
|
||||
path = ".."
|
||||
[dependencies.embedded-hal]
|
||||
@ -17,3 +21,6 @@ workspace = true
|
||||
workspace = true
|
||||
[dependencies.uom]
|
||||
workspace = true
|
||||
[dependencies.embassy-stm32]
|
||||
workspace = true
|
||||
optional = true
|
||||
|
17
node/src/comms.rs
Normal file
17
node/src/comms.rs
Normal file
@ -0,0 +1,17 @@
|
||||
pub trait Sender {
|
||||
async fn send(&mut self, msg: &[u8]) -> Result<(), Reset>;
|
||||
}
|
||||
|
||||
pub trait Receiver {
|
||||
async fn receive(&mut self, buffer: &mut [u8]) -> Result<(), Reset>;
|
||||
}
|
||||
|
||||
//TODO: Replace with !
|
||||
pub struct Never;
|
||||
|
||||
/// Communication errors indicates either:
|
||||
/// Our connection was already disconnected, in which case we should reset and wait for new connection to made.
|
||||
/// or
|
||||
/// There was an unexpected, irrecoverable error in communication, in which case we don't want to enter a terminal error
|
||||
/// safe mode, because there is no indication the actual control is broken, so all we can really do is reset the connection.
|
||||
pub struct Reset;
|
@ -1,3 +1,8 @@
|
||||
#![no_std]
|
||||
|
||||
#[cfg(feature = "comms")]
|
||||
pub mod comms;
|
||||
#[cfg(feature = "stm32")]
|
||||
pub mod stm32;
|
||||
|
||||
pub use physical::CriticalError;
|
0
node/src/stm32/mod.rs
Normal file
0
node/src/stm32/mod.rs
Normal file
Reference in New Issue
Block a user