Skip to content

Commit f76a192

Browse files
authored
Merge pull request #5040 from yangjie11/comments
[kernel]Normalized kernel API annotation
2 parents 673718c + fe5d506 commit f76a192

File tree

8 files changed

+444
-260
lines changed

8 files changed

+444
-260
lines changed

src/device.c

Lines changed: 60 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,13 @@
3939
#endif /* RT_USING_DEVICE_OPS */
4040

4141
/**
42-
* This function registers a device driver with specified name.
42+
* @brief This function registers a device driver with a specified name.
4343
*
44-
* @param dev the pointer of device driver structure
45-
* @param name the device driver's name
46-
* @param flags the capabilities flag of device
44+
* @param dev is the pointer of device driver structure.
45+
*
46+
* @param name is the device driver's name.
47+
*
48+
* @param flags is the capabilities flag of device.
4749
*
4850
* @return the error code, RT_EOK on initialization successfully.
4951
*/
@@ -72,9 +74,9 @@ rt_err_t rt_device_register(rt_device_t dev,
7274
RTM_EXPORT(rt_device_register);
7375

7476
/**
75-
* This function removes a previously registered device driver
77+
* @brief This function removes a previously registered device driver.
7678
*
77-
* @param dev the pointer of device driver structure
79+
* @param dev is the pointer of device driver structure.
7880
*
7981
* @return the error code, RT_EOK on successfully.
8082
*/
@@ -91,9 +93,9 @@ rt_err_t rt_device_unregister(rt_device_t dev)
9193
RTM_EXPORT(rt_device_unregister);
9294

9395
/**
94-
* This function finds a device driver by specified name.
96+
* @brief This function finds a device driver by specified name.
9597
*
96-
* @param name the device driver's name
98+
* @param name is the device driver's name.
9799
*
98100
* @return the registered device driver on successful, or RT_NULL on failure.
99101
*/
@@ -105,10 +107,11 @@ RTM_EXPORT(rt_device_find);
105107

106108
#ifdef RT_USING_HEAP
107109
/**
108-
* This function creates a device object with user data size.
110+
* @brief This function creates a device object with user data size.
109111
*
110-
* @param type, the kind type of this device object.
111-
* @param attach_size, the size of user data.
112+
* @param type is the type of the device object.
113+
*
114+
* @param attach_size is the size of user data.
112115
*
113116
* @return the allocated device object, or RT_NULL when failed.
114117
*/
@@ -134,9 +137,9 @@ rt_device_t rt_device_create(int type, int attach_size)
134137
RTM_EXPORT(rt_device_create);
135138

136139
/**
137-
* This function destroy the specific device object.
140+
* @brief This function destroy the specific device object.
138141
*
139-
* @param dev, the specific device object.
142+
* @param dev is a specific device object.
140143
*/
141144
void rt_device_destroy(rt_device_t dev)
142145
{
@@ -153,11 +156,11 @@ RTM_EXPORT(rt_device_destroy);
153156
#endif /* RT_USING_HEAP */
154157

155158
/**
156-
* This function will initialize the specified device
159+
* @brief This function will initialize the specified device.
157160
*
158-
* @param dev the pointer of device driver structure
161+
* @param dev is the pointer of device driver structure.
159162
*
160-
* @return the result
163+
* @return the result, RT_EOK on successfully.
161164
*/
162165
rt_err_t rt_device_init(rt_device_t dev)
163166
{
@@ -187,12 +190,13 @@ rt_err_t rt_device_init(rt_device_t dev)
187190
}
188191

189192
/**
190-
* This function will open a device
193+
* @brief This function will open a device.
194+
*
195+
* @param dev is the pointer of device driver structure.
191196
*
192-
* @param dev the pointer of device driver structure
193-
* @param oflag the flags for device open
197+
* @param oflag is the flags for device open.
194198
*
195-
* @return the result
199+
* @return the result, RT_EOK on successfully.
196200
*/
197201
rt_err_t rt_device_open(rt_device_t dev, rt_uint16_t oflag)
198202
{
@@ -253,11 +257,11 @@ rt_err_t rt_device_open(rt_device_t dev, rt_uint16_t oflag)
253257
RTM_EXPORT(rt_device_open);
254258

255259
/**
256-
* This function will close a device
260+
* @brief This function will close a device.
257261
*
258-
* @param dev the pointer of device driver structure
262+
* @param dev is the pointer of device driver structure.
259263
*
260-
* @return the result
264+
* @return the result, RT_EOK on successfully.
261265
*/
262266
rt_err_t rt_device_close(rt_device_t dev)
263267
{
@@ -289,12 +293,15 @@ rt_err_t rt_device_close(rt_device_t dev)
289293
RTM_EXPORT(rt_device_close);
290294

291295
/**
292-
* This function will read some data from a device.
296+
* @brief This function will read some data from a device.
297+
*
298+
* @param dev is the pointer of device driver structure.
299+
*
300+
* @param pos is the position when reading.
301+
*
302+
* @param buffer is a data buffer to save the read data.
293303
*
294-
* @param dev the pointer of device driver structure
295-
* @param pos the position of reading
296-
* @param buffer the data buffer to save read data
297-
* @param size the size of buffer
304+
* @param size is the size of buffer.
298305
*
299306
* @return the actually read size on successful, otherwise negative returned.
300307
*
@@ -328,12 +335,15 @@ rt_size_t rt_device_read(rt_device_t dev,
328335
RTM_EXPORT(rt_device_read);
329336

330337
/**
331-
* This function will write some data to a device.
338+
* @brief This function will write some data to a device.
332339
*
333-
* @param dev the pointer of device driver structure
334-
* @param pos the position of written
335-
* @param buffer the data buffer to be written to device
336-
* @param size the size of buffer
340+
* @param dev is the pointer of device driver structure.
341+
*
342+
* @param pos is the position when writing.
343+
*
344+
* @param buffer is the data buffer to be written to device.
345+
*
346+
* @param size is the size of buffer.
337347
*
338348
* @return the actually written size on successful, otherwise negative returned.
339349
*
@@ -367,13 +377,15 @@ rt_size_t rt_device_write(rt_device_t dev,
367377
RTM_EXPORT(rt_device_write);
368378

369379
/**
370-
* This function will perform a variety of control functions on devices.
380+
* @brief This function will perform a variety of control functions on devices.
381+
*
382+
* @param dev is the pointer of device driver structure.
371383
*
372-
* @param dev the pointer of device driver structure
373-
* @param cmd the command sent to device
374-
* @param arg the argument of command
384+
* @param cmd is the command sent to device.
375385
*
376-
* @return the result
386+
* @param arg is the argument of command.
387+
*
388+
* @return the result, -RT_ENOSYS for failed.
377389
*/
378390
rt_err_t rt_device_control(rt_device_t dev, int cmd, void *arg)
379391
{
@@ -391,11 +403,12 @@ rt_err_t rt_device_control(rt_device_t dev, int cmd, void *arg)
391403
RTM_EXPORT(rt_device_control);
392404

393405
/**
394-
* This function will set the reception indication callback function. This callback function
395-
* is invoked when this device receives data.
406+
* @brief This function will set the reception indication callback function. This callback function
407+
* is invoked when this device receives data.
408+
*
409+
* @param dev is the pointer of device driver structure.
396410
*
397-
* @param dev the pointer of device driver structure
398-
* @param rx_ind the indication callback function
411+
* @param rx_ind is the indication callback function.
399412
*
400413
* @return RT_EOK
401414
*/
@@ -413,11 +426,12 @@ rt_device_set_rx_indicate(rt_device_t dev,
413426
RTM_EXPORT(rt_device_set_rx_indicate);
414427

415428
/**
416-
* This function will set the indication callback function when device has
417-
* written data to physical hardware.
429+
* @brief This function will set a callback function. The callback function
430+
* will be called when device has written data to physical hardware.
431+
*
432+
* @param dev is the pointer of device driver structure.
418433
*
419-
* @param dev the pointer of device driver structure
420-
* @param tx_done the indication callback function
434+
* @param tx_done is the indication callback function.
421435
*
422436
* @return RT_EOK
423437
*/

src/idle.c

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,13 @@ static struct rt_semaphore system_sem;
6868
static void (*idle_hook_list[RT_IDLE_HOOK_LIST_SIZE])(void);
6969

7070
/**
71-
* @ingroup Hook
72-
* This function sets a hook function to idle thread loop. When the system performs
73-
* idle loop, this hook function should be invoked.
71+
* @brief This function sets a hook function to idle thread loop. When the system performs
72+
* idle loop, this hook function should be invoked.
7473
*
75-
* @param hook the specified hook function
74+
* @param hook the specified hook function.
7675
*
77-
* @return RT_EOK: set OK
78-
* -RT_EFULL: hook list is full
76+
* @return RT_EOK: set OK.
77+
* -RT_EFULL: hook list is full.
7978
*
8079
* @note the hook function must be simple and never be blocked or suspend.
8180
*/
@@ -104,12 +103,12 @@ rt_err_t rt_thread_idle_sethook(void (*hook)(void))
104103
}
105104

106105
/**
107-
* delete the idle hook on hook list
106+
* @brief delete the idle hook on hook list.
108107
*
109-
* @param hook the specified hook function
108+
* @param hook the specified hook function.
110109
*
111-
* @return RT_EOK: delete OK
112-
* -RT_ENOSYS: hook was not found
110+
* @return RT_EOK: delete OK.
111+
* -RT_ENOSYS: hook was not found.
113112
*/
114113
rt_err_t rt_thread_idle_delhook(void (*hook)(void))
115114
{
@@ -153,8 +152,10 @@ rt_inline int _idle_has_defunct_thread(void)
153152
}
154153
#endif /* RT_USING_MODULE */
155154

156-
/* enqueue a thread to defunct queue
157-
* it must be called between rt_hw_interrupt_disable and rt_hw_interrupt_enable
155+
/**
156+
* @brief Enqueue a thread to defunct queue.
157+
*
158+
* @note It must be called between rt_hw_interrupt_disable and rt_hw_interrupt_enable
158159
*/
159160
void rt_thread_defunct_enqueue(rt_thread_t thread)
160161
{
@@ -164,8 +165,10 @@ void rt_thread_defunct_enqueue(rt_thread_t thread)
164165
#endif
165166
}
166167

167-
/* dequeue a thread from defunct queue
168-
* it must be called between rt_hw_interrupt_disable and rt_hw_interrupt_enable
168+
/**
169+
* @brief Dequeue a thread from defunct queue.
170+
*
171+
* @note It must be called between rt_hw_interrupt_disable and rt_hw_interrupt_enable.
169172
*/
170173
rt_thread_t rt_thread_defunct_dequeue(void)
171174
{
@@ -183,9 +186,7 @@ rt_thread_t rt_thread_defunct_dequeue(void)
183186
}
184187

185188
/**
186-
* @ingroup Thread
187-
*
188-
* This function will perform system background job when system idle.
189+
* @brief This function will perform system background job when system idle.
189190
*/
190191
static void rt_defunct_execute(void)
191192
{
@@ -316,9 +317,7 @@ static void rt_thread_system_entry(void *parameter)
316317
#endif
317318

318319
/**
319-
* @ingroup SystemInit
320-
*
321-
* This function will initialize idle thread, then start it.
320+
* @brief This function will initialize idle thread, then start it.
322321
*
323322
* @note this function must be invoked when system init.
324323
*/
@@ -365,10 +364,7 @@ void rt_thread_idle_init(void)
365364
}
366365

367366
/**
368-
* @ingroup Thread
369-
*
370-
* This function will get the handler of the idle thread.
371-
*
367+
* @brief This function will get the handler of the idle thread.
372368
*/
373369
rt_thread_t rt_thread_idle_gethandler(void)
374370
{

0 commit comments

Comments
 (0)