@@ -22,14 +22,10 @@ extern "C"
22
22
* @name ev_flags
23
23
* Event flags
24
24
*/
25
- #define EVENT_OP_AND 0 /** All event flags are required */
26
- #define EVENT_OP_OR 1 /** Not all event flags are required */
25
+ #define EVENT_OP_AND 0 /**< All event flags are required */
26
+ #define EVENT_OP_OR 1 /**< Not all event flags are required */
27
27
28
- /**
29
- * @name ev_wait
30
- */
31
- #define EVENT_WAIT_SUSPEND 0xFFFFFFFF /** Suspend task until requested flags are set */
32
- #define EVENT_NO_WAIT 0 /** Do not wait */
28
+ #define OS_WAIT_FOREVER (-1U) /**< Wait indefinitely */
33
29
34
30
/**
35
31
* Sleep Type
@@ -54,7 +50,7 @@ struct osmsg_t {
54
50
uint32_t message ; /**< Message ID */
55
51
uint32_t param1 ; /**< First parameter */
56
52
uint32_t param2 ; /**< Second parameter */
57
- int source_taskid ; /**< Filled automatically by os_get_message () */
53
+ int source_taskid ; /**< Filled automatically by @ref os_message_get () */
58
54
};
59
55
60
56
/**
@@ -82,7 +78,7 @@ void sys_setsleep_timeout(uint32_t ms);
82
78
/**
83
79
* Enter sleep mode
84
80
* @note only available on NBIoT Platforms
85
- * @param type [in] Type of sleep @a sleeptype_e
81
+ * @param type [in] Type of sleep @ref sleeptype_e
86
82
*/
87
83
void sys_setsleep (int type );
88
84
#endif
@@ -91,105 +87,111 @@ void sys_setsleep(int type);
91
87
* Task sleep API
92
88
* @param ms [in] time in milliseconds
93
89
*/
94
- void os_sleep (unsigned int ms );
90
+ void os_task_sleep (unsigned int ms );
95
91
96
92
/**
97
93
* Get message from task external queue
98
94
* @param msg [in] Pointer to OS message structure @ref osmsg_t
99
95
* @return 0 on success, negative value on error
100
96
*/
101
- int os_get_message (struct osmsg_t * msg );
97
+ int os_message_get (struct osmsg_t * msg );
102
98
103
99
/**
104
100
* Send message to a task external queue, Maximum number of messages are 30
105
- * OS will raise an assert if more than 30 messages are sent to task queue.
101
+ * @note on GSM Platform, an assert is raised if more than 30 messages are sent to task queue.
106
102
* @param dest_taskid [in] Destination task id
107
103
* @param message [in] Message ID
108
104
* @param param1 [in] Parameter 1
109
105
* @param param2 [in] Parameter 2
110
106
* @return 0 on success, negative value on error
111
107
*/
112
- int os_send_message (int dest_taskid , uint32_t message , uint32_t param1 , uint32_t param2 );
108
+ int os_message_send (int dest_taskid , uint32_t message , uint32_t param1 , uint32_t param2 );
113
109
114
110
/**
115
111
* Create a mutex
116
112
* Mutex created once cannot be destroyed.
117
- * @param name [in] Name for mutex (cannot be null)
118
113
* @return Mutex ID
119
114
*/
120
- uint32_t os_create_mutex ( const char * name );
115
+ uint32_t os_mutex_create ( void );
121
116
122
117
/**
123
118
* Take a mutex. If mutex is not available, Task will be suspended until mutex is available.
124
- * @param mutex [in] Mutex ID created by os_create_mutex()
119
+ * @param mutex [in] Mutex ID created by @ref os_mutex_create()
120
+ * @return 0 on success, negative value on error
121
+ */
122
+ int os_mutex_take (uint32_t mutex );
123
+
124
+ /**
125
+ * Try to take a mutex. This API is similar to @ref os_mutex_take() with a optional timeout
126
+ * @param mutex [in] Mutex ID created by @ref os_mutex_create()
127
+ * @param timeout [in] duration in ms to wait, @ref OS_WAIT_FOREVER for indefinite wait, 0 to return immediately
125
128
* @return 0 on success, negative value on error
126
129
*/
127
- int os_take_mutex (uint32_t mutex );
130
+ int os_mutex_trytake (uint32_t mutex , uint32_t timeout );
128
131
129
132
/**
130
133
* Release a mutex. Once a mutex is released, OS does not yield on waiting task. Task switch happens when executing task is suspended
131
134
* by sleep or waiting on external queue message.
132
- * @param mutex [in] Mutex ID created by os_create_mutex ()
135
+ * @param mutex [in] Mutex ID created by @ref os_mutex_create ()
133
136
* @return 0 on success, negative value on error
134
137
*/
135
- int os_give_mutex (uint32_t mutex );
138
+ int os_mutex_give (uint32_t mutex );
136
139
137
140
/**
138
141
* Create a semaphore
139
- * @param name [in] Name of semaphore (cannot be null), for debugging only.
140
142
* @param val [in] Initial value of semaphore
141
143
* @return Semaphore ID
142
144
*/
143
- uint32_t os_create_semaphore ( const char * name , int val );
145
+ uint32_t os_semaphore_create ( int val );
144
146
145
147
/**
146
148
* Take a semaphore. When semaphore is not available and wait is requested, task will be suspended until semaphore is available
147
- * @param sem [in] Semaphore ID created by os_create_semaphore()
148
- * @param wait [in] TRUE if wait for semaphore to be available, FALSE to return immediately
149
+ * @param sem [in] Semaphore ID created by @ref os_semaphore_create()
150
+ * @param timeout [in] duration in ms to timeout, @ref OS_WAIT_FOREVER for indefinite timeout, 0 to return immediately\n
151
+ * On GSM platforms, when timeout is non zero API blocks until semaphore is acquired
149
152
* @return 0 on success, negative value on error
150
153
*/
151
- int os_take_semaphore (uint32_t sem , int wait );
154
+ int os_semaphore_take (uint32_t sem , int timeout );
152
155
153
156
/**
154
157
* Give a semaphore.
155
- * @param sem [in] Semaphore ID created by os_create_semaphore ()
158
+ * @param sem [in] Semaphore ID created by @ref os_semaphore_create ()
156
159
* @return 0 on success, negative value on error
157
160
*/
158
- int os_give_semaphore (uint32_t sem );
161
+ int os_semaphore_give (uint32_t sem );
159
162
160
163
/**
161
164
* Create event group. Event group has 32 flags represented by each bit of a 32-bit word.
162
- * @param name [in] Name of event group (cannot be null).
163
165
* @return event group ID
164
166
*/
165
- uint32_t os_create_eventgroup ( const char * name );
167
+ uint32_t os_eventgroup_create ( void );
166
168
167
169
/**
168
170
* Set event in event group
169
171
* @param egid [in] Event group ID
170
172
* @param event_flags [in] Event flags to set. Each bit represents an event flags
171
173
* @return
172
174
*/
173
- int os_eg_setevent (uint32_t egid , uint32_t event_flags );
175
+ int os_eventgroup_setevent (uint32_t egid , uint32_t event_flags );
174
176
175
177
/**
176
178
* Wait for event flag to set
177
179
* @param egid [in] Event group id
178
- * @param event_flags [in] Requeted flags
180
+ * @param event_flags [in] Requested flags
179
181
* @return 0 on success, negative value on error
180
182
*/
181
- int os_eg_waitevent (uint32_t egid , uint32_t event_flags );
183
+ int os_eventgroup_waitevent (uint32_t egid , uint32_t event_flags );
182
184
183
185
/**
184
186
* Extended function for event flag wait
185
187
* @param egid [in] Event group ID
186
188
* @param req_flags [in] Requested flags
187
189
* @param op [in] Operation type ev_flags
188
190
* @param out_flags [out] Actual event flags available
189
- * @param timeout [in] Timeout in milliseconds or one of the ev_wait flags
191
+ * @param timeout [in] Timeout in milliseconds or @ref OS_WAIT_FOREVER to wait until an event is raised
190
192
* @return 0 on success, negative value on error
191
193
*/
192
- int os_eg_waiteventex (uint32_t egid , uint32_t req_flags , int op , uint32_t * out_flags , uint32_t timeout );
194
+ int os_eventgroup_waiteventex (uint32_t egid , uint32_t req_flags , int op , uint32_t * out_flags , uint32_t timeout );
193
195
194
196
/**
195
197
* Get available stack size of running task
@@ -201,7 +203,7 @@ uint32_t os_task_getavailstack(void);
201
203
* Get task id of running task
202
204
* @return Returns task id
203
205
*/
204
- uint32_t os_get_currtaskid (void );
206
+ uint32_t os_task_getid (void );
205
207
206
208
/**
207
209
* Create a new OS task, Maximum 10 tasks can be created
@@ -210,7 +212,7 @@ uint32_t os_get_currtaskid(void);
210
212
* @param suspend [in] TRUE will suspend the task on creation, FALSE otherwise. Suspended task can be started later by calling os_start_task()
211
213
* @return On success task ID is returned, -1 on error.
212
214
*/
213
- int os_create_task (os_taskfn_f fn , void * arg , int suspend );
215
+ int os_task_create (os_taskfn_f fn , void * arg , int suspend );
214
216
215
217
#if defined(SOC_RDA8910 ) || defined(PLATFORM_BC20 ) || defined(_DOXYGEN_ )
216
218
/**
@@ -222,10 +224,10 @@ int os_create_task(os_taskfn_f fn, void *arg, int suspend);
222
224
* @param suspend [in] TRUE will suspend the task on creation, FALSE otherwise. Suspended task can be started later by calling os_start_task()
223
225
* @return On success task ID is returned, -1 on error.
224
226
*/
225
- int os_create_taskex (os_taskfn_f fn , uint32_t stack , void * arg , int suspend );
227
+ int os_task_create_ex (os_taskfn_f fn , uint32_t stack , void * arg , int suspend );
226
228
227
229
/**
228
- * Start a task created by os_create_task()/os_create_taskex ()
230
+ * Start a task created by @ref os_task_create() /@ref os_task_create_ex ()
229
231
* @note only available on NBIoT Platforms
230
232
* @param taskid [in] Task ID
231
233
* @return 0 on success, negative value on error
@@ -240,17 +242,17 @@ uint64_t os_get_tickms(void);
240
242
241
243
/**
242
244
* Get OS tick/uptime in microseconds
243
- * @return tick counter in microseonds
245
+ * @return tick counter in microseconds
244
246
*/
245
247
uint64_t os_get_tickus (void );
246
248
#endif
247
249
248
250
/**
249
- * Start a task created by os_create_task ()
251
+ * Start a task created by @ref os_task_create ()
250
252
* @param taskid [in] Task ID
251
253
* @return 0 on success, negative value on error
252
254
*/
253
- int os_start_task (int taskid );
255
+ int os_task_start (int taskid );
254
256
255
257
/**
256
258
* Enter critical section
@@ -260,7 +262,7 @@ uint32_t os_enter_critical(void);
260
262
261
263
/**
262
264
* Exit critical section
263
- * @param flags [in] IRQ flags from os_enter_critical()
265
+ * @param flags [in] IRQ flags from @ref os_enter_critical()
264
266
*/
265
267
void os_exit_critical (uint32_t flags );
266
268
0 commit comments