added rp2040 stuff

This commit is contained in:
Jacob Weaver
2024-12-16 15:55:03 -06:00
parent 282531ee81
commit 70e6bae41a
8 changed files with 116 additions and 7 deletions
+4 -1
View File
@@ -7,9 +7,10 @@ edition = "2021"
path = "src/hs.rs"
[features]
default = []
default = ["rp2040"]
std = ["dep:sysinfo"]
nix = ["dep:watchdog-device"]
rp2040 = ["dep:rp2040-hal", "dep:rp2040-pac"]
[dependencies]
rfe = { path = "../../rfe" }
@@ -21,3 +22,5 @@ sysinfo = { version = "0.32.0", default-features = false, optional = true, featu
"disk",
"system",
] }
rp2040-hal = { workspace = true, optional = true }
rp2040-pac = { workspace = true, optional = true }
+6
View File
@@ -75,6 +75,12 @@ mod infograbber_std {
pub use infograbber_std::*;
pub struct StubSystemInfoGrabber;
impl StubSystemInfoGrabber {
pub fn new() -> Self {
Self {}
}
}
impl SystemInfoGrabber for StubSystemInfoGrabber {
fn check_cpu_usage(&mut self) -> Vec<u8> {
Vec::new()
+43
View File
@@ -82,3 +82,46 @@ impl<'a> Watchdog for WatchdogRef<'a> {
}
}
}
#[cfg(feature = "rp2040")]
mod watchdog_rp2040 {
use rp2040_hal::Watchdog;
pub struct Rp2040Watchdog {
wd: Watchdog,
time: u32,
}
impl Rp2040Watchdog {
pub fn new(wd: Watchdog) -> Self {
Self {
wd,
time: 10 * 1000000,
}
}
}
impl super::Watchdog for Rp2040Watchdog {
fn enable(&mut self) {
self.wd
.start(rp2040_hal::fugit::Duration::<u32, 1, 1000000>::from_ticks(
self.time,
));
}
fn disable(&mut self) {
self.wd.disable();
}
fn set_timeout(&mut self, time: i32) {
self.time = time as u32 * 1000000;
}
fn feed(&mut self) {
self.wd.feed();
}
}
}
#[cfg(feature = "rp2040")]
pub use watchdog_rp2040::*;