initial modem setup (pins, serial, power...)
This commit is contained in:
parent
cf7edc3c4b
commit
f6da3a73fc
1 changed files with 49 additions and 5 deletions
54
src/main.rs
54
src/main.rs
|
@ -3,19 +3,63 @@
|
||||||
|
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_println::println;
|
use esp_println::println;
|
||||||
use hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, Delay};
|
use hal::{
|
||||||
|
clock::ClockControl,
|
||||||
|
gpio::{IO},
|
||||||
|
peripherals::Peripherals,
|
||||||
|
prelude::*,
|
||||||
|
prelude::nb::block,
|
||||||
|
Delay,
|
||||||
|
uart::{
|
||||||
|
TxRxPins,
|
||||||
|
config::{
|
||||||
|
Config,
|
||||||
|
Parity,
|
||||||
|
StopBits,
|
||||||
|
DataBits,
|
||||||
|
},
|
||||||
|
Uart,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
#[entry]
|
#[entry]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
let peripherals = Peripherals::take();
|
let peripherals = Peripherals::take();
|
||||||
let system = peripherals.DPORT.split();
|
let mut system = peripherals.DPORT.split();
|
||||||
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();
|
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();
|
||||||
let mut delay = Delay::new(&clocks);
|
let mut delay = Delay::new(&clocks);
|
||||||
|
|
||||||
println!("Hello world!");
|
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,
|
||||||
|
};
|
||||||
|
|
||||||
|
// 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 {
|
loop {
|
||||||
println!("Loop...");
|
serial.write(0x42).ok();
|
||||||
delay.delay_ms(500u32);
|
let read = block!(serial.read()).unwrap();
|
||||||
|
println!("{}", read);
|
||||||
|
|
||||||
|
delay.delay_ms(1000_u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue