Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update esp-hal packages #320

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ esp-println = { version = "0.6.0" }
esp-backtrace = { version = "0.8.0", features = ["panic-handler", "exception-handler", "print-uart"] }
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]
esp32c6-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "4c34ebe9e264fcc31fabba862274adae8daa680a" }
esp-hal-common = { git = "https://github.com/esp-rs/esp-hal.git", rev = "4c34ebe9e264fcc31fabba862274adae8daa680a" }
esp32-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "9cb8f7e" }
esp32s2-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "9cb8f7e" }
esp32s3-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "9cb8f7e" }
esp32c2-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "9cb8f7e" }
esp32c3-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "9cb8f7e" }
esp32c6-hal = { git = "https://github.com/esp-rs/esp-hal.git", rev = "9cb8f7e" }
esp-hal-common = { git = "https://github.com/esp-rs/esp-hal.git", rev = "9cb8f7e" }
16 changes: 7 additions & 9 deletions esp-wifi/src/ble/controller/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@ use embedded_io::{
Error, Io,
};

use crate::hal::{
peripheral::{Peripheral, PeripheralRef},
radio,
};
use crate::hal::peripheral::{Peripheral, PeripheralRef};
use crate::hal::peripherals::BT as BluetoothRadio;
use crate::EspWifiInitialization;

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

pub struct BleConnector<'d> {
_device: PeripheralRef<'d, radio::Bluetooth>,
_device: PeripheralRef<'d, BluetoothRadio>,
}

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

use super::BleConnectorError;
use super::{read_hci, send_hci};
use super::{read_hci, send_hci, BluetoothRadio};
use crate::hal::peripheral::{Peripheral, PeripheralRef};
use embassy_sync::waitqueue::AtomicWaker;
use embedded_io::asynch;
Expand All @@ -103,13 +101,13 @@ pub mod asynch {
}

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

impl<'d> BleConnector<'d> {
pub fn new(
init: &EspWifiInitialization,
device: impl Peripheral<P = crate::hal::radio::Bluetooth> + 'd,
device: impl Peripheral<P = BluetoothRadio> + 'd,
) -> BleConnector<'d> {
if !init.is_ble() {
panic!("Not initialized for BLE use");
Expand Down
14 changes: 6 additions & 8 deletions esp-wifi/src/esp_now/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use critical_section::Mutex;

use crate::compat::queue::SimpleQueue;
use crate::hal::peripheral::{Peripheral, PeripheralRef};
use crate::hal::radio;
use crate::hal::peripherals::WIFI as WifiRadio;
use crate::EspWifiInitialization;

use crate::binary::include::*;
Expand Down Expand Up @@ -262,9 +262,7 @@ pub struct EspNowWithWifiCreateToken {
_private: (),
}

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

Expand Down Expand Up @@ -535,7 +533,7 @@ impl<'d> Drop for EspNowRc<'d> {
/// Currently this implementation (when used together with traditional Wi-Fi) ONLY support STA mode.
///
pub struct EspNow<'d> {
_device: Option<PeripheralRef<'d, radio::Wifi>>,
_device: Option<PeripheralRef<'d, WifiRadio>>,
manager: EspNowManager<'d>,
sender: EspNowSender<'d>,
receiver: EspNowReceiver<'d>,
Expand All @@ -544,7 +542,7 @@ pub struct EspNow<'d> {
impl<'d> EspNow<'d> {
pub fn new(
inited: &EspWifiInitialization,
device: impl Peripheral<P = radio::Wifi> + 'd,
device: impl Peripheral<P = WifiRadio> + 'd,
) -> Result<EspNow<'d>, EspNowError> {
EspNow::new_internal(inited, Some(device.into_ref()))
}
Expand All @@ -553,12 +551,12 @@ impl<'d> EspNow<'d> {
inited: &EspWifiInitialization,
_token: EspNowWithWifiCreateToken,
) -> Result<EspNow<'d>, EspNowError> {
EspNow::new_internal(inited, None::<PeripheralRef<'d, radio::Wifi>>)
EspNow::new_internal(inited, None::<PeripheralRef<'d, WifiRadio>>)
}

fn new_internal(
inited: &EspWifiInitialization,
device: Option<PeripheralRef<'d, radio::Wifi>>,
device: Option<PeripheralRef<'d, WifiRadio>>,
) -> Result<EspNow<'d>, EspNowError> {
if !inited.is_wifi() {
return Err(EspNowError::Error(Error::NotInitialized));
Expand Down
10 changes: 5 additions & 5 deletions esp-wifi/src/timer/riscv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ use crate::{
preempt::preempt::task_switch,
};

#[cfg(feature = "esp32c6")]
#[cfg(esp32c6)]
use peripherals::INTPRI as SystemPeripheral;
#[cfg(not(feature = "esp32c6"))]
#[cfg(not(esp32c6))]
use peripherals::SYSTEM as SystemPeripheral;

pub type TimeBase = Alarm<Target, 0>;
Expand All @@ -29,9 +29,9 @@ 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());
alarm0.set_period(TIMER_DELAY.into_duration());
alarm0.clear_interrupt();
alarm0.interrupt_enable(true);
alarm0.enable_interrupt(true);

critical_section::with(|cs| ALARM0.borrow_ref_mut(cs).replace(alarm0));

Expand Down Expand Up @@ -77,7 +77,7 @@ fn FROM_CPU_INTR3(trap_frame: &mut TrapFrame) {
let mut alarm0 = ALARM0.borrow_ref_mut(cs);
let alarm0 = unwrap!(alarm0.as_mut());

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

Expand Down
13 changes: 7 additions & 6 deletions esp-wifi/src/wifi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::esp_wifi_result;
use crate::hal::macros::ram;
use crate::hal::peripheral::Peripheral;
use crate::hal::peripheral::PeripheralRef;
use crate::hal::peripherals::WIFI as WifiRadio;
use crate::EspWifiInitialization;

use critical_section::Mutex;
Expand Down Expand Up @@ -780,7 +781,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 = WifiRadio> + 'd,
config: embedded_svc::wifi::Configuration,
) -> Result<(WifiDevice<'d>, WifiController<'d>), WifiError> {
if !inited.is_wifi() {
Expand All @@ -797,7 +798,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 = WifiRadio> + 'd,
mode: WifiMode,
) -> Result<(WifiDevice<'d>, WifiController<'d>), WifiError> {
new_with_config(
Expand All @@ -812,11 +813,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, WifiRadio>,
}

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

Expand Down Expand Up @@ -854,13 +855,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, WifiRadio>,
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, WifiRadio>,
config: embedded_svc::wifi::Configuration,
) -> Result<Self, WifiError> {
// We set up the controller with the default config because we need to call
Expand Down
3 changes: 2 additions & 1 deletion esp-wifi/src/wifi/utils.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::hal::peripherals::WIFI as WifiRadio;
use smoltcp::{
iface::{Config, Interface, SocketSet, SocketStorage},
socket::dhcpv4::Socket as Dhcpv4Socket,
Expand All @@ -14,7 +15,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 = WifiRadio> + 'd,
mode: WifiMode,
storage: &'a mut [SocketStorage<'a>],
) -> Result<(Interface, WifiDevice<'d>, WifiController<'d>, SocketSet<'a>), WifiError> {
Expand Down
Loading