Skip to content

Commit e0f990c

Browse files
committed
include: Update OS API
Signed-off-by: Ajay Bhargav <[email protected]>
1 parent 3240c94 commit e0f990c

File tree

1 file changed

+43
-41
lines changed

1 file changed

+43
-41
lines changed

include/os_api.h

Lines changed: 43 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,10 @@ extern "C"
2222
* @name ev_flags
2323
* Event flags
2424
*/
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 */
2727

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 */
3329

3430
/**
3531
* Sleep Type
@@ -54,7 +50,7 @@ struct osmsg_t {
5450
uint32_t message; /**< Message ID */
5551
uint32_t param1; /**< First parameter */
5652
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() */
5854
};
5955

6056
/**
@@ -82,7 +78,7 @@ void sys_setsleep_timeout(uint32_t ms);
8278
/**
8379
* Enter sleep mode
8480
* @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
8682
*/
8783
void sys_setsleep(int type);
8884
#endif
@@ -91,105 +87,111 @@ void sys_setsleep(int type);
9187
* Task sleep API
9288
* @param ms [in] time in milliseconds
9389
*/
94-
void os_sleep(unsigned int ms);
90+
void os_task_sleep(unsigned int ms);
9591

9692
/**
9793
* Get message from task external queue
9894
* @param msg [in] Pointer to OS message structure @ref osmsg_t
9995
* @return 0 on success, negative value on error
10096
*/
101-
int os_get_message(struct osmsg_t *msg);
97+
int os_message_get(struct osmsg_t *msg);
10298

10399
/**
104100
* 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.
106102
* @param dest_taskid [in] Destination task id
107103
* @param message [in] Message ID
108104
* @param param1 [in] Parameter 1
109105
* @param param2 [in] Parameter 2
110106
* @return 0 on success, negative value on error
111107
*/
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);
113109

114110
/**
115111
* Create a mutex
116112
* Mutex created once cannot be destroyed.
117-
* @param name [in] Name for mutex (cannot be null)
118113
* @return Mutex ID
119114
*/
120-
uint32_t os_create_mutex(const char *name);
115+
uint32_t os_mutex_create(void);
121116

122117
/**
123118
* 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
125128
* @return 0 on success, negative value on error
126129
*/
127-
int os_take_mutex(uint32_t mutex);
130+
int os_mutex_trytake(uint32_t mutex, uint32_t timeout);
128131

129132
/**
130133
* Release a mutex. Once a mutex is released, OS does not yield on waiting task. Task switch happens when executing task is suspended
131134
* 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()
133136
* @return 0 on success, negative value on error
134137
*/
135-
int os_give_mutex(uint32_t mutex);
138+
int os_mutex_give(uint32_t mutex);
136139

137140
/**
138141
* Create a semaphore
139-
* @param name [in] Name of semaphore (cannot be null), for debugging only.
140142
* @param val [in] Initial value of semaphore
141143
* @return Semaphore ID
142144
*/
143-
uint32_t os_create_semaphore(const char *name, int val);
145+
uint32_t os_semaphore_create(int val);
144146

145147
/**
146148
* 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
149152
* @return 0 on success, negative value on error
150153
*/
151-
int os_take_semaphore(uint32_t sem, int wait);
154+
int os_semaphore_take(uint32_t sem, int timeout);
152155

153156
/**
154157
* 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()
156159
* @return 0 on success, negative value on error
157160
*/
158-
int os_give_semaphore(uint32_t sem);
161+
int os_semaphore_give(uint32_t sem);
159162

160163
/**
161164
* 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).
163165
* @return event group ID
164166
*/
165-
uint32_t os_create_eventgroup(const char *name);
167+
uint32_t os_eventgroup_create(void);
166168

167169
/**
168170
* Set event in event group
169171
* @param egid [in] Event group ID
170172
* @param event_flags [in] Event flags to set. Each bit represents an event flags
171173
* @return
172174
*/
173-
int os_eg_setevent(uint32_t egid, uint32_t event_flags);
175+
int os_eventgroup_setevent(uint32_t egid, uint32_t event_flags);
174176

175177
/**
176178
* Wait for event flag to set
177179
* @param egid [in] Event group id
178-
* @param event_flags [in] Requeted flags
180+
* @param event_flags [in] Requested flags
179181
* @return 0 on success, negative value on error
180182
*/
181-
int os_eg_waitevent(uint32_t egid, uint32_t event_flags);
183+
int os_eventgroup_waitevent(uint32_t egid, uint32_t event_flags);
182184

183185
/**
184186
* Extended function for event flag wait
185187
* @param egid [in] Event group ID
186188
* @param req_flags [in] Requested flags
187189
* @param op [in] Operation type ev_flags
188190
* @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
190192
* @return 0 on success, negative value on error
191193
*/
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);
193195

194196
/**
195197
* Get available stack size of running task
@@ -201,7 +203,7 @@ uint32_t os_task_getavailstack(void);
201203
* Get task id of running task
202204
* @return Returns task id
203205
*/
204-
uint32_t os_get_currtaskid(void);
206+
uint32_t os_task_getid(void);
205207

206208
/**
207209
* Create a new OS task, Maximum 10 tasks can be created
@@ -210,7 +212,7 @@ uint32_t os_get_currtaskid(void);
210212
* @param suspend [in] TRUE will suspend the task on creation, FALSE otherwise. Suspended task can be started later by calling os_start_task()
211213
* @return On success task ID is returned, -1 on error.
212214
*/
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);
214216

215217
#if defined(SOC_RDA8910) || defined(PLATFORM_BC20) || defined(_DOXYGEN_)
216218
/**
@@ -222,10 +224,10 @@ int os_create_task(os_taskfn_f fn, void *arg, int suspend);
222224
* @param suspend [in] TRUE will suspend the task on creation, FALSE otherwise. Suspended task can be started later by calling os_start_task()
223225
* @return On success task ID is returned, -1 on error.
224226
*/
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);
226228

227229
/**
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()
229231
* @note only available on NBIoT Platforms
230232
* @param taskid [in] Task ID
231233
* @return 0 on success, negative value on error
@@ -240,17 +242,17 @@ uint64_t os_get_tickms(void);
240242

241243
/**
242244
* Get OS tick/uptime in microseconds
243-
* @return tick counter in microseonds
245+
* @return tick counter in microseconds
244246
*/
245247
uint64_t os_get_tickus(void);
246248
#endif
247249

248250
/**
249-
* Start a task created by os_create_task()
251+
* Start a task created by @ref os_task_create()
250252
* @param taskid [in] Task ID
251253
* @return 0 on success, negative value on error
252254
*/
253-
int os_start_task(int taskid);
255+
int os_task_start(int taskid);
254256

255257
/**
256258
* Enter critical section
@@ -260,7 +262,7 @@ uint32_t os_enter_critical(void);
260262

261263
/**
262264
* Exit critical section
263-
* @param flags [in] IRQ flags from os_enter_critical()
265+
* @param flags [in] IRQ flags from @ref os_enter_critical()
264266
*/
265267
void os_exit_critical(uint32_t flags);
266268

0 commit comments

Comments
 (0)