#![no_std] #![no_main] use esp_backtrace as _; use esp_println::println; use hal::{ clock::ClockControl, gpio::{IO}, peripherals::Peripherals, prelude::*, prelude::nb::block, Delay, uart::{ TxRxPins, config::{ Config, Parity, StopBits, DataBits, }, Uart, } }; #[entry] fn main() -> ! { let peripherals = Peripherals::take(); let mut system = peripherals.DPORT.split(); let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); let mut delay = Delay::new(&clocks); let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); // LilyGo A7670E serial pins. // LilyGo TTGO T-Call sim800l board power / reset pins. let modem_uart_pins = TxRxPins::new_tx_rx( io.pins.gpio26.into_push_pull_output(), io.pins.gpio27.into_floating_input(), ); let mut power = io.pins.gpio4.into_push_pull_output(); power.set_high().ok(); let config = Config { baudrate: 115200, data_bits: DataBits::DataBits8, parity: Parity::ParityNone, stop_bits: StopBits::STOP1, }; // UART interface for the GSM modem let mut serial = Uart::new_with_config( peripherals.UART1, Some(config), Some(modem_uart_pins), &clocks, &mut system.peripheral_clock_control, ); println!("Start"); loop { serial.write(0x42).ok(); let read = block!(serial.read()).unwrap(); println!("{}", read); delay.delay_ms(1000_u32); } }