mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-09-21 02:06:14 +08:00
[drivers/serial] Introduce hooker for TTY (#8733)
In this patch, a hook list has been introduced to address the concerns regarding coupling issues arising from modifications to the serial code for integrating TTY logic. Signed-off-by: Shell <smokewood@qq.com>
This commit is contained in:
@@ -102,6 +102,14 @@
|
||||
0 \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets a hook function when RX indicate is called
|
||||
*
|
||||
* @param thread is the target thread that initializing
|
||||
*/
|
||||
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);
|
||||
|
||||
struct serial_configure
|
||||
{
|
||||
rt_uint32_t baud_rate;
|
||||
@@ -186,4 +194,5 @@ rt_err_t rt_hw_serial_register(struct rt_serial_device *serial,
|
||||
void *data);
|
||||
|
||||
rt_err_t rt_hw_serial_register_tty(struct rt_serial_device *serial);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2022, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-11-16 GuEe-GUI first version
|
||||
*/
|
||||
|
||||
#ifndef __SERIAL_DM_H__
|
||||
#define __SERIAL_DM_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include <string.h>
|
||||
|
||||
int serial_dev_set_name(struct rt_serial_device *sdev);
|
||||
|
||||
void *serial_base_from_args(char *str);
|
||||
struct serial_configure serial_cfg_from_args(char *str);
|
||||
|
||||
#define serial_for_each_args(arg, args) \
|
||||
for (char *context = (arg = (typeof(arg))args, (void *)RT_NULL), \
|
||||
*context_end = rt_strchrnul((char *)args, ' '); \
|
||||
(arg = strtok_r(arg, ",", &context)) && arg < context_end; \
|
||||
arg = RT_NULL)
|
||||
|
||||
#endif /* __SERIAL_DM_H__ */
|
||||
@@ -103,6 +103,14 @@
|
||||
0 \
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Sets a hook function when RX indicate is called
|
||||
*
|
||||
* @param thread is the target thread that initializing
|
||||
*/
|
||||
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);
|
||||
|
||||
struct serial_configure
|
||||
{
|
||||
rt_uint32_t baud_rate;
|
||||
|
||||
Reference in New Issue
Block a user