Thread, Timer and flash.sh improvements (#165)

- Various improvements to Thread and Timer:
  - Remove "mark as static" option as it is unused
  - Implemented core pinning for ESP32 platforms
  - Use `TickType_t` consistently (instead of `uint32_t`)
  - Use `enum class` instead of `enum`
- Fix for `flash.sh` not working when using `pip` to install `esptool`
This commit is contained in:
Ken Van Hoeylandt
2025-01-13 20:20:43 +01:00
committed by GitHub
parent 5d189fe5a3
commit 43c78c69d8
20 changed files with 151 additions and 198 deletions
-2
View File
@@ -74,8 +74,6 @@ const struct esp_elfsym elf_symbols[] {
ESP_ELFSYM_EXPORT(tt_thread_alloc_ext),
ESP_ELFSYM_EXPORT(tt_thread_free),
ESP_ELFSYM_EXPORT(tt_thread_set_name),
ESP_ELFSYM_EXPORT(tt_thread_mark_as_static),
ESP_ELFSYM_EXPORT(tt_thread_is_marked_as_static),
ESP_ELFSYM_EXPORT(tt_thread_set_stack_size),
ESP_ELFSYM_EXPORT(tt_thread_set_callback),
ESP_ELFSYM_EXPORT(tt_thread_set_priority),
-8
View File
@@ -31,14 +31,6 @@ void tt_thread_set_name(ThreadHandle handle, const char* name) {
HANDLE_AS_THREAD(handle)->setName(name);
}
void tt_thread_mark_as_static(ThreadHandle handle) {
HANDLE_AS_THREAD(handle)->markAsStatic();
}
bool tt_thread_is_marked_as_static(ThreadHandle handle) {
return HANDLE_AS_THREAD(handle)->isMarkedAsStatic();
}
void tt_thread_set_stack_size(ThreadHandle handle, size_t size) {
HANDLE_AS_THREAD(handle)->setStackSize(size);
}
+8 -10
View File
@@ -38,14 +38,14 @@ typedef int32_t (*ThreadCallback)(void* context);
typedef void (*ThreadStateCallback)(ThreadState state, void* context);
typedef enum {
ThreadPriorityNone = 0, /**< Uninitialized, choose system default */
ThreadPriorityIdle = 1,
ThreadPriorityLowest = 2,
ThreadPriorityLow = 3,
ThreadPriorityNormal = 4,
ThreadPriorityHigh = 5,
ThreadPriorityHigher = 6,
ThreadPriorityHighest = 7
ThreadPriorityNone = 0U, /**< Uninitialized, choose system default */
ThreadPriorityIdle = 1U,
ThreadPriorityLowest = 2U,
ThreadPriorityLow = 3U,
ThreadPriorityNormal = 4U,
ThreadPriorityHigh = 5U,
ThreadPriorityHigher = 6U,
ThreadPriorityHighest = 7U
} ThreadPriority;
ThreadHandle tt_thread_alloc();
@@ -57,8 +57,6 @@ ThreadHandle tt_thread_alloc_ext(
);
void tt_thread_free(ThreadHandle handle);
void tt_thread_set_name(ThreadHandle handle, const char* name);
void tt_thread_mark_as_static(ThreadHandle handle);
bool tt_thread_is_marked_as_static(ThreadHandle handle);
void tt_thread_set_stack_size(ThreadHandle handle, size_t size);
void tt_thread_set_callback(ThreadHandle handle, ThreadCallback callback, void* _Nullable callbackContext);
void tt_thread_set_priority(ThreadHandle handle, ThreadPriority priority);
+2 -2
View File
@@ -58,8 +58,8 @@ bool tt_timer_set_pending_callback(TimerHandle handle, TimerPendingCallback call
);
}
void tt_timer_set_thread_priority(TimerHandle handle, TimerThreadPriority priority) {
((TimerWrapper*)handle)->timer->setThreadPriority((tt::Timer::ThreadPriority)priority);
void tt_timer_set_thread_priority(TimerHandle handle, ThreadPriority priority) {
((TimerWrapper*)handle)->timer->setThreadPriority((tt::Thread::Priority)priority);
}
}
+2 -6
View File
@@ -1,5 +1,6 @@
#pragma once
#include "tt_thread.h"
#include <freertos/FreeRTOS.h>
#ifdef __cplusplus
@@ -16,11 +17,6 @@ typedef enum {
TimerTypePeriodic = 1 ///< Repeating timer.
} TimerType;
typedef enum {
TimerThreadPriorityNormal, /**< Lower then other threads */
TimerThreadPriorityElevated, /**< Same as other threads */
} TimerThreadPriority;
typedef void (*TimerCallback)(void* context);
typedef void (*TimerPendingCallback)(void* context, uint32_t arg);
@@ -32,7 +28,7 @@ bool tt_timer_stop(TimerHandle handle);
bool tt_timer_is_running(TimerHandle handle);
uint32_t tt_timer_get_expire_time(TimerHandle handle);
bool tt_timer_set_pending_callback(TimerHandle handle, TimerPendingCallback callback, void* callbackContext, uint32_t callbackArg, TickType_t timeoutTicks);
void tt_timer_set_thread_priority(TimerHandle handle, TimerThreadPriority priority);
void tt_timer_set_thread_priority(TimerHandle handle, ThreadPriority priority);
#ifdef __cplusplus
}