Update docs and fix bugs (#149)

Improved the docs for the 3 main Tactility projects. I also fixed some inaccuracies and bugs in certain APIs as I went through the code.
This commit is contained in:
Ken Van Hoeylandt
2025-01-07 20:45:23 +01:00
committed by GitHub
parent ff4287e2ce
commit 415096c3b2
62 changed files with 503 additions and 517 deletions
+34 -88
View File
@@ -7,13 +7,7 @@
#include <cstdint>
#include <string>
#ifdef ESP_PLATFORM
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#else
#include "FreeRTOS.h"
#include "task.h"
#endif
#include "RtosCompatTask.h"
namespace tt {
@@ -47,14 +41,14 @@ public:
typedef int32_t (*Callback)(void* context);
/** Write to stdout callback
* @param data pointer to data
* @param size data size @warning your handler must consume everything
* @param[in] data pointer to data
* @param[in] size data size @warning your handler must consume everything
*/
typedef void (*StdoutWriteCallback)(const char* data, size_t size);
/** Thread state change callback called upon thread state change
* @param state new thread state
* @param context callback context
* @param[in] state new thread state
* @param[in] context callback context
*/
typedef void (*StateCallback)(State state, void* context);
@@ -85,11 +79,10 @@ public:
Thread();
/** Allocate Thread, shortcut version
* @param name
* @param stack_size
* @param callback
* @param context
* @param[in] name
* @param[in] stack_size
* @param[in] callback
* @param[in] callbackContext
* @return Thread*
*/
Thread(
@@ -102,8 +95,7 @@ public:
~Thread();
/** Set Thread name
*
* @param name string
* @param[in] name string
*/
void setName(const std::string& name);
@@ -118,75 +110,49 @@ public:
bool isMarkedAsStatic() const;
/** Set Thread stack size
*
* @param thread Thread instance
* @param stackSize stack size in bytes
* @param[in] stackSize stack size in bytes
*/
void setStackSize(size_t stackSize);
/** Set Thread callback
*
* @param thread Thread instance
* @param callback ThreadCallback, called upon thread run
* @param callbackContext what to pass to the callback
* @param[in] callback ThreadCallback, called upon thread run
* @param[in] callbackContext what to pass to the callback
*/
void setCallback(Callback callback, _Nullable void* callbackContext = nullptr);
/** Set Thread priority
*
* @param thread Thread instance
* @param priority ThreadPriority value
* @param[in] priority ThreadPriority value
*/
void setPriority(Priority priority);
/** Set Thread state change callback
*
* @param thread Thread instance
* @param callback state change callback
* @param context pointer to context
* @param[in] callback state change callback
* @param[in] callbackContext pointer to context
*/
void setStateCallback(StateCallback callback, _Nullable void* callbackContext = nullptr);
/** Get Thread state
*
* @param thread Thread instance
*
* @return thread state from ThreadState
*/
State getState() const;
/** Start Thread
*
* @param thread Thread instance
*/
void start();
/** Join Thread
*
* @warning Use this method only when CPU is not busy(Idle task receives
* control), otherwise it will wait forever.
*
* @param thread Thread instance
*
* @warning Use this method only when CPU is not busy (Idle task receives control), otherwise it will wait forever.
* @return success result
*/
bool join();
/** Get FreeRTOS ThreadId for Thread instance
*
* @param thread Thread instance
*
* @return ThreadId or nullptr
*/
ThreadId getId();
/** Get thread return code
*
* @param thread Thread instance
*
* @return return code
*/
/** @return thread return code */
int32_t getReturnCode();
private:
@@ -200,31 +166,17 @@ private:
#define THREAD_PRIORITY_ISR (TT_CONFIG_THREAD_MAX_PRIORITIES - 1)
/** Set current thread priority
*
* @param priority ThreadPriority value
* @param[in] priority ThreadPriority value
*/
void thread_set_current_priority(Thread::Priority priority);
/** Get current thread priority
*
* @return ThreadPriority value
*/
/** @return ThreadPriority value */
Thread::Priority thread_get_current_priority();
/** Thread related methods that doesn't involve Thread directly */
/** Get FreeRTOS ThreadId for current thread
*
* @param thread Thread instance
*
* @return ThreadId or NULL
*/
/** @return FreeRTOS ThreadId or NULL */
ThreadId thread_get_current_id();
/** Get Thread instance for current thread
*
* @return pointer to Thread or NULL if this thread doesn't belongs to Tactility
*/
/** @return pointer to Thread instance or NULL if this thread doesn't belongs to Tactility */
Thread* thread_get_current();
/** Return control to scheduler */
@@ -240,44 +192,38 @@ uint32_t thread_flags_wait(uint32_t flags, uint32_t options, uint32_t timeout);
/**
* @brief Get thread name
*
* @param thread_id
* @param[in] threadId
* @return const char* name or NULL
*/
const char* thread_get_name(ThreadId thread_id);
const char* thread_get_name(ThreadId threadId);
/**
* @brief Get thread stack watermark
*
* @param thread_id
* @param[in] threadId
* @return uint32_t
*/
uint32_t thread_get_stack_space(ThreadId thread_id);
uint32_t thread_get_stack_space(ThreadId threadId);
/** Suspend thread
*
* @param thread_id thread id
* @param[in] threadId thread id
*/
void thread_suspend(ThreadId thread_id);
void thread_suspend(ThreadId threadId);
/** Resume thread
*
* @param thread_id thread id
* @param[in] threadId thread id
*/
void thread_resume(ThreadId thread_id);
void thread_resume(ThreadId threadId);
/** Get thread suspended state
*
* @param thread_id thread id
* @param[in] threadId thread id
* @return true if thread is suspended
*/
bool thread_is_suspended(ThreadId thread_id);
bool thread_is_suspended(ThreadId threadId);
/** Check if the thread was created with static memory
*
* @param thread_id thread id
* @param[in] threadId thread id
* @return true if thread memory is static
*/
bool thread_mark_is_static(ThreadId thread_id);
bool thread_mark_is_static(ThreadId threadId);
} // namespace