Skip to content

Commit

Permalink
Use types from core::ffi:: (esp-rs#159)
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoernQ committed May 23, 2024
1 parent cb35f12 commit 38bce5d
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 12 deletions.
10 changes: 9 additions & 1 deletion esp-wifi/src/ble/btdm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,15 @@ unsafe extern "C" fn task_create(

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

queue_work(func, name, stack_depth, param, prio, handle, core_id);
queue_work(
func,
name as *const i8,
stack_depth,
param,
prio,
handle,
core_id,
);
1
}

Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/src/ble/npl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ unsafe extern "C" fn task_create(
task_handle: *const crate::binary::c_types::c_void,
core_id: u32,
) -> i32 {
let name_str = StrBuf::from(name);
let name_str = StrBuf::from(name as *const u8);
log::trace!(
"task_create {:p} {} {} {:p} {} {:p} {}",
task_func,
Expand Down
5 changes: 4 additions & 1 deletion esp-wifi/src/common_adapter/common_adapter_esp32c2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ pub(crate) unsafe fn phy_enable() {
[0u8; core::mem::size_of::<esp_phy_calibration_data_t>()];

let phy_version = get_phy_version_str();
trace!("phy_version {}", StrBuf::from(phy_version).as_str_ref());
trace!(
"phy_version {}",
StrBuf::from(phy_version as *const u8).as_str_ref()
);

let init_data = &PHY_INIT_DATA_DEFAULT;

Expand Down
5 changes: 4 additions & 1 deletion esp-wifi/src/common_adapter/common_adapter_esp32c3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ pub(crate) unsafe fn phy_enable() {
[0u8; core::mem::size_of::<esp_phy_calibration_data_t>()];

let phy_version = get_phy_version_str();
trace!("phy_version {}", StrBuf::from(phy_version).as_str_ref());
trace!(
"phy_version {}",
StrBuf::from(phy_version as *const u8).as_str_ref()
);

let init_data = &PHY_INIT_DATA_DEFAULT;

Expand Down
5 changes: 4 additions & 1 deletion esp-wifi/src/common_adapter/common_adapter_esp32c6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ pub(crate) unsafe fn phy_enable() {
[0u8; core::mem::size_of::<esp_phy_calibration_data_t>()];

let phy_version = get_phy_version_str();
trace!("phy_version {}", StrBuf::from(phy_version).as_str_ref());
trace!(
"phy_version {}",
StrBuf::from(phy_version as *const u8).as_str_ref()
);

let init_data = &PHY_INIT_DATA_DEFAULT;

Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/src/common_adapter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ pub unsafe extern "C" fn pp_printf(s: *const u8, args: ...) {
}

// #define ESP_EVENT_DEFINE_BASE(id) esp_event_base_t id = #id
static mut EVT: u8 = 0;
static mut EVT: i8 = 0;
#[no_mangle]
static mut WIFI_EVENT: esp_event_base_t = unsafe { &EVT };

Expand Down
2 changes: 1 addition & 1 deletion esp-wifi/src/wifi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ pub fn wifi_start() -> Result<(), WifiError> {

let cntry_code = [b'C', b'N', 0];
let country = wifi_country_t {
cc: cntry_code,
cc: core::mem::transmute(cntry_code),
schan: 1,
nchan: 13,
max_tx_power: 20,
Expand Down
10 changes: 5 additions & 5 deletions esp-wifi/src/wifi/os_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ pub unsafe extern "C" fn task_create_pinned_to_core(
) -> i32 {
trace!("task_create_pinned_to_core task_func {:p} name {} stack_depth {} param {:p} prio {}, task_handle {:p} core_id {}",
task_func,
StrBuf::from(name).as_str_ref(),
StrBuf::from(name as *const u8).as_str_ref(),
stack_depth,
param,
prio,
Expand Down Expand Up @@ -1090,7 +1090,7 @@ pub unsafe extern "C" fn phy_update_country_info(
country: *const crate::binary::c_types::c_char,
) -> crate::binary::c_types::c_int {
// not implemented in original code
trace!("phy_update_country_info {}", *country as char);
trace!("phy_update_country_info {}", *country as u8 as char);
-1
}

Expand Down Expand Up @@ -1516,7 +1516,7 @@ pub unsafe extern "C" fn log_write(
return;

#[cfg(target_arch = "riscv32")]
syslog(_level, _format, _args);
syslog(_level, _format as *const u8, _args);
}

/****************************************************************************
Expand Down Expand Up @@ -1548,15 +1548,15 @@ pub unsafe extern "C" fn log_writev(
#[cfg(target_arch = "xtensa")]
#[allow(unreachable_code)]
{
let s = StrBuf::from(_format);
let s = StrBuf::from(_format as *const u8);
log::info!("{}", s.as_str_ref());
}

#[cfg(target_arch = "riscv32")]
#[allow(unreachable_code)]
{
let _args = core::mem::transmute(_args);
syslog(_level, _format, _args);
syslog(_level, _format as *const u8, _args);
}
}

Expand Down

0 comments on commit 38bce5d

Please sign in to comment.