Skip to content

Commit cef9709

Browse files
supperthomasrcitach
authored andcommitted
[doxygen] add driver example for doxygen (RT-Thread#9446)
1 parent 3eeaab1 commit cef9709

File tree

6 files changed

+316
-41
lines changed

6 files changed

+316
-41
lines changed

.github/workflows/doxygen.yml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,13 @@ on:
33
# Runs at 16:00 UTC (BeiJing 00:00) on the 30st of every month
44
schedule:
55
- cron: '0 16 30 * *'
6-
push:
7-
branches:
8-
- master
9-
paths-ignore:
10-
- '**/README.md'
11-
- '**/README_zh.md'
12-
pull_request:
13-
branches:
14-
- master
15-
paths-ignore:
16-
- bsp/**
17-
- examples/**
18-
- .github/**
19-
- '**/README.md'
20-
- '**/README_zh.md'
6+
workflow_dispatch:
217

228
jobs:
239
build:
2410
runs-on: ubuntu-latest
2511
name: doxygen_doc generate
26-
if: github.repository_owner == 'RT-Thread' && false
12+
if: github.repository_owner == 'RT-Thread'
2713
steps:
2814
- uses: actions/checkout@v4
2915
with:

components/drivers/include/drivers/dev_can.h

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,16 @@ enum CANBAUD
6363
#define RT_CAN_MODE_PRIV 0x01
6464
#define RT_CAN_MODE_NOPRIV 0x00
6565

66-
/** @defgroup CAN_receive_FIFO_number CAN Receive FIFO Number
67-
* @{
68-
*/
66+
/**
67+
* @addtogroup Drivers RTTHREAD Driver
68+
* @defgroup CAN_Device CAN Driver
69+
* @ingroup Drivers
70+
*/
71+
72+
/*!
73+
* @addtogroup CAN_Device
74+
* @{
75+
*/
6976
#define CAN_RX_FIFO0 (0x00000000U) /*!< CAN receive FIFO 0 */
7077
#define CAN_RX_FIFO1 (0x00000001U) /*!< CAN receive FIFO 1 */
7178

@@ -360,5 +367,8 @@ rt_err_t rt_hw_can_register(struct rt_can_device *can,
360367
const struct rt_can_ops *ops,
361368
void *data);
362369
void rt_hw_can_isr(struct rt_can_device *can, int event);
363-
#endif /*__DEV_CAN_H*/
364370

371+
/*! @}
372+
*/
373+
374+
#endif /*__DEV_CAN_H*/

components/drivers/include/drivers/dev_serial.h

Lines changed: 128 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2024, RT-Thread Development Team
2+
* Copyright (c) 2006-2024 RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -15,7 +15,105 @@
1515
#define __DEV_SERIAL_H__
1616

1717
#include <rtthread.h>
18+
/**
19+
* @addtogroup Drivers RTTHREAD Driver
20+
* @defgroup Serial Serial
21+
*
22+
* @brief Serial driver api
23+
*
24+
* <b>Example</b>
25+
* @code {.c}
26+
*
27+
* #include <rtthread.h>
28+
*
29+
* #define SAMPLE_UART_NAME "uart2"
30+
* static struct rt_semaphore rx_sem;
31+
* static rt_device_t serial;
32+
*
33+
* static rt_err_t uart_input(rt_device_t dev, rt_size_t size)
34+
* {
35+
*
36+
* rt_sem_release(&rx_sem);
37+
*
38+
* return RT_EOK;
39+
* }
40+
*
41+
* static void serial_thread_entry(void *parameter)
42+
* {
43+
* char ch;
44+
*
45+
* while (1)
46+
* {
47+
*
48+
* while (rt_device_read(serial, -1, &ch, 1) != 1)
49+
* {
50+
*
51+
* rt_sem_take(&rx_sem, RT_WAITING_FOREVER);
52+
* }
53+
*
54+
* ch = ch + 1;
55+
* rt_device_write(serial, 0, &ch, 1);
56+
* }
57+
* }
58+
*
59+
* static int uart_sample(int argc, char *argv[])
60+
* {
61+
* rt_err_t ret = RT_EOK;
62+
* char uart_name[RT_NAME_MAX];
63+
* char str[] = "hello RT-Thread!\r\n";
64+
*
65+
* if (argc == 2)
66+
* {
67+
* rt_strncpy(uart_name, argv[1], RT_NAME_MAX);
68+
* }
69+
* else
70+
* {
71+
* rt_strncpy(uart_name, SAMPLE_UART_NAME, RT_NAME_MAX);
72+
* }
73+
*
74+
*
75+
* serial = rt_device_find(uart_name);
76+
* if (!serial)
77+
* {
78+
* rt_kprintf("find %s failed!\n", uart_name);
79+
* return RT_ERROR;
80+
* }
81+
*
82+
*
83+
* rt_sem_init(&rx_sem, "rx_sem", 0, RT_IPC_FLAG_FIFO);
84+
*
85+
* rt_device_open(serial, RT_DEVICE_FLAG_INT_RX);
86+
*
87+
* rt_device_set_rx_indicate(serial, uart_input);
88+
*
89+
* rt_device_write(serial, 0, str, (sizeof(str) - 1));
90+
*
91+
*
92+
* rt_thread_t thread = rt_thread_create("serial", serial_thread_entry, RT_NULL, 1024, 25, 10);
93+
*
94+
* if (thread != RT_NULL)
95+
* {
96+
* rt_thread_startup(thread);
97+
* }
98+
* else
99+
* {
100+
* ret = RT_ERROR;
101+
* }
102+
*
103+
* return ret;
104+
* }
105+
*
106+
* MSH_CMD_EXPORT(uart_sample, uart device sample);
107+
* @endcode
108+
*
109+
* @ingroup Drivers
110+
*/
18111

112+
113+
/*!
114+
* @addtogroup Serial
115+
* @{
116+
*/
19117
#define BAUD_RATE_2400 2400
20118
#define BAUD_RATE_4800 4800
21119
#define BAUD_RATE_9600 9600
@@ -105,7 +203,6 @@
105203
/**
106204
* @brief Sets a hook function when RX indicate is called
107205
*
108-
* @param thread is the target thread that initializing
109206
*/
110207
typedef void (*rt_hw_serial_rxind_hookproto_t)(rt_device_t dev, rt_size_t size);
111208
RT_OBJECT_HOOKLIST_DECLARE(rt_hw_serial_rxind_hookproto_t, rt_hw_serial_rxind);
@@ -173,7 +270,7 @@ struct rt_serial_device
173270
typedef struct rt_serial_device rt_serial_t;
174271

175272
/**
176-
* uart operators
273+
* @brief Configure the serial device
177274
*/
178275
struct rt_uart_ops
179276
{
@@ -186,13 +283,41 @@ struct rt_uart_ops
186283
rt_ssize_t (*dma_transmit)(struct rt_serial_device *serial, rt_uint8_t *buf, rt_size_t size, int direction);
187284
};
188285

286+
/**
287+
* @brief Serial interrupt service routine
288+
* @param serial serial device
289+
* @param event event mask
290+
* @ingroup Serial
291+
*/
189292
void rt_hw_serial_isr(struct rt_serial_device *serial, int event);
190293

294+
/**
295+
* @brief Register a serial device to device list
296+
*
297+
* @param serial serial device
298+
* @param name device name
299+
* @param flag device flag
300+
* @param data device private data
301+
* @return rt_err_t error code
302+
* @note This function will register a serial device to system device list,
303+
* and add a device object to system object list.
304+
* @ingroup Serial
305+
*/
191306
rt_err_t rt_hw_serial_register(struct rt_serial_device *serial,
192307
const char *name,
193308
rt_uint32_t flag,
194309
void *data);
195310

311+
/**
312+
* @brief register a serial device to system device list and add a device object to system object list
313+
*
314+
* @param serial serial device
315+
* @return rt_err_t error code
316+
*
317+
* @ingroup Serial
318+
*/
196319
rt_err_t rt_hw_serial_register_tty(struct rt_serial_device *serial);
197320

321+
/*! @}*/
322+
198323
#endif

0 commit comments

Comments
 (0)