Skip to content

Commit 1a84e07

Browse files
committed
Use types from core::ffi:: (esp-rs#159)
1 parent c4fbe97 commit 1a84e07

File tree

8 files changed

+29
-12
lines changed

8 files changed

+29
-12
lines changed

esp-wifi/src/ble/btdm.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,15 @@ unsafe extern "C" fn task_create(
296296

297297
*(handle as *mut usize) = 0; // we will run it in task 0
298298

299-
queue_work(func, name, stack_depth, param, prio, handle, core_id);
299+
queue_work(
300+
func,
301+
name as *const i8,
302+
stack_depth,
303+
param,
304+
prio,
305+
handle,
306+
core_id,
307+
);
300308
1
301309
}
302310

esp-wifi/src/ble/npl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ unsafe extern "C" fn task_create(
361361
task_handle: *const crate::binary::c_types::c_void,
362362
core_id: u32,
363363
) -> i32 {
364-
let name_str = StrBuf::from(name);
364+
let name_str = StrBuf::from(name as *const u8);
365365
log::trace!(
366366
"task_create {:p} {} {} {:p} {} {:p} {}",
367367
task_func,

esp-wifi/src/common_adapter/common_adapter_esp32c2.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ pub(crate) unsafe fn phy_enable() {
3232
[0u8; core::mem::size_of::<esp_phy_calibration_data_t>()];
3333

3434
let phy_version = get_phy_version_str();
35-
trace!("phy_version {}", StrBuf::from(phy_version).as_str_ref());
35+
trace!(
36+
"phy_version {}",
37+
StrBuf::from(phy_version as *const u8).as_str_ref()
38+
);
3639

3740
let init_data = &PHY_INIT_DATA_DEFAULT;
3841

esp-wifi/src/common_adapter/common_adapter_esp32c3.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ pub(crate) unsafe fn phy_enable() {
3232
[0u8; core::mem::size_of::<esp_phy_calibration_data_t>()];
3333

3434
let phy_version = get_phy_version_str();
35-
trace!("phy_version {}", StrBuf::from(phy_version).as_str_ref());
35+
trace!(
36+
"phy_version {}",
37+
StrBuf::from(phy_version as *const u8).as_str_ref()
38+
);
3639

3740
let init_data = &PHY_INIT_DATA_DEFAULT;
3841

esp-wifi/src/common_adapter/common_adapter_esp32c6.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,10 @@ pub(crate) unsafe fn phy_enable() {
3232
[0u8; core::mem::size_of::<esp_phy_calibration_data_t>()];
3333

3434
let phy_version = get_phy_version_str();
35-
trace!("phy_version {}", StrBuf::from(phy_version).as_str_ref());
35+
trace!(
36+
"phy_version {}",
37+
StrBuf::from(phy_version as *const u8).as_str_ref()
38+
);
3639

3740
let init_data = &PHY_INIT_DATA_DEFAULT;
3841

esp-wifi/src/common_adapter/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ pub unsafe extern "C" fn pp_printf(s: *const u8, args: ...) {
382382
}
383383

384384
// #define ESP_EVENT_DEFINE_BASE(id) esp_event_base_t id = #id
385-
static mut EVT: u8 = 0;
385+
static mut EVT: i8 = 0;
386386
#[no_mangle]
387387
static mut WIFI_EVENT: esp_event_base_t = unsafe { &EVT };
388388

esp-wifi/src/wifi/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ pub fn wifi_start() -> Result<(), WifiError> {
644644

645645
let cntry_code = [b'C', b'N', 0];
646646
let country = wifi_country_t {
647-
cc: cntry_code,
647+
cc: core::mem::transmute(cntry_code),
648648
schan: 1,
649649
nchan: 13,
650650
max_tx_power: 20,

esp-wifi/src/wifi/os_adapter.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ pub unsafe extern "C" fn task_create_pinned_to_core(
698698
) -> i32 {
699699
trace!("task_create_pinned_to_core task_func {:p} name {} stack_depth {} param {:p} prio {}, task_handle {:p} core_id {}",
700700
task_func,
701-
StrBuf::from(name).as_str_ref(),
701+
StrBuf::from(name as *const u8).as_str_ref(),
702702
stack_depth,
703703
param,
704704
prio,
@@ -1090,7 +1090,7 @@ pub unsafe extern "C" fn phy_update_country_info(
10901090
country: *const crate::binary::c_types::c_char,
10911091
) -> crate::binary::c_types::c_int {
10921092
// not implemented in original code
1093-
trace!("phy_update_country_info {}", *country as char);
1093+
trace!("phy_update_country_info {}", *country as u8 as char);
10941094
-1
10951095
}
10961096

@@ -1516,7 +1516,7 @@ pub unsafe extern "C" fn log_write(
15161516
return;
15171517

15181518
#[cfg(target_arch = "riscv32")]
1519-
syslog(_level, _format, _args);
1519+
syslog(_level, _format as *const u8, _args);
15201520
}
15211521

15221522
/****************************************************************************
@@ -1548,15 +1548,15 @@ pub unsafe extern "C" fn log_writev(
15481548
#[cfg(target_arch = "xtensa")]
15491549
#[allow(unreachable_code)]
15501550
{
1551-
let s = StrBuf::from(_format);
1551+
let s = StrBuf::from(_format as *const u8);
15521552
log::info!("{}", s.as_str_ref());
15531553
}
15541554

15551555
#[cfg(target_arch = "riscv32")]
15561556
#[allow(unreachable_code)]
15571557
{
15581558
let _args = core::mem::transmute(_args);
1559-
syslog(_level, _format, _args);
1559+
syslog(_level, _format as *const u8, _args);
15601560
}
15611561
}
15621562

0 commit comments

Comments
 (0)