From 600d8e7c02c117677c04c4cbe012561081ceb207 Mon Sep 17 00:00:00 2001 From: Caio DaSilva Date: Mon, 16 Mar 2026 10:13:29 -0400 Subject: [PATCH] add thread sleep wrapper --- threadX/inc/u_tx_threads.h | 11 +++++++++++ threadX/src/u_tx_threads.c | 7 +++++++ 2 files changed, 18 insertions(+) diff --git a/threadX/inc/u_tx_threads.h b/threadX/inc/u_tx_threads.h index 4a502dd9..2b822010 100644 --- a/threadX/inc/u_tx_threads.h +++ b/threadX/inc/u_tx_threads.h @@ -24,6 +24,17 @@ typedef struct { TX_THREAD _TX_THREAD; } thread_t; +/* Creates a thread based on the provided configuration. + * + * @param byte_pool Pointer to the byte pool to allocate the thread's stack from. + * @param thread Pointer to a thread_t struct containing the thread's configuration. + * @return U_SUCCESS if the thread was created successfully, U_ERROR otherwise. + */ uint8_t create_thread(TX_BYTE_POOL *byte_pool, thread_t *thread); +/** + * Sleeps the current thread for the specified number of milliseconds. + */ +uint8_t thread_sleep_ms(uint32_t ms); + #endif \ No newline at end of file diff --git a/threadX/src/u_tx_threads.c b/threadX/src/u_tx_threads.c index 2adf2407..8226bb74 100644 --- a/threadX/src/u_tx_threads.c +++ b/threadX/src/u_tx_threads.c @@ -1,6 +1,7 @@ #include "u_tx_threads.h" #include "u_tx_debug.h" +#include "u_tx_general.h" // clang-format off @@ -27,4 +28,10 @@ uint8_t create_thread(TX_BYTE_POOL *byte_pool, thread_t *thread) return U_SUCCESS; } +uint8_t thread_sleep_ms(uint32_t ms) +{ + tx_thread_sleep(MS_TO_TICKS(ms)); + return U_SUCCESS; +} + // clang-format on \ No newline at end of file