Skip to content

Commit

Permalink
upgrade hal rev
Browse files Browse the repository at this point in the history
  • Loading branch information
MabezDev committed Oct 31, 2023
1 parent 35ea534 commit 2431c19
Show file tree
Hide file tree
Showing 18 changed files with 45 additions and 47 deletions.
12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ embedded-hal-async = { version = "1.0.0-rc.1" }

# patching esp32c6-hal for BLE - it would compile with 0.5.0 but not work
[patch.crates-io]
esp32c2-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "2d2561024f5c40c91687397c7bb884a4271b4022" }
esp32c3-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "2d2561024f5c40c91687397c7bb884a4271b4022" }
esp32-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "2d2561024f5c40c91687397c7bb884a4271b4022" }
esp32s2-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "2d2561024f5c40c91687397c7bb884a4271b4022" }
esp32s3-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "2d2561024f5c40c91687397c7bb884a4271b4022" }
esp-hal-common = { git = "https://github.com/esp-rs/esp-hal.git", rev = "2d2561024f5c40c91687397c7bb884a4271b4022" }
esp32c2-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "9cb8f7e941fd62f5ec1d46ee0dd9e8b2b2675872" }
esp32c3-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "9cb8f7e941fd62f5ec1d46ee0dd9e8b2b2675872" }
esp32-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "9cb8f7e941fd62f5ec1d46ee0dd9e8b2b2675872" }
esp32s2-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "9cb8f7e941fd62f5ec1d46ee0dd9e8b2b2675872" }
esp32s3-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "9cb8f7e941fd62f5ec1d46ee0dd9e8b2b2675872" }
esp-hal-common = { git = "https://github.com/esp-rs/esp-hal.git", rev = "9cb8f7e941fd62f5ec1d46ee0dd9e8b2b2675872" }
2 changes: 1 addition & 1 deletion esp-wifi/examples/access_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn main() -> ! {
)
.unwrap();

