2023-09-20 00:15:04 +02:00
|
|
|
#![no_std]
|
|
|
|
#![no_main]
|
|
|
|
|
|
|
|
use esp_backtrace as _;
|
|
|
|
use esp_println::println;
|
2023-09-20 00:15:43 +02:00
|
|
|
use hal::{
|
|
|
|
clock::ClockControl,
|
|
|
|
gpio::{IO},
|
|
|
|
peripherals::Peripherals,
|
|
|
|
prelude::*,
|
|
|
|
prelude::nb::block,
|
|
|
|
Delay,
|
|
|
|
uart::{
|
|
|
|
TxRxPins,
|
|
|
|
config::{
|
|
|
|
Config,
|
|
|
|
Parity,
|
|
|
|
StopBits,
|
|
|
|
DataBits,
|
|
|
|
},
|
|
|
|
Uart,
|
|
|
|
}
|
|
|
|
};
|
2023-09-20 00:15:04 +02:00
|
|
|
|
|
|
|
#[entry]
|
|
|
|
fn main() -> ! {
|
|
|
|
let peripherals = Peripherals::take();
|
2023-09-20 00:15:43 +02:00
|
|
|
let mut system = peripherals.DPORT.split();
|
2023-09-20 00:15:04 +02:00
|
|
|
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();
|
|
|
|
let mut delay = Delay::new(&clocks);
|
|
|
|
|
2023-09-20 00:15:43 +02:00
|
|
|
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 config = Config {
|
|
|
|
baudrate: 115200,
|
|
|
|
data_bits: DataBits::DataBits8,
|
|
|
|
parity: Parity::ParityNone,
|
|
|
|
stop_bits: StopBits::STOP1,
|
|
|
|
};
|
2023-09-20 00:15:04 +02:00
|
|
|
|
2023-09-20 00:15:43 +02:00
|
|
|
// 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");
|
2023-09-20 00:15:04 +02:00
|
|
|
loop {
|
2023-09-20 00:15:43 +02:00
|
|
|
serial.write(0x42).ok();
|
|
|
|
let read = block!(serial.read()).unwrap();
|
|
|
|
println!("{}", read);
|
|
|
|
|
|
|
|
delay.delay_ms(1000_u32);
|
2023-09-20 00:15:04 +02:00
|
|
|
}
|
|
|
|
}
|