Skip to content

Commit

Permalink
Use esp-hal 0.17.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoernQ committed Apr 19, 2024
1 parent b18ed4a commit 9bdef35
Show file tree
Hide file tree
Showing 34 changed files with 225 additions and 145 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ debug = true

[workspace.dependencies]
defmt = "0.3.6"
esp-hal = { version = "0.16.1", default-features = false }
esp-hal = { version = "0.17.0", default-features = false }
smoltcp = { version = "0.11.0", default-features = false, features = [
"medium-ethernet",
"socket-raw",
Expand Down Expand Up @@ -51,7 +51,7 @@ bleps = { git = "https://github.com/bjoernQ/bleps", package = "bleps", rev = "93
"macros",
] }
embassy-executor = { version = "0.5.0", package = "embassy-executor", features = [
"nightly",
"task-arena-size-12288",
"integrated-timers",
] }
embassy-time = { version = "0.3.0" }
Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/automated-tests/esp_now_broadcaster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use esp_wifi::{current_millis, initialize, EspWifiInitFor};
mod examples_util;
use examples_util::hal;
use hal::clock::ClockControl;
use hal::Rng;
use hal::rng::Rng;
use hal::{peripherals::Peripherals, prelude::*};

#[entry]
Expand All @@ -23,7 +23,7 @@ fn main() -> ! {
let clocks = ClockControl::max(system.clock_control).freeze();

#[cfg(target_arch = "xtensa")]
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks).timer0;
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks, None).timer0;
#[cfg(target_arch = "riscv32")]
let timer = hal::systimer::SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/automated-tests/open_access_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use esp_wifi::wifi::WifiApDevice;
use esp_wifi::wifi_interface::WifiStack;
use esp_wifi::{current_millis, EspWifiInitFor};
use hal::clock::ClockControl;
use hal::Rng;
use hal::rng::Rng;
use hal::{peripherals::Peripherals, prelude::*};

use smoltcp::iface::SocketStorage;
Expand All @@ -32,7 +32,7 @@ fn main() -> ! {
let clocks = ClockControl::max(system.clock_control).freeze();

#[cfg(target_arch = "xtensa")]
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks).timer0;
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks, None).timer0;
#[cfg(target_arch = "riscv32")]
let timer = hal::systimer::SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/automated-tests/test_ble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use esp_backtrace as _;
use esp_println::println;
use esp_wifi::{ble::controller::BleConnector, initialize, EspWifiInitFor};
use examples_util::hal;
use hal::{clock::ClockControl, peripherals::*, prelude::*, Rng};
use hal::{clock::ClockControl, peripherals::*, prelude::*, rng::Rng};
#[path = "../../examples-util/util.rs"]
mod examples_util;

Expand All @@ -29,7 +29,7 @@ fn main() -> ! {
let clocks = ClockControl::max(system.clock_control).freeze();

#[cfg(target_arch = "xtensa")]
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks).timer0;
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks, None).timer0;
#[cfg(target_arch = "riscv32")]
let timer = hal::systimer::SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/automated-tests/test_connect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use esp_wifi::wifi::{utils::create_network_interface, WifiError};
use esp_wifi::wifi_interface::WifiStack;
use esp_wifi::{current_millis, EspWifiInitFor};
use hal::clock::ClockControl;
use hal::Rng;
use hal::rng::Rng;
use hal::{peripherals::Peripherals, prelude::*};

use smoltcp::iface::SocketStorage;
Expand Down Expand Up @@ -45,7 +45,7 @@ fn main() -> ! {
let clocks = ClockControl::max(system.clock_control).freeze();

#[cfg(target_arch = "xtensa")]
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks).timer0;
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks, None).timer0;
#[cfg(target_arch = "riscv32")]
let timer = hal::systimer::SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/automated-tests/test_esp_now.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use esp_wifi::{initialize, EspWifiInitFor};
mod examples_util;
use examples_util::hal;
use hal::clock::ClockControl;
use hal::Rng;
use hal::rng::Rng;
use hal::{peripherals::Peripherals, prelude::*};

