73 lines
2.2 KiB
Rust
73 lines
2.2 KiB
Rust
#![no_std]
|
|
#![no_main]
|
|
#![deny(
|
|
clippy::mem_forget,
|
|
reason = "mem::forget is generally not safe to do with esp_hal types, especially those \
|
|
holding buffers for the duration of a data transfer."
|
|
)]
|
|
#![deny(clippy::large_stack_frames)]
|
|
|
|
use esp_hal::{
|
|
clock::CpuClock,
|
|
gpio::{Output, OutputConfig},
|
|
main,
|
|
time::{Duration, Instant},
|
|
};
|
|
|
|
use esp_backtrace as _;
|
|
|
|
extern crate alloc;
|
|
|
|
// This creates a default app-descriptor required by the esp-idf bootloader.
|
|
// For more information see: <https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/system/app_image_format.html#application-description>
|
|
esp_bootloader_esp_idf::esp_app_desc!();
|
|
|
|
#[allow(
|
|
clippy::large_stack_frames,
|
|
reason = "it's not unusual to allocate larger buffers etc. in main"
|
|
)]
|
|
#[main]
|
|
fn main() -> ! {
|
|
// generator version: 1.3.0
|
|
// generator parameters: --chip esp32 -o esp32-wroom-32e -o alloc -o esp-backtrace -o log -o vscode
|
|
|
|
esp_println::logger::init_logger_from_env();
|
|
|
|
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
|
|
let peripherals = esp_hal::init(config);
|
|
|
|
// The following pins are used to bootstrap the chip. They are available
|
|
// for use, but check the datasheet of the module for more information on them.
|
|
// - GPIO0
|
|
// - GPIO2
|
|
// - GPIO5
|
|
// - GPIO12
|
|
// - GPIO15
|
|
// These GPIO pins are in use by some feature of the module and should not be used.
|
|
let _ = peripherals.GPIO6;
|
|
let _ = peripherals.GPIO7;
|
|
let _ = peripherals.GPIO8;
|
|
let _ = peripherals.GPIO9;
|
|
let _ = peripherals.GPIO10;
|
|
let _ = peripherals.GPIO11;
|
|
let _ = peripherals.GPIO16;
|
|
let _ = peripherals.GPIO20;
|
|
|
|
esp_alloc::heap_allocator!(#[esp_hal::ram(reclaimed)] size: 98768);
|
|
|
|
let mut led = Output::new(
|
|
peripherals.GPIO21,
|
|
esp_hal::gpio::Level::High,
|
|
OutputConfig::default(),
|
|
);
|
|
|
|
loop {
|
|
log::info!("Hello world!");
|
|
led.toggle();
|
|
let delay_start = Instant::now();
|
|
while delay_start.elapsed() < Duration::from_millis(500) {}
|
|
}
|
|
|
|
// for inspiration have a look at the examples at https://github.com/esp-rs/esp-hal/tree/esp-hal-v1.1.0/examples
|
|
}
|