diff --git a/Cargo.toml b/Cargo.toml index 58382fb..dde9b18 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,10 @@ members = [ # Device types "node", "commander", + # Peripherals + "peripherals/standalone-ads1256/*", + # Peripheral components + "peripheral-components/ads1256/*", # Examples "examples/playground" ] @@ -17,7 +21,6 @@ repository = "https://git.bfpower.io/BFPOWER/physical" readme = "README.md" license = "MIT" -[workspace.dependencies] #----- no-std ---------------------------------- # Math [workspace.dependencies.libm] @@ -55,6 +58,13 @@ version = "0.7.*" [workspace.dependencies.panic-probe] version = "0.3.*" features = ["print-defmt"] +# BFPOWER Drivers +[workspace.dependencies.ads1256-types] +git = "https://git.bfpower.io/BFPOWER/bfpower-drivers.git" +features = ["defmt"] +[workspace.dependencies.ads1256] +git = "https://git.bfpower.io/BFPOWER/bfpower-drivers.git" +features = ["uom"] # Embassy [workspace.dependencies.embassy-futures] version = "0.1.*" diff --git a/node/Cargo.toml b/node/Cargo.toml index ba7f818..7eb900a 100644 --- a/node/Cargo.toml +++ b/node/Cargo.toml @@ -16,6 +16,4 @@ workspace = true [dependencies.defmt] workspace = true [dependencies.uom] -workspace = true -[dependencies.embassy-sync] workspace = true \ No newline at end of file diff --git a/node/src/lib.rs b/node/src/lib.rs index cf06c83..66ffc1f 100644 --- a/node/src/lib.rs +++ b/node/src/lib.rs @@ -1 +1,4 @@ -mod cell; +#![feature(async_fn_in_trait)] + +pub mod cell; +mod transducer; \ No newline at end of file diff --git a/node/src/transducer/input.rs b/node/src/transducer/input.rs new file mode 100644 index 0000000..839acc6 --- /dev/null +++ b/node/src/transducer/input.rs @@ -0,0 +1,2 @@ +pub use physical::transducer::input::*; + diff --git a/node/src/transducer/mod.rs b/node/src/transducer/mod.rs new file mode 100644 index 0000000..b0a4544 --- /dev/null +++ b/node/src/transducer/mod.rs @@ -0,0 +1,15 @@ +mod input; +mod output; + +pub use physical::transducer::*; + +// --------------------------------------------------------------------------------------------------------------------- +// ----- Publisher ------------------------ +// --------------------------------------------------------------------------------------------------------------------- +#[cfg(feature = "embassy-sync")] +pub trait Publisher { + type Value: Copy; + + + fn subscribe() -> SubT; +} \ No newline at end of file diff --git a/node/src/transducer/output.rs b/node/src/transducer/output.rs new file mode 100644 index 0000000..c441daa --- /dev/null +++ b/node/src/transducer/output.rs @@ -0,0 +1 @@ +pub use physical::transducer::output::*; \ No newline at end of file diff --git a/peripheral-components/ads1256/node/Cargo.toml b/peripheral-components/ads1256/node/Cargo.toml new file mode 100644 index 0000000..76d72d0 --- /dev/null +++ b/peripheral-components/ads1256/node/Cargo.toml @@ -0,0 +1,29 @@ +[package] +name = "physical-ads1256" +description = "Shared abstractions for ADS1256 components." +version.workspace = true +edition.workspace = true +repository.workspace = true +readme.workspace = true +license.workspace = true + +[features] +standard-multiplexer = [] + +[dependencies.physical-node] +path = "../../../node" +[dependencies.physical-ads1256-types] +path = "../types" +[dependencies.ads1256] +workspace = true +[dependencies.embedded-hal] +workspace = true +[dependencies.embedded-hal-async] +workspace = true +[dependencies.defmt] +workspace = true +[dependencies.uom] +workspace = true +[dependencies.embassy-sync] +workspace = true +optional = true \ No newline at end of file diff --git a/peripheral-components/ads1256/node/src/analog_input.rs b/peripheral-components/ads1256/node/src/analog_input.rs new file mode 100644 index 0000000..bf02d65 --- /dev/null +++ b/peripheral-components/ads1256/node/src/analog_input.rs @@ -0,0 +1,10 @@ + +struct AnalogInput {} + +// AnalogInputS +// AnalogInputI +// AnalogInputC +// AnalogInputSI +// AnalogInputSC +// AnalogInputIC +// AnalogInputSIC diff --git a/peripheral-components/ads1256/node/src/lib.rs b/peripheral-components/ads1256/node/src/lib.rs new file mode 100644 index 0000000..54dc809 --- /dev/null +++ b/peripheral-components/ads1256/node/src/lib.rs @@ -0,0 +1,4 @@ +#![no_std] + +#[cfg(feature = "standard-multiplexer")] +mod analog_input; \ No newline at end of file diff --git a/peripheral-components/ads1256/types/Cargo.toml b/peripheral-components/ads1256/types/Cargo.toml new file mode 100644 index 0000000..29dbf41 --- /dev/null +++ b/peripheral-components/ads1256/types/Cargo.toml @@ -0,0 +1,17 @@ +[package] +name = "physical-ads1256-types" +description = "ADS1256 Physical types." +version.workspace = true +edition.workspace = true +repository.workspace = true +readme.workspace = true +license.workspace = true + +[features] +standard-multiplexer = [] + +[dependencies.ads1256-types] +workspace = true +[dependencies.defmt] +workspace = true +optional = true \ No newline at end of file diff --git a/peripheral-components/ads1256/types/src/lib.rs b/peripheral-components/ads1256/types/src/lib.rs new file mode 100644 index 0000000..0c9ac1a --- /dev/null +++ b/peripheral-components/ads1256/types/src/lib.rs @@ -0,0 +1 @@ +#![no_std] diff --git a/peripherals/standalone-ads1256/node/Cargo.toml b/peripherals/standalone-ads1256/node/Cargo.toml new file mode 100644 index 0000000..b88e589 --- /dev/null +++ b/peripherals/standalone-ads1256/node/Cargo.toml @@ -0,0 +1,25 @@ +[package] +name = "physical-standalone-ads1256" +description = "Support for dedicated ADS1256 boards (i.e. boards that have no other functionality other than to expose the ADS1256)" +version.workspace = true +edition.workspace = true +repository.workspace = true +readme.workspace = true +license.workspace = true + +[dependencies.physical-node] +path = "../../../node" +[dependencies.physical-standalone-ads1256-types] +path = "../types" +[dependencies.physical-ads1256] +path = "../../../peripheral-components/ads1256/node" +[dependencies.ads1256] +workspace = true +[dependencies.embedded-hal] +workspace = true +[dependencies.embedded-hal-async] +workspace = true +[dependencies.defmt] +workspace = true +[dependencies.uom] +workspace = true \ No newline at end of file diff --git a/peripherals/standalone-ads1256/node/src/lib.rs b/peripherals/standalone-ads1256/node/src/lib.rs new file mode 100644 index 0000000..2e7f0d4 --- /dev/null +++ b/peripherals/standalone-ads1256/node/src/lib.rs @@ -0,0 +1 @@ +#![no_std] \ No newline at end of file diff --git a/peripherals/standalone-ads1256/types/Cargo.toml b/peripherals/standalone-ads1256/types/Cargo.toml new file mode 100644 index 0000000..1dd8682 --- /dev/null +++ b/peripherals/standalone-ads1256/types/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "physical-standalone-ads1256-types" +description = "Support for dedicated ADS1256 boards (i.e. boards that have no other functionality other than to expose the ADS1256)" +version.workspace = true +edition.workspace = true +repository.workspace = true +readme.workspace = true +license.workspace = true + +[dependencies.ads1256-types] +workspace = true +[dependencies.physical-ads1256-types] +path = "../../../peripheral-components/ads1256/types" \ No newline at end of file diff --git a/peripherals/standalone-ads1256/types/src/lib.rs b/peripherals/standalone-ads1256/types/src/lib.rs new file mode 100644 index 0000000..0c9ac1a --- /dev/null +++ b/peripherals/standalone-ads1256/types/src/lib.rs @@ -0,0 +1 @@ +#![no_std] diff --git a/src/lib.rs b/src/lib.rs index 1ef6109..4ef2a82 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,2 +1,3 @@ #![no_std] +pub mod transducer; \ No newline at end of file diff --git a/src/transducer/input.rs b/src/transducer/input.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/transducer/mod.rs b/src/transducer/mod.rs new file mode 100644 index 0000000..ac4c6a2 --- /dev/null +++ b/src/transducer/mod.rs @@ -0,0 +1,10 @@ +pub mod input; +pub mod output; + +// Initialisation will always be async and won't complete until a state is available for all +// stateful transducers. +pub trait Stateful { + type Value: Copy; + + fn state() -> Self::Value; +} diff --git a/src/transducer/output.rs b/src/transducer/output.rs new file mode 100644 index 0000000..1c7180f --- /dev/null +++ b/src/transducer/output.rs @@ -0,0 +1,7 @@ +pub trait Output { + type Value: Copy; + + //TODO: return result + //TODO: Make maybe async + fn set(setting: Self::Value); +} \ No newline at end of file