diff options
| author | s-ol <s+removethis@s-ol.nu> | 2026-03-30 16:58:14 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2026-03-30 16:58:14 +0000 |
| commit | e249f617177c228c6f961c02a2640e88c328ff61 (patch) | |
| tree | 50b0766c4cf34f0fff14da2ce72c8b00976ba1e2 | |
| parent | initial commit (diff) | |
| download | t144-meshcore-example-main.tar.gz t144-meshcore-example-main.zip | |
Diffstat (limited to '')
| -rw-r--r-- | README.md | 60 | ||||
| -rw-r--r-- | src/bin/example/display.rs (renamed from src/display.rs) | 0 | ||||
| -rw-r--r-- | src/bin/example/main.rs (renamed from src/main.rs) | 0 | ||||
| -rw-r--r-- | src/bin/example/radio.rs (renamed from src/radio.rs) | 0 |
4 files changed, 60 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..e78dacb --- /dev/null +++ b/README.md @@ -0,0 +1,60 @@ +t144-meshcore-example +===================== +A rust-based Meshcore firmware proof-of-concept for the Heltek T114 using [Meshcore-rs][meshcore] and [Embassy][embassy]. + +# Notes +I don't have the standard ST7789 TFT display module Heltek ships with these, so the code is written for the [SSD1322 OLED][display] I do have. +If you have the dev boad with display, I'd appreciate a patch that changes to that since that's a much more common configuration. + +The code layout is a little overengineered since I adapted this from a larger project that uses multiple crates to support different boards (with different architectures). +Because of this `lib.rs` contains the firmware's "logic" as different embassy tasks, while `src/bin` contains the code specific to the Heltek T114 board. + +The tasks defined in `lib.rs` aren't decorated with embassy's `#[embassy_executor::task]` as you might expect: +since the arguments to the tasks (the peripherals the tasks operate on) vary from platform to platform, the task functions have to be generic. +They are specialized in the modules in `src/bin/example` and started from `src/bin/example/main.rs`: + +```rust +// generic task definition (uses "impl Task") - can't be turned into an embassy task +pub async fn led_task( + led_pin: &Mutex<CriticalSectionRawMutex, impl StatefulOutputPin<Error = Infallible>>, +) { + // ... +} + +// specialized task definition +#[embassy_executor::task] +async fn led_task(led_pin: &'static PinMutex<'static>) { + t114_meshcore_example::led_task(led_pin).await; +} + +// embassy entrypoint +#[embassy_executor::main] +async fn main(spawner: Spawner) { + // ... + + let p = embassy_nrf::init(Default::default()); + + // start task + let led = Output::new(p.P1_03, Level::High, OutputDrive::Standard); + let pin: PinMutex = Mutex::new(led); + let pin_ref = Box::leak(Box::new(pin)); + spawner.spawn(led_task(pin_ref)).unwrap(); +} +``` + +# Building + +You can run and debug using [probe-rs][probe-rs]: + + # install probe-rs + $ DEFMT_LOG=info cargo run + +Or just build the ELF file and deploy it using some other method: + + $ cargo build + $ some-flashing-tool target/thumbv7em-none-eabi/debug/main + +[meshcore]: https://git.housedillon.com/wdillon/Meshcore-rs +[embassy]: https://embassy.dev/ +[display]: https://newhavendisplay.com/content/specs/NHD-2.7-12864WDW3.pdf +[probe-rs]: https://probe.rs/ diff --git a/src/display.rs b/src/bin/example/display.rs index 5830254..5830254 100644 --- a/src/display.rs +++ b/src/bin/example/display.rs diff --git a/src/main.rs b/src/bin/example/main.rs index 94a8c9e..94a8c9e 100644 --- a/src/main.rs +++ b/src/bin/example/main.rs diff --git a/src/radio.rs b/src/bin/example/radio.rs index db677ee..db677ee 100644 --- a/src/radio.rs +++ b/src/bin/example/radio.rs |
