refactor: unified host/ communication module, cfg-free run()
- Created host/ module with internal cfg dispatch (USB vs UART) - Moved usb/task.rs → host/usb.rs, uart/task.rs → host/uart.rs - Moved protocol_io.rs → host/framing.rs - Renamed usb_task/uart_task to host_task (uniform name) - Removed all host-comm cfg from main.rs - The run() function now has ZERO board-specific conditional compilation - Deleted old usb/, uart/, protocol_io.rs modules
This commit is contained in:
1 parent
fb334118fd
commit
2c852b9f45
7 files changed
+44
-79
No files matched your search
+12
-31
@@ -25,15 +25,11 @@ mod display;
|
||||
mod driver;
|
||||
#[cfg(not(test))]
|
||||
mod hal;
|
||||
#[cfg(not(test))]
|
||||
mod host;
|
||||
mod protocol;
|
||||
#[cfg(not(test))]
|
||||
mod radio;
|
||||
#[cfg(not(test))]
|
||||
mod protocol_io;
|
||||
#[cfg(all(not(test), feature = "heltec_v3"))]
|
||||
mod uart;
|
||||
#[cfg(all(not(test), not(feature = "heltec_v3")))]
|
||||
mod usb;
|
||||
|
||||
#[cfg(not(test))]
|
||||
use embassy_executor::Spawner;
|
||||
@@ -90,31 +86,16 @@ async fn run(spawner: Spawner) {
|
||||
.spawn(radio::radio_task(radio, &COMMANDS, &RESPONSES, &STATUS))
|
||||
.expect("spawn radio_task");
|
||||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "heltec_v3")] {
|
||||
spawner
|
||||
.spawn(uart::uart_task(
|
||||
comm,
|
||||
&COMMANDS,
|
||||
&RESPONSES,
|
||||
&DISPLAY_COMMANDS,
|
||||
has_display,
|
||||
mac,
|
||||
))
|
||||
.expect("spawn uart_task");
|
||||
} else {
|
||||
spawner
|
||||
.spawn(usb::usb_task(
|
||||
comm,
|
||||
&COMMANDS,
|
||||
&RESPONSES,
|
||||
&DISPLAY_COMMANDS,
|
||||
has_display,
|
||||
mac,
|
||||
))
|
||||
.expect("spawn usb_task");
|
||||
}
|
||||
}
|
||||
spawner
|
||||
.spawn(host::host_task(
|
||||
comm,
|
||||
&COMMANDS,
|
||||
&RESPONSES,
|
||||
&DISPLAY_COMMANDS,
|
||||
has_display,
|
||||
mac,
|
||||
))
|
||||
.expect("spawn host_task");
|
||||
|
||||
if let Some(dp) = display {
|
||||
spawner
|
||||
|
||||
Reference in new issue
Block a user