Skip to content

Commit

Permalink
Add ESP32- H2 soc/efuse methods (esp-rs#486)
Browse files Browse the repository at this point in the history
* feat: ✨ Implement efuse methods

* feat: ✨ Add NUM_PINS

* doc: Update link to point at specific commit

Co-authored-by: Jesse Braham <jessebraham@users.noreply.github.com>

---------

Co-authored-by: Jesse Braham <jessebraham@users.noreply.github.com>
  • Loading branch information
SergioGasquez and jessebraham committed May 5, 2023
1 parent c944719 commit 77d6838
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
34 changes: 31 additions & 3 deletions esp-hal-common/src/soc/esp32h2/efuse.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
//! Reading of eFuses

use crate::peripherals::EFUSE;

pub struct Efuse;

impl Efuse {
Expand All @@ -19,16 +23,40 @@ impl Efuse {
/// );
/// ```
pub fn get_mac_address() -> [u8; 6] {
todo!()
let efuse = unsafe { &*EFUSE::ptr() };

let mac_low: u32 = efuse.rd_mac_sys_0.read().mac_0().bits();
let mac_high: u32 = efuse.rd_mac_sys_1.read().mac_1().bits() as u32;

let mac_low_bytes = mac_low.to_be_bytes();
let mac_high_bytes = mac_high.to_be_bytes();

[
mac_high_bytes[2],
mac_high_bytes[3],
mac_low_bytes[0],
mac_low_bytes[1],
mac_low_bytes[2],
mac_low_bytes[3],
]
}

/// Get status of SPI boot encryption.
pub fn get_flash_encryption() -> bool {
todo!()
let efuse = unsafe { &*EFUSE::ptr() };
(efuse
.rd_repeat_data1
.read()
.spi_boot_crypt_cnt()
.bits()
.count_ones()
% 2)
!= 0
}

/// Get the multiplier for the timeout value of the RWDT STAGE 0 register.
pub fn get_rwdt_multiplier() -> u8 {
todo!()
let efuse = unsafe { &*EFUSE::ptr() };
efuse.rd_repeat_data1.read().wdt_delay_sel().bits()
}
}
3 changes: 2 additions & 1 deletion esp-hal-common/src/soc/esp32h2/gpio.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use paste::paste;

pub const NUM_PINS: usize = 0; // FIXME
// https://github.com/espressif/esp-idf/blob/df9310a/components/soc/esp32h2/gpio_periph.c#L42
pub const NUM_PINS: usize = 27;

pub type OutputSignalType = u8;
pub const OUTPUT_SIGNAL_MAX: u8 = 0; // FIXME
Expand Down

0 comments on commit 77d6838

Please sign in to comment.