11/*
22 * Copyright (c) 2014-2016, Freescale Semiconductor, Inc.
33 * Copyright 2016-2020 NXP
4+ * Copyright 2021 ACRIOS Systems s.r.o.
45 * All rights reserved.
56 *
67 *
@@ -70,14 +71,19 @@ class Thread
7071public:
7172 // ! @brief Unique identifier for a thread.
7273 typedef void *thread_id_t ;
74+ #if ERPC_THREADS_IS(FREERTOS)
75+ typedef StackType_t *thread_stack_pointer;
76+ #else
77+ typedef void *thread_stack_pointer;
78+ #endif
7379
7480 /* !
7581 * @brief Default constructor for use with the init() method.
7682 *
7783 * If this constructor is used, the init() method must be called before the thread can be
7884 * started.
7985 *
80- * @param name Optional name for the thread.
86+ * @param[in] name Optional name for the thread.
8187 */
8288 Thread (const char *name = 0 );
8389
@@ -86,12 +92,14 @@ class Thread
8692 *
8793 * This constructor fully initializes the thread object.
8894 *
89- * @param entry
90- * @param priority
91- * @param stackSize
92- * @param name Optional name for the thread.
95+ * @param[in] entry
96+ * @param[in] priority
97+ * @param[in] stackSize
98+ * @param[in] name Optional name for the thread.
99+ * @param[in] stackPtr Mandatory task stack pointer for static api usage.
93100 */
94- Thread (thread_entry_t entry, uint32_t priority = 0 , uint32_t stackSize = 0 , const char *name = 0 );
101+ Thread (thread_entry_t entry, uint32_t priority = 0 , uint32_t stackSize = 0 , const char *name = 0 ,
102+ thread_stack_pointer stackPtr = 0 );
95103
96104 /* !
97105 * @brief Destructor.
@@ -118,8 +126,9 @@ class Thread
118126 * @param[in] entry Entry function.
119127 * @param[in] priority Task priority.
120128 * @param[in] stackSize Stack size.
129+ * @param[in] stackPtr Mandatory task stack pointer for static api usage.
121130 */
122- void init (thread_entry_t entry, uint32_t priority = 0 , uint32_t stackSize = 0 );
131+ void init (thread_entry_t entry, uint32_t priority = 0 , uint32_t stackSize = 0 , thread_stack_pointer stackPtr = 0 );
123132
124133 /* !
125134 * @brief This function starts thread execution.
@@ -152,7 +161,7 @@ class Thread
152161 return reinterpret_cast <thread_id_t >(m_thread->get_id ());
153162#elif ERPC_THREADS_IS(WIN32)
154163 return reinterpret_cast <thread_id_t >(m_thread);
155- #elif ERPC_THREADS_IS(THREADX)
164+ #elif ERPC_THREADS_IS(THREADX)
156165 return reinterpret_cast <thread_id_t >(m_thread.tx_thread_id );
157166#endif
158167 }
@@ -212,18 +221,22 @@ class Thread
212221 virtual void threadEntryPoint (void );
213222
214223private:
215- const char *m_name; /* !< Thread name. */
216- thread_entry_t m_entry; /* !< Thread entry function. */
217- void *m_arg; /* !< Entry parameter. */
218- uint32_t m_stackSize; /* !< Stack size. */
219- uint32_t m_priority; /* !< Task priority. */
224+ const char *m_name; /* !< Thread name. */
225+ thread_entry_t m_entry; /* !< Thread entry function. */
226+ void *m_arg; /* !< Entry parameter. */
227+ uint32_t m_stackSize; /* !< Stack size. */
228+ uint32_t m_priority; /* !< Task priority. */
229+ thread_stack_pointer m_stackPtr; /* !< Task pointer. */
220230#if ERPC_THREADS_IS(PTHREADS)
221231 static pthread_key_t s_threadObjectKey; /* !< Thread key. */
222232 pthread_t m_thread; /* !< Current thread. */
223233#elif ERPC_THREADS_IS(FREERTOS)
224- TaskHandle_t m_task; /* !< Current task. */
225- Thread *m_next; /* !< Pointer to next Thread. */
226- static Thread *s_first; /* !< Pointer to first Thread. */
234+ TaskHandle_t m_task; /* !< Current task. */
235+ Thread *m_next; /* !< Pointer to next Thread. */
236+ static Thread *s_first; /* !< Pointer to first Thread. */
237+ #if ERPC_ALLOCATION_POLICY == ERPC_ALLOCATION_POLICY_STATIC
238+ StaticTask_t m_staticTask; /* !< Hold static task data. */
239+ #endif
227240#elif ERPC_THREADS_IS(ZEPHYR)
228241 struct k_thread m_thread; /* !< Current thread. */
229242 k_thread_stack_t *m_stack; /* !< Pointer to stack. */
@@ -238,7 +251,7 @@ class Thread
238251 static Thread *s_first; /* !< Pointer to first Thread. */
239252 static CRITICAL_SECTION m_critical_section;
240253 static BOOL m_critical_section_inited;
241- #elif ERPC_THREADS_IS(THREADX)
254+ #elif ERPC_THREADS_IS(THREADX)
242255 TX_THREAD m_thread; /* !< Underlying Thread instance */
243256 Thread *m_next; /* !< Pointer to next Thread. */
244257 static Thread *s_first; /* !< Pointer to first Thread. */
@@ -397,7 +410,8 @@ class Mutex
397410#if ERPC_THREADS_IS(PTHREADS)
398411 pthread_mutex_t m_mutex; /* !< Mutex.*/
399412#elif ERPC_THREADS_IS(FREERTOS)
400- SemaphoreHandle_t m_mutex; /* !< Mutex.*/
413+ SemaphoreHandle_t m_mutex; /* !< Mutex.*/
414+ StaticSemaphore_t m_staticQueue; /* !< Static queue. */
401415#elif ERPC_THREADS_IS(ZEPHYR)
402416 struct k_mutex m_mutex; /* !< Mutex.*/
403417#elif ERPC_THREADS_IS(MBED)
@@ -484,7 +498,8 @@ class Semaphore
484498 until some predicate on shared data is satisfied. */
485499 Mutex m_mutex; /* !< Mutext. */
486500#elif ERPC_THREADS_IS(FREERTOS)
487- SemaphoreHandle_t m_sem; /* !< Semaphore. */
501+ SemaphoreHandle_t m_sem; /* !< Semaphore. */
502+ StaticSemaphore_t m_staticQueue; /* !< Static queue. */
488503#elif ERPC_THREADS_IS(ZEPHYR)
489504 struct k_sem m_sem; /* !< Semaphore. */
490505#elif ERPC_THREADS_IS(MBED)
0 commit comments