Skip to content

Commit

Permalink
Fix dead code section from IDF
Browse files Browse the repository at this point in the history
  • Loading branch information
playfulFence committed Mar 12, 2024
1 parent 465a876 commit 6ecccce
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
4 changes: 2 additions & 2 deletions esp-hal/src/rng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub struct Rng {
impl Rng {
/// Create a new random number generator instance
pub fn new(_rng: impl Peripheral<P = RNG>) -> Self {
#[cfg(not(any(esp32p4, esp32s2)))]
#[cfg(not(esp32p4))]
crate::soc::trng::ensure_randomness();

Self {
Expand Down Expand Up @@ -138,5 +138,5 @@ impl rand_core::RngCore for Rng {
}
}

#[cfg(not(any(esp32p4, esp32s2)))]
#[cfg(not(esp32p4))]
impl rand_core::CryptoRng for Rng {}
2 changes: 1 addition & 1 deletion esp-hal/src/soc/esp32s2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub mod peripherals;
#[cfg(psram)]
pub mod psram;
pub mod radio_clocks;
// pub mod trng;
pub mod trng;
pub mod ulp_core;

pub(crate) mod constants {
Expand Down
8 changes: 1 addition & 7 deletions esp-hal/src/soc/esp32s2/trng.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,6 @@ fn reg_get_bit(reg: u32, b: u32) -> u32 {
unsafe { (reg as *mut u32).read_volatile() & b }
}

fn reg_get_field(reg: u32, s: u32, v: u32) -> u32 {
unsafe { ((reg as *mut u32).read_volatile() >> s) & v }
}

fn reg_clr_bit(reg: u32, bit: u32) {
unsafe {
(reg as *mut u32).write_volatile((reg as *mut u32).read_volatile() & !bit);
Expand Down Expand Up @@ -282,10 +278,8 @@ pub(crate) fn regi2c_write_mask(block: u8, _host_id: u8, reg_add: u8, msb: u8, l
| (reg_add as u32 & I2C_RTC_ADDR_V as u32) << I2C_RTC_ADDR_S as u32;
reg_write(I2C_RTC_CONFIG2, temp);
while reg_get_bit(I2C_RTC_CONFIG2, I2C_RTC_BUSY) != 0 {}
temp = reg_get_field(I2C_RTC_CONFIG2, I2C_RTC_DATA_S, I2C_RTC_DATA_V);
// Write the i2c bus register
temp &= (!(0xFFFFFFFF << lsb)) | (0xFFFFFFFF << (msb + 1));
temp |= (data as u32 & (!(0xFFFFFFFF << (msb as u32 - lsb as u32 + 1)))) << (lsb as u32);
temp = (data as u32 & (!(0xFFFFFFFF << (msb as u32 - lsb as u32 + 1)))) << (lsb as u32);
temp = ((block as u32 & I2C_RTC_SLAVE_ID_V as u32) << I2C_RTC_SLAVE_ID_S as u32)
| ((reg_add as u32 & I2C_RTC_ADDR_V as u32) << I2C_RTC_ADDR_S as u32)
| ((0x1 & I2C_RTC_WR_CNTL_V as u32) << I2C_RTC_WR_CNTL_S as u32)
Expand Down

0 comments on commit 6ecccce

Please sign in to comment.