This commit is contained in:
ivmarkov 2023-09-19 08:56:21 +00:00
parent 53a48597d8
commit 4df6030eb8
2 changed files with 0 additions and 49 deletions

View File

@ -62,4 +62,3 @@ esp-idf-sys = { version = "0.33", features = ["native", "binstart"] }
mipidsi = "0.5.0"
display-interface-spi = "0.4.1"
embedded-graphics = "0.7.1"
edge-executor = "0.3"

View File

@ -1,48 +0,0 @@
//! UART loopback test
//!
//! Folowing pins are used:
//! TX GPIO5
//! RX GPIO6
//!
//! Depending on your target and the board you are using you have to change the pins.
//!
//! This example transfers data via UART.
//! Connect TX and RX pins to see the outgoing data is read as incoming data.
use esp_idf_hal::delay::BLOCK;
use esp_idf_hal::gpio;
use esp_idf_hal::peripherals::Peripherals;
use esp_idf_hal::prelude::*;
use esp_idf_hal::task::executor::*;
use esp_idf_hal::uart::*;
fn main() -> anyhow::Result<()> {
esp_idf_hal::sys::link_patches();
let peripherals = Peripherals::take().unwrap();
let tx = peripherals.pins.gpio5;
let rx = peripherals.pins.gpio6;
println!("Starting UART loopback test");
let config = config::Config::new().baudrate(Hertz(115_200));
let uart = AsyncUartDriver::new(
peripherals.uart1,
tx,
rx,
Option::<gpio::Gpio0>::None,
Option::<gpio::Gpio1>::None,
&config,
)
.unwrap();
EspBlocker::new().block_on(async {
loop {
uart.write(&[0xaa]).await?;
let mut buf = [0_u8; 1];
uart.read(&mut buf).await?;
println!("Written 0xaa, read 0x{:02x}", buf[0]);
}
})
}