platform: add chip_id function to board api

This commit is contained in:
Victoria Fischer 2024-12-14 11:07:34 +01:00
parent e57ceeb149
commit b6e34111ff
2 changed files with 11 additions and 2 deletions

View File

@ -103,6 +103,14 @@ impl Board for Esp32Board {
type Output = StrideOutput<[Rgb<u8>; 310], FastWs2812Esp32Rmt<'static>>;
type Surfaces = BufferedSurfacePool;
type Scheduler = FixedSizeScheduler<4>;
fn chip_id() -> u64 {
let mut chip_id: [u8; 8] = [0; 8];
unsafe {
esp_efuse_mac_get_default(&mut chip_id as *mut u8);
}
return u64::from_be_bytes(chip_id);
}
fn take() -> Self {
// It is necessary to call this function once. Otherwise some patches to the runtime
@ -120,7 +128,7 @@ impl Board for Esp32Board {
esp_efuse_mac_get_default(&mut chip_id as *mut u8);
}
log::info!("Setting up output for chip ID {:x?}", chip_id);
log::info!("Setting up output for chip ID {:x?}", Self::chip_id());
const POWER_VOLTS : u32 = 5;
const POWER_MA : u32 = 500;
@ -135,7 +143,7 @@ impl Board for Esp32Board {
// But the implementation spawns a thread based on the core the driver was created in,
// so we create the driver in another thread briefly.
// Fun stuff.
let output = match chip_id { // panel test board
let output = match Self::chip_id().to_be_bytes() { // panel test board
[72, 202, 67, 89, 145, 204, 0, 0] => {
StrideOutput::new(
Pixbuf::new(),

View File

@ -20,4 +20,5 @@ pub trait Board {
fn output(&mut self) -> Self::Output;
fn surfaces(&mut self) -> Self::Surfaces;
fn system_tasks(&mut self) -> Self::Scheduler;
fn chip_id() -> u64;
}