#![no_std]
#![no_main]
use esp32_hal::{clock::ClockControl, pac::Peripherals, prelude::*, timer::TimerGroup, Rtc, IO, Delay};
use esp_backtrace as _;
use xtensa_lx_rt::entry;
use esp_println::println;
#[entry]
fn main() -> ! {
let peripherals = Peripherals::take().unwrap();
let system = peripherals.DPORT.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();
// Disable the RTC and TIMG watchdog timers
let mut rtc = Rtc::new(peripherals.RTC_CNTL);
let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
let mut wdt0 = timer_group0.wdt;
let timer_group1 = TimerGroup::new(peripherals.TIMG1, &clocks);
let mut wdt1 = timer_group1.wdt;
rtc.rwdt.disable();
wdt0.disable();
wdt1.disable();
let cs = io.pins.gpio5.into_push_pull_output();
let rst = io.pins.gpio16.into_push_pull_output();
let busy = io.pins.gpio4.into_floating_input();
let dc = io.pins.gpio17.into_push_pull_output();
let mut spi = spi::Spi::new_no_cs_no_miso(
// let spi = spi::Spi::new(
peripherals.SPI2, // Real HW working with SPI2, but Wokwi seems to work only with SPI3
io.pins.gpio18, // SCLK
io.pins.gpio23, // MOSI
4u32.MHz(),
spi::SpiMode::Mode0,
&mut system.peripheral_clock_control,
&clocks,
);
loop {
println!("Hello World!");
delay.delay_ms(1000u32);
}
}