mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
- 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`
72 lines
2.0 KiB
C
72 lines
2.0 KiB
C
#pragma once
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#ifdef ESP_PLATFORM
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#else
|
|
#include "FreeRTOS.h"
|
|
#include "task.h"
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
|
|
typedef void* ThreadHandle;
|
|
|
|
typedef enum {
|
|
ThreadStateStopped,
|
|
ThreadStateStarting,
|
|
ThreadStateRunning,
|
|
} ThreadState;
|
|
|
|
typedef TaskHandle_t ThreadId;
|
|
|
|
/** ThreadCallback Your callback to run in new thread
|
|
* @warning never use osThreadExit in Thread
|
|
*/
|
|
typedef int32_t (*ThreadCallback)(void* context);
|
|
|
|
/** Thread state change callback called upon thread state change
|
|
* @param state new thread state
|
|
* @param context callback context
|
|
*/
|
|
typedef void (*ThreadStateCallback)(ThreadState state, void* context);
|
|
|
|
typedef enum {
|
|
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();
|
|
ThreadHandle tt_thread_alloc_ext(
|
|
const char* name,
|
|
uint32_t stackSize,
|
|
ThreadCallback callback,
|
|
void* _Nullable callbackContext
|
|
);
|
|
void tt_thread_free(ThreadHandle handle);
|
|
void tt_thread_set_name(ThreadHandle handle, const char* name);
|
|
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);
|
|
void tt_thread_set_state_callback(ThreadHandle handle, ThreadStateCallback callback, void* _Nullable callbackContext);
|
|
ThreadState tt_thread_get_state(ThreadHandle handle);
|
|
void tt_thread_start(ThreadHandle handle);
|
|
bool tt_thread_join(ThreadHandle handle);
|
|
ThreadId tt_thread_get_id(ThreadHandle handle);
|
|
int32_t tt_thread_get_return_code(ThreadHandle handle);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif |