Skip to content

Commit

Permalink
Remove embedded-hal dependency (esp-rs#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani authored and bjoernQ committed May 23, 2024
1 parent ad70cef commit eebd9c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion esp-wifi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ license = "MIT OR Apache-2.0"

[dependencies]
defmt = { workspace = true, optional = true }
embedded-hal.workspace = true
esp32c3-hal = { workspace = true, optional = true }
esp32c2-hal = { workspace = true, optional = true }
esp32c6-hal = { workspace = true, optional = true }
Expand Down
12 changes: 6 additions & 6 deletions esp-wifi/src/common_adapter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ use crate::binary::include::esp_event_base_t;
use crate::binary::include::esp_timer_create_args_t;
use crate::binary::include::esp_timer_handle_t;
use crate::compat::timer_compat::*;
use crate::{trace, unwrap};
use embedded_hal::prelude::_embedded_hal_blocking_rng_Read;
use crate::trace;

use crate::compat::common::*;

Expand Down Expand Up @@ -146,9 +145,7 @@ pub unsafe extern "C" fn random() -> crate::binary::c_types::c_ulong {
trace!("random");

if let Some(ref mut rng) = RANDOM_GENERATOR {
let mut buffer = [0u8; 4];
unwrap!(rng.read(&mut buffer));
u32::from_le_bytes(buffer)
rng.random()
} else {
0
}
Expand Down Expand Up @@ -436,7 +433,10 @@ pub unsafe extern "C" fn esp_fill_random(dst: *mut u8, len: u32) {
let dst = core::slice::from_raw_parts_mut(dst, len as usize);

if let Some(ref mut rng) = RANDOM_GENERATOR {
unwrap!(rng.read(dst));
for chunk in dst.chunks_mut(4) {
let bytes = rng.random().to_le_bytes();
chunk.copy_from_slice(&bytes[..chunk.len()]);
}
}
}

Expand Down

0 comments on commit eebd9c3

Please sign in to comment.