Embedded Wireless Framework
ewf_platform_pthread.h
Go to the documentation of this file.
1 /************************************************************************/
9 #ifndef __ewf_platform_pthread__h__included__
10 #define __ewf_platform_pthread__h__included__
11 
12 #include "ewf_platform.h"
13 
14 #ifndef EWF_PLATFORM_PTHREAD
15 #error EWF_PLATFORM_PTHREAD must be defined before including this file
16 #endif
17 
18 #include <pthread.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
24 /************************************************************************/
31 /************************************************************************/
39 #define EWF_PLATFORM_TICKS_PER_SECOND (1000)
40 
42 #define EWF_THREAD_PRIORITY_HIGH (THREAD_PRIORITY_ABOVE_NORMAL)
43 #define EWF_THREAD_PRIORITY_MEDIUM (THREAD_PRIORITY_NORMAL)
44 #define EWF_THREAD_PRIORITY_LOW (THREAD_PRIORITY_IDLE)
45 
46 /************************************************************************/
51 {
52  pthread_t thread;
53  pthread_attr_t attr;
54  ewf_platform_thread_function thread_function_ptr;
55  void* thread_function_data;
56  size_t stacksize;
57  int prio;
58 };
59 
60 #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) \
61 do { \
62 static ewf_platform_thread__##thread_name_symb = {0}; \
63 ewf_platform_pthread__##thread_name_symb.thread_function_ptr = thread_function_ptr_param; \
64 ewf_platform_pthread__##thread_name_symb.thread_function_data = thread_function_data_param; \
65 ewf_platform_pthread__##thread_name_symb.stacksize = stack_size_param; \
66 ewf_platform_pthread__##thread_name_symb.prio = thread_priority_param; \
67 thread_ptr = &(ewf_platform_pthread__##thread_name_symb); \
68 } while(0)
69 
71 {
72  pthread_mutex_t mutex;
73  pthread_mutexattr_t mutexattr;
74 };
75 
76 #define EWF_PLATFORM_MUTEX_STATIC_DECLARE(mutex_ptr, mutex_name_symb) \
77 do { \
78 static ewf_platform_mutex ewf_platform_mutex__##mutex_name_symb = {0}; \
79 mutex_ptr = &(ewf_platform_mutex__##mutex_name_symb); \
80 } while(0)
81 
83 {
84  pthread_mutex_t mutex;
85  pthread_mutexattr_t mutexattr;
86  void* data;
87  uint32_t item_size;
88  volatile uint32_t queue_size;
89  volatile uint32_t tail_index;
90  volatile uint32_t used_count;
91 };
92 
100 #define EWF_PLATFORM_QUEUE_STATIC_DECLARE(queue_ptr, queue_name_symb, item_type, item_count) \
101 do { \
102 static item_type ewf_platform_queue__data__##queue_name_symb[item_count]; \
103 static ewf_platform_queue ewf_platform_queue__##queue_name_symb = {0}; \
104 ewf_platform_queue__##queue_name_symb.data = ewf_platform_queue__data__##queue_name_symb; \
105 ewf_platform_queue__##queue_name_symb.item_size = sizeof(item_type); \
106 ewf_platform_queue__##queue_name_symb.queue_size = item_count; \
107 ewf_platform_queue__##queue_name_symb.tail_index = 0; \
108 ewf_platform_queue__##queue_name_symb.used_count = 0; \
109 queue_ptr = &(ewf_platform_queue__##queue_name_symb); \
110 } while(0)
111 
112 /************************************************************************/
116 #ifdef __cplusplus
117 }
118 #endif
119 
120 #endif /* __ewf_platform_pthread__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