Merge develop into main (#365)

### TactilityC
- Create UART HAL
- Refactor locking APIs
- Bind new C++ functionality
- Bind new LVGL functionality

### Apps
- Remove Serial Console as it has been ported as an external app
This commit is contained in:
Ken Van Hoeylandt
2025-10-08 23:16:45 +02:00
committed by GitHub
parent 17b4fc6a47
commit d25603166a
26 changed files with 391 additions and 702 deletions
-13
View File
@@ -1,13 +0,0 @@
#pragma once
#include "tt_lock.h"
#ifdef __cplusplus
extern "C" {
#endif
LockHandle tt_lock_alloc_for_file(const char* path);
#ifdef __cplusplus
}
#endif
+152
View File
@@ -0,0 +1,152 @@
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
#include <tt_kernel.h>
#ifdef __cplusplus
extern "C" {
#endif
/**
* @file tt_hal_uart.h
* @brief C HAL interface for UART devices used by Tactility C modules.
*
* This header exposes a minimal, C-compatible UART API that mirrors the higher-level
* C++ UART interface (see Tactility/hal/uart).
*
* General notes:
* - Start the UART before I/O using tt_hal_uart_start(); stop it with tt_hal_uart_stop().
*/
typedef void* UartHandle; /**< Opaque handle to an underlying UART instance. */
/**
* @brief Get the number of UART devices available on this platform.
* @return Count of discoverable UARTs (0 if none).
*/
size_t tt_hal_uart_get_count();
/**
* @brief Get the user-friendly name of a UART by index.
* @param index Zero-based UART index in the range [0, tt_hal_uart_get_count()).
* @param[out] name Destination buffer to receive a null-terminated name.
* @param nameSizeLimit Size in bytes of the destination buffer. The name will be
* truncated to fit and always null-terminated if the size
* is greater than 0.
* @return true if a name was written to the buffer; false if the index is out of range
* or on other failure.
*/
bool tt_hal_uart_get_name(size_t index, char* name, size_t nameSizeLimit);
/**
* @brief Allocate an opaque UART handle by index.
*
* Allocation does not start the hardware; call tt_hal_uart_start() to begin I/O.
*
* @param index Zero-based UART index.
* @return A valid UartHandle on success; NULL on failure (e.g., invalid index or already in use).
*/
UartHandle tt_hal_uart_alloc(size_t index);
/**
* @brief Release a previously allocated UART handle and any associated resources.
* @param handle Handle returned by tt_hal_uart_alloc()
*/
void tt_hal_uart_free(UartHandle handle);
/**
* @brief Start the UART so it can perform I/O.
* @param handle A valid UART handle.
* @return true on success; false on failure.
*/
bool tt_hal_uart_start(UartHandle handle);
/**
* @brief Query whether the UART has been started.
* @param handle A valid UART handle.
* @return true if started; false otherwise.
*/
bool tt_hal_uart_is_started(UartHandle handle);
/**
* @brief Stop the UART
* @param handle A valid UART handle.
* @return true on success; false on failure.
*/
bool tt_hal_uart_stop(UartHandle handle);
/**
* @brief Read up to bufferSize bytes into buffer.
*
* This call may block up to timeout ticks waiting for data. It returns the actual
* number of bytes placed into the buffer, which can be less than bufferSize if
* fewer bytes became available before the timeout expired.
*
* @param handle A valid UART handle.
* @param[out] buffer Destination buffer.
* @param bufferSize Capacity of the destination buffer in bytes.
* @param timeout Maximum time to wait in ticks. Use 0 for non-blocking; use TT_MAX_TICKS
* to wait indefinitely.
* @return The number of bytes read (0 on timeout with no data). Never exceeds bufferSize.
*/
size_t tt_hal_uart_read_bytes(UartHandle handle, char* buffer, size_t bufferSize, TickType timeout);
/**
* @brief Read a single byte.
*
* @param handle A valid UART handle.
* @param[out] output Where to store the read byte.
* @param timeout Maximum time to wait in ticks. Use 0 for non-blocking; use TT_MAX_TICKS
* to wait indefinitely.
* @return true if a byte was read and stored in output; false on timeout or failure.
*/
bool tt_hal_uart_read_byte(UartHandle handle, char* output, TickType timeout);
/**
* @brief Write up to bufferSize bytes from buffer.
*
* This call may block up to timeout ticks waiting for transmit queue space. It returns
* the number of bytes accepted for transmission.
*
* @param handle A valid UART handle.
* @param[in] buffer Source buffer containing bytes to write.
* @param bufferSize Number of bytes to write from buffer.
* @param timeout Maximum time to wait in ticks. Use 0 for non-blocking; use TT_MAX_TICKS
* to wait indefinitely.
* @return The number of bytes written (may be less than bufferSize on timeout).
*/
size_t tt_hal_uart_write_bytes(UartHandle handle, const char* buffer, size_t bufferSize, TickType timeout);
/**
* @brief Get the number of bytes currently available to read without blocking.
* @param handle A valid UART handle.
* @return The count of bytes available in the receive buffer.
*/
size_t tt_hal_uart_available(UartHandle handle);
/**
* @brief Set the UART baud rate.
* @param handle A valid UART handle.
* @param baud_rate Desired baud rate in bits per second (e.g., 115200).
* @return true on success; false if the rate is unsupported or on error.
*/
bool tt_hal_uart_set_baud_rate(UartHandle handle, size_t baud_rate);
/**
* @brief Get the current UART baud rate.
* @param handle A valid UART handle.
* @return The configured baud rate in bits per second.
*/
uint32_t tt_hal_uart_get_baud_rate(UartHandle handle);
/**
* @brief Flush the UART input (receive) buffer, discarding any unread data.
* @param handle A valid UART handle.
*/
void tt_hal_uart_flush_input(UartHandle handle);
#ifdef __cplusplus
}
#endif
+21
View File
@@ -10,6 +10,26 @@ extern "C" {
/** A handle that represents a lock instance. A lock could be a Mutex or similar construct */
typedef void* LockHandle;
enum TtMutexType {
MutexTypeNormal,
MutexTypeRecursive
};
/**
* Allocate a new mutex instance
* @param[in] type specify if the mutex is either a normal one, or whether it can recursively (re)lock
* @return the allocated lock handle
*/
LockHandle tt_lock_alloc_mutex(enum TtMutexType type);
/**
* Allocate a lock for a file or folder.
* Locking is required before reading files for filesystems that are on a shared bus (e.g. SPI SD card sharing the bus with the display)
* @param path the path to create the lock for
* @return the allocated lock handle
*/
LockHandle tt_lock_alloc_for_path(const char* path);
/**
* Attempt to lock the lock.
* @param[in] handle the handle that represents the mutex instance
@@ -26,6 +46,7 @@ bool tt_lock_acquire(LockHandle handle, TickType timeout);
bool tt_lock_release(LockHandle handle);
/** Free the memory for this lock
* This does not auto-release the lock.
* @param[in] handle the handle that represents the mutex instance
*/
void tt_lock_free(LockHandle handle);
+3 -1
View File
@@ -6,6 +6,8 @@
extern "C" {
#endif
#define TT_LVGL_DEFAULT_LOCK_TIME 500 // 500 ticks = 500 ms
/** @return true if LVGL is started and active */
bool tt_lvgl_is_started();
@@ -16,7 +18,7 @@ void tt_lvgl_start();
void tt_lvgl_stop();
/** Lock the LVGL context. Call this before doing LVGL-related operations from a non-LVLG thread */
void tt_lvgl_lock();
bool tt_lvgl_lock(TickType timeout);
/** Unlock the LVGL context */
void tt_lvgl_unlock();
-48
View File
@@ -1,48 +0,0 @@
#pragma once
#include "tt_kernel.h"
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stdbool.h>
/** A handle that represents a mutex instance */
typedef void* MutexHandle;
enum TtMutexType {
MUTEX_TYPE_NORMAL,
MUTEX_TYPE_RECURSIVE
};
/**
* Allocate a new mutex instance
* @param[in] type specify if the mutex is either a normal one, or whether it can recursively (re)lock
* @return the allocated instance
*/
MutexHandle tt_mutex_alloc(enum TtMutexType type);
/** Free up the memory of the specified mutex instance. */
void tt_mutex_free(MutexHandle handle);
/**
* Attempt to lock a mutex.
* @param[in] handle the handle that represents the mutex instance
* @param[in] timeout the maximum amount of ticks to wait when trying to lock
* @return true when the lock was acquired
*/
bool tt_mutex_lock(MutexHandle handle, TickType timeout);
/**
* Attempt to unlock a mutex.
* @param[in] handle the handle that represents the mutex instance
* @param[in] timeout the maximum amount of ticks to wait when trying to unlock
* @return true when the lock was unlocked
*/
bool tt_mutex_unlock(MutexHandle handle);
#ifdef __cplusplus
}
#endif
+5
View File
@@ -0,0 +1,5 @@
#pragma once
#include <private/elf_symbol.h>
extern const esp_elfsym cplusplus_symbols[];
+18
View File
@@ -0,0 +1,18 @@
#include <private/elf_symbol.h>
#include <cstddef>
#include <symbols/cplusplus.h>
extern "C" {
extern void* _Znwj(uint32_t size); // operator new(unsigned int)
extern void _ZdlPvj(void* p, uint64_t size); // operator delete(void*, unsigned int)
extern void __cxa_pure_virtual();
}
const esp_elfsym cplusplus_symbols[] = {
ESP_ELFSYM_EXPORT(_Znwj), // operator new(unsigned int)
ESP_ELFSYM_EXPORT(_ZdlPvj), // operator delete(void*, unsigned int)
ESP_ELFSYM_EXPORT(__cxa_pure_virtual), // class-related, see https://arobenko.github.io/bare_metal_cpp/
// delimiter
ESP_ELFSYM_END
};
+6
View File
@@ -1,4 +1,8 @@
#include <private/elf_symbol.h>
#include <cstddef>
#include <symbols/esp_event.h>
#include <esp_event.h>
const esp_elfsym esp_event_symbols[] = {
@@ -19,4 +23,6 @@ const esp_elfsym esp_event_symbols[] = {
ESP_ELFSYM_EXPORT(esp_event_post_to),
ESP_ELFSYM_EXPORT(esp_event_isr_post),
ESP_ELFSYM_EXPORT(esp_event_isr_post_to),
// delimiter
ESP_ELFSYM_END
};
@@ -1,4 +1,8 @@
#include <private/elf_symbol.h>
#include <cstddef>
#include <symbols/esp_http_client.h>
#include <esp_http_client.h>
const esp_elfsym esp_http_client_symbols[] = {
@@ -43,4 +47,6 @@ const esp_elfsym esp_http_client_symbols[] = {
ESP_ELFSYM_EXPORT(esp_http_client_flush_response),
ESP_ELFSYM_EXPORT(esp_http_client_get_url),
ESP_ELFSYM_EXPORT(esp_http_client_get_chunk_length),
// delimiter
ESP_ELFSYM_END
};
+6 -2
View File
@@ -1,6 +1,10 @@
#include <cstdlib>
#include <private/elf_symbol.h>
#include <cstddef>
#include <symbols/gcc_soft_float.h>
#include <cstdlib>
// Reference: https://gcc.gnu.org/onlinedocs/gccint/Soft-float-library-routines.html
extern "C" {
@@ -139,7 +143,7 @@ int __gtsf2(float a, float b);
int __gtdf2(double a, double b);
// int __gttf2(long double a, long double b);
}
} // extern "C"
const esp_elfsym gcc_soft_float_symbols[] = {
ESP_ELFSYM_EXPORT(__addsf3),
+6
View File
@@ -1,4 +1,8 @@
#include <private/elf_symbol.h>
#include <cstddef>
#include <symbols/pthread.h>
#include <pthread.h>
const esp_elfsym pthread_symbols[] = {
@@ -8,4 +12,6 @@ const esp_elfsym pthread_symbols[] = {
ESP_ELFSYM_EXPORT(pthread_detach),
ESP_ELFSYM_EXPORT(pthread_join),
ESP_ELFSYM_EXPORT(pthread_exit),
// delimiter
ESP_ELFSYM_END
};
+8 -9
View File
@@ -1,18 +1,17 @@
#include <private/elf_symbol.h>
#include <cstddef>
#include <symbols/stl.h>
#include <bits/functexcept.h>
extern "C" {
extern void* _Znwj(uint32_t size); // operator new(unsigned int)
extern void _ZdlPvj(void* p, uint64_t size); // operator delete(void*, unsigned int)
}
const esp_elfsym stl_symbols[] = {
ESP_ELFSYM_EXPORT(_Znwj), // operator new(unsigned int)
ESP_ELFSYM_EXPORT(_ZdlPvj), // operator delete(void*, unsigned int)
// Note: You have to use the mangled names here
{ "_ZSt20__throw_length_errorPKc", (void*)&(std::__throw_length_error) },
{ "_ZSt17__throw_bad_allocv", (void*)&(std::__throw_bad_alloc) },
{ "_ZSt28__throw_bad_array_new_lengthv", (void*)&(std::__throw_bad_array_new_length) },
{ "_ZSt17__throw_bad_allocv", (void*)&(std::__throw_bad_alloc) }
{ "_ZSt25__throw_bad_function_callv", (void*)&(std::__throw_bad_function_call) },
{ "_ZSt20__throw_length_errorPKc", (void*)&(std::__throw_length_error) },
// { "", (void*)&(std::) },
// delimiter
ESP_ELFSYM_END
};
-13
View File
@@ -1,13 +0,0 @@
#include <tt_file.h>
#include <tt_lock_private.h>
#include <Tactility/file/File.h>
extern "C" {
LockHandle tt_lock_alloc_for_file(const char* path) {
auto lock = tt::file::getLock(path);
auto holder = new LockHolder(lock);
return holder;
}
}
+82
View File
@@ -0,0 +1,82 @@
#include "tt_hal_uart.h"
#include <Tactility/hal/uart/Uart.h>
using namespace tt::hal;
struct UartWrapper {
std::shared_ptr<uart::Uart> uart;
};
#define HANDLE_AS_UART(handle) static_cast<UartWrapper*>(handle)->uart
extern "C" {
size_t tt_hal_uart_get_count() {
return uart::getNames().size();
}
bool tt_hal_uart_get_name(size_t index, char* name, size_t nameSizeLimit) {
assert(index < uart::getNames().size());
auto source_name = uart::getNames()[index];
return strncpy(name, source_name.c_str(), nameSizeLimit) != nullptr;
}
UartHandle tt_hal_uart_alloc(size_t index) {
assert(index < uart::getNames().size());
auto* wrapper = new UartWrapper();
auto name = uart::getNames()[index];
wrapper->uart = uart::open(name);
assert(wrapper->uart != nullptr);
return wrapper;
}
void tt_hal_uart_free(UartHandle handle) {
auto* wrapper = static_cast<UartWrapper*>(handle);
assert(wrapper->uart != nullptr);
if (wrapper->uart->isStarted()) {
wrapper->uart->stop();
}
delete wrapper;
}
bool tt_hal_uart_start(UartHandle handle) {
return HANDLE_AS_UART(handle)->start();
}
bool tt_hal_uart_is_started(UartHandle handle) {
return HANDLE_AS_UART(handle)->isStarted();
}
bool tt_hal_uart_stop(UartHandle handle) {
return HANDLE_AS_UART(handle)->stop();
}
size_t tt_hal_uart_read_bytes(UartHandle handle, char* buffer, size_t bufferSize, TickType timeout) {
return HANDLE_AS_UART(handle)->readBytes(reinterpret_cast<std::byte*>(buffer), bufferSize, timeout);
}
bool tt_hal_uart_read_byte(UartHandle handle, char* output, TickType timeout) {
return HANDLE_AS_UART(handle)->readByte(reinterpret_cast<std::byte*>(output), timeout);
}
size_t tt_hal_uart_write_bytes(UartHandle handle, const char* buffer, size_t bufferSize, TickType timeout) {
return HANDLE_AS_UART(handle)->writeBytes(reinterpret_cast<const std::byte*>(buffer), bufferSize, timeout);
}
size_t tt_hal_uart_available(UartHandle handle) {
return HANDLE_AS_UART(handle)->available();
}
bool tt_hal_uart_set_baud_rate(UartHandle handle, size_t baud_rate) {
return HANDLE_AS_UART(handle)->setBaudRate(baud_rate);
}
uint32_t tt_hal_uart_get_baud_rate(UartHandle handle) {
return HANDLE_AS_UART(handle)->getBaudRate();
}
void tt_hal_uart_flush_input(UartHandle handle) {
HANDLE_AS_UART(handle)->flushInput();
}
}
+34 -11
View File
@@ -4,7 +4,6 @@
#include "tt_app_alertdialog.h"
#include "tt_app_selectiondialog.h"
#include "tt_bundle.h"
#include "tt_file.h"
#include "tt_gps.h"
#include "tt_hal.h"
#include "tt_hal_device.h"
@@ -12,13 +11,14 @@
#include "tt_hal_gpio.h"
#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"
#include "tt_lvgl_spinner.h"
#include "tt_lvgl_toolbar.h"
#include "tt_message_queue.h"
#include "tt_mutex.h"
#include "tt_preferences.h"
#include "tt_semaphore.h"
#include "tt_thread.h"
@@ -31,6 +31,7 @@
#include "symbols/gcc_soft_float.h"
#include "symbols/pthread.h"
#include "symbols/stl.h"
#include "symbols/cplusplus.h"
#include <cstring>
#include <ctype.h>
@@ -57,6 +58,8 @@ const esp_elfsym main_symbols[] {
ESP_ELFSYM_EXPORT(rand),
ESP_ELFSYM_EXPORT(srand),
ESP_ELFSYM_EXPORT(rand_r),
ESP_ELFSYM_EXPORT(atoi),
ESP_ELFSYM_EXPORT(atol),
// esp random
ESP_ELFSYM_EXPORT(esp_random),
ESP_ELFSYM_EXPORT(esp_fill_random),
@@ -169,7 +172,8 @@ const esp_elfsym main_symbols[] {
ESP_ELFSYM_EXPORT(tt_app_get_user_data_child_path),
ESP_ELFSYM_EXPORT(tt_app_get_assets_path),
ESP_ELFSYM_EXPORT(tt_app_get_assets_child_path),
ESP_ELFSYM_EXPORT(tt_lock_alloc_for_file),
ESP_ELFSYM_EXPORT(tt_lock_alloc_mutex),
ESP_ELFSYM_EXPORT(tt_lock_alloc_for_path),
ESP_ELFSYM_EXPORT(tt_lock_acquire),
ESP_ELFSYM_EXPORT(tt_lock_release),
ESP_ELFSYM_EXPORT(tt_lock_free),
@@ -215,6 +219,20 @@ const esp_elfsym main_symbols[] {
ESP_ELFSYM_EXPORT(tt_hal_touch_driver_alloc),
ESP_ELFSYM_EXPORT(tt_hal_touch_driver_free),
ESP_ELFSYM_EXPORT(tt_hal_touch_driver_get_touched_points),
ESP_ELFSYM_EXPORT(tt_hal_uart_get_count),
ESP_ELFSYM_EXPORT(tt_hal_uart_get_name),
ESP_ELFSYM_EXPORT(tt_hal_uart_alloc),
ESP_ELFSYM_EXPORT(tt_hal_uart_free),
ESP_ELFSYM_EXPORT(tt_hal_uart_start),
ESP_ELFSYM_EXPORT(tt_hal_uart_is_started),
ESP_ELFSYM_EXPORT(tt_hal_uart_stop),
ESP_ELFSYM_EXPORT(tt_hal_uart_read_bytes),
ESP_ELFSYM_EXPORT(tt_hal_uart_read_byte),
ESP_ELFSYM_EXPORT(tt_hal_uart_write_bytes),
ESP_ELFSYM_EXPORT(tt_hal_uart_available),
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),
@@ -252,10 +270,6 @@ const esp_elfsym main_symbols[] {
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_mutex_alloc),
ESP_ELFSYM_EXPORT(tt_mutex_free),
ESP_ELFSYM_EXPORT(tt_mutex_lock),
ESP_ELFSYM_EXPORT(tt_mutex_unlock),
ESP_ELFSYM_EXPORT(tt_preferences_alloc),
ESP_ELFSYM_EXPORT(tt_preferences_free),
ESP_ELFSYM_EXPORT(tt_preferences_opt_bool),
@@ -322,9 +336,12 @@ const esp_elfsym main_symbols[] {
// lv_obj
ESP_ELFSYM_EXPORT(lv_color_hex),
ESP_ELFSYM_EXPORT(lv_color_make),
ESP_ELFSYM_EXPORT(lv_obj_clean),
ESP_ELFSYM_EXPORT(lv_obj_create),
ESP_ELFSYM_EXPORT(lv_obj_delete),
ESP_ELFSYM_EXPORT(lv_obj_add_event_cb),
ESP_ELFSYM_EXPORT(lv_obj_add_flag),
ESP_ELFSYM_EXPORT(lv_obj_add_state),
ESP_ELFSYM_EXPORT(lv_obj_align),
ESP_ELFSYM_EXPORT(lv_obj_align_to),
ESP_ELFSYM_EXPORT(lv_obj_get_parent),
@@ -337,11 +354,11 @@ const esp_elfsym main_symbols[] {
ESP_ELFSYM_EXPORT(lv_obj_get_content_width),
ESP_ELFSYM_EXPORT(lv_obj_get_content_height),
ESP_ELFSYM_EXPORT(lv_obj_center),
ESP_ELFSYM_EXPORT(lv_obj_remove_event_cb),
ESP_ELFSYM_EXPORT(lv_obj_get_user_data),
ESP_ELFSYM_EXPORT(lv_obj_set_user_data),
ESP_ELFSYM_EXPORT(lv_obj_remove_event_cb),
ESP_ELFSYM_EXPORT(lv_obj_remove_flag),
ESP_ELFSYM_EXPORT(lv_obj_add_flag),
ESP_ELFSYM_EXPORT(lv_obj_remove_state),
ESP_ELFSYM_EXPORT(lv_obj_set_pos),
ESP_ELFSYM_EXPORT(lv_obj_set_flex_align),
ESP_ELFSYM_EXPORT(lv_obj_set_flex_flow),
@@ -442,6 +459,9 @@ const esp_elfsym main_symbols[] {
ESP_ELFSYM_EXPORT(lv_dropdown_get_option_count),
ESP_ELFSYM_EXPORT(lv_dropdown_get_option_index),
ESP_ELFSYM_EXPORT(lv_dropdown_get_options),
ESP_ELFSYM_EXPORT(lv_dropdown_get_selected),
ESP_ELFSYM_EXPORT(lv_dropdown_get_selected_str),
ESP_ELFSYM_EXPORT(lv_dropdown_get_selected_highlight),
ESP_ELFSYM_EXPORT(lv_dropdown_set_dir),
ESP_ELFSYM_EXPORT(lv_dropdown_set_options),
ESP_ELFSYM_EXPORT(lv_dropdown_set_options_static),
@@ -462,6 +482,8 @@ const esp_elfsym main_symbols[] {
ESP_ELFSYM_EXPORT(lv_textarea_get_label),
ESP_ELFSYM_EXPORT(lv_textarea_get_max_length),
ESP_ELFSYM_EXPORT(lv_textarea_get_one_line),
ESP_ELFSYM_EXPORT(lv_textarea_get_text),
ESP_ELFSYM_EXPORT(lv_textarea_get_text_selection),
ESP_ELFSYM_EXPORT(lv_textarea_set_one_line),
ESP_ELFSYM_EXPORT(lv_textarea_set_accepted_chars),
ESP_ELFSYM_EXPORT(lv_textarea_set_align),
@@ -526,9 +548,10 @@ uintptr_t tt_symbol_resolver(const char* symbolName) {
main_symbols,
gcc_soft_float_symbols,
stl_symbols,
cplusplus_symbols,
esp_event_symbols,
esp_http_client_symbols,
pthread_symbols
pthread_symbols,
};
for (const auto* symbols : all_symbols) {
@@ -545,7 +568,7 @@ void tt_init_tactility_c() {
elf_set_symbol_resolver(tt_symbol_resolver);
}
}
} // extern "C"
#else // Simulator
+27 -5
View File
@@ -1,20 +1,42 @@
#include <tt_lock.h>
#include <tt_lock_private.h>
#include <Tactility/Mutex.h>
#include <Tactility/file/File.h>
#define HANDLE_AS_LOCK(handle) (static_cast<LockHolder*>(handle)->lock)
extern "C" {
LockHandle tt_lock_alloc_mutex(TtMutexType type) {
auto* lock_holder = new LockHolder();
switch (type) {
case MutexTypeNormal:
lock_holder->lock = std::make_shared<tt::Mutex>(tt::Mutex::Type::Normal);
break;
case MutexTypeRecursive:
lock_holder->lock = std::make_shared<tt::Mutex>(tt::Mutex::Type::Recursive);
break;
default:
tt_crash("Type not supported");
}
return lock_holder;
}
LockHandle tt_lock_alloc_for_path(const char* path) {
const auto lock = tt::file::getLock(path);
return new LockHolder(lock);
}
bool tt_lock_acquire(LockHandle handle, TickType timeout) {
auto holder = static_cast<LockHolder*>(handle);
return holder->lock->lock(timeout);
return HANDLE_AS_LOCK(handle)->lock(timeout);
}
bool tt_lock_release(LockHandle handle) {
auto holder = static_cast<LockHolder*>(handle);
return holder->lock->unlock();
return HANDLE_AS_LOCK(handle)->unlock();
}
void tt_lock_free(LockHandle handle) {
auto holder = static_cast<LockHolder*>(handle);
const auto holder = static_cast<LockHolder*>(handle);
delete holder;
}
+3 -2
View File
@@ -1,3 +1,4 @@
#include <tt_kernel.h>
#include <Tactility/lvgl/Lvgl.h>
#include <Tactility/lvgl/LvglSync.h>
@@ -15,8 +16,8 @@ void tt_lvgl_stop() {
tt::lvgl::stop();
}
void tt_lvgl_lock() {
tt::lvgl::getSyncLock()->lock();
void tt_lvgl_lock(TickType timeout) {
tt::lvgl::getSyncLock()->lock(timeout);
}
void tt_lvgl_unlock() {
-31
View File
@@ -1,31 +0,0 @@
#include "tt_mutex.h"
#include <Tactility/Mutex.h>
extern "C" {
#define HANDLE_AS_MUTEX(handle) ((tt::Mutex*)(handle))
MutexHandle tt_mutex_alloc(TtMutexType type) {
switch (type) {
case MUTEX_TYPE_NORMAL:
return new tt::Mutex(tt::Mutex::Type::Normal);
case MUTEX_TYPE_RECURSIVE:
return new tt::Mutex(tt::Mutex::Type::Recursive);
default:
tt_crash("Type not supported");
}
}
void tt_mutex_free(MutexHandle handle) {
delete HANDLE_AS_MUTEX(handle);
}
bool tt_mutex_lock(MutexHandle handle, TickType timeout) {
return HANDLE_AS_MUTEX(handle)->lock(timeout);
}
bool tt_mutex_unlock(MutexHandle handle) {
return HANDLE_AS_MUTEX(handle)->unlock();
}
}