#[entry]
Expand All @@ -23,7 +23,7 @@ fn main() -> ! {
let clocks = ClockControl::max(system.clock_control).freeze();

#[cfg(target_arch = "xtensa")]
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks).timer0;
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks, None).timer0;
#[cfg(target_arch = "riscv32")]
let timer = hal::systimer::SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/examples/access_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use esp_wifi::wifi::WifiApDevice;
use esp_wifi::wifi_interface::WifiStack;
use esp_wifi::{current_millis, EspWifiInitFor};
use hal::clock::ClockControl;
use hal::Rng;
use hal::rng::Rng;
use hal::{peripherals::Peripherals, prelude::*};

use smoltcp::iface::SocketStorage;
Expand All @@ -32,7 +32,7 @@ fn main() -> ! {
let clocks = ClockControl::max(system.clock_control).freeze();

#[cfg(target_arch = "xtensa")]
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks).timer0;
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks, None).timer0;
#[cfg(target_arch = "riscv32")]
let timer = hal::systimer::SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/examples/access_point_with_sta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use esp_wifi::wifi::utils::{create_ap_sta_network_interface, ApStaInterface};
use esp_wifi::wifi_interface::WifiStack;
use esp_wifi::{current_millis, EspWifiInitFor};
use hal::clock::ClockControl;
use hal::Rng;
use hal::rng::Rng;
use hal::{peripherals::Peripherals, prelude::*};

use smoltcp::iface::SocketStorage;
Expand All @@ -36,7 +36,7 @@ fn main() -> ! {
let clocks = ClockControl::max(system.clock_control).freeze();

#[cfg(target_arch = "xtensa")]
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks).timer0;
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks, None).timer0;
#[cfg(target_arch = "riscv32")]
let timer = hal::systimer::SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
Expand Down
13 changes: 7 additions & 6 deletions esp-wifi/examples/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use esp_wifi::wifi::{WifiError, WifiStaDevice};
use esp_wifi::wifi_interface::WifiStack;
use esp_wifi::{current_millis, initialize, EspWifiInitFor};
use hal::clock::ClockControl;
use hal::Rng;
use hal::delay::Delay;
use hal::rng::Rng;
use hal::{peripherals::Peripherals, prelude::*};
use smoltcp::iface::SocketStorage;
use smoltcp::wire::IpAddress;
Expand Down Expand Up @@ -46,7 +47,7 @@ fn main() -> ! {
let server_address: Ipv4Address = HOST_IP.parse().expect("Invalid HOST_IP address");

#[cfg(target_arch = "xtensa")]
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks).timer0;
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks, None).timer0;
#[cfg(target_arch = "riscv32")]
let timer = hal::systimer::SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
Expand Down Expand Up @@ -119,18 +120,18 @@ fn main() -> ! {
let mut tx_buffer = [0u8; TX_BUFFER_SIZE];
let mut socket = wifi_stack.get_socket(&mut rx_buffer, &mut tx_buffer);

let mut delay = hal::Delay::new(&clocks);
let delay = Delay::new(&clocks);

loop {
test_download(server_address, &mut socket);
delay.delay_ms(3_000u32);
delay.delay_millis(3_000u32);
socket.work();
test_upload(server_address, &mut socket);
socket.work();
delay.delay_ms(3_000u32);
delay.delay_millis(3_000u32);
test_upload_download(server_address, &mut socket);
socket.work();
delay.delay_ms(3_000u32);
delay.delay_millis(3_000u32);
}
}

Expand Down
8 changes: 4 additions & 4 deletions esp-wifi/examples/ble.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use esp_wifi::{ble::controller::BleConnector, initialize, EspWifiInitFor};
#[path = "../../examples-util/util.rs"]
mod examples_util;
use examples_util::hal;
use hal::{clock::ClockControl, peripherals::*, prelude::*, Rng, IO};
use hal::{clock::ClockControl, gpio::IO, peripherals::*, prelude::*, rng::Rng};

#[entry]
fn main() -> ! {
Expand All @@ -27,7 +27,7 @@ fn main() -> ! {
let clocks = ClockControl::max(system.clock_control).freeze();

#[cfg(target_arch = "xtensa")]
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks).timer0;
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks, None).timer0;
#[cfg(target_arch = "riscv32")]
let timer = hal::systimer::SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
Expand Down Expand Up @@ -124,7 +124,7 @@ fn main() -> ! {
loop {
let mut notification = None;

if button.is_low().unwrap() && debounce_cnt > 0 {
if button.is_low() && debounce_cnt > 0 {
debounce_cnt -= 1;
if debounce_cnt == 0 {
let mut cccd = [0u8; 1];
Expand All @@ -144,7 +144,7 @@ fn main() -> ! {
}
};

if button.is_high().unwrap() {
if button.is_high() {
debounce_cnt = 500;
}

Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/examples/coex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use esp_backtrace as _;
use esp_println::{print, println};
use esp_wifi::initialize;
use esp_wifi::wifi::utils::create_network_interface;
use hal::{clock::ClockControl, Rng};
use hal::{clock::ClockControl, rng::Rng};
use hal::{peripherals::Peripherals, prelude::*};
use smoltcp::{iface::SocketStorage, wire::IpAddress, wire::Ipv4Address};

Expand All @@ -43,7 +43,7 @@ fn main() -> ! {
let clocks = ClockControl::max(system.clock_control).freeze();

#[cfg(target_arch = "xtensa")]
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks).timer0;
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks, None).timer0;
#[cfg(target_arch = "riscv32")]
let timer = hal::systimer::SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
Expand Down
4 changes: 2 additions & 2 deletions esp-wifi/examples/dhcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use esp_wifi::wifi::{WifiError, WifiStaDevice};
use esp_wifi::wifi_interface::WifiStack;
use esp_wifi::{current_millis, initialize, EspWifiInitFor};
use hal::clock::ClockControl;
use hal::Rng;
use hal::rng::Rng;
use hal::{peripherals::Peripherals, prelude::*};
use smoltcp::iface::SocketStorage;
use smoltcp::wire::IpAddress;
Expand All @@ -35,7 +35,7 @@ fn main() -> ! {
let clocks = ClockControl::max(system.clock_control).freeze();

#[cfg(target_arch = "xtensa")]
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks).timer0;
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks, None).timer0;
#[cfg(target_arch = "riscv32")]
let timer = hal::systimer::SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
Expand Down
6 changes: 3 additions & 3 deletions esp-wifi/examples/embassy_access_point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use esp_wifi::wifi::{AccessPointConfiguration, Configuration};
use esp_wifi::wifi::{WifiApDevice, WifiController, WifiDevice, WifiEvent, WifiState};
use esp_wifi::{initialize, EspWifiInitFor};
use hal::clock::ClockControl;
use hal::Rng;
use hal::rng::Rng;
use hal::{embassy, peripherals::Peripherals, prelude::*, timer::TimerGroup};
use static_cell::make_static;

Expand All @@ -33,7 +33,7 @@ async fn main(spawner: Spawner) -> ! {
let clocks = ClockControl::max(system.clock_control).freeze();

#[cfg(target_arch = "xtensa")]
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks).timer0;
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks, None).timer0;
#[cfg(target_arch = "riscv32")]
let timer = hal::systimer::SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
Expand All @@ -49,7 +49,7 @@ async fn main(spawner: Spawner) -> ! {
let (wifi_interface, controller) =
esp_wifi::wifi::new_with_mode(&init, wifi, WifiApDevice).unwrap();

let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
let timer_group0 = TimerGroup::new_async(peripherals.TIMG0, &clocks);
embassy::init(&clocks, timer_group0);

let config = Config::ipv4_static(StaticConfigV4 {
Expand Down
6 changes: 3 additions & 3 deletions esp-wifi/examples/embassy_access_point_with_sta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use esp_wifi::wifi::{
};
use esp_wifi::{initialize, EspWifiInitFor};
use hal::clock::ClockControl;
use hal::Rng;
use hal::rng::Rng;
use hal::{embassy, peripherals::Peripherals, prelude::*, timer::TimerGroup};
use static_cell::make_static;

Expand All @@ -38,7 +38,7 @@ async fn main(spawner: Spawner) -> ! {
let clocks = ClockControl::max(system.clock_control).freeze();

#[cfg(target_arch = "xtensa")]
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks).timer0;
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks, None).timer0;
#[cfg(target_arch = "riscv32")]
let timer = hal::systimer::SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
Expand All @@ -54,7 +54,7 @@ async fn main(spawner: Spawner) -> ! {
let (wifi_ap_interface, wifi_sta_interface, mut controller) =
esp_wifi::wifi::new_ap_sta(&init, wifi).unwrap();

let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
let timer_group0 = TimerGroup::new_async(peripherals.TIMG0, &clocks);
embassy::init(&clocks, timer_group0);

let ap_config = Config::ipv4_static(StaticConfigV4 {
Expand Down
18 changes: 12 additions & 6 deletions esp-wifi/examples/embassy_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use esp_wifi::wifi::{ClientConfiguration, Configuration, WifiStaDevice};
use esp_wifi::wifi::{WifiController, WifiDevice, WifiEvent, WifiState};
use esp_wifi::{initialize, EspWifiInitFor};
use hal::clock::ClockControl;
use hal::Rng;
use hal::rng::Rng;
use hal::{embassy, peripherals::Peripherals, prelude::*, timer::TimerGroup};
use static_cell::make_static;

Expand All @@ -33,6 +33,10 @@ const DOWNLOAD_PORT: u16 = 4321;
const UPLOAD_PORT: u16 = 4322;
const UPLOAD_DOWNLOAD_PORT: u16 = 4323;

// static buffers to not need a huge task-arena
static mut RX_BUFFER: [u8; RX_BUFFER_SIZE] = [0; RX_BUFFER_SIZE];
static mut TX_BUFFER: [u8; TX_BUFFER_SIZE] = [0; TX_BUFFER_SIZE];

#[main]
async fn main(spawner: Spawner) -> ! {
#[cfg(feature = "log")]
Expand All @@ -46,7 +50,7 @@ async fn main(spawner: Spawner) -> ! {
let server_address: Ipv4Address = HOST_IP.parse().expect("Invalid HOST_IP address");

#[cfg(target_arch = "xtensa")]
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks).timer0;
let timer = hal::timer::TimerGroup::new(peripherals.TIMG1, &clocks, None).timer0;
#[cfg(target_arch = "riscv32")]
let timer = hal::systimer::SystemTimer::new(peripherals.SYSTIMER).alarm0;
let init = initialize(
Expand All @@ -62,7 +66,7 @@ async fn main(spawner: Spawner) -> ! {
let (wifi_interface, controller) =
esp_wifi::wifi::new_with_mode(&init, wifi, WifiStaDevice).unwrap();

let timer_group0 = TimerGroup::new(peripherals.TIMG0, &clocks);
let timer_group0 = TimerGroup::new_async(peripherals.TIMG0, &clocks);
embassy::init(&clocks, timer_group0);

let config = Config::dhcpv4(Default::default());
Expand Down Expand Up @@ -96,9 +100,11 @@ async fn main(spawner: Spawner) -> ! {
Timer::after(Duration::from_millis(500)).await;
}

let mut rx_buffer = [0; RX_BUFFER_SIZE];
let mut tx_buffer = [0; TX_BUFFER_SIZE];
let mut socket = TcpSocket::new(stack, &mut rx_buffer, &mut tx_buffer);
let mut socket = TcpSocket::new(
stack,
unsafe { &mut *core::ptr::addr_of_mut!(RX_BUFFER) },
unsafe { &mut *core::ptr::addr_of_mut!(TX_BUFFER) },
);

loop {
let _down = test_download(server_address, &mut socket).await;
Expand Down
Loading

0 comments on commit 9bdef35

Please sign in to comment.