Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adc driver #7

Merged
merged 22 commits into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions boards/pressure/src/data_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl DataManager {
pub fn handle_data(&mut self, data: Message) {
match data.data {
messages::Data::Sensor(ref sensor) => match sensor.data {
messages::sensor::SensorData::SbgData(ref sbg_data) => match sbg_data{
messages::sensor::SensorData::SbgData(ref sbg_data) => match sbg_data {
messages::sensor::SbgData::EkfNavAcc(_) => {
self.ekf_nav_acc = Some(data);
}
Expand Down Expand Up @@ -154,7 +154,7 @@ impl DataManager {
messages::sensor::SbgData::GpsPos2(_) => {
self.gps_pos_2 = Some(data);
}
}
},
messages::sensor::SensorData::RecoverySensing(_) => {
self.recovery_sensing = Some(data);
}
Expand Down
33 changes: 19 additions & 14 deletions boards/pressure/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ mod app {
loop {
cx.shared.em.run(|| {
let message = Message::new(
cx.shared.rtc.lock(|rtc| {
messages::FormattedNaiveDateTime(rtc.date_time().unwrap())
}),
cx.shared
.rtc
.lock(|rtc| messages::FormattedNaiveDateTime(rtc.date_time().unwrap())),
COM_ID,
messages::state::State::new(messages::state::StateData::Initializing),
);
Expand Down Expand Up @@ -363,10 +363,13 @@ mod app {
stm32h7xx_hal::rcc::ResetReason::Unknown { rcc_rsr } => sensor::ResetReason::Unknown { rcc_rsr },
stm32h7xx_hal::rcc::ResetReason::WindowWatchdogReset => sensor::ResetReason::WindowWatchdogReset,
};
let message =
messages::Message::new(cx.shared.rtc.lock(|rtc| {
messages::FormattedNaiveDateTime(rtc.date_time().unwrap())
}), COM_ID, sensor::Sensor::new(x));
let message = messages::Message::new(
cx.shared
.rtc
.lock(|rtc| messages::FormattedNaiveDateTime(rtc.date_time().unwrap())),
COM_ID,
sensor::Sensor::new(x),
);

cx.shared.em.run(|| {
spawn!(send_gs, message)?;
Expand All @@ -385,10 +388,13 @@ mod app {
.lock(|data_manager| data_manager.state.clone());
cx.shared.em.run(|| {
if let Some(x) = state_data {
let message =
Message::new(cx.shared.rtc.lock(|rtc| {
messages::FormattedNaiveDateTime(rtc.date_time().unwrap())
}), COM_ID, messages::state::State::new(x));
let message = Message::new(
cx.shared
.rtc
.lock(|rtc| messages::FormattedNaiveDateTime(rtc.date_time().unwrap())),
COM_ID,
messages::state::State::new(x),
);
spawn!(send_gs, message)?;
} // if there is none we still return since we simply don't have data yet.
Ok(())
Expand Down Expand Up @@ -442,8 +448,7 @@ mod app {
}

#[task(priority = 3, shared = [rtc, &em])]
async fn send_gs_intermediate(mut cx: send_gs_intermediate::Context, m: Data)
{
async fn send_gs_intermediate(mut cx: send_gs_intermediate::Context, m: Data) {
cx.shared.em.run(|| {
cx.shared.rtc.lock(|rtc| {
let message = messages::Message::new(
Expand Down Expand Up @@ -572,4 +577,4 @@ mod app {
sbg.set_low();
});
}
}
}
4 changes: 2 additions & 2 deletions boards/strain/src/data_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl DataManager {
pub fn handle_data(&mut self, data: Message) {
match data.data {
messages::Data::Sensor(ref sensor) => match sensor.data {
messages::sensor::SensorData::SbgData(ref sbg_data) => match sbg_data{
messages::sensor::SensorData::SbgData(ref sbg_data) => match sbg_data {
messages::sensor::SbgData::EkfNavAcc(_) => {
self.ekf_nav_acc = Some(data);
}
Expand Down Expand Up @@ -154,7 +154,7 @@ impl DataManager {
messages::sensor::SbgData::GpsPos2(_) => {
self.gps_pos_2 = Some(data);
}
}
},
messages::sensor::SensorData::RecoverySensing(_) => {
self.recovery_sensing = Some(data);
}
Expand Down
33 changes: 19 additions & 14 deletions boards/strain/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ mod app {
loop {
cx.shared.em.run(|| {
let message = Message::new(
cx.shared.rtc.lock(|rtc| {
messages::FormattedNaiveDateTime(rtc.date_time().unwrap())
}),
cx.shared
.rtc
.lock(|rtc| messages::FormattedNaiveDateTime(rtc.date_time().unwrap())),
COM_ID,
messages::state::State::new(messages::state::StateData::Initializing),
);
Expand Down Expand Up @@ -363,10 +363,13 @@ mod app {
stm32h7xx_hal::rcc::ResetReason::Unknown { rcc_rsr } => sensor::ResetReason::Unknown { rcc_rsr },
stm32h7xx_hal::rcc::ResetReason::WindowWatchdogReset => sensor::ResetReason::WindowWatchdogReset,
};
let message =
messages::Message::new(cx.shared.rtc.lock(|rtc| {
messages::FormattedNaiveDateTime(rtc.date_time().unwrap())
}), COM_ID, sensor::Sensor::new(x));
let message = messages::Message::new(
cx.shared
.rtc
.lock(|rtc| messages::FormattedNaiveDateTime(rtc.date_time().unwrap())),
COM_ID,
sensor::Sensor::new(x),
);

cx.shared.em.run(|| {
spawn!(send_gs, message)?;
Expand All @@ -385,10 +388,13 @@ mod app {
.lock(|data_manager| data_manager.state.clone());
cx.shared.em.run(|| {
if let Some(x) = state_data {
let message =
Message::new(cx.shared.rtc.lock(|rtc| {
messages::FormattedNaiveDateTime(rtc.date_time().unwrap())
}), COM_ID, messages::state::State::new(x));
let message = Message::new(
cx.shared
.rtc
.lock(|rtc| messages::FormattedNaiveDateTime(rtc.date_time().unwrap())),
COM_ID,
messages::state::State::new(x),
);
spawn!(send_gs, message)?;
} // if there is none we still return since we simply don't have data yet.
Ok(())
Expand Down Expand Up @@ -442,8 +448,7 @@ mod app {
}

#[task(priority = 3, shared = [rtc, &em])]
async fn send_gs_intermediate(mut cx: send_gs_intermediate::Context, m: Data)
{
async fn send_gs_intermediate(mut cx: send_gs_intermediate::Context, m: Data) {
cx.shared.em.run(|| {
cx.shared.rtc.lock(|rtc| {
let message = messages::Message::new(
Expand Down Expand Up @@ -572,4 +577,4 @@ mod app {
sbg.set_low();
});
}
}
}
4 changes: 2 additions & 2 deletions boards/temperature/src/data_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl DataManager {
pub fn handle_data(&mut self, data: Message) {
match data.data {
messages::Data::Sensor(ref sensor) => match sensor.data {
messages::sensor::SensorData::SbgData(ref sbg_data) => match sbg_data{
messages::sensor::SensorData::SbgData(ref sbg_data) => match sbg_data {
messages::sensor::SbgData::EkfNavAcc(_) => {
self.ekf_nav_acc = Some(data);
}
Expand Down Expand Up @@ -154,7 +154,7 @@ impl DataManager {
messages::sensor::SbgData::GpsPos2(_) => {
self.gps_pos_2 = Some(data);
}
}
},
messages::sensor::SensorData::RecoverySensing(_) => {
self.recovery_sensing = Some(data);
}
Expand Down
33 changes: 19 additions & 14 deletions boards/temperature/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,9 @@ mod app {
loop {
cx.shared.em.run(|| {
let message = Message::new(
cx.shared.rtc.lock(|rtc| {
messages::FormattedNaiveDateTime(rtc.date_time().unwrap())
}),
cx.shared
.rtc
.lock(|rtc| messages::FormattedNaiveDateTime(rtc.date_time().unwrap())),
COM_ID,
messages::state::State::new(messages::state::StateData::Initializing),
);
Expand Down Expand Up @@ -363,10 +363,13 @@ mod app {
stm32h7xx_hal::rcc::ResetReason::Unknown { rcc_rsr } => sensor::ResetReason::Unknown { rcc_rsr },
stm32h7xx_hal::rcc::ResetReason::WindowWatchdogReset => sensor::ResetReason::WindowWatchdogReset,
};
let message =
messages::Message::new(cx.shared.rtc.lock(|rtc| {
messages::FormattedNaiveDateTime(rtc.date_time().unwrap())
}), COM_ID, sensor::Sensor::new(x));
let message = messages::Message::new(
cx.shared
.rtc
.lock(|rtc| messages::FormattedNaiveDateTime(rtc.date_time().unwrap())),
COM_ID,
sensor::Sensor::new(x),
);

cx.shared.em.run(|| {
spawn!(send_gs, message)?;
Expand All @@ -385,10 +388,13 @@ mod app {
.lock(|data_manager| data_manager.state.clone());
cx.shared.em.run(|| {
if let Some(x) = state_data {
let message =
Message::new(cx.shared.rtc.lock(|rtc| {
messages::FormattedNaiveDateTime(rtc.date_time().unwrap())
}), COM_ID, messages::state::State::new(x));
let message = Message::new(
cx.shared
.rtc
.lock(|rtc| messages::FormattedNaiveDateTime(rtc.date_time().unwrap())),
COM_ID,
messages::state::State::new(x),
);
spawn!(send_gs, message)?;
} // if there is none we still return since we simply don't have data yet.
Ok(())
Expand Down Expand Up @@ -442,8 +448,7 @@ mod app {
}

#[task(priority = 3, shared = [rtc, &em])]
async fn send_gs_intermediate(mut cx: send_gs_intermediate::Context, m: Data)
{
async fn send_gs_intermediate(mut cx: send_gs_intermediate::Context, m: Data) {
cx.shared.em.run(|| {
cx.shared.rtc.lock(|rtc| {
let message = messages::Message::new(
Expand Down Expand Up @@ -572,4 +577,4 @@ mod app {
sbg.set_low();
});
}
}
}
25 changes: 25 additions & 0 deletions crates/ads126x/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[package]
name = "ads126x"
version = "0.1.0"
edition = "2021"

[dependencies]
defmt = {workspace = true}
embedded-hal = {workspace = true}
bitflags = { version = "2.3.1", features = ["serde"] }
nb = "1.1.0"
heapless = {workspace = true}

[dev-dependencies]
defmt-test = { workspace = true }
panic-probe = { workspace = true }
stm32h7xx-hal = { workspace = true }
cortex-m = { workspace = true }

[[test]]
name = "example"
harness = false

[lib]
name = "ads126x"
harness = false
4 changes: 4 additions & 0 deletions crates/ads126x/src/error.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pub enum ADS126xError {
IO,
InvalidInputData,
}
Loading
Loading