Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use types from core::ffi:: #159

Merged
merged 1 commit into from
Apr 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions esp-wifi-sys/src/c_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
dead_code
)]

pub type c_uint = u32;
pub type c_int = i32;
pub type c_ulonglong = u32;
pub type c_longlong = i32;
pub type c_uchar = u8;
pub type c_uint = core::ffi::c_uint;
pub type c_int = core::ffi::c_int;
pub type c_ulonglong = core::ffi::c_ulonglong;
pub type c_longlong = core::ffi::c_longlong;
pub type c_uchar = core::ffi::c_uchar;

pub type c_short = i16;
pub type c_ushort = u16;
pub type c_schar = i8;
pub type c_char = u8;
pub type c_long = i32;
pub type c_ulong = u32;
pub type c_short = core::ffi::c_short;
pub type c_ushort = core::ffi::c_ushort;
pub type c_schar = core::ffi::c_schar;
pub type c_char = core::ffi::c_char;
pub type c_long = core::ffi::c_long;
pub type c_ulong = core::ffi::c_ulong;

pub enum c_void {}
pub type c_void = core::ffi::c_void;
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