ESP
This commit is contained in:
parent
a4884bd189
commit
865599e059
64 changed files with 6448 additions and 1221 deletions
1
common/.gitignore
vendored
Normal file
1
common/.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
target
|
||||
16
common/Cargo.lock
generated
Normal file
16
common/Cargo.lock
generated
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "common"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"embedded-hal",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "embedded-hal"
|
||||
version = "1.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "361a90feb7004eca4019fb28352a9465666b24f840f5c3cddf0ff13920590b89"
|
||||
7
common/Cargo.toml
Normal file
7
common/Cargo.toml
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
[package]
|
||||
name = "common"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
embedded-hal = "1.0.0"
|
||||
9
common/rustfmt.toml
Normal file
9
common/rustfmt.toml
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
hard_tabs = true
|
||||
newline_style = "Unix"
|
||||
imports_granularity = "Crate"
|
||||
|
||||
unstable_features = true
|
||||
format_code_in_doc_comments = true
|
||||
format_macro_bodies = true
|
||||
format_macro_matchers = true
|
||||
format_strings = true
|
||||
5
common/src/cm.rs
Normal file
5
common/src/cm.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
/// CPU to Modem
|
||||
pub enum CMMessage {
|
||||
Ping(u32),
|
||||
Pong(u32),
|
||||
}
|
||||
15
common/src/lib.rs
Normal file
15
common/src/lib.rs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
pub mod cm;
|
||||
pub mod mc;
|
||||
|
||||
pub const VERSION: u32 = 1;
|
||||
|
||||
enum State {
|
||||
/// Not ready, not even pinged
|
||||
Idle,
|
||||
/// Ping failed
|
||||
Fail,
|
||||
/// Waiting for pong
|
||||
Pinging,
|
||||
/// Ready to work
|
||||
Ready,
|
||||
}
|
||||
26
common/src/mc.rs
Normal file
26
common/src/mc.rs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
use crate::{cm::CMMessage, State};
|
||||
|
||||
/// Modem to CPU
|
||||
pub enum MCMessage {
|
||||
Ping(u32),
|
||||
Pong(u32),
|
||||
}
|
||||
|
||||
/// Modem-side connection driver
|
||||
pub struct MCConnection<SPI> {
|
||||
spi: SPI,
|
||||
state: State,
|
||||
}
|
||||
|
||||
impl<SPI> MCConnection<SPI> where SPI: embedded_hal::spi::SpiDevice {
|
||||
pub fn new(spi: SPI) -> Self {
|
||||
Self {
|
||||
spi,
|
||||
state: State::Idle,
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_message(message: CMMessage) {
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue