From 614fb263fb164dbff23c02db022a90c08c75ac3f Mon Sep 17 00:00:00 2001 From: Scott Mabin Date: Wed, 6 Sep 2023 16:27:59 +0100 Subject: [PATCH] Make utils a single file module for remaining util items --- Cargo.toml | 1 - examples-esp32/Cargo.toml | 1 - examples-esp32/examples/access_point.rs | 2 ++ examples-esp32/examples/async_ble.rs | 5 ++++- examples-esp32/examples/ble.rs | 5 ++++- examples-esp32/examples/coex.rs | 2 ++ examples-esp32/examples/dhcp.rs | 2 ++ .../examples/embassy_access_point.rs | 2 ++ examples-esp32/examples/embassy_dhcp.rs | 2 ++ examples-esp32/examples/embassy_esp_now.rs | 2 ++ examples-esp32/examples/esp_now.rs | 2 ++ examples-esp32/examples/static_ip.rs | 2 ++ examples-esp32c2/Cargo.toml | 1 - examples-esp32c2/examples/access_point.rs | 2 ++ examples-esp32c2/examples/async_ble.rs | 5 ++++- examples-esp32c2/examples/ble.rs | 5 ++++- examples-esp32c2/examples/dhcp.rs | 2 ++ .../examples/embassy_access_point.rs | 2 ++ examples-esp32c2/examples/embassy_dhcp.rs | 2 ++ examples-esp32c2/examples/embassy_esp_now.rs | 2 ++ examples-esp32c2/examples/esp_now.rs | 2 ++ examples-esp32c2/examples/static_ip.rs | 2 ++ examples-esp32c3/Cargo.toml | 1 - examples-esp32c3/examples/access_point.rs | 2 ++ examples-esp32c3/examples/async_ble.rs | 5 ++++- examples-esp32c3/examples/ble.rs | 5 ++++- examples-esp32c3/examples/coex.rs | 2 ++ examples-esp32c3/examples/dhcp.rs | 2 ++ .../examples/embassy_access_point.rs | 2 ++ examples-esp32c3/examples/embassy_dhcp.rs | 2 ++ examples-esp32c3/examples/embassy_esp_now.rs | 2 ++ examples-esp32c3/examples/esp_now.rs | 2 ++ examples-esp32c3/examples/static_ip.rs | 2 ++ examples-esp32c6/Cargo.toml | 1 - examples-esp32c6/examples/access_point.rs | 2 ++ examples-esp32c6/examples/async_ble.rs | 5 ++++- examples-esp32c6/examples/ble.rs | 5 ++++- examples-esp32c6/examples/dhcp.rs | 2 ++ .../examples/embassy_access_point.rs | 2 ++ examples-esp32c6/examples/embassy_dhcp.rs | 2 ++ examples-esp32c6/examples/embassy_esp_now.rs | 2 ++ examples-esp32c6/examples/esp_now.rs | 2 ++ examples-esp32c6/examples/static_ip.rs | 2 ++ examples-esp32s2/Cargo.toml | 1 - examples-esp32s2/examples/access_point.rs | 2 ++ examples-esp32s2/examples/dhcp.rs | 2 ++ .../examples/embassy_access_point.rs | 2 ++ examples-esp32s2/examples/embassy_dhcp.rs | 2 ++ examples-esp32s2/examples/embassy_esp_now.rs | 2 ++ examples-esp32s2/examples/esp_now.rs | 2 ++ examples-esp32s2/examples/static_ip.rs | 2 ++ examples-esp32s3/Cargo.toml | 1 - examples-esp32s3/examples/access_point.rs | 2 ++ examples-esp32s3/examples/async_ble.rs | 5 ++++- examples-esp32s3/examples/ble.rs | 5 ++++- examples-esp32s3/examples/coex.rs | 2 ++ examples-esp32s3/examples/dhcp.rs | 2 ++ .../examples/embassy_access_point.rs | 2 ++ examples-esp32s3/examples/embassy_dhcp.rs | 2 ++ examples-esp32s3/examples/embassy_esp_now.rs | 2 ++ examples-esp32s3/examples/esp_now.rs | 2 ++ examples-esp32s3/examples/static_ip.rs | 2 ++ examples-util/Cargo.toml | 20 ------------------- examples-util/{src/lib.rs => util.rs} | 14 +------------ 64 files changed, 131 insertions(+), 50 deletions(-) delete mode 100644 examples-util/Cargo.toml rename examples-util/{src/lib.rs => util.rs} (67%) diff --git a/Cargo.toml b/Cargo.toml index 834ad4c7..f13b9c6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,6 @@ members = [ "esp-wifi", "esp-wifi-sys", "xtask", - "examples-util", "examples-esp32c2", "examples-esp32c3", "examples-esp32c6", diff --git a/examples-esp32/Cargo.toml b/examples-esp32/Cargo.toml index c7aad5d5..63824074 100644 --- a/examples-esp32/Cargo.toml +++ b/examples-esp32/Cargo.toml @@ -19,7 +19,6 @@ heapless.workspace = true embassy-net = { workspace = true, optional = true } esp32-hal.workspace = true -examples-util = { path = "../examples-util", features = ["esp32"] } esp-backtrace = { workspace = true, features = ["esp32"] } esp-wifi = { path = "../esp-wifi", default-features = false, features = ["esp32", "utils"] } embedded-hal-async = { workspace = true, optional = true } diff --git a/examples-esp32/examples/access_point.rs b/examples-esp32/examples/access_point.rs index 77cd24c9..ddf87805 100644 --- a/examples-esp32/examples/access_point.rs +++ b/examples-esp32/examples/access_point.rs @@ -3,6 +3,8 @@ #![feature(c_variadic)] #![feature(const_mut_refs)] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embedded_io::blocking::*; diff --git a/examples-esp32/examples/async_ble.rs b/examples-esp32/examples/async_ble.rs index ac1cca44..e55b6dac 100644 --- a/examples-esp32/examples/async_ble.rs +++ b/examples-esp32/examples/async_ble.rs @@ -22,6 +22,8 @@ use esp_println::println; use esp_wifi::{ ble::controller::asynch::BleConnector, initialize, EspWifiInitFor, EspWifiInitialization, }; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use examples_util::BootButton; use hal::{ @@ -147,7 +149,8 @@ fn main() -> ! { ) .unwrap(); - let button = examples_util::boot_button!(peripherals); + let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); + let button = io.pins.gpio0.into_pull_down_input(); // Async requires the GPIO interrupt to wake futures hal::interrupt::enable( diff --git a/examples-esp32/examples/ble.rs b/examples-esp32/examples/ble.rs index 059c683b..2f0a6b19 100644 --- a/examples-esp32/examples/ble.rs +++ b/examples-esp32/examples/ble.rs @@ -11,6 +11,8 @@ use bleps::{ use esp_backtrace as _; use esp_println::println; 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}; @@ -39,7 +41,8 @@ fn main() -> ! { ) .unwrap(); - let button = examples_util::boot_button!(peripherals); + let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); + let button = io.pins.gpio0.into_pull_down_input(); let mut debounce_cnt = 500; diff --git a/examples-esp32/examples/coex.rs b/examples-esp32/examples/coex.rs index 2ab7ee6c..09f195a6 100644 --- a/examples-esp32/examples/coex.rs +++ b/examples-esp32/examples/coex.rs @@ -1,6 +1,8 @@ #![no_std] #![no_main] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use bleps::{ diff --git a/examples-esp32/examples/dhcp.rs b/examples-esp32/examples/dhcp.rs index 150192dc..22cecfca 100644 --- a/examples-esp32/examples/dhcp.rs +++ b/examples-esp32/examples/dhcp.rs @@ -1,6 +1,8 @@ #![no_std] #![no_main] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embedded_io::blocking::*; diff --git a/examples-esp32/examples/embassy_access_point.rs b/examples-esp32/examples/embassy_access_point.rs index 35bf7629..12f27ca5 100644 --- a/examples-esp32/examples/embassy_access_point.rs +++ b/examples-esp32/examples/embassy_access_point.rs @@ -10,6 +10,8 @@ use embassy_net::ConfigV4; use embassy_net::{ Config, IpListenEndpoint, Ipv4Address, Ipv4Cidr, Stack, StackResources, StaticConfigV4, }; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embassy_executor::Executor; diff --git a/examples-esp32/examples/embassy_dhcp.rs b/examples-esp32/examples/embassy_dhcp.rs index c1f4bbaf..9ed962ed 100644 --- a/examples-esp32/examples/embassy_dhcp.rs +++ b/examples-esp32/examples/embassy_dhcp.rs @@ -5,6 +5,8 @@ use embassy_executor::_export::StaticCell; use embassy_net::tcp::TcpSocket; use embassy_net::{Config, Ipv4Address, Stack, StackResources}; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embassy_executor::Executor; diff --git a/examples-esp32/examples/embassy_esp_now.rs b/examples-esp32/examples/embassy_esp_now.rs index 757d0579..dacbb490 100644 --- a/examples-esp32/examples/embassy_esp_now.rs +++ b/examples-esp32/examples/embassy_esp_now.rs @@ -4,6 +4,8 @@ use embassy_executor::_export::StaticCell; use embassy_futures::select::{select, Either}; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embassy_executor::Executor; diff --git a/examples-esp32/examples/esp_now.rs b/examples-esp32/examples/esp_now.rs index 5ff306f2..33ffefe2 100644 --- a/examples-esp32/examples/esp_now.rs +++ b/examples-esp32/examples/esp_now.rs @@ -5,6 +5,8 @@ use esp_backtrace as _; use esp_println::println; use esp_wifi::esp_now::{PeerInfo, BROADCAST_ADDRESS}; use esp_wifi::{current_millis, initialize, EspWifiInitFor}; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use hal::clock::ClockControl; use hal::Rng; diff --git a/examples-esp32/examples/static_ip.rs b/examples-esp32/examples/static_ip.rs index 6739bb96..af4a7333 100644 --- a/examples-esp32/examples/static_ip.rs +++ b/examples-esp32/examples/static_ip.rs @@ -1,6 +1,8 @@ #![no_std] #![no_main] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embedded_io::blocking::*; diff --git a/examples-esp32c2/Cargo.toml b/examples-esp32c2/Cargo.toml index fdb361f0..dc8a39db 100644 --- a/examples-esp32c2/Cargo.toml +++ b/examples-esp32c2/Cargo.toml @@ -19,7 +19,6 @@ heapless.workspace = true embassy-net = { workspace = true, optional = true } esp32c2-hal.workspace = true -examples-util = { path = "../examples-util", features = ["esp32c2"] } esp-backtrace = { workspace = true, features = ["esp32c2"] } esp-wifi = { path = "../esp-wifi", default-features = false, features = ["esp32c2", "utils"] } embedded-hal-async = { workspace = true, optional = true } diff --git a/examples-esp32c2/examples/access_point.rs b/examples-esp32c2/examples/access_point.rs index e0582766..413e3d35 100644 --- a/examples-esp32c2/examples/access_point.rs +++ b/examples-esp32c2/examples/access_point.rs @@ -3,6 +3,8 @@ #![feature(c_variadic)] #![feature(const_mut_refs)] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embedded_io::blocking::*; diff --git a/examples-esp32c2/examples/async_ble.rs b/examples-esp32c2/examples/async_ble.rs index ca8f8209..7174a2d1 100644 --- a/examples-esp32c2/examples/async_ble.rs +++ b/examples-esp32c2/examples/async_ble.rs @@ -22,6 +22,8 @@ use esp_println::println; use esp_wifi::{ ble::controller::asynch::BleConnector, initialize, EspWifiInitFor, EspWifiInitialization, }; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use examples_util::BootButton; use hal::{ @@ -142,7 +144,8 @@ fn main() -> ! { ) .unwrap(); - let button = examples_util::boot_button!(peripherals); + let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); + let button = io.pins.gpio9.into_pull_down_input(); // Async requires the GPIO interrupt to wake futures hal::interrupt::enable( diff --git a/examples-esp32c2/examples/ble.rs b/examples-esp32c2/examples/ble.rs index ef0f6b0b..4aff7c99 100644 --- a/examples-esp32c2/examples/ble.rs +++ b/examples-esp32c2/examples/ble.rs @@ -11,6 +11,8 @@ use bleps::{ use esp_backtrace as _; use esp_println::println; 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::*, systimer::SystemTimer, Rng, IO}; @@ -34,7 +36,8 @@ fn main() -> ! { ) .unwrap(); - let button = examples_util::boot_button!(peripherals); + let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); + let button = io.pins.gpio9.into_pull_down_input(); let mut debounce_cnt = 500; diff --git a/examples-esp32c2/examples/dhcp.rs b/examples-esp32c2/examples/dhcp.rs index 1637183c..9b516bc3 100644 --- a/examples-esp32c2/examples/dhcp.rs +++ b/examples-esp32c2/examples/dhcp.rs @@ -1,6 +1,8 @@ #![no_std] #![no_main] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embedded_io::blocking::*; diff --git a/examples-esp32c2/examples/embassy_access_point.rs b/examples-esp32c2/examples/embassy_access_point.rs index 48ff92a7..2c30484d 100644 --- a/examples-esp32c2/examples/embassy_access_point.rs +++ b/examples-esp32c2/examples/embassy_access_point.rs @@ -10,6 +10,8 @@ use embassy_net::ConfigV4; use embassy_net::{ Config, IpListenEndpoint, Ipv4Address, Ipv4Cidr, Stack, StackResources, StaticConfigV4, }; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embassy_executor::Executor; diff --git a/examples-esp32c2/examples/embassy_dhcp.rs b/examples-esp32c2/examples/embassy_dhcp.rs index fb90e5dd..f92079be 100644 --- a/examples-esp32c2/examples/embassy_dhcp.rs +++ b/examples-esp32c2/examples/embassy_dhcp.rs @@ -5,6 +5,8 @@ use embassy_executor::_export::StaticCell; use embassy_net::tcp::TcpSocket; use embassy_net::{Config, Ipv4Address, Stack, StackResources}; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embassy_executor::Executor; diff --git a/examples-esp32c2/examples/embassy_esp_now.rs b/examples-esp32c2/examples/embassy_esp_now.rs index f9e0db21..f0315b6d 100644 --- a/examples-esp32c2/examples/embassy_esp_now.rs +++ b/examples-esp32c2/examples/embassy_esp_now.rs @@ -4,6 +4,8 @@ use embassy_executor::_export::StaticCell; use embassy_futures::select::{select, Either}; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embassy_executor::Executor; diff --git a/examples-esp32c2/examples/esp_now.rs b/examples-esp32c2/examples/esp_now.rs index 867681c0..c62ec4bc 100644 --- a/examples-esp32c2/examples/esp_now.rs +++ b/examples-esp32c2/examples/esp_now.rs @@ -6,6 +6,8 @@ use esp_backtrace as _; use esp_println::println; use esp_wifi::esp_now::{PeerInfo, BROADCAST_ADDRESS}; use esp_wifi::{current_millis, initialize, EspWifiInitFor}; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use hal::clock::ClockControl; use hal::{peripherals::Peripherals, prelude::*}; diff --git a/examples-esp32c2/examples/static_ip.rs b/examples-esp32c2/examples/static_ip.rs index bd473c18..c79ee8c6 100644 --- a/examples-esp32c2/examples/static_ip.rs +++ b/examples-esp32c2/examples/static_ip.rs @@ -1,6 +1,8 @@ #![no_std] #![no_main] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embedded_io::blocking::*; diff --git a/examples-esp32c3/Cargo.toml b/examples-esp32c3/Cargo.toml index 9b68c8a2..020f8c9c 100644 --- a/examples-esp32c3/Cargo.toml +++ b/examples-esp32c3/Cargo.toml @@ -19,7 +19,6 @@ heapless.workspace = true embassy-net = { workspace = true, optional = true } esp32c3-hal.workspace = true -examples-util = { path = "../examples-util", features = ["esp32c3"] } esp-backtrace = { workspace = true, features = ["esp32c3"] } esp-wifi = { path = "../esp-wifi", default-features = false, features = ["esp32c3", "utils"] } embedded-hal-async = { workspace = true, optional = true } diff --git a/examples-esp32c3/examples/access_point.rs b/examples-esp32c3/examples/access_point.rs index b90a005d..dd45e723 100644 --- a/examples-esp32c3/examples/access_point.rs +++ b/examples-esp32c3/examples/access_point.rs @@ -3,6 +3,8 @@ #![feature(c_variadic)] #![feature(const_mut_refs)] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embedded_io::blocking::*; diff --git a/examples-esp32c3/examples/async_ble.rs b/examples-esp32c3/examples/async_ble.rs index ca8f8209..7174a2d1 100644 --- a/examples-esp32c3/examples/async_ble.rs +++ b/examples-esp32c3/examples/async_ble.rs @@ -22,6 +22,8 @@ use esp_println::println; use esp_wifi::{ ble::controller::asynch::BleConnector, initialize, EspWifiInitFor, EspWifiInitialization, }; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use examples_util::BootButton; use hal::{ @@ -142,7 +144,8 @@ fn main() -> ! { ) .unwrap(); - let button = examples_util::boot_button!(peripherals); + let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); + let button = io.pins.gpio9.into_pull_down_input(); // Async requires the GPIO interrupt to wake futures hal::interrupt::enable( diff --git a/examples-esp32c3/examples/ble.rs b/examples-esp32c3/examples/ble.rs index ef0f6b0b..4aff7c99 100644 --- a/examples-esp32c3/examples/ble.rs +++ b/examples-esp32c3/examples/ble.rs @@ -11,6 +11,8 @@ use bleps::{ use esp_backtrace as _; use esp_println::println; 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::*, systimer::SystemTimer, Rng, IO}; @@ -34,7 +36,8 @@ fn main() -> ! { ) .unwrap(); - let button = examples_util::boot_button!(peripherals); + let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); + let button = io.pins.gpio9.into_pull_down_input(); let mut debounce_cnt = 500; diff --git a/examples-esp32c3/examples/coex.rs b/examples-esp32c3/examples/coex.rs index 5a2970e9..7ca64423 100644 --- a/examples-esp32c3/examples/coex.rs +++ b/examples-esp32c3/examples/coex.rs @@ -1,6 +1,8 @@ #![no_std] #![no_main] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use bleps::{ diff --git a/examples-esp32c3/examples/dhcp.rs b/examples-esp32c3/examples/dhcp.rs index 1637183c..9b516bc3 100644 --- a/examples-esp32c3/examples/dhcp.rs +++ b/examples-esp32c3/examples/dhcp.rs @@ -1,6 +1,8 @@ #![no_std] #![no_main] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embedded_io::blocking::*; diff --git a/examples-esp32c3/examples/embassy_access_point.rs b/examples-esp32c3/examples/embassy_access_point.rs index 48ff92a7..2c30484d 100644 --- a/examples-esp32c3/examples/embassy_access_point.rs +++ b/examples-esp32c3/examples/embassy_access_point.rs @@ -10,6 +10,8 @@ use embassy_net::ConfigV4; use embassy_net::{ Config, IpListenEndpoint, Ipv4Address, Ipv4Cidr, Stack, StackResources, StaticConfigV4, }; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embassy_executor::Executor; diff --git a/examples-esp32c3/examples/embassy_dhcp.rs b/examples-esp32c3/examples/embassy_dhcp.rs index fb90e5dd..f92079be 100644 --- a/examples-esp32c3/examples/embassy_dhcp.rs +++ b/examples-esp32c3/examples/embassy_dhcp.rs @@ -5,6 +5,8 @@ use embassy_executor::_export::StaticCell; use embassy_net::tcp::TcpSocket; use embassy_net::{Config, Ipv4Address, Stack, StackResources}; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embassy_executor::Executor; diff --git a/examples-esp32c3/examples/embassy_esp_now.rs b/examples-esp32c3/examples/embassy_esp_now.rs index 3fd3e2cc..a5bf3d75 100644 --- a/examples-esp32c3/examples/embassy_esp_now.rs +++ b/examples-esp32c3/examples/embassy_esp_now.rs @@ -4,6 +4,8 @@ use embassy_executor::_export::StaticCell; use embassy_futures::select::{select, Either}; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embassy_executor::Executor; diff --git a/examples-esp32c3/examples/esp_now.rs b/examples-esp32c3/examples/esp_now.rs index 867681c0..c62ec4bc 100644 --- a/examples-esp32c3/examples/esp_now.rs +++ b/examples-esp32c3/examples/esp_now.rs @@ -6,6 +6,8 @@ use esp_backtrace as _; use esp_println::println; use esp_wifi::esp_now::{PeerInfo, BROADCAST_ADDRESS}; use esp_wifi::{current_millis, initialize, EspWifiInitFor}; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use hal::clock::ClockControl; use hal::{peripherals::Peripherals, prelude::*}; diff --git a/examples-esp32c3/examples/static_ip.rs b/examples-esp32c3/examples/static_ip.rs index bd473c18..c79ee8c6 100644 --- a/examples-esp32c3/examples/static_ip.rs +++ b/examples-esp32c3/examples/static_ip.rs @@ -1,6 +1,8 @@ #![no_std] #![no_main] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embedded_io::blocking::*; diff --git a/examples-esp32c6/Cargo.toml b/examples-esp32c6/Cargo.toml index 3b42a3ab..7d23a074 100644 --- a/examples-esp32c6/Cargo.toml +++ b/examples-esp32c6/Cargo.toml @@ -19,7 +19,6 @@ heapless.workspace = true embassy-net = { workspace = true, optional = true } esp32c6-hal.workspace = true -examples-util = { path = "../examples-util", features = ["esp32c6"] } esp-backtrace = { workspace = true, features = ["esp32c6"] } esp-wifi = { path = "../esp-wifi", default-features = false, features = ["esp32c6", "utils"] } diff --git a/examples-esp32c6/examples/access_point.rs b/examples-esp32c6/examples/access_point.rs index b757477c..2d393402 100644 --- a/examples-esp32c6/examples/access_point.rs +++ b/examples-esp32c6/examples/access_point.rs @@ -3,6 +3,8 @@ #![feature(c_variadic)] #![feature(const_mut_refs)] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embedded_io::blocking::*; diff --git a/examples-esp32c6/examples/async_ble.rs b/examples-esp32c6/examples/async_ble.rs index 4cee6326..9d124306 100644 --- a/examples-esp32c6/examples/async_ble.rs +++ b/examples-esp32c6/examples/async_ble.rs @@ -22,6 +22,8 @@ use esp_println::println; use esp_wifi::{ ble::controller::asynch::BleConnector, initialize, EspWifiInitFor, EspWifiInitialization, }; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use examples_util::BootButton; use hal::{ @@ -142,7 +144,8 @@ fn main() -> ! { ) .unwrap(); - let button = examples_util::boot_button!(peripherals); + let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); + let button = io.pins.gpio9.into_pull_down_input(); // Async requires the GPIO interrupt to wake futures hal::interrupt::enable( diff --git a/examples-esp32c6/examples/ble.rs b/examples-esp32c6/examples/ble.rs index d897d186..8de1f09f 100644 --- a/examples-esp32c6/examples/ble.rs +++ b/examples-esp32c6/examples/ble.rs @@ -11,6 +11,8 @@ use bleps::{ use esp_backtrace as _; use esp_println::println; 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::*, systimer::SystemTimer, Rng, IO}; @@ -34,7 +36,8 @@ fn main() -> ! { ) .unwrap(); - let button = examples_util::boot_button!(peripherals); + let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); + let button = io.pins.gpio9.into_pull_down_input(); let mut debounce_cnt = 500; diff --git a/examples-esp32c6/examples/dhcp.rs b/examples-esp32c6/examples/dhcp.rs index ca61c2d3..ccf3fc2b 100644 --- a/examples-esp32c6/examples/dhcp.rs +++ b/examples-esp32c6/examples/dhcp.rs @@ -1,6 +1,8 @@ #![no_std] #![no_main] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embedded_io::blocking::*; diff --git a/examples-esp32c6/examples/embassy_access_point.rs b/examples-esp32c6/examples/embassy_access_point.rs index e69bf1ef..bc77021e 100644 --- a/examples-esp32c6/examples/embassy_access_point.rs +++ b/examples-esp32c6/examples/embassy_access_point.rs @@ -10,6 +10,8 @@ use embassy_net::ConfigV4; use embassy_net::{ Config, IpListenEndpoint, Ipv4Address, Ipv4Cidr, Stack, StackResources, StaticConfigV4, }; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embassy_executor::Executor; diff --git a/examples-esp32c6/examples/embassy_dhcp.rs b/examples-esp32c6/examples/embassy_dhcp.rs index 91c41367..41817f28 100644 --- a/examples-esp32c6/examples/embassy_dhcp.rs +++ b/examples-esp32c6/examples/embassy_dhcp.rs @@ -5,6 +5,8 @@ use embassy_executor::_export::StaticCell; use embassy_net::tcp::TcpSocket; use embassy_net::{Config, Ipv4Address, Stack, StackResources}; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embassy_executor::Executor; diff --git a/examples-esp32c6/examples/embassy_esp_now.rs b/examples-esp32c6/examples/embassy_esp_now.rs index 33a77c53..9f5600cd 100644 --- a/examples-esp32c6/examples/embassy_esp_now.rs +++ b/examples-esp32c6/examples/embassy_esp_now.rs @@ -4,6 +4,8 @@ use embassy_executor::_export::StaticCell; use embassy_futures::select::{select, Either}; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embassy_executor::Executor; diff --git a/examples-esp32c6/examples/esp_now.rs b/examples-esp32c6/examples/esp_now.rs index 6104e7b8..f1d7271b 100644 --- a/examples-esp32c6/examples/esp_now.rs +++ b/examples-esp32c6/examples/esp_now.rs @@ -6,6 +6,8 @@ use esp_backtrace as _; use esp_println::println; use esp_wifi::esp_now::{PeerInfo, BROADCAST_ADDRESS}; use esp_wifi::{current_millis, initialize, EspWifiInitFor}; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use hal::clock::ClockControl; use hal::{peripherals::Peripherals, prelude::*}; diff --git a/examples-esp32c6/examples/static_ip.rs b/examples-esp32c6/examples/static_ip.rs index f4500209..34f51d21 100644 --- a/examples-esp32c6/examples/static_ip.rs +++ b/examples-esp32c6/examples/static_ip.rs @@ -1,6 +1,8 @@ #![no_std] #![no_main] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embedded_io::blocking::*; diff --git a/examples-esp32s2/Cargo.toml b/examples-esp32s2/Cargo.toml index cc7c5fa8..f36d96d3 100644 --- a/examples-esp32s2/Cargo.toml +++ b/examples-esp32s2/Cargo.toml @@ -19,7 +19,6 @@ heapless.workspace = true embassy-net = { workspace = true, optional = true } esp32s2-hal.workspace = true -examples-util = { path = "../examples-util", features = ["esp32s2"] } esp-backtrace = { workspace = true, features = ["esp32s2"] } esp-wifi = { path = "../esp-wifi", default-features = false, features = ["esp32s2", "utils"] } diff --git a/examples-esp32s2/examples/access_point.rs b/examples-esp32s2/examples/access_point.rs index 3c9da94c..f4e32cf7 100644 --- a/examples-esp32s2/examples/access_point.rs +++ b/examples-esp32s2/examples/access_point.rs @@ -3,6 +3,8 @@ #![feature(c_variadic)] #![feature(const_mut_refs)] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embedded_io::blocking::*; diff --git a/examples-esp32s2/examples/dhcp.rs b/examples-esp32s2/examples/dhcp.rs index 32d0704a..3d57e307 100644 --- a/examples-esp32s2/examples/dhcp.rs +++ b/examples-esp32s2/examples/dhcp.rs @@ -1,6 +1,8 @@ #![no_std] #![no_main] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embedded_io::blocking::*; diff --git a/examples-esp32s2/examples/embassy_access_point.rs b/examples-esp32s2/examples/embassy_access_point.rs index 5867d8e0..8269590f 100644 --- a/examples-esp32s2/examples/embassy_access_point.rs +++ b/examples-esp32s2/examples/embassy_access_point.rs @@ -10,6 +10,8 @@ use embassy_net::ConfigV4; use embassy_net::{ Config, IpListenEndpoint, Ipv4Address, Ipv4Cidr, Stack, StackResources, StaticConfigV4, }; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embassy_executor::Executor; diff --git a/examples-esp32s2/examples/embassy_dhcp.rs b/examples-esp32s2/examples/embassy_dhcp.rs index 441fcd87..120d104c 100644 --- a/examples-esp32s2/examples/embassy_dhcp.rs +++ b/examples-esp32s2/examples/embassy_dhcp.rs @@ -5,6 +5,8 @@ use embassy_executor::_export::StaticCell; use embassy_net::tcp::TcpSocket; use embassy_net::{Config, Ipv4Address, Stack, StackResources}; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embassy_executor::Executor; diff --git a/examples-esp32s2/examples/embassy_esp_now.rs b/examples-esp32s2/examples/embassy_esp_now.rs index 55aec7aa..8b78e46c 100644 --- a/examples-esp32s2/examples/embassy_esp_now.rs +++ b/examples-esp32s2/examples/embassy_esp_now.rs @@ -4,6 +4,8 @@ use embassy_executor::_export::StaticCell; use embassy_futures::select::{select, Either}; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embassy_executor::Executor; diff --git a/examples-esp32s2/examples/esp_now.rs b/examples-esp32s2/examples/esp_now.rs index 20c397bf..765c8bea 100644 --- a/examples-esp32s2/examples/esp_now.rs +++ b/examples-esp32s2/examples/esp_now.rs @@ -6,6 +6,8 @@ use esp_backtrace as _; use esp_println::println; use esp_wifi::esp_now::{PeerInfo, BROADCAST_ADDRESS}; use esp_wifi::{current_millis, initialize, EspWifiInitFor}; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use hal::clock::ClockControl; use hal::Rng; diff --git a/examples-esp32s2/examples/static_ip.rs b/examples-esp32s2/examples/static_ip.rs index ddcbec86..55a333ec 100644 --- a/examples-esp32s2/examples/static_ip.rs +++ b/examples-esp32s2/examples/static_ip.rs @@ -1,6 +1,8 @@ #![no_std] #![no_main] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embedded_io::blocking::*; diff --git a/examples-esp32s3/Cargo.toml b/examples-esp32s3/Cargo.toml index 5ddba6a8..a3006403 100644 --- a/examples-esp32s3/Cargo.toml +++ b/examples-esp32s3/Cargo.toml @@ -19,7 +19,6 @@ heapless.workspace = true embassy-net = { workspace = true, optional = true } esp32s3-hal.workspace = true -examples-util = { path = "../examples-util", features = ["esp32s3"] } esp-backtrace = { workspace = true, features = ["esp32s3"] } esp-wifi = { path = "../esp-wifi", default-features = false, features = ["esp32s3", "utils"] } embedded-hal-async = { workspace = true, optional = true } diff --git a/examples-esp32s3/examples/access_point.rs b/examples-esp32s3/examples/access_point.rs index 92d9ed09..cdd8e67e 100644 --- a/examples-esp32s3/examples/access_point.rs +++ b/examples-esp32s3/examples/access_point.rs @@ -3,6 +3,8 @@ #![feature(c_variadic)] #![feature(const_mut_refs)] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embedded_io::blocking::*; diff --git a/examples-esp32s3/examples/async_ble.rs b/examples-esp32s3/examples/async_ble.rs index bdf7a474..807dba32 100644 --- a/examples-esp32s3/examples/async_ble.rs +++ b/examples-esp32s3/examples/async_ble.rs @@ -22,6 +22,8 @@ use esp_println::println; use esp_wifi::{ ble::controller::asynch::BleConnector, initialize, EspWifiInitFor, EspWifiInitialization, }; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use examples_util::BootButton; use hal::{ @@ -147,7 +149,8 @@ fn main() -> ! { ) .unwrap(); - let button = examples_util::boot_button!(peripherals); + let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); + let button = io.pins.gpio0.into_pull_down_input(); // Async requires the GPIO interrupt to wake futures hal::interrupt::enable( diff --git a/examples-esp32s3/examples/ble.rs b/examples-esp32s3/examples/ble.rs index 7e159da7..b5fa25ad 100644 --- a/examples-esp32s3/examples/ble.rs +++ b/examples-esp32s3/examples/ble.rs @@ -11,6 +11,8 @@ use bleps::{ use esp_backtrace as _; use esp_println::println; 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}; @@ -39,7 +41,8 @@ fn main() -> ! { ) .unwrap(); - let button = examples_util::boot_button!(peripherals); + let io = IO::new(peripherals.GPIO, peripherals.IO_MUX); + let button = io.pins.gpio0.into_pull_down_input(); let mut debounce_cnt = 500; diff --git a/examples-esp32s3/examples/coex.rs b/examples-esp32s3/examples/coex.rs index 7d8b29d6..28d2901e 100644 --- a/examples-esp32s3/examples/coex.rs +++ b/examples-esp32s3/examples/coex.rs @@ -1,6 +1,8 @@ #![no_std] #![no_main] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use bleps::{ diff --git a/examples-esp32s3/examples/dhcp.rs b/examples-esp32s3/examples/dhcp.rs index ce50cbdc..abace712 100644 --- a/examples-esp32s3/examples/dhcp.rs +++ b/examples-esp32s3/examples/dhcp.rs @@ -1,6 +1,8 @@ #![no_std] #![no_main] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embedded_io::blocking::*; diff --git a/examples-esp32s3/examples/embassy_access_point.rs b/examples-esp32s3/examples/embassy_access_point.rs index 268d4a9d..606e186a 100644 --- a/examples-esp32s3/examples/embassy_access_point.rs +++ b/examples-esp32s3/examples/embassy_access_point.rs @@ -10,6 +10,8 @@ use embassy_net::ConfigV4; use embassy_net::{ Config, IpListenEndpoint, Ipv4Address, Ipv4Cidr, Stack, StackResources, StaticConfigV4, }; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embassy_executor::Executor; diff --git a/examples-esp32s3/examples/embassy_dhcp.rs b/examples-esp32s3/examples/embassy_dhcp.rs index 3c4b76da..d1e59c75 100644 --- a/examples-esp32s3/examples/embassy_dhcp.rs +++ b/examples-esp32s3/examples/embassy_dhcp.rs @@ -5,6 +5,8 @@ use embassy_executor::_export::StaticCell; use embassy_net::tcp::TcpSocket; use embassy_net::{Config, Ipv4Address, Stack, StackResources}; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embassy_executor::Executor; diff --git a/examples-esp32s3/examples/embassy_esp_now.rs b/examples-esp32s3/examples/embassy_esp_now.rs index c436a88d..dc24ca2d 100644 --- a/examples-esp32s3/examples/embassy_esp_now.rs +++ b/examples-esp32s3/examples/embassy_esp_now.rs @@ -4,6 +4,8 @@ use embassy_executor::_export::StaticCell; use embassy_futures::select::{select, Either}; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embassy_executor::Executor; diff --git a/examples-esp32s3/examples/esp_now.rs b/examples-esp32s3/examples/esp_now.rs index 101f64c0..38c2ed2c 100644 --- a/examples-esp32s3/examples/esp_now.rs +++ b/examples-esp32s3/examples/esp_now.rs @@ -6,6 +6,8 @@ use esp_backtrace as _; use esp_println::println; use esp_wifi::esp_now::{PeerInfo, BROADCAST_ADDRESS}; use esp_wifi::{current_millis, initialize, EspWifiInitFor}; +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use hal::clock::ClockControl; use hal::Rng; diff --git a/examples-esp32s3/examples/static_ip.rs b/examples-esp32s3/examples/static_ip.rs index d1c7df3d..500f75e3 100644 --- a/examples-esp32s3/examples/static_ip.rs +++ b/examples-esp32s3/examples/static_ip.rs @@ -1,6 +1,8 @@ #![no_std] #![no_main] +#[path = "../../examples-util/util.rs"] +mod examples_util; use examples_util::hal; use embedded_io::blocking::*; diff --git a/examples-util/Cargo.toml b/examples-util/Cargo.toml deleted file mode 100644 index 5e877e22..00000000 --- a/examples-util/Cargo.toml +++ /dev/null @@ -1,20 +0,0 @@ -[package] -name = "examples-util" -version = "0.1.0" -edition = "2021" - -[dependencies] -esp32c3-hal = { workspace = true, optional = true } -esp32c2-hal = { workspace = true, optional = true } -esp32c6-hal = { workspace = true, optional = true } -esp32-hal = { workspace = true, optional = true } -esp32s3-hal = { workspace = true, optional = true } -esp32s2-hal = { workspace = true, optional = true } - -[features] -esp32c3 = [ "esp32c3-hal" ] -esp32c2 = [ "esp32c2-hal" ] -esp32c6 = [ "esp32c6-hal" ] -esp32 = [ "esp32-hal" ] -esp32s3 = [ "esp32s3-hal" ] -esp32s2 = [ "esp32s2-hal" ] diff --git a/examples-util/src/lib.rs b/examples-util/util.rs similarity index 67% rename from examples-util/src/lib.rs rename to examples-util/util.rs index 9fa8af90..692042c9 100644 --- a/examples-util/src/lib.rs +++ b/examples-util/util.rs @@ -1,4 +1,4 @@ -#![no_std] +#![allow(unused)] #[cfg(feature = "esp32")] pub use esp32_hal as hal; @@ -13,18 +13,6 @@ pub use esp32s2_hal as hal; #[cfg(feature = "esp32s3")] pub use esp32s3_hal as hal; -#[macro_export] -macro_rules! boot_button { - ($peripherals: ident) => {{ - let io = IO::new($peripherals.GPIO, $peripherals.IO_MUX); - #[cfg(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3"))] - let button = io.pins.gpio0.into_pull_down_input(); - #[cfg(any(feature = "esp32c2", feature = "esp32c3"))] - let button = io.pins.gpio9.into_pull_down_input(); - button - }}; -} - #[cfg(any(feature = "esp32c2", feature = "esp32c3"))] pub type BootButton = crate::hal::gpio::Gpio9>; #[cfg(any(feature = "esp32", feature = "esp32s2", feature = "esp32s3"))]