Skip to content

Commit 4cd719d

Browse files
committed
Esp32c2 coex (esp-rs#347)
* Support COEX on ESP32-C2 * Fix script * Remove WiFi scan from COEX example
1 parent 3a70d43 commit 4cd719d

File tree

4 files changed

+12
-17
lines changed

4 files changed

+12
-17
lines changed

esp-wifi/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn main() -> Result<(), String> {
1717
"#
1818
);
1919
}
20-
#[cfg(all(feature = "coex", any(feature = "esp32s2", feature = "esp32c2")))]
20+
#[cfg(all(feature = "coex", any(feature = "esp32s2")))]
2121
{
2222
panic!(
2323
r#"

esp-wifi/examples/coex.rs

+6-15
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ use esp_wifi::{
2020

2121
use embedded_io::*;
2222
use embedded_svc::ipv4::Interface;
23-
use embedded_svc::wifi::{AccessPointInfo, ClientConfiguration, Configuration, Wifi};
23+
use embedded_svc::wifi::{ClientConfiguration, Configuration, Wifi};
2424

2525
use esp_backtrace as _;
2626
use esp_println::{print, println};
2727
use esp_wifi::initialize;
28-
use esp_wifi::wifi::{utils::create_network_interface, WifiError};
28+
use esp_wifi::wifi::utils::create_network_interface;
2929
use hal::{clock::ClockControl, Rng};
3030
use hal::{peripherals::Peripherals, prelude::*};
3131
use smoltcp::{iface::SocketStorage, wire::IpAddress, wire::Ipv4Address};
@@ -59,7 +59,7 @@ fn main() -> ! {
5959
let wifi = peripherals.WIFI;
6060
let bluetooth = peripherals.BT;
6161

62-
let mut socket_set_entries: [SocketStorage; 3] = Default::default();
62+
let mut socket_set_entries: [SocketStorage; 2] = Default::default();
6363
let (iface, device, mut controller, sockets) =
6464
create_network_interface(&init, wifi, WifiStaDevice, &mut socket_set_entries).unwrap();
6565
let wifi_stack = WifiStack::new(iface, device, sockets, current_millis);
@@ -74,15 +74,6 @@ fn main() -> ! {
7474

7575
controller.start().unwrap();
7676
println!("is wifi started: {:?}", controller.is_started());
77-
78-
println!("Start Wifi Scan");
79-
let res: Result<(heapless::Vec<AccessPointInfo, 10>, usize), WifiError> = controller.scan_n();
80-
if let Ok((res, _count)) = res {
81-
for ap in res {
82-
println!("{:?}", ap);
83-
}
84-
}
85-
8677
println!("{:?}", controller.get_capabilities());
8778
println!("wifi_connect {:?}", controller.connect());
8879

@@ -138,8 +129,8 @@ fn main() -> ! {
138129

139130
println!("Start busy loop on main");
140131

141-
let mut rx_buffer = [0u8; 1536];
142-
let mut tx_buffer = [0u8; 1536];
132+
let mut rx_buffer = [0u8; 128];
133+
let mut tx_buffer = [0u8; 128];
143134
let mut socket = wifi_stack.get_socket(&mut rx_buffer, &mut tx_buffer);
144135

145136
loop {
@@ -157,7 +148,7 @@ fn main() -> ! {
157148

158149
let wait_end = current_millis() + 20 * 1000;
159150
loop {
160-
let mut buffer = [0u8; 512];
151+
let mut buffer = [0u8; 128];
161152
if let Ok(len) = socket.read(&mut buffer) {
162153
let to_print = unsafe { core::str::from_utf8_unchecked(&buffer[..len]) };
163154
print!("{}", to_print);

esp-wifi/src/ble/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ pub(crate) unsafe extern "C" fn malloc(size: u32) -> *mut crate::binary::c_types
2525
crate::compat::malloc::malloc(size as usize).cast()
2626
}
2727

28+
#[cfg(any(esp32, esp32c3, esp32s3))]
2829
pub(crate) unsafe extern "C" fn malloc_internal(size: u32) -> *mut crate::binary::c_types::c_void {
2930
crate::compat::malloc::malloc(size as usize).cast()
3031
}

esp-wifi/src/wifi/mod.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ pub enum InternalWifiError {
310310
EspErrWifiTxDisallow = 0x3016,
311311
}
312312

313-
#[cfg(all(coex, any(esp32, esp32c3, esp32c6, esp32s3)))]
313+
#[cfg(all(coex, any(esp32, esp32c2, esp32c3, esp32c6, esp32s3)))]
314314
static mut G_COEX_ADAPTER_FUNCS: coex_adapter_funcs_t = coex_adapter_funcs_t {
315315
_version: include::COEX_ADAPTER_VERSION as i32,
316316
_task_yield_from_isr: Some(task_yield_from_isr),
@@ -339,6 +339,9 @@ static mut G_COEX_ADAPTER_FUNCS: coex_adapter_funcs_t = coex_adapter_funcs_t {
339339
_int_disable: Some(wifi_int_disable),
340340
#[cfg(esp32)]
341341
_int_enable: Some(wifi_int_restore),
342+
343+
#[cfg(esp32c2)]
344+
_slowclk_cal_get: Some(slowclk_cal_get),
342345
};
343346

344347
#[cfg(coex)]

0 commit comments

Comments
 (0)