summaryrefslogtreecommitdiff
path: root/components/drivers/serial/serial.c
diff options
context:
space:
mode:
authorShell <[email protected]>2024-03-28 23:42:56 +0800
committerGitHub <[email protected]>2024-03-28 23:42:56 +0800
commit83e95bdff4c48c661b50e1eec56d5fd293b28fbb (patch)
tree9e0c2065950f0804e5009da71c8e0f590224cade /components/drivers/serial/serial.c
parent40e26f4909fa61ada775ba86b44d8300aaf5d250 (diff)
sync smart & dfs (#8672)
Signed-off-by: xqyjlj <[email protected]> Signed-off-by: Shell <[email protected]> Co-authored-by: xqyjlj <[email protected]>
Diffstat (limited to 'components/drivers/serial/serial.c')
-rw-r--r--components/drivers/serial/serial.c36
1 files changed, 28 insertions, 8 deletions
diff --git a/components/drivers/serial/serial.c b/components/drivers/serial/serial.c
index 0382f3c856..8604c78db7 100644
--- a/components/drivers/serial/serial.c
+++ b/components/drivers/serial/serial.c
@@ -909,7 +909,7 @@ static rt_ssize_t rt_serial_write(struct rt_device *dev,
}
}
-#if defined(RT_USING_POSIX_TERMIOS) && !defined(RT_USING_TTY)
+#if defined(RT_USING_POSIX_TERMIOS) && !defined(RT_USING_SMART)
struct speed_baudrate_item
{
speed_t speed;
@@ -1058,7 +1058,7 @@ static rt_err_t rt_serial_control(struct rt_device *dev,
}
break;
#ifdef RT_USING_POSIX_STDIO
-#if defined(RT_USING_POSIX_TERMIOS) && !defined(RT_USING_TTY)
+#if defined(RT_USING_POSIX_TERMIOS) && !defined(RT_USING_SMART)
case TCGETA:
{
struct termios *tio = (struct termios*)args;
@@ -1315,9 +1315,21 @@ rt_err_t rt_hw_serial_register(struct rt_serial_device *serial,
device->fops = &_serial_fops;
#endif
+#if defined(RT_USING_SMART)
+ rt_hw_serial_register_tty(serial);
+#endif
+
return ret;
}
+#if defined(RT_USING_SMART) && defined(LWP_DEBUG)
+static volatile int _early_input = 0;
+int lwp_startup_debug_request(void)
+{
+ return _early_input;
+}
+#endif
+
/* ISR for serial interrupt */
void rt_hw_serial_isr(struct rt_serial_device *serial, int event)
{
@@ -1360,8 +1372,17 @@ void rt_hw_serial_isr(struct rt_serial_device *serial, int event)
rt_spin_unlock_irqrestore(&(serial->spinlock), level);
}
- /* invoke callback */
- if (serial->parent.rx_indicate != RT_NULL)
+ /**
+ * Invoke callback.
+ * First try notify if any, and if notify is existed, rx_indicate()
+ * is not callback. This seperate the priority and makes the reuse
+ * of same serial device reasonable for RT console.
+ */
+ if (serial->rx_notify.notify)
+ {
+ serial->rx_notify.notify(serial->rx_notify.dev);
+ }
+ else if (serial->parent.rx_indicate != RT_NULL)
{
rt_size_t rx_length;
@@ -1376,10 +1397,9 @@ void rt_hw_serial_isr(struct rt_serial_device *serial, int event)
serial->parent.rx_indicate(&serial->parent, rx_length);
}
}
- if (serial->rx_notify.notify)
- {
- serial->rx_notify.notify(serial->rx_notify.dev);
- }
+ #if defined(RT_USING_SMART) && defined(LWP_DEBUG)
+ _early_input = 1;
+ #endif
break;
}
case RT_SERIAL_EVENT_TX_DONE: