Create TactilityFreertos subproject (#440)

This commit is contained in:
Ken Van Hoeylandt
2026-01-03 00:19:40 +01:00
committed by GitHub
parent a4dc633063
commit 7283920def
154 changed files with 1926 additions and 2676 deletions
+1 -2
View File
@@ -103,9 +103,8 @@ bool tt_hal_i2c_lock(i2c_port_t port, TickType_t timeout);
/**
* Used to unlock an I2C port.
* This is useful for creating thread-safe I2C calls while calling ESP-IDF directly of third party I2C APIs.
* @param[in] port the I2C port to unlock
*/
bool tt_hal_i2c_unlock(i2c_port_t port);
void tt_hal_i2c_unlock(i2c_port_t port);
#ifdef __cplusplus
}
-39
View File
@@ -1,8 +1,6 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
@@ -11,43 +9,6 @@ typedef unsigned long TickType;
#define TT_MAX_TICKS ((TickType)(~(TickType)0))
/**
* Stall the current task for the specified amount of time.
* @param milliseconds the time in milliseconds to stall.
*/
void tt_kernel_delay_millis(uint32_t milliseconds);
/**
* Stall the current task for the specified amount of time.
* @param milliseconds the time in microsends to stall.
*/
void tt_kernel_delay_micros(uint32_t microSeconds);
/**
* Stall the current task for the specified amount of time.
* @param milliseconds the time in ticks to stall.
*/
void tt_kernel_delay_ticks(TickType ticks);
/** @return the number of ticks since the device was started */
TickType tt_kernel_get_ticks();
/** Convert milliseconds to ticks */
TickType tt_kernel_millis_to_ticks(uint32_t milliSeconds);
/** Stall the current task until the specified timestamp
* @return false if for some reason the delay was broken off
*/
bool tt_kernel_delay_until_tick(TickType tick);
/** @return the tick frequency of the kernel (commonly 1000 Hz when running FreeRTOS) */
uint32_t tt_kernel_get_tick_frequency();
/** @return the number of milliseconds that have passed since the device was started */
uint32_t tt_kernel_get_millis();
unsigned long tt_kernel_get_micros();
#ifdef __cplusplus
}
#endif
+1 -2
View File
@@ -41,9 +41,8 @@ bool tt_lock_acquire(LockHandle handle, TickType timeout);
/**
* Attempt to unlock the lock.
* @param[in] handle the handle that represents the mutex instance
* @return true when the lock was unlocked
*/
bool tt_lock_release(LockHandle handle);
void tt_lock_release(LockHandle handle);
/** Free the memory for this lock
* This does not auto-release the lock.
+1 -11
View File
@@ -41,23 +41,13 @@ bool tt_message_queue_put(MessageQueueHandle handle, const void* message, TickTy
*/
bool tt_message_queue_get(MessageQueueHandle handle, void* message, TickType_t timeout);
/** @return the total amount of messages that this queue can hold */
uint32_t tt_message_queue_get_capacity(MessageQueueHandle handle);
/** @return the size of a single message in the queue */
uint32_t tt_message_queue_get_message_size(MessageQueueHandle handle);
/** @return the current amount of items in the queue */
uint32_t tt_message_queue_get_count(MessageQueueHandle handle);
/** @return the remaining capacity in the queue */
uint32_t tt_message_queue_get_space(MessageQueueHandle handle);
/**
* Remove all items from the queue (if any)
* @return true on failure
*/
bool tt_message_queue_reset(MessageQueueHandle handle);
void tt_message_queue_reset(MessageQueueHandle handle);
#ifdef __cplusplus
}
+5 -5
View File
@@ -27,7 +27,7 @@ typedef enum {
} ThreadState;
/** The identifier that represents the thread */
typedef TaskHandle_t ThreadId;
typedef TaskHandle_t TaskHandle;
/** ThreadCallback Your callback to run in new thread
* @warning never use osThreadExit in Thread
@@ -132,16 +132,16 @@ void tt_thread_start(ThreadHandle handle);
/**
* Wait (block) for the thread to finish.
* @param[in] handle the thread instance handle
* @warning make sure you manually interrupt any logic in your thread (e.g. by an EventFlag or boolean+Mutex)
* @warning make sure you manually interrupt any logic in your thread (e.g. by an EventGroup or boolean+Mutex)
*/
bool tt_thread_join(ThreadHandle handle, TickType_t timeout);
/**
* Get thread id
* Get thread task handle
* @param[in] handle the thread instance handle
* @return the ThreadId of a thread
* @return the task handle of a thread
* */
ThreadId tt_thread_get_id(ThreadHandle handle);
TaskHandle tt_thread_get_task_handle(ThreadHandle handle);
/**
* Get the return code of a thread
+16 -10
View File
@@ -1,7 +1,7 @@
#pragma once
#include "tt_kernel.h"
#include "tt_thread.h"
#include <freertos/FreeRTOS.h>
#include <stdint.h>
#include <stdbool.h>
@@ -15,8 +15,8 @@ typedef void* TimerHandle;
/** The behaviour of the timer */
typedef enum {
TimerTypeOnce = 0, ///< One-shot timer.
TimerTypePeriodic = 1 ///< Repeating timer.
TimerTypeOnce = 0, // Timer triggers once after time has passed
TimerTypePeriodic = 1 // Timer triggers repeatedly after time has passed
} TimerType;
typedef void (*TimerCallback)(void* context);
@@ -27,7 +27,7 @@ typedef void (*TimerPendingCallback)(void* context, uint32_t arg);
* @param[in] callback the callback to call when the timer expires
* @param[in] callbackContext the data to pass to the callback
*/
TimerHandle tt_timer_alloc(TimerType type, TimerCallback callback, void* callbackContext);
TimerHandle tt_timer_alloc(TimerType type, TickType ticks, TimerCallback callback, void* callbackContext);
/** Free up the memory of a timer instance */
void tt_timer_free(TimerHandle handle);
@@ -35,18 +35,24 @@ void tt_timer_free(TimerHandle handle);
/**
* Start the timer
* @param[in] handle the timer instance handle
* @parma[in] interval the interval of the timer
* @return true when the timer was successfully started
*/
bool tt_timer_start(TimerHandle handle, TickType_t interval);
bool tt_timer_start(TimerHandle handle);
/**
* Restart an already started timer
* @param[in] handle the timer instance handle
* @parma[in] interval the interval of the timer
* @param[in] interval the timer new interval
* @return true when the timer was successfully restarted
*/
bool tt_timer_restart(TimerHandle handle, TickType_t interval);
bool tt_timer_reset_with_interval(TimerHandle handle, TickType interval);
/**
* Restart an already started timer
* @param[in] handle the timer instance handle
* @return true when the timer was successfully restarted
*/
bool tt_timer_reset(TimerHandle handle);
/**
* Stop a started timer
@@ -63,11 +69,11 @@ bool tt_timer_stop(TimerHandle handle);
bool tt_timer_is_running(TimerHandle handle);
/**
* Get the expire time of a timer
* Get the expiry time of a timer
* @param[in] handle the timer instance handle
* @return the absolute timestamp at which the timer will expire
*/
uint32_t tt_timer_get_expire_time(TimerHandle handle);
uint32_t tt_timer_get_expiry_time(TimerHandle handle);
/**
* Set the pending callback for a timer
+64 -3
View File
@@ -3,19 +3,80 @@
#include <symbols/freertos.h>
#include <Tactility/RtosCompat.h>
#include <Tactility/freertoscompat/RTOS.h>
#include <freertos/task.h>
#include <freertos/event_groups.h>
const esp_elfsym freertos_symbols[] = {
// Task
ESP_ELFSYM_EXPORT(vTaskDelay),
ESP_ELFSYM_EXPORT(vTaskDelete),
ESP_ELFSYM_EXPORT(vTaskDeleteWithCaps),
ESP_ELFSYM_EXPORT(vTaskSetTimeOutState),
ESP_ELFSYM_EXPORT(vTaskPrioritySet),
ESP_ELFSYM_EXPORT(vTaskSetTaskNumber),
ESP_ELFSYM_EXPORT(vTaskSetThreadLocalStoragePointer),
ESP_ELFSYM_EXPORT(vTaskSetThreadLocalStoragePointerAndDelCallback),
ESP_ELFSYM_EXPORT(vTaskGetInfo),
ESP_ELFSYM_EXPORT(xTaskCreate),
ESP_ELFSYM_EXPORT(xTaskAbortDelay),
ESP_ELFSYM_EXPORT(xTaskCheckForTimeOut),
ESP_ELFSYM_EXPORT(xTaskCreatePinnedToCore),
ESP_ELFSYM_EXPORT(xTaskCreateStatic),
ESP_ELFSYM_EXPORT(xTaskCreateStaticPinnedToCore),
ESP_ELFSYM_EXPORT(xTaskCreateWithCaps),
ESP_ELFSYM_EXPORT(xTaskDelayUntil),
ESP_ELFSYM_EXPORT(xTaskGenericNotify),
ESP_ELFSYM_EXPORT(xTaskGenericNotifyFromISR),
ESP_ELFSYM_EXPORT(pvTaskGetThreadLocalStoragePointer),
ESP_ELFSYM_EXPORT(pvTaskIncrementMutexHeldCount),
ESP_ELFSYM_EXPORT(uxTaskGetStackHighWaterMark),
ESP_ELFSYM_EXPORT(uxTaskGetNumberOfTasks),
ESP_ELFSYM_EXPORT(uxTaskGetTaskNumber),
ESP_ELFSYM_EXPORT(uxTaskPriorityGet),
ESP_ELFSYM_EXPORT(uxTaskPriorityGetFromISR),
// EventGroup
ESP_ELFSYM_EXPORT(xEventGroupCreate),
ESP_ELFSYM_EXPORT(xEventGroupCreateWithCaps),
ESP_ELFSYM_EXPORT(xEventGroupCreateStatic),
ESP_ELFSYM_EXPORT(xEventGroupClearBits),
ESP_ELFSYM_EXPORT(xEventGroupSetBits),
ESP_ELFSYM_EXPORT(xEventGroupWaitBits),
ESP_ELFSYM_EXPORT(xEventGroupClearBitsFromISR),
ESP_ELFSYM_EXPORT(vEventGroupDelete),
ESP_ELFSYM_EXPORT(xEventGroupGetStaticBuffer),
ESP_ELFSYM_EXPORT(xEventGroupGetBitsFromISR),
ESP_ELFSYM_EXPORT(xEventGroupSetBits),
ESP_ELFSYM_EXPORT(xEventGroupSetBitsFromISR),
ESP_ELFSYM_EXPORT(xEventGroupSync),
ESP_ELFSYM_EXPORT(xEventGroupWaitBits),
// Queue
ESP_ELFSYM_EXPORT(xQueueGenericCreate),
ESP_ELFSYM_EXPORT(xQueueGenericCreateStatic),
ESP_ELFSYM_EXPORT(xQueueGenericReset),
ESP_ELFSYM_EXPORT(xQueueGenericSend),
ESP_ELFSYM_EXPORT(xQueueGenericSendFromISR),
ESP_ELFSYM_EXPORT(vQueueDelete),
ESP_ELFSYM_EXPORT(vQueueDeleteWithCaps),
ESP_ELFSYM_EXPORT(vQueueSetQueueNumber),
ESP_ELFSYM_EXPORT(vQueueWaitForMessageRestricted),
ESP_ELFSYM_EXPORT(uxQueueGetQueueNumber),
ESP_ELFSYM_EXPORT(uxQueueMessagesWaiting),
ESP_ELFSYM_EXPORT(uxQueueMessagesWaitingFromISR),
ESP_ELFSYM_EXPORT(uxQueueSpacesAvailable),
// Timer
ESP_ELFSYM_EXPORT(xTimerCreate),
ESP_ELFSYM_EXPORT(xTimerCreateStatic),
ESP_ELFSYM_EXPORT(xTimerGenericCommand),
ESP_ELFSYM_EXPORT(xTimerIsTimerActive),
ESP_ELFSYM_EXPORT(xTimerGetExpiryTime),
ESP_ELFSYM_EXPORT(xTimerPendFunctionCall),
ESP_ELFSYM_EXPORT(xTimerPendFunctionCallFromISR),
ESP_ELFSYM_EXPORT(xTimerGetPeriod),
// portmacro.h
ESP_ELFSYM_EXPORT(xPortInIsrContext),
ESP_ELFSYM_EXPORT(xPortCanYield),
ESP_ELFSYM_EXPORT(xPortGetCoreID),
ESP_ELFSYM_EXPORT(xPortGetTickRateHz),
ESP_ELFSYM_EXPORT(xPortInterruptedFromISRContext),
// delimiter
ESP_ELFSYM_END
};
+1 -1
View File
@@ -3,7 +3,7 @@
#include <Tactility/app/AppPaths.h>
#include <Tactility/app/AppContext.h>
#include <Tactility/app/ElfApp.h>
#include <Tactility/file/FileLock.h>
#include <Tactility/Log.h>
#include <cstring>
+2 -2
View File
@@ -43,8 +43,8 @@ bool tt_hal_i2c_lock(i2c_port_t port, TickType_t timeout) {
return tt::hal::i2c::getLock(port).lock(timeout);
}
bool tt_hal_i2c_unlock(i2c_port_t port) {
return tt::hal::i2c::getLock(port).unlock();
void tt_hal_i2c_unlock(i2c_port_t port) {
tt::hal::i2c::getLock(port).unlock();
}
}
+4 -15
View File
@@ -12,7 +12,6 @@
#include "tt_hal_i2c.h"
#include "tt_hal_touch.h"
#include "tt_hal_uart.h"
#include "tt_kernel.h"
#include <tt_lock.h>
#include "tt_lvgl.h"
#include "tt_lvgl_keyboard.h"
@@ -261,15 +260,6 @@ const esp_elfsym main_symbols[] {
ESP_ELFSYM_EXPORT(tt_hal_uart_set_baud_rate),
ESP_ELFSYM_EXPORT(tt_hal_uart_get_baud_rate),
ESP_ELFSYM_EXPORT(tt_hal_uart_flush_input),
ESP_ELFSYM_EXPORT(tt_kernel_delay_millis),
ESP_ELFSYM_EXPORT(tt_kernel_delay_micros),
ESP_ELFSYM_EXPORT(tt_kernel_delay_ticks),
ESP_ELFSYM_EXPORT(tt_kernel_get_ticks),
ESP_ELFSYM_EXPORT(tt_kernel_millis_to_ticks),
ESP_ELFSYM_EXPORT(tt_kernel_delay_until_tick),
ESP_ELFSYM_EXPORT(tt_kernel_get_tick_frequency),
ESP_ELFSYM_EXPORT(tt_kernel_get_millis),
ESP_ELFSYM_EXPORT(tt_kernel_get_micros),
ESP_ELFSYM_EXPORT(tt_lvgl_is_started),
ESP_ELFSYM_EXPORT(tt_lvgl_lock),
ESP_ELFSYM_EXPORT(tt_lvgl_unlock),
@@ -295,8 +285,6 @@ const esp_elfsym main_symbols[] {
ESP_ELFSYM_EXPORT(tt_message_queue_free),
ESP_ELFSYM_EXPORT(tt_message_queue_put),
ESP_ELFSYM_EXPORT(tt_message_queue_get),
ESP_ELFSYM_EXPORT(tt_message_queue_get_capacity),
ESP_ELFSYM_EXPORT(tt_message_queue_get_message_size),
ESP_ELFSYM_EXPORT(tt_message_queue_get_count),
ESP_ELFSYM_EXPORT(tt_message_queue_reset),
ESP_ELFSYM_EXPORT(tt_preferences_alloc),
@@ -324,15 +312,16 @@ const esp_elfsym main_symbols[] {
ESP_ELFSYM_EXPORT(tt_thread_get_state),
ESP_ELFSYM_EXPORT(tt_thread_start),
ESP_ELFSYM_EXPORT(tt_thread_join),
ESP_ELFSYM_EXPORT(tt_thread_get_id),
ESP_ELFSYM_EXPORT(tt_thread_get_task_handle),
ESP_ELFSYM_EXPORT(tt_thread_get_return_code),
ESP_ELFSYM_EXPORT(tt_timer_alloc),
ESP_ELFSYM_EXPORT(tt_timer_free),
ESP_ELFSYM_EXPORT(tt_timer_start),
ESP_ELFSYM_EXPORT(tt_timer_restart),
ESP_ELFSYM_EXPORT(tt_timer_reset),
ESP_ELFSYM_EXPORT(tt_timer_reset_with_interval),
ESP_ELFSYM_EXPORT(tt_timer_stop),
ESP_ELFSYM_EXPORT(tt_timer_is_running),
ESP_ELFSYM_EXPORT(tt_timer_get_expire_time),
ESP_ELFSYM_EXPORT(tt_timer_get_expiry_time),
ESP_ELFSYM_EXPORT(tt_timer_set_pending_callback),
ESP_ELFSYM_EXPORT(tt_timer_set_thread_priority),
ESP_ELFSYM_EXPORT(tt_timezone_set),
-42
View File
@@ -1,42 +0,0 @@
#include "tt_kernel.h"
#include <Tactility/kernel/Kernel.h>
extern "C" {
void tt_kernel_delay_millis(uint32_t milliseconds) {
tt::kernel::delayMillis(milliseconds);
}
void tt_kernel_delay_micros(uint32_t microSeconds) {
tt::kernel::delayMicros(microSeconds);
}
void tt_kernel_delay_ticks(TickType ticks) {
tt::kernel::delayTicks((TickType_t)ticks);
}
TickType tt_kernel_get_ticks() {
return tt::kernel::getTicks();
}
TickType tt_kernel_millis_to_ticks(uint32_t milliSeconds) {
return tt::kernel::millisToTicks(milliSeconds);
}
bool tt_kernel_delay_until_tick(TickType tick) {
return tt::kernel::delayUntilTick(tick);
}
uint32_t tt_kernel_get_tick_frequency() {
return tt::kernel::getTickFrequency();
}
uint32_t tt_kernel_get_millis() {
return tt::kernel::getMillis();
}
unsigned long tt_kernel_get_micros() {
return tt::kernel::getMicros();
}
}
+2 -2
View File
@@ -32,8 +32,8 @@ bool tt_lock_acquire(LockHandle handle, TickType timeout) {
return HANDLE_AS_LOCK(handle)->lock(timeout);
}
bool tt_lock_release(LockHandle handle) {
return HANDLE_AS_LOCK(handle)->unlock();
void tt_lock_release(LockHandle handle) {
HANDLE_AS_LOCK(handle)->unlock();
}
void tt_lock_free(LockHandle handle) {
+1 -13
View File
@@ -21,23 +21,11 @@ bool tt_message_queue_get(MessageQueueHandle handle, void* message, TickType_t t
return HANDLE_TO_MESSAGE_QUEUE(handle)->get(message, timeout);
}
uint32_t tt_message_queue_get_capacity(MessageQueueHandle handle) {
return HANDLE_TO_MESSAGE_QUEUE(handle)->getCapacity();
}
uint32_t tt_message_queue_get_message_size(MessageQueueHandle handle) {
return HANDLE_TO_MESSAGE_QUEUE(handle)->getMessageSize();
}
uint32_t tt_message_queue_get_count(MessageQueueHandle handle) {
return HANDLE_TO_MESSAGE_QUEUE(handle)->getCount();
}
uint32_t tt_message_queue_get_space(MessageQueueHandle handle) {
return HANDLE_TO_MESSAGE_QUEUE(handle)->getSpace();
}
bool tt_message_queue_reset(MessageQueueHandle handle) {
void tt_message_queue_reset(MessageQueueHandle handle) {
return HANDLE_TO_MESSAGE_QUEUE(handle)->reset();
}
+2 -2
View File
@@ -66,8 +66,8 @@ bool tt_thread_join(ThreadHandle handle, TickType_t timeout) {
return HANDLE_AS_THREAD(handle)->join(timeout);
}
ThreadId tt_thread_get_id(ThreadHandle handle) {
return HANDLE_AS_THREAD(handle)->getId();
TaskHandle tt_thread_get_task_handle(ThreadHandle handle) {
return HANDLE_AS_THREAD(handle)->getTaskHandle();
}
int32_t tt_thread_get_return_code(ThreadHandle handle) {
+14 -10
View File
@@ -9,9 +9,9 @@ struct TimerWrapper {
extern "C" {
TimerHandle tt_timer_alloc(TimerType type, TimerCallback callback, void* callbackContext) {
TimerHandle tt_timer_alloc(TimerType type, TickType ticks, TimerCallback callback, void* callbackContext) {
auto wrapper = new TimerWrapper;
wrapper->timer = std::make_unique<tt::Timer>(static_cast<tt::Timer::Type>(type), [callback, callbackContext](){ callback(callbackContext); });
wrapper->timer = std::make_unique<tt::Timer>(static_cast<tt::Timer::Type>(type), ticks, [callback, callbackContext](){ callback(callbackContext); });
return wrapper;
}
@@ -21,12 +21,16 @@ void tt_timer_free(TimerHandle handle) {
delete wrapper;
}
bool tt_timer_start(TimerHandle handle, TickType_t intervalTicks) {
return HANDLE_TO_WRAPPER(handle)->timer->start(intervalTicks);
bool tt_timer_start(TimerHandle handle) {
return HANDLE_TO_WRAPPER(handle)->timer->start();
}
bool tt_timer_restart(TimerHandle handle, TickType_t intervalTicks) {
return HANDLE_TO_WRAPPER(handle)->timer->restart(intervalTicks);
bool tt_timer_reset(TimerHandle handle) {
return HANDLE_TO_WRAPPER(handle)->timer->reset();
}
bool tt_timer_reset_with_interval(TimerHandle handle, TickType interval) {
return HANDLE_TO_WRAPPER(handle)->timer->reset(interval);
}
bool tt_timer_stop(TimerHandle handle) {
@@ -37,8 +41,8 @@ bool tt_timer_is_running(TimerHandle handle) {
return HANDLE_TO_WRAPPER(handle)->timer->isRunning();
}
uint32_t tt_timer_get_expire_time(TimerHandle handle) {
return HANDLE_TO_WRAPPER(handle)->timer->getExpireTime();
uint32_t tt_timer_get_expiry_time(TimerHandle handle) {
return HANDLE_TO_WRAPPER(handle)->timer->getExpiryTime();
}
bool tt_timer_set_pending_callback(TimerHandle handle, TimerPendingCallback callback, void* callbackContext, uint32_t callbackArg, TickType_t timeoutTicks) {
@@ -46,12 +50,12 @@ bool tt_timer_set_pending_callback(TimerHandle handle, TimerPendingCallback call
callback,
callbackContext,
callbackArg,
(TickType_t)timeoutTicks
timeoutTicks
);
}
void tt_timer_set_thread_priority(TimerHandle handle, ThreadPriority priority) {
HANDLE_TO_WRAPPER(handle)->timer->setThreadPriority(static_cast<tt::Thread::Priority>(priority));
HANDLE_TO_WRAPPER(handle)->timer->setCallbackPriority(static_cast<tt::Thread::Priority>(priority));
}
}