Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
supperthomas committed Sep 14, 2024
1 parent 3c7435a commit 76f749f
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions components/drivers/include/drivers/dev_serial.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2024, RT-Thread Development Team
* Copyright (c) 2006-2024 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
Expand All @@ -17,51 +17,51 @@
#include <rtthread.h>
/**
* @addtogroup Drivers RTTHREAD Driver
* @defgroup Serial Serial
* @defgroup Serial Serial
*
* @brief Serial driver api
*
*
* <b>Example</b>
* @code {.c}
*
*
* #include <rtthread.h>
*
*
* #define SAMPLE_UART_NAME "uart2"
* static struct rt_semaphore rx_sem;
* static rt_device_t serial;
*
*
* static rt_err_t uart_input(rt_device_t dev, rt_size_t size)
* {
*
*
* rt_sem_release(&rx_sem);
*
*
* return RT_EOK;
* }
*
*
* static void serial_thread_entry(void *parameter)
* {
* char ch;
*
*
* while (1)
* {
*
*
* while (rt_device_read(serial, -1, &ch, 1) != 1)
* {
*
*
* rt_sem_take(&rx_sem, RT_WAITING_FOREVER);
* }
*
*
* ch = ch + 1;
* rt_device_write(serial, 0, &ch, 1);
* }
* }
*
*
* static int uart_sample(int argc, char *argv[])
* {
* rt_err_t ret = RT_EOK;
* char uart_name[RT_NAME_MAX];
* char str[] = "hello RT-Thread!\r\n";
*
*
* if (argc == 2)
* {
* rt_strncpy(uart_name, argv[1], RT_NAME_MAX);
Expand All @@ -70,27 +70,27 @@
* {
* rt_strncpy(uart_name, SAMPLE_UART_NAME, RT_NAME_MAX);
* }
*
*
*
*
* serial = rt_device_find(uart_name);
* if (!serial)
* {
* rt_kprintf("find %s failed!\n", uart_name);
* return RT_ERROR;
* }
*
*
*
*
* rt_sem_init(&rx_sem, "rx_sem", 0, RT_IPC_FLAG_FIFO);
*
*
* rt_device_open(serial, RT_DEVICE_FLAG_INT_RX);
*
*
* rt_device_set_rx_indicate(serial, uart_input);
*
*
* rt_device_write(serial, 0, str, (sizeof(str) - 1));
*
*
*
*
* rt_thread_t thread = rt_thread_create("serial", serial_thread_entry, RT_NULL, 1024, 25, 10);
*
*
* if (thread != RT_NULL)
* {
* rt_thread_startup(thread);
Expand All @@ -99,13 +99,13 @@
* {
* ret = RT_ERROR;
* }
*
*
* return ret;
* }
*
*
* MSH_CMD_EXPORT(uart_sample, uart device sample);
* @endcode
*
*
* @ingroup Drivers
*/

Expand Down Expand Up @@ -202,7 +202,7 @@

/**
* @brief Sets a hook function when RX indicate is called
*
*
*/
typedef void (*rt_hw_serial_rxind_hookproto_t)(rt_device_t dev, rt_size_t size);
RT_OBJECT_HOOKLIST_DECLARE(rt_hw_serial_rxind_hookproto_t, rt_hw_serial_rxind);
Expand Down Expand Up @@ -293,7 +293,7 @@ void rt_hw_serial_isr(struct rt_serial_device *serial, int event);

/**
* @brief Register a serial device to device list
*
*
* @param serial serial device
* @param name device name
* @param flag device flag
Expand All @@ -310,10 +310,10 @@ rt_err_t rt_hw_serial_register(struct rt_serial_device *serial,

/**
* @brief register a serial device to system device list and add a device object to system object list
*
*
* @param serial serial device
* @return rt_err_t error code
*
*
* @ingroup Serial
*/
rt_err_t rt_hw_serial_register_tty(struct rt_serial_device *serial);
Expand Down

0 comments on commit 76f749f

Please sign in to comment.