Skip to content

Commit fd67b79

Browse files
committed
Use just xTaskCreate on ESP8266.
1 parent a093902 commit fd67b79

File tree

3 files changed

+29
-3
lines changed

3 files changed

+29
-3
lines changed

src/libstd/build.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,9 @@ fn main() {
6262
}
6363
println!("cargo:rustc-link-lib=c");
6464
println!("cargo:rustc-link-lib=compiler_rt");
65+
} else if target.contains("esp32") {
66+
println!(r#"cargo:rustc-cfg=target_device="esp32""#);
67+
} else if target.contains("esp8266") {
68+
println!(r#"cargo:rustc-cfg=target_device="esp8266""#);
6569
}
6670
}

src/libstd/sys/unix/freertos/ffi.rs

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub const pdFALSE: BaseType_t = 0;
1414
pub const pdTRUE: BaseType_t = 1;
1515
pub const semGIVE_BLOCK_TIME: TickType_t = 0;
1616
pub const queueSEND_TO_BACK: BaseType_t = 0;
17-
pub const tskNO_AFFINITY: BaseType_t = BaseType_t::max_value();
17+
const tskNO_AFFINITY: BaseType_t = BaseType_t::max_value();
1818
pub const errCOULD_NOT_ALLOCATE_REQUIRED_MEMORY: BaseType_t = -1;
1919

2020
extern "C" {
@@ -44,6 +44,16 @@ extern "C" {
4444
#[link_name = "xQueueCreateCountingSemaphore"]
4545
pub fn xSemaphoreCreateCounting(max: UBaseType_t, initial: UBaseType_t) -> SemaphoreHandle_t;
4646
pub fn xPortGetTickRateHz() -> u32;
47+
#[cfg(target_device = "esp8266")]
48+
pub fn xTaskCreate(
49+
pxTaskCode: TaskFunction_t,
50+
pcName: *const libc::c_char,
51+
usStackDepth: u32,
52+
pvParameters: *const libc::c_void,
53+
uxPriority: UBaseType_t,
54+
pxCreatedTask: *mut TaskHandle_t,
55+
) -> BaseType_t;
56+
#[cfg(target_device = "esp32")]
4757
pub fn xTaskCreatePinnedToCore(
4858
pxTaskCode: TaskFunction_t,
4959
pcName: *const libc::c_char,
@@ -55,6 +65,19 @@ extern "C" {
5565
) -> BaseType_t;
5666
}
5767

68+
#[cfg(target_device = "esp32")]
69+
#[inline]
70+
pub unsafe fn xTaskCreate(
71+
pxTaskCode: TaskFunction_t,
72+
pcName: *const libc::c_char,
73+
usStackDepth: u32,
74+
pvParameters: *const libc::c_void,
75+
uxPriority: UBaseType_t,
76+
pxCreatedTask: *mut TaskHandle_t,
77+
) -> BaseType_t {
78+
xTaskCreatePinnedToCore(pxTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask, tskNO_AFFINITY)
79+
}
80+
5881
#[inline]
5982
pub unsafe fn xSemaphoreCreateRecursiveMutex() -> SemaphoreHandle_t {
6083
xQueueCreateMutex(queueQUEUE_TYPE_RECURSIVE_MUTEX)

src/libstd/sys/unix/freertos/thread.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,13 @@ impl Thread {
3939

4040
let mut thread = Thread { name, id: ptr::null_mut(), join_mutex, state };
4141

42-
let res = xTaskCreatePinnedToCore(
42+
let res = xTaskCreate(
4343
thread_start,
4444
thread.name.as_ptr(),
4545
stack as u32,
4646
Box::into_raw(arg) as *mut libc::c_void,
4747
5,
4848
&mut thread.id,
49-
tskNO_AFFINITY,
5049
);
5150

5251
if res != pdTRUE {

0 commit comments

Comments
 (0)