TactilitySDK updates (#442)
- Removed custom `TickType` - Removed TactilityC functionality that is now covered by TactilityFreeRtos
This commit is contained in:
committed by
GitHub
parent
524b197105
commit
812c2901db
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <tt_kernel.h>
|
||||
#include <tt_hal_device.h>
|
||||
#include <stdbool.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -48,7 +48,7 @@ void tt_hal_display_driver_free(DisplayDriverHandle handle);
|
||||
* @param[in] timeout the maximum amount of ticks to wait for getting a lock
|
||||
* @return true if the lock was acquired
|
||||
*/
|
||||
bool tt_hal_display_driver_lock(DisplayDriverHandle handle, TickType timeout);
|
||||
bool tt_hal_display_driver_lock(DisplayDriverHandle handle, TickType_t timeout);
|
||||
|
||||
/**
|
||||
* Unlock the display device. Must be called exactly once after locking.
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <tt_kernel.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -91,7 +91,7 @@ bool tt_hal_uart_stop(UartHandle handle);
|
||||
* 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);
|
||||
size_t tt_hal_uart_read_bytes(UartHandle handle, char* buffer, size_t bufferSize, TickType_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Read a single byte.
|
||||
@@ -102,7 +102,7 @@ size_t tt_hal_uart_read_bytes(UartHandle handle, char* buffer, size_t bufferSize
|
||||
* 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);
|
||||
bool tt_hal_uart_read_byte(UartHandle handle, char* output, TickType_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Write up to bufferSize bytes from buffer.
|
||||
@@ -117,7 +117,7 @@ bool tt_hal_uart_read_byte(UartHandle handle, char* output, TickType timeout);
|
||||
* 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);
|
||||
size_t tt_hal_uart_write_bytes(UartHandle handle, const char* buffer, size_t bufferSize, TickType_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Get the number of bytes currently available to read without blocking.
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef unsigned long TickType;
|
||||
|
||||
#define TT_MAX_TICKS ((TickType)(~(TickType)0))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "tt_kernel.h"
|
||||
#include <stdbool.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -15,13 +15,6 @@ typedef enum {
|
||||
MutexTypeRecursive
|
||||
} TtMutexType;
|
||||
|
||||
/**
|
||||
* 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(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)
|
||||
@@ -36,7 +29,7 @@ LockHandle tt_lock_alloc_for_path(const char* path);
|
||||
* @param[in] timeout the maximum amount of ticks to wait when trying to lock
|
||||
* @return true when the lock was acquired
|
||||
*/
|
||||
bool tt_lock_acquire(LockHandle handle, TickType timeout);
|
||||
bool tt_lock_acquire(LockHandle handle, TickType_t timeout);
|
||||
|
||||
/**
|
||||
* Attempt to unlock the lock.
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <freertos/FreeRTOS.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@@ -18,7 +19,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 */
|
||||
bool tt_lvgl_lock(TickType timeout);
|
||||
bool tt_lvgl_lock(TickType_t timeout);
|
||||
|
||||
/** Unlock the LVGL context */
|
||||
void tt_lvgl_unlock();
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <freertos/FreeRTOS.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/** A handle that represents a message queue instance */
|
||||
typedef void* MessageQueueHandle;
|
||||
|
||||
/**
|
||||
* Allocate a new message queue in memory.
|
||||
* @param[in] capacity how many messages this queue can contain before it starts blocking input
|
||||
* @param[in] messageSize the size of a message
|
||||
*/
|
||||
MessageQueueHandle tt_message_queue_alloc(uint32_t capacity, uint32_t messageSize);
|
||||
|
||||
/** Free up the memory of a queue (dealloc) */
|
||||
void tt_message_queue_free(MessageQueueHandle handle);
|
||||
|
||||
/**
|
||||
* Put (post) a message in the queue
|
||||
* @param[in] handle the queue handle
|
||||
* @param[in] message the message of the correct size - its data will be copied
|
||||
* @param[timeout] timeout the amount of ticks to wait until the message is queued
|
||||
* @return true if the item was successfully queued
|
||||
*/
|
||||
bool tt_message_queue_put(MessageQueueHandle handle, const void* message, TickType_t timeout);
|
||||
|
||||
/**
|
||||
* Get the oldest message from the queue.
|
||||
* @param[in] handle the queue handle
|
||||
* @param[out] message a pointer to a message of the correct size
|
||||
* @param[in] timeout the amount of ticks to wait until a message was copied
|
||||
* @return true if a message was successfully copied
|
||||
*/
|
||||
bool tt_message_queue_get(MessageQueueHandle handle, void* message, TickType_t timeout);
|
||||
|
||||
/** @return the current amount of items in the queue */
|
||||
uint32_t tt_message_queue_get_count(MessageQueueHandle handle);
|
||||
|
||||
/**
|
||||
* Remove all items from the queue (if any)
|
||||
*/
|
||||
void tt_message_queue_reset(MessageQueueHandle handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,50 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <freertos/FreeRTOS.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/** A handle that represents a semaphore instance */
|
||||
typedef void* SemaphoreHandle;
|
||||
|
||||
/**
|
||||
* Allocate a new semaphore instance.
|
||||
* @param[in] maxCount the maximum counter value
|
||||
* @param[in] initialCount the initial counter value
|
||||
* @return the handle that represents the new instance
|
||||
*/
|
||||
SemaphoreHandle tt_semaphore_alloc(uint32_t maxCount, TickType_t initialCount);
|
||||
|
||||
/** Free up the memory of a specified semaphore instance */
|
||||
void tt_semaphore_free(SemaphoreHandle handle);
|
||||
|
||||
/**
|
||||
* Attempt to acquire a semaphore (increase counter)
|
||||
* @param[in] handle the instance handle
|
||||
* @param[in] timeout the maximum amount of ticks to wait while trying to acquire
|
||||
* @return true on successfully acquiring the semaphore (counter is increased)
|
||||
*/
|
||||
bool tt_semaphore_acquire(SemaphoreHandle handle, TickType_t timeout);
|
||||
|
||||
/**
|
||||
* Release an acquired semaphore (decrease counter)
|
||||
* @param[in] handle the instance handle
|
||||
* @return true on successfully releasing the semaphore (counter is decreased)
|
||||
*/
|
||||
bool tt_semaphore_release(SemaphoreHandle handle);
|
||||
|
||||
/**
|
||||
* Get the counter value of this semaphore instance
|
||||
* @param[in] handle the instance handle
|
||||
* @return the current counter value (acquisition count)
|
||||
*/
|
||||
uint32_t tt_semaphore_get_count(SemaphoreHandle handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,156 +0,0 @@
|
||||
#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>
|
||||
|
||||
/** The handle that represents the thread insance */
|
||||
typedef void* ThreadHandle;
|
||||
|
||||
/** The state of a thread instance */
|
||||
typedef enum {
|
||||
ThreadStateStopped,
|
||||
ThreadStateStarting,
|
||||
ThreadStateRunning,
|
||||
} ThreadState;
|
||||
|
||||
/** The identifier that represents the thread */
|
||||
typedef TaskHandle_t TaskHandle;
|
||||
|
||||
/** 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;
|
||||
|
||||
/** @return a thread handle that represents a newly allocated thread instance */
|
||||
ThreadHandle tt_thread_alloc();
|
||||
|
||||
/**
|
||||
* Allocate a thread and provide some common parameters so it's all ready to be started.
|
||||
* @param[in] name the name of the thread
|
||||
* @param[in] stackSize the size of the stack in bytes
|
||||
* @param[in] callback the callback to call from the thread
|
||||
* @param[in] callbackContext the data to pass to the callback
|
||||
*/
|
||||
ThreadHandle tt_thread_alloc_ext(
|
||||
const char* name,
|
||||
uint32_t stackSize,
|
||||
ThreadCallback callback,
|
||||
void* _Nullable callbackContext
|
||||
);
|
||||
|
||||
/**
|
||||
* Free up the memory of the thread that is represented by this handle
|
||||
* @param[in] handle the thread instance handle
|
||||
*/
|
||||
void tt_thread_free(ThreadHandle handle);
|
||||
|
||||
/**
|
||||
* Set the name of a thread
|
||||
* @param[in] handle the thread instance handle
|
||||
* @param[in] name the name to set
|
||||
*/
|
||||
void tt_thread_set_name(ThreadHandle handle, const char* name);
|
||||
|
||||
/**
|
||||
* Set the stack size of the thread (in bytes)
|
||||
* @param[in] handle the thread instance handle
|
||||
* @param[in] the size of the thread in bytes
|
||||
*/
|
||||
void tt_thread_set_stack_size(ThreadHandle handle, size_t size);
|
||||
|
||||
/** Set CPu core affinity for this thread
|
||||
* @param[in] handle the thread instance handle
|
||||
* @param[in] affinity -1 means not pinned, otherwise it's the core id (e.g. 0 or 1 on ESP32)
|
||||
*/
|
||||
void tt_thread_set_affinity(ThreadHandle handle, int affinity);
|
||||
|
||||
/**
|
||||
* Set the callback for a thread. This method is executed when the thread is started.
|
||||
* @param[in] handle the thread instance handle
|
||||
* @param[in] callback the callback to set
|
||||
* @param[in] callbackContext the data to pass to the callback
|
||||
*/
|
||||
void tt_thread_set_callback(ThreadHandle handle, ThreadCallback callback, void* _Nullable callbackContext);
|
||||
|
||||
/**
|
||||
* Set the priority of a thread
|
||||
* @param[in] handle the thread instance handle
|
||||
* @param[in] priority the priority to set
|
||||
*/
|
||||
void tt_thread_set_priority(ThreadHandle handle, ThreadPriority priority);
|
||||
|
||||
/**
|
||||
* Set the state callback for a thread
|
||||
* @param[in] handle the thread instance handle
|
||||
* @param[in] callback the callback to set
|
||||
* @param[in] callbackContext the data to pass to the callback
|
||||
*/
|
||||
void tt_thread_set_state_callback(ThreadHandle handle, ThreadStateCallback callback, void* _Nullable callbackContext);
|
||||
|
||||
/**
|
||||
* @param[in] handle the thread instance handle
|
||||
* @return the current state of a thread
|
||||
*/
|
||||
ThreadState tt_thread_get_state(ThreadHandle handle);
|
||||
|
||||
/**
|
||||
* Start a thread
|
||||
* @param[in] handle the thread instance handle
|
||||
*/
|
||||
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 EventGroup or boolean+Mutex)
|
||||
*/
|
||||
bool tt_thread_join(ThreadHandle handle, TickType_t timeout);
|
||||
|
||||
/**
|
||||
* Get thread task handle
|
||||
* @param[in] handle the thread instance handle
|
||||
* @return the task handle of a thread
|
||||
* */
|
||||
TaskHandle tt_thread_get_task_handle(ThreadHandle handle);
|
||||
|
||||
/**
|
||||
* Get the return code of a thread
|
||||
* @warning crashes when state is not "stopped"
|
||||
* @param[in] handle the thread instance handle
|
||||
* @return the return code of a thread or
|
||||
*/
|
||||
int32_t tt_thread_get_return_code(ThreadHandle handle);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -1,97 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include "tt_kernel.h"
|
||||
#include "tt_thread.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/** The handle that represents a timer instance */
|
||||
typedef void* TimerHandle;
|
||||
|
||||
/** The behaviour of the timer */
|
||||
typedef enum {
|
||||
TimerTypeOnce = 0, // Timer triggers once after time has passed
|
||||
TimerTypePeriodic = 1 // Timer triggers repeatedly after time has passed
|
||||
} TimerType;
|
||||
|
||||
typedef void (*TimerCallback)(void* context);
|
||||
typedef void (*TimerPendingCallback)(void* context, uint32_t arg);
|
||||
|
||||
/**
|
||||
* Create a new timer instance
|
||||
* @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, TickType ticks, TimerCallback callback, void* callbackContext);
|
||||
|
||||
/** Free up the memory of a timer instance */
|
||||
void tt_timer_free(TimerHandle handle);
|
||||
|
||||
/**
|
||||
* Start the timer
|
||||
* @param[in] handle the timer instance handle
|
||||
* @return true when the timer was successfully started
|
||||
*/
|
||||
bool tt_timer_start(TimerHandle handle);
|
||||
|
||||
/**
|
||||
* Restart an already started timer
|
||||
* @param[in] handle the timer instance handle
|
||||
* @param[in] interval the timer new interval
|
||||
* @return true when the timer was successfully restarted
|
||||
*/
|
||||
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
|
||||
* @param[in] handle the timer instance handle
|
||||
* @return true when the timer was successfully stopped
|
||||
*/
|
||||
bool tt_timer_stop(TimerHandle handle);
|
||||
|
||||
/**
|
||||
* Check if a timer is started
|
||||
* @param[in] handle the timer instance handle
|
||||
* @return true when the timer is started (pending)
|
||||
*/
|
||||
bool tt_timer_is_running(TimerHandle handle);
|
||||
|
||||
/**
|
||||
* 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_expiry_time(TimerHandle handle);
|
||||
|
||||
/**
|
||||
* Set the pending callback for a timer
|
||||
* @param[in] handle the timer instance handle
|
||||
* @param[in] callback the callback to set
|
||||
* @param[in] callbackContext the context to pass to the callback
|
||||
* @param[in] timeout the timeout for setting the callback
|
||||
* @return when the callback was successfully set
|
||||
*/
|
||||
bool tt_timer_set_pending_callback(TimerHandle handle, TimerPendingCallback callback, void* callbackContext, uint32_t callbackArg, TickType_t timeout);
|
||||
|
||||
/**
|
||||
* Set the thread priority for the callback of the timer
|
||||
* @param[in] handle the timer instance handle
|
||||
* @param[in] priority the thread priority to set
|
||||
*/
|
||||
void tt_timer_set_thread_priority(TimerHandle handle, ThreadPriority priority);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user