Skip to content

Commit

Permalink
chore: format and debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
zpg6 committed Dec 30, 2024
1 parent af8a228 commit 149c6b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
1 change: 0 additions & 1 deletion examples/src/bin/uart_break_detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use esp_backtrace as _;
use esp_hal::{
entry,
gpio::{Level, Output},
uart::{Config as UartConfig, DataBits, StopBits, Uart},
};

Expand Down
14 changes: 5 additions & 9 deletions examples/src/bin/uart_break_detection_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@

use embassy_executor::Spawner;
use esp_backtrace as _;
use esp_hal::{
gpio::{Level, Output},
uart::{Config as UartConfig, DataBits, StopBits, Uart},
};
use esp_hal::uart::{Config as UartConfig, DataBits, StopBits, Uart};

#[esp_hal_embassy::main]
async fn main(_spawner: Spawner) {
Expand All @@ -39,11 +36,10 @@ async fn main(_spawner: Spawner) {
uart.wait_for_break_async().await;
esp_println::print!("\nBREAK");

let mut buf = [0u8; 1024];
while let Ok(size) = uart.read_async(&mut buf).await {
for i in 0..size {
esp_println::print!(" {:02X}", buf[i]);
}
let mut buf = [0u8; 11];
let len = uart.read_async(&mut buf).await.unwrap();
for byte in buf.iter().take(len) {
esp_println::print!(" {:02X}", byte);
}
}
}

0 comments on commit 149c6b9

Please sign in to comment.