summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorrcitach <[email protected]>2025-08-01 20:59:08 +0800
committerGitHub <[email protected]>2025-08-01 20:59:08 +0800
commitae50e406da41f87d1567fada7593df3ed3ad0627 (patch)
tree4f6191d1e90a4500ecacc0b8dc4f756bd96bf4b0 /components
parentd82dd71aefd6a4ec4d3e43698a396dd235bfdb0f (diff)
【SMART】【BSP】【allwinner】Fix smart serial_v2 bypass compile error issue (#10524)
* Modify the reference path of the header file in the middle section * format * Fix smart serial_v2 bypass compile error issue * add allwinner/d1s ci
Diffstat (limited to 'components')
-rw-r--r--components/drivers/include/drivers/dev_serial_v2.h3
-rw-r--r--components/drivers/include/rtdevice.h2
-rw-r--r--components/drivers/serial/bypass.c22
3 files changed, 25 insertions, 2 deletions
diff --git a/components/drivers/include/drivers/dev_serial_v2.h b/components/drivers/include/drivers/dev_serial_v2.h
index 16fc82fcf9..5360b011e3 100644
--- a/components/drivers/include/drivers/dev_serial_v2.h
+++ b/components/drivers/include/drivers/dev_serial_v2.h
@@ -333,6 +333,9 @@ struct rt_serial_device
struct rt_spinlock spinlock;
+#ifdef RT_USING_SERIAL_BYPASS
+ struct rt_serial_bypass* bypass;
+#endif
struct rt_device_notify rx_notify;
};
diff --git a/components/drivers/include/rtdevice.h b/components/drivers/include/rtdevice.h
index fd4d316960..7007441c6b 100644
--- a/components/drivers/include/rtdevice.h
+++ b/components/drivers/include/rtdevice.h
@@ -152,10 +152,10 @@ extern "C" {
#include "drivers/dev_serial_v2.h"
#else
#include "drivers/dev_serial.h"
+#endif /* RT_USING_SERIAL_V2 */
#ifdef RT_USING_SERIAL_BYPASS
#include "drivers/serial_bypass.h"
#endif /* RT_USING_SERIAL_BYPASS */
-#endif
#endif /* RT_USING_SERIAL */
#ifdef RT_USING_I2C
diff --git a/components/drivers/serial/bypass.c b/components/drivers/serial/bypass.c
index 04ed71a724..9da1833b70 100644
--- a/components/drivers/serial/bypass.c
+++ b/components/drivers/serial/bypass.c
@@ -41,7 +41,11 @@ rt_err_t rt_serial_bypass_init(struct rt_serial_device* serial)
{
serial->bypass = rt_malloc(sizeof(struct rt_serial_bypass));
rt_memset(serial->bypass, 0, sizeof(struct rt_serial_bypass));
+#ifdef RT_USING_SERIAL_V2
+ serial->bypass->pipe = rt_ringbuffer_create(serial->config.rx_bufsz);
+#else
serial->bypass->pipe = rt_ringbuffer_create(serial->config.bufsz);
+#endif
serial->bypass->mutex = rt_mutex_create("serial_bypass", RT_IPC_FLAG_FIFO);
return RT_EOK;
@@ -140,6 +144,22 @@ static inline rt_err_t _bypass_getchar_form_serial_fifo(struct rt_serial_device*
level = rt_spin_lock_irqsave(&(serial->spinlock));
/* there's no data: */
+#ifdef RT_USING_SERIAL_V2
+ rt_size_t ringbuf_date_stat;
+ ringbuf_date_stat = rt_ringbuffer_data_len(&rx_fifo->rb);
+ if(!ringbuf_date_stat)
+ {
+ /* no data, enable interrupt and break out */
+ rt_spin_unlock_irqrestore(&(serial->spinlock), level);
+ return -RT_EEMPTY;
+ }
+ if(!rt_ringbuffer_getchar(&rx_fifo->rb, (rt_uint8_t *)ch))
+ {
+ /* Failed to read data */
+ rt_spin_unlock_irqrestore(&(serial->spinlock), level);
+ return -RT_EOK;
+ }
+#else
if ((rx_fifo->get_index == rx_fifo->put_index) && (rx_fifo->is_full == RT_FALSE))
{
/* no data, enable interrupt and break out */
@@ -156,7 +176,7 @@ static inline rt_err_t _bypass_getchar_form_serial_fifo(struct rt_serial_device*
{
rx_fifo->is_full = RT_FALSE;
}
-
+#endif
/* enable interrupt */
rt_spin_unlock_irqrestore(&(serial->spinlock), level);