scuffed uart print
This commit is contained in:
@@ -49,19 +49,28 @@ pub static CMD_CH: Channel<CriticalSectionRawMutex, LowPowerCmd, 1> = Channel::n
|
||||
|
||||
#[embassy_executor::task]
|
||||
pub async fn uart_cmd_task() {
|
||||
let _ = PIPE_HW_TX.write(
|
||||
b"\r\n\
|
||||
Modes:\r\n\
|
||||
[1] Standby + 8 KB SRAM2 retention\r\n\
|
||||
[2] Standby + full SRAM2 retention\r\n\
|
||||
[3] Standby minimal\r\n\
|
||||
[4] Shutdown\r\n\
|
||||
[5] Stop mode (0-3)\r\n\
|
||||
"
|
||||
).await;
|
||||
async fn print_menu() {
|
||||
while PIPE_HW_TX.len() > 0 {
|
||||
embassy_time::Timer::after(embassy_time::Duration::from_millis(2)).await;
|
||||
}
|
||||
let _ = PIPE_HW_TX.write(b"\x1B[2J\x1B[H").await;
|
||||
let _ = PIPE_HW_TX.write(
|
||||
b"\r\n\
|
||||
Modes:\r\n\
|
||||
[1] Standby + 8 KB SRAM2 retention\r\n\
|
||||
[2] Standby + full SRAM2 retention\r\n\
|
||||
[3] Standby minimal\r\n\
|
||||
[4] Shutdown\r\n\
|
||||
[5] Stop mode (0-3)\r\n\
|
||||
"
|
||||
).await;
|
||||
}
|
||||
|
||||
print_menu().await;
|
||||
|
||||
let mut b = [0u8; 2];
|
||||
loop {
|
||||
b.fill(0);
|
||||
let n = PIPE_HW_RX.read(&mut b).await;
|
||||
if n == 0 { continue; }
|
||||
|
||||
@@ -71,29 +80,30 @@ pub async fn uart_cmd_task() {
|
||||
b'3' => CMD_CH.send(LowPowerCmd::Standby).await,
|
||||
b'4' => CMD_CH.send(LowPowerCmd::Shutdown).await,
|
||||
b'5' => {
|
||||
// Expect 2 digits: e.g. b'5' + '13' = Stop1 WfeNoEventClear
|
||||
let _ = PIPE_HW_TX.write(b"Enter Stop mode number (0-3): ").await;
|
||||
let _ = PIPE_HW_RX.read(&mut b[1..2]).await;
|
||||
let stop_mode = match b[1] {
|
||||
let _ = PIPE_HW_TX.write(b"Enter Stop mode number (1-3): ").await;
|
||||
b.fill(0);
|
||||
let n = PIPE_HW_RX.read(&mut b).await;
|
||||
if n == 0 { print_menu().await; continue; }
|
||||
let stop_mode = match b[0] {
|
||||
b'1' => StopMode::Stop1,
|
||||
b'2' => StopMode::Stop2,
|
||||
_ => StopMode::Stop3,
|
||||
b'3' => StopMode::Stop3,
|
||||
_ => { print_menu().await; continue; }
|
||||
};
|
||||
|
||||
let _ = PIPE_HW_TX.write(b"Enter entry method (1=WFI,2=WFE,3=WFE no clear): ").await;
|
||||
let n = PIPE_HW_RX.read(&mut b[1..2]).await;
|
||||
if n > 0 {
|
||||
let entry = match b[1] {
|
||||
b'1' => StopEntry::Wfi,
|
||||
b'2' => StopEntry::Wfe,
|
||||
_ => StopEntry::WfeNoEventClear,
|
||||
};
|
||||
CMD_CH.send(LowPowerCmd::StopMode(StopModeConfig { mode: stop_mode, entry })).await;
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
let _ = PIPE_HW_TX.write(b"Unknown command\r\n").await;
|
||||
b.fill(0);
|
||||
let n = PIPE_HW_RX.read(&mut b).await;
|
||||
if n == 0 { print_menu().await; continue; }
|
||||
let entry = match b[0] {
|
||||
b'1' => StopEntry::Wfi,
|
||||
b'2' => StopEntry::Wfe,
|
||||
b'3' => StopEntry::WfeNoEventClear,
|
||||
_ => { print_menu().await; continue; }
|
||||
};
|
||||
CMD_CH.send(LowPowerCmd::StopMode(StopModeConfig { mode: stop_mode, entry })).await;
|
||||
}
|
||||
_ => { print_menu().await; continue; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user