feat: init esp32 project
This commit is contained in:
parent
3f542d8db0
commit
a69b064f39
15 changed files with 1804 additions and 10 deletions
43
src/bin/main.rs
Normal file
43
src/bin/main.rs
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
#![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."
|
||||
)]
|
||||
|
||||
use defmt::info;
|
||||
use esp_hal::clock::CpuClock;
|
||||
use esp_hal::main;
|
||||
use esp_hal::time::{Duration, Instant};
|
||||
use esp_hal::timer::timg::TimerGroup;
|
||||
use panic_rtt_target 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!();
|
||||
|
||||
#[main]
|
||||
fn main() -> ! {
|
||||
// generator version: 0.5.0
|
||||
|
||||
rtt_target::rtt_init_defmt!();
|
||||
|
||||
let config = esp_hal::Config::default().with_cpu_clock(CpuClock::max());
|
||||
let peripherals = esp_hal::init(config);
|
||||
|
||||
esp_alloc::heap_allocator!(size: 64 * 1024);
|
||||
|
||||
let timg0 = TimerGroup::new(peripherals.TIMG0);
|
||||
let _init = esp_wifi::init(timg0.timer0, esp_hal::rng::Rng::new(peripherals.RNG)).unwrap();
|
||||
|
||||
loop {
|
||||
info!("Hello world!");
|
||||
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.0.0-rc.0/examples/src/bin
|
||||
}
|
||||
1
src/lib.rs
Normal file
1
src/lib.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
#![no_std]
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue