rtic
rtic copied to clipboard
Reusable modules and encapsulation
What is the recommended approach to handling encapsulation or breaking out functionality into modules? By design, using a the single file for task and resource management appears to be required, but this starts to get really crowded in larger applications. What are people doing to workaround this or just accepting it? Any examples of large complex RTIC projects that might be helpful to reference in the docs?
@jthacker Bit late but I'll answer this one.
You can add an extern "Rust" block and define all the function signatures in there without a body eg
extern "Rust" {
// FSR-Button Bus Tasks
#[task(priority = 3, shared = [foo])]
async fn read_adc_pins(
ctx: read_adc_pins::Context<'_>,
sender: Sender<'static, ButtonEvent, 1>,
);
}
Then create the module somewhere else in your codebase and rust will Link the function.
We've done this for many huge projects and it works really well.