Skip to content

Commit 292f60f

Browse files
committed
Reliably avoid r_ble_hci_ram_hs_cmd_tx assert (esp-rs#362)
1 parent e414e10 commit 292f60f

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

esp-wifi/src/ble/npl.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ extern "C" {
267267

268268
pub(crate) fn r_ble_hci_trans_buf_free(buf: *const u8);
269269

270-
pub(crate) fn ets_delay_us(us: u32);
270+
static mut ble_hci_trans_env_p: u32;
271271
}
272272

273273
#[repr(C)]
@@ -1098,9 +1098,17 @@ pub(crate) fn ble_init() {
10981098
self::ble_os_adapter_chip_specific::ble_ll_random_override as *const u32 as u32;
10991099
}
11001100

1101-
// this is a workaround for an unclear problem
1102-
// (ASSERT r_ble_hci_ram_hs_cmd_tx:34 0 0)
1103-
ets_delay_us(10_000);
1101+
// this is to avoid (ASSERT r_ble_hci_ram_hs_cmd_tx:34 0 0)
1102+
// r_ble_hci_trans_cfg_ll initializes ble_hci_trans_env_p + 0x34
1103+
// it's called by r_ble_ll_task which is run in another task
1104+
// in r_ble_hci_ram_hs_cmd_tx this is checked for non-null
1105+
while (ble_hci_trans_env_p as *const u32)
1106+
.add(0x34 / 4)
1107+
.read_volatile()
1108+
== 0
1109+
{
1110+
// wait
1111+
}
11041112

11051113
debug!("The ble_controller_init was initialized");
11061114
}

0 commit comments

Comments
 (0)