first commit

This commit is contained in:
2023-09-24 13:11:36 -04:00
commit f23e21bedd
9 changed files with 317 additions and 0 deletions

40
src/main.rs Normal file
View File

@@ -0,0 +1,40 @@
#![no_std]
#![no_main]
extern crate alloc;
use core::mem::MaybeUninit;
use esp_backtrace as _;
use esp_println::println;
use hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, Delay};
#[global_allocator]
static ALLOCATOR: esp_alloc::EspHeap = esp_alloc::EspHeap::empty();
fn init_heap() {
const HEAP_SIZE: usize = 32 * 1024;
static mut HEAP: MaybeUninit<[u8; HEAP_SIZE]> = MaybeUninit::uninit();
unsafe {
ALLOCATOR.init(HEAP.as_mut_ptr() as *mut u8, HEAP_SIZE);
}
}
#[entry]
fn main() -> ! {
init_heap();
let peripherals = Peripherals::take();
let system = peripherals.DPORT.split();
let clocks = ClockControl::max(system.clock_control).freeze();
let mut delay = Delay::new(&clocks);
// setup logger
// To change the log_level change the env section in .cargo/config.toml
// or remove it and set ESP_LOGLEVEL manually before running cargo run
// this requires a clean rebuild because of https://github.com/rust-lang/cargo/issues/10358
esp_println::logger::init_logger_from_env();
log::info!("Logger is setup");
println!("Hello world!");
loop {
println!("Loop...");
delay.delay_ms(500u32);
}
}