Embedded Wireless Framework
ewf_platform_threadx.h
Go to the documentation of this file.
1 /************************************************************************/
9 #ifndef __ewf_platform_threadx__h__included__
10 #define __ewf_platform_threadx__h__included__
11 
12 #include "ewf_platform.h"
13 
14 #ifndef EWF_PLATFORM_THREADX
15 #error EWF_PLATFORM_THREADX must be defined before including this file
16 #endif
17 
18 #include "tx_api.h"
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 /************************************************************************/
31 /************************************************************************/
39 #ifndef EWF_PLATFORM_TICKS_PER_SECOND
41 #define EWF_PLATFORM_TICKS_PER_SECOND (TX_TIMER_TICKS_PER_SECOND)
42 #endif
43 
44 #ifndef EWF_PLATFORM_THREAD_PRIORITY_HIGH
46 #define EWF_PLATFORM_THREAD_PRIORITY_HIGH (1)
47 #endif
48 
49 #ifndef EWF_PLATFORM_THREAD_PRIORITY_MEDIUM
51 #define EWF_PLATFORM_THREAD_PRIORITY_MEDIUM (7)
52 #endif
53 
54 #ifndef EWF_PLATFORM_THREAD_PRIORITY_LOW
56 #define EWF_PLATFORM_THREAD_PRIORITY_LOW (15)
57 #endif
58 
59 /************************************************************************/
67 {
68  TX_THREAD thread;
69  CHAR* name_cstr;
70  ewf_platform_thread_function thread_function_ptr;
71  void* thread_function_data;
72  VOID* stack_ptr;
73  unsigned stack_size;
74  UINT priority;
75  UINT preempt_threshold;
76  ULONG time_slice;
77 };
78 
87 #define EWF_PLATFORM_THREAD_STATIC_DECLARE(thread_ptr, thread_name_symb, thread_function_ptr_param, thread_function_data_param, stack_size_param, thread_priority_param) \
88 do { \
89 static ULONG _ewf_platform_thread__stack__##thread_name_symb[stack_size_param / sizeof(ULONG)]; \
90 static struct _ewf_platform_thread _ewf_platform_thread__##thread_name_symb = {0}; \
91 _ewf_platform_thread__##thread_name_symb.name_cstr = #thread_name_symb; \
92 _ewf_platform_thread__##thread_name_symb.thread_function_ptr = thread_function_ptr_param; \
93 _ewf_platform_thread__##thread_name_symb.thread_function_data = thread_function_data_param; \
94 _ewf_platform_thread__##thread_name_symb.stack_ptr = _ewf_platform_thread__stack__##thread_name_symb; \
95 _ewf_platform_thread__##thread_name_symb.stack_size = stack_size_param; \
96 _ewf_platform_thread__##thread_name_symb.priority = thread_priority_param; \
97 _ewf_platform_thread__##thread_name_symb.preempt_threshold = thread_priority_param; \
98 _ewf_platform_thread__##thread_name_symb.time_slice = 1; \
99 thread_ptr = &(_ewf_platform_thread__##thread_name_symb); \
100 } while(0)
101 
105 struct _ewf_platform_mutex
106 {
107  /* Use a ThreadX binary semaphore for implementation! */
108  TX_SEMAPHORE sem;
109  CHAR * name_cstr;
110 };
111 
117 #define EWF_PLATFORM_MUTEX_STATIC_DECLARE(mutex_ptr, mutex_name_symb) \
118 do { \
119 static struct _ewf_platform_mutex _ewf_platform_mutex__##mutex_name_symb = {0}; \
120 _ewf_platform_mutex__##mutex_name_symb.name_cstr = #mutex_name_symb; \
121 mutex_ptr = &(_ewf_platform_mutex__##mutex_name_symb); \
122 } while(0)
123 
127 struct _ewf_platform_queue
128 {
129  TX_QUEUE queue;
130  CHAR* name_cstr;
131  UINT message_size;
132  VOID* queue_start;
133  ULONG queue_size;
134 };
135 
143 #define EWF_PLATFORM_QUEUE_STATIC_DECLARE(queue_ptr, queue_name_symb, item_type, item_count) \
144 do { \
145 static ULONG _ewf_platform_queue__buffer__##queue_name_symb[sizeof(item_type) * item_count]; \
146 static ewf_platform_queue _ewf_platform_queue__##queue_name_symb = {0}; \
147 _ewf_platform_queue__##queue_name_symb.name_cstr = #queue_name_symb; \
148 _ewf_platform_queue__##queue_name_symb.message_size = sizeof(item_type); \
149 _ewf_platform_queue__##queue_name_symb.queue_start = _ewf_platform_queue__buffer__##queue_name_symb; \
150 _ewf_platform_queue__##queue_name_symb.queue_size = sizeof(_ewf_platform_queue__buffer__##queue_name_symb); \
151 queue_ptr = &(_ewf_platform_queue__##queue_name_symb); \
152 } while(0)
153 
154 #ifdef __cplusplus
155 }
156 #endif
157 
158 #endif /* __ewf_platform_threadx__h__included__ */
The Embedded Wireless Framework Software Platform API.
The platform mutex structure.
Definition: ewf_platform_freertos.h:69
The platform queue structure.
Definition: ewf_platform_bare_metal.h:74
The platform thread structure.
Definition: ewf_platform_freertos.h:43