let (wifi, ..) = peripherals.RADIO.split();
let wifi = peripherals.WIFI;
let mut socket_set_entries: [SocketStorage; 3] = Default::default();
let (iface, device, mut controller, sockets) =
create_network_interface(&init, wifi, WifiMode::Ap, &mut socket_set_entries).unwrap();
Expand Down
13 changes: 7 additions & 6 deletions esp-wifi/examples/async_ble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@ use esp_wifi::{
mod examples_util;
use examples_util::hal;
use examples_util::BootButton;
use hal::{
clock::ClockControl, embassy, peripherals::*, prelude::*, radio::Bluetooth, timer::TimerGroup,
Rng, IO,
};
use hal::{clock::ClockControl, embassy, peripherals::*, prelude::*, timer::TimerGroup, Rng, IO};

#[embassy_executor::task]
async fn run(init: EspWifiInitialization, mut bluetooth: Bluetooth, pin: BootButton) {
async fn run(
init: EspWifiInitialization,
mut bluetooth: crate::hal::peripherals::BT,
pin: BootButton,
) {
let connector = BleConnector::new(&init, &mut bluetooth);
let mut ble = Ble::new(connector, esp_wifi::current_millis);
println!("Connector created");
Expand Down Expand Up @@ -160,7 +161,7 @@ fn main() -> ! {
)
.unwrap();

let (_, bluetooth, ..) = peripherals.RADIO.split();
let bluetooth = peripherals.BT;

let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
embassy::init(&clocks, timer_group0.timer0);
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/examples/ble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn main() -> ! {

let mut debounce_cnt = 500;

let (_, mut bluetooth, ..) = peripherals.RADIO.split();
let mut bluetooth = peripherals.BT;

loop {
let connector = BleConnector::new(&init, &mut bluetooth);
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/examples/dhcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ fn main() -> ! {
)
.unwrap();

let (wifi, ..) = peripherals.RADIO.split();
let wifi = peripherals.WIFI;
let mut socket_set_entries: [SocketStorage; 3] = Default::default();
let (iface, device, mut controller, sockets) =
create_network_interface(&init, wifi, WifiMode::Sta, &mut socket_set_entries).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/examples/embassy_access_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn main() -> ! {
)
.unwrap();

let (wifi, ..) = peripherals.RADIO.split();
let wifi = peripherals.WIFI;
let (wifi_interface, controller) =
esp_wifi::wifi::new_with_mode(&init, wifi, WifiMode::Ap).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/examples/embassy_dhcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ fn main() -> ! {
)
.unwrap();

let (wifi, ..) = peripherals.RADIO.split();
let wifi = peripherals.WIFI;
let (wifi_interface, controller) =
esp_wifi::wifi::new_with_mode(&init, wifi, WifiMode::Sta).unwrap();

Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/examples/embassy_esp_now.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn main() -> ! {
)
.unwrap();

let (wifi, ..) = peripherals.RADIO.split();
let wifi = peripherals.WIFI;
let esp_now = esp_wifi::esp_now::EspNow::new(&init, wifi).unwrap();
println!("esp-now version {}", esp_now.get_version().unwrap());

Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/examples/embassy_esp_now_duplex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ fn main() -> ! {
)
.unwrap();

let (wifi, ..) = peripherals.RADIO.split();
let wifi = peripherals.WIFI;
let esp_now = esp_wifi::esp_now::EspNow::new(&init, wifi).unwrap();
println!("esp-now version {}", esp_now.get_version().unwrap());

Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/examples/esp_now.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn main() -> ! {
)
.unwrap();

let (wifi, ..) = peripherals.RADIO.split();
let wifi = peripherals.WIFI;
let mut esp_now = esp_wifi::esp_now::EspNow::new(&init, wifi).unwrap();

println!("esp-now version {}", esp_now.get_version().unwrap());
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/examples/static_ip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn main() -> ! {
)
.unwrap();

let (wifi, ..) = peripherals.RADIO.split();
let wifi = peripherals.WIFI;
let mut socket_set_entries: [SocketStorage; 3] = Default::default();
let (iface, device, mut controller, sockets) =
create_network_interface(&init, wifi, WifiMode::Sta, &mut socket_set_entries).unwrap();
Expand Down
13 changes: 5 additions & 8 deletions esp-wifi/src/ble/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@ use embedded_io::{
Error, Io,
};

use crate::hal::{
peripheral::{Peripheral, PeripheralRef},
radio,
};
use crate::hal::peripheral::{Peripheral, PeripheralRef};
use crate::EspWifiInitialization;

use super::{read_hci, read_next, send_hci};

pub struct BleConnector<'d> {
_device: PeripheralRef<'d, radio::Bluetooth>,
_device: PeripheralRef<'d, crate::hal::peripherals::BT>,
}

impl<'d> BleConnector<'d> {
pub fn new(
init: &EspWifiInitialization,
device: impl Peripheral<P = radio::Bluetooth> + 'd,
device: impl Peripheral<P = crate::hal::peripherals::BT> + 'd,
) -> BleConnector<'d> {
if !init.is_ble() {
panic!("Not initialized for BLE use");
Expand Down Expand Up @@ -103,13 +100,13 @@ pub mod asynch {
}

pub struct BleConnector<'d> {
_device: PeripheralRef<'d, crate::hal::radio::Bluetooth>,
_device: PeripheralRef<'d, crate::hal::peripherals::BT>,
}

impl<'d> BleConnector<'d> {
pub fn new(
init: &EspWifiInitialization,
device: impl Peripheral<P = crate::hal::radio::Bluetooth> + 'd,
device: impl Peripheral<P = crate::hal::peripherals::BT> + 'd,
) -> BleConnector<'d> {
if !init.is_ble() {
panic!("Not initialized for BLE use");
Expand Down
6 changes: 3 additions & 3 deletions esp-wifi/src/ble/os_adapter_esp32c3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(super) struct osi_funcs_s {
magic: u32,
version: u32,
interrupt_set: Option<unsafe extern "C" fn(i32, i32, i32, i32)>,
interrupt_clear: Option<unsafe extern "C" fn(i32, i32)>,
clear_interrupt: Option<unsafe extern "C" fn(i32, i32)>,
interrupt_handler_set: Option<unsafe extern "C" fn(i32, extern "C" fn(), *const ())>,
interrupt_disable: Option<unsafe extern "C" fn()>,
interrupt_enable: Option<unsafe extern "C" fn()>,
Expand Down Expand Up @@ -81,7 +81,7 @@ pub(super) static G_OSI_FUNCS: osi_funcs_s = osi_funcs_s {
magic: 0xfadebead,
version: 0x00010006,
interrupt_set: Some(ble_os_adapter_chip_specific::interrupt_set),
interrupt_clear: Some(ble_os_adapter_chip_specific::interrupt_clear),
clear_interrupt: Some(ble_os_adapter_chip_specific::clear_interrupt),
interrupt_handler_set: Some(ble_os_adapter_chip_specific::interrupt_handler_set),
interrupt_disable: Some(interrupt_disable),
interrupt_enable: Some(interrupt_enable),
Expand Down Expand Up @@ -222,7 +222,7 @@ pub(crate) unsafe extern "C" fn interrupt_set(
// NO-OP
}

pub(crate) unsafe extern "C" fn interrupt_clear(_interrupt_source: i32, _interrupt_no: i32) {
pub(crate) unsafe extern "C" fn clear_interrupt(_interrupt_source: i32, _interrupt_no: i32) {
todo!();
}

Expand Down
6 changes: 3 additions & 3 deletions esp-wifi/src/ble/os_adapter_esp32s3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub(super) struct osi_funcs_s {
magic: u32,
version: u32,
interrupt_set: Option<unsafe extern "C" fn(i32, i32, i32, i32)>,
interrupt_clear: Option<unsafe extern "C" fn(i32, i32)>,
clear_interrupt: Option<unsafe extern "C" fn(i32, i32)>,
interrupt_handler_set: Option<unsafe extern "C" fn(i32, extern "C" fn(), *const ())>,
interrupt_disable: Option<unsafe extern "C" fn()>,
interrupt_enable: Option<unsafe extern "C" fn()>,
Expand Down Expand Up @@ -81,7 +81,7 @@ pub(super) static G_OSI_FUNCS: osi_funcs_s = osi_funcs_s {
magic: 0xfadebead,
version: 0x00010006,
interrupt_set: Some(ble_os_adapter_chip_specific::interrupt_set),
interrupt_clear: Some(ble_os_adapter_chip_specific::interrupt_clear),
clear_interrupt: Some(ble_os_adapter_chip_specific::clear_interrupt),
interrupt_handler_set: Some(ble_os_adapter_chip_specific::interrupt_handler_set),
interrupt_disable: Some(interrupt_disable),
interrupt_enable: Some(interrupt_enable),
Expand Down Expand Up @@ -216,7 +216,7 @@ pub(crate) unsafe extern "C" fn interrupt_set(
);
}

pub(crate) unsafe extern "C" fn interrupt_clear(_interrupt_source: i32, _interrupt_no: i32) {
pub(crate) unsafe extern "C" fn clear_interrupt(_interrupt_source: i32, _interrupt_no: i32) {
todo!();
}

Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/src/esp_now/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ pub struct EspNowWithWifiCreateToken {
}

pub fn enable_esp_now_with_wifi(
device: crate::hal::radio::Wifi,
) -> (crate::hal::radio::Wifi, EspNowWithWifiCreateToken) {
device: crate::hal::peripherals::WIFI,
) -> (crate::hal::peripherals::WIFI, EspNowWithWifiCreateToken) {
(device, EspNowWithWifiCreateToken { _private: () })
}

Expand Down
6 changes: 3 additions & 3 deletions esp-wifi/src/timer/riscv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static ALARM0: Mutex<RefCell<Option<Alarm<Periodic, 0>>>> = Mutex::new(RefCell::
pub fn setup_timer(systimer: TimeBase) {
let alarm0 = systimer.into_periodic();
alarm0.set_period(TIMER_DELAY.into_duration());
alarm0.interrupt_clear();
alarm0.clear_interrupt();
alarm0.enable_interrupt(true);

critical_section::with(|cs| ALARM0.borrow_ref_mut(cs).replace(alarm0));
Expand Down Expand Up @@ -58,7 +58,7 @@ pub fn setup_multitasking() {
fn SYSTIMER_TARGET0(trap_frame: &mut TrapFrame) {
// clear the systimer intr
critical_section::with(|cs| {
unwrap!(ALARM0.borrow_ref_mut(cs).as_mut()).interrupt_clear();
unwrap!(ALARM0.borrow_ref_mut(cs).as_mut()).clear_interrupt();
});

task_switch(trap_frame);
Expand All @@ -78,7 +78,7 @@ fn FROM_CPU_INTR3(trap_frame: &mut TrapFrame) {
let alarm0 = unwrap!(alarm0.as_mut());

alarm0.set_period(TIMER_DELAY.into_duration());
alarm0.interrupt_clear();
alarm0.clear_interrupt();
});

task_switch(trap_frame);
Expand Down
12 changes: 6 additions & 6 deletions esp-wifi/src/wifi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ pub fn wifi_start_scan(block: bool) -> i32 {

pub fn new_with_config<'d>(
inited: &EspWifiInitialization,
device: impl Peripheral<P = crate::hal::radio::Wifi> + 'd,
device: impl Peripheral<P = crate::hal::peripherals::WIFI> + 'd,
config: embedded_svc::wifi::Configuration,
) -> Result<(WifiDevice<'d>, WifiController<'d>), WifiError> {
if !inited.is_wifi() {
Expand All @@ -797,7 +797,7 @@ pub fn new_with_config<'d>(

pub fn new_with_mode<'d>(
inited: &EspWifiInitialization,
device: impl Peripheral<P = crate::hal::radio::Wifi> + 'd,
device: impl Peripheral<P = crate::hal::peripherals::WIFI> + 'd,
mode: WifiMode,
) -> Result<(WifiDevice<'d>, WifiController<'d>), WifiError> {
new_with_config(
Expand All @@ -812,11 +812,11 @@ pub fn new_with_mode<'d>(

/// A wifi device implementing smoltcp's Device trait.
pub struct WifiDevice<'d> {
_device: PeripheralRef<'d, crate::hal::radio::Wifi>,
_device: PeripheralRef<'d, crate::hal::peripherals::WIFI>,
}

impl<'d> WifiDevice<'d> {
pub(crate) fn new(_device: PeripheralRef<'d, crate::hal::radio::Wifi>) -> WifiDevice {
pub(crate) fn new(_device: PeripheralRef<'d, crate::hal::peripherals::WIFI>) -> WifiDevice {
Self { _device }
}

Expand Down Expand Up @@ -854,13 +854,13 @@ fn convert_ap_info(record: &include::wifi_ap_record_t) -> AccessPointInfo {

/// A wifi controller implementing embedded_svc::Wifi traits
pub struct WifiController<'d> {
_device: PeripheralRef<'d, crate::hal::radio::Wifi>,
_device: PeripheralRef<'d, crate::hal::peripherals::WIFI>,
config: embedded_svc::wifi::Configuration,
}

impl<'d> WifiController<'d> {
pub(crate) fn new_with_config(
_device: PeripheralRef<'d, crate::hal::radio::Wifi>,
_device: PeripheralRef<'d, crate::hal::peripherals::WIFI>,
config: embedded_svc::wifi::Configuration,
) -> Result<Self, WifiError> {
// We set up the controller with the default config because we need to call
Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/src/wifi/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use super::{WifiController, WifiDevice, WifiError, WifiMode};
/// You can use the provided macros to create and pass a suitable backing storage.
pub fn create_network_interface<'a, 'd>(
inited: &EspWifiInitialization,
device: impl crate::hal::peripheral::Peripheral<P = crate::hal::radio::Wifi> + 'd,
device: impl crate::hal::peripheral::Peripheral<P = crate::hal::peripherals::WIFI> + 'd,
mode: WifiMode,
storage: &'a mut [SocketStorage<'a>],
) -> Result<(Interface, WifiDevice<'d>, WifiController<'d>, SocketSet<'a>), WifiError> {
Expand Down

0 comments on commit 2431c19

Please sign in to comment.