提交 c45f5a24 编写于 作者: B bernard

[Drivers] re-write serial framework.

上级 fc6747ef
...@@ -95,7 +95,7 @@ void rt_at91_usart_handler(int vector, void *param) ...@@ -95,7 +95,7 @@ void rt_at91_usart_handler(int vector, void *param)
return; return;
} }
rt_interrupt_enter(); rt_interrupt_enter();
rt_hw_serial_isr(dev); rt_hw_serial_isr((struct rt_serial_device *)dev, RT_SERIAL_EVENT_RX_IND);
rt_interrupt_leave(); rt_interrupt_leave();
} }
...@@ -231,7 +231,6 @@ static const struct rt_uart_ops at91_usart_ops = ...@@ -231,7 +231,6 @@ static const struct rt_uart_ops at91_usart_ops =
#if defined(RT_USING_DBGU) #if defined(RT_USING_DBGU)
static struct rt_serial_device serial_dbgu; static struct rt_serial_device serial_dbgu;
static struct serial_ringbuffer dbgu_int_rx;
struct at91_uart dbgu = { struct at91_uart dbgu = {
DBGU, DBGU,
AT91_ID_SYS AT91_ID_SYS
...@@ -241,7 +240,6 @@ struct at91_uart dbgu = { ...@@ -241,7 +240,6 @@ struct at91_uart dbgu = {
#if defined(RT_USING_UART0) #if defined(RT_USING_UART0)
static struct rt_serial_device serial0; static struct rt_serial_device serial0;
static struct serial_ringbuffer uart0_int_rx;
struct at91_uart uart0 = { struct at91_uart uart0 = {
UART0, UART0,
AT91SAM9260_ID_US0 AT91SAM9260_ID_US0
...@@ -250,7 +248,6 @@ struct at91_uart uart0 = { ...@@ -250,7 +248,6 @@ struct at91_uart uart0 = {
#if defined(RT_USING_UART1) #if defined(RT_USING_UART1)
static struct rt_serial_device serial1; static struct rt_serial_device serial1;
static struct serial_ringbuffer uart1_int_rx;
struct at91_uart uart1 = { struct at91_uart uart1 = {
UART1, UART1,
AT91SAM9260_ID_US1 AT91SAM9260_ID_US1
...@@ -259,7 +256,6 @@ struct at91_uart uart1 = { ...@@ -259,7 +256,6 @@ struct at91_uart uart1 = {
#if defined(RT_USING_UART2) #if defined(RT_USING_UART2)
static struct rt_serial_device serial2; static struct rt_serial_device serial2;
static struct serial_ringbuffer uart2_int_rx;
struct at91_uart uart2 = { struct at91_uart uart2 = {
UART2, UART2,
AT91SAM9260_ID_US2 AT91SAM9260_ID_US2
...@@ -268,7 +264,6 @@ struct at91_uart uart2 = { ...@@ -268,7 +264,6 @@ struct at91_uart uart2 = {
#if defined(RT_USING_UART3) #if defined(RT_USING_UART3)
static struct rt_serial_device serial3; static struct rt_serial_device serial3;
static struct serial_ringbuffer uart3_int_rx;
struct at91_uart uart3 = { struct at91_uart uart3 = {
UART3, UART3,
AT91SAM9260_ID_US3 AT91SAM9260_ID_US3
...@@ -337,29 +332,29 @@ void rt_hw_uart_init(void) ...@@ -337,29 +332,29 @@ void rt_hw_uart_init(void)
#if defined(RT_USING_DBGU) #if defined(RT_USING_DBGU)
serial_dbgu.ops = &at91_usart_ops; serial_dbgu.ops = &at91_usart_ops;
serial_dbgu.int_rx = &dbgu_int_rx;
serial_dbgu.config.baud_rate = BAUD_RATE_115200; serial_dbgu.config.baud_rate = BAUD_RATE_115200;
serial_dbgu.config.bit_order = BIT_ORDER_LSB; serial_dbgu.config.bit_order = BIT_ORDER_LSB;
serial_dbgu.config.data_bits = DATA_BITS_8; serial_dbgu.config.data_bits = DATA_BITS_8;
serial_dbgu.config.parity = PARITY_NONE; serial_dbgu.config.parity = PARITY_NONE;
serial_dbgu.config.stop_bits = STOP_BITS_1; serial_dbgu.config.stop_bits = STOP_BITS_1;
serial_dbgu.config.invert = NRZ_NORMAL; serial_dbgu.config.invert = NRZ_NORMAL;
serial_dbgu.config.bufsz = RT_SERIAL_RB_BUFSZ;
/* register vcom device */ /* register vcom device */
rt_hw_serial_register(&serial_dbgu, "dbgu", rt_hw_serial_register(&serial_dbgu, "dbgu",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
&dbgu); &dbgu);
#endif #endif
#if defined(RT_USING_UART0) #if defined(RT_USING_UART0)
serial0.ops = &at91_usart_ops; serial0.ops = &at91_usart_ops;
serial0.int_rx = &uart0_int_rx;
serial0.config.baud_rate = BAUD_RATE_115200; serial0.config.baud_rate = BAUD_RATE_115200;
serial0.config.bit_order = BIT_ORDER_LSB; serial0.config.bit_order = BIT_ORDER_LSB;
serial0.config.data_bits = DATA_BITS_8; serial0.config.data_bits = DATA_BITS_8;
serial0.config.parity = PARITY_NONE; serial0.config.parity = PARITY_NONE;
serial0.config.stop_bits = STOP_BITS_1; serial0.config.stop_bits = STOP_BITS_1;
serial0.config.invert = NRZ_NORMAL; serial0.config.invert = NRZ_NORMAL;
serial0.config.bufsz = RT_SERIAL_RB_BUFSZ;
/* register vcom device */ /* register vcom device */
rt_hw_serial_register(&serial0, "uart0", rt_hw_serial_register(&serial0, "uart0",
...@@ -379,10 +374,11 @@ void rt_hw_uart_init(void) ...@@ -379,10 +374,11 @@ void rt_hw_uart_init(void)
serial1.config.parity = PARITY_NONE; serial1.config.parity = PARITY_NONE;
serial1.config.stop_bits = STOP_BITS_1; serial1.config.stop_bits = STOP_BITS_1;
serial1.config.invert = NRZ_NORMAL; serial1.config.invert = NRZ_NORMAL;
serial1.config.bufsz = RT_SERIAL_RB_BUFSZ;
/* register vcom device */ /* register vcom device */
rt_hw_serial_register(&serial1, "uart1", rt_hw_serial_register(&serial1, "uart1",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
&uart1); &uart1);
rt_hw_interrupt_install(uart1.irq, rt_at91_usart_handler, rt_hw_interrupt_install(uart1.irq, rt_at91_usart_handler,
(void *)&(serial1.parent), "UART1"); (void *)&(serial1.parent), "UART1");
...@@ -391,17 +387,17 @@ void rt_hw_uart_init(void) ...@@ -391,17 +387,17 @@ void rt_hw_uart_init(void)
#if defined(RT_USING_UART2) #if defined(RT_USING_UART2)
serial2.ops = &at91_usart_ops; serial2.ops = &at91_usart_ops;
serial2.int_rx = &uart2_int_rx;
serial2.config.baud_rate = BAUD_RATE_115200; serial2.config.baud_rate = BAUD_RATE_115200;
serial2.config.bit_order = BIT_ORDER_LSB; serial2.config.bit_order = BIT_ORDER_LSB;
serial2.config.data_bits = DATA_BITS_8; serial2.config.data_bits = DATA_BITS_8;
serial2.config.parity = PARITY_NONE; serial2.config.parity = PARITY_NONE;
serial2.config.stop_bits = STOP_BITS_1; serial2.config.stop_bits = STOP_BITS_1;
serial2.config.invert = NRZ_NORMAL; serial2.config.invert = NRZ_NORMAL;
serial2.config.bufsz = RT_SERIAL_RB_BUFSZ;
/* register vcom device */ /* register vcom device */
rt_hw_serial_register(&serial2, "uart2", rt_hw_serial_register(&serial2, "uart2",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
&uart2); &uart2);
rt_hw_interrupt_install(uart2.irq, rt_at91_usart_handler, rt_hw_interrupt_install(uart2.irq, rt_at91_usart_handler,
(void *)&(serial2.parent), "UART2"); (void *)&(serial2.parent), "UART2");
...@@ -410,17 +406,17 @@ void rt_hw_uart_init(void) ...@@ -410,17 +406,17 @@ void rt_hw_uart_init(void)
#if defined(RT_USING_UART3) #if defined(RT_USING_UART3)
serial3.ops = &at91_usart_ops; serial3.ops = &at91_usart_ops;
serial3.int_rx = &uart3_int_rx;
serial3.config.baud_rate = BAUD_RATE_115200; serial3.config.baud_rate = BAUD_RATE_115200;
serial3.config.bit_order = BIT_ORDER_LSB; serial3.config.bit_order = BIT_ORDER_LSB;
serial3.config.data_bits = DATA_BITS_8; serial3.config.data_bits = DATA_BITS_8;
serial3.config.parity = PARITY_NONE; serial3.config.parity = PARITY_NONE;
serial3.config.stop_bits = STOP_BITS_1; serial3.config.stop_bits = STOP_BITS_1;
serial3.config.invert = NRZ_NORMAL; serial3.config.invert = NRZ_NORMAL;
serial3.config.bufsz = RT_SERIAL_RB_BUFSZ;
/* register vcom device */ /* register vcom device */
rt_hw_serial_register(&serial3, "uart3", rt_hw_serial_register(&serial3, "uart3",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
&uart3); &uart3);
rt_hw_interrupt_install(uart3.irq, rt_at91_usart_handler, rt_hw_interrupt_install(uart3.irq, rt_at91_usart_handler,
(void *)&(serial3.parent), "UART3"); (void *)&(serial3.parent), "UART3");
......
...@@ -41,7 +41,7 @@ static void am33xx_uart_isr(int irqno, void* param) ...@@ -41,7 +41,7 @@ static void am33xx_uart_isr(int irqno, void* param)
if ((iir & (0x02 << 1)) || (iir & (0x6 << 1))) if ((iir & (0x02 << 1)) || (iir & (0x6 << 1)))
{ {
rt_hw_serial_isr(serial); rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
} }
} }
...@@ -165,7 +165,6 @@ static const struct rt_uart_ops am33xx_uart_ops = ...@@ -165,7 +165,6 @@ static const struct rt_uart_ops am33xx_uart_ops =
/* UART device driver structure */ /* UART device driver structure */
#ifdef RT_USING_UART0 #ifdef RT_USING_UART0
struct serial_ringbuffer uart0_int_rx;
struct am33xx_uart uart0 = struct am33xx_uart uart0 =
{ {
UART0_BASE, UART0_BASE,
...@@ -175,7 +174,6 @@ struct rt_serial_device serial0; ...@@ -175,7 +174,6 @@ struct rt_serial_device serial0;
#endif #endif
#ifdef RT_USING_UART1 #ifdef RT_USING_UART1
struct serial_ringbuffer uart1_int_rx;
struct am33xx_uart uart1 = struct am33xx_uart uart1 =
{ {
UART1_BASE, UART1_BASE,
...@@ -185,7 +183,6 @@ struct rt_serial_device serial1; ...@@ -185,7 +183,6 @@ struct rt_serial_device serial1;
#endif #endif
#ifdef RT_USING_UART2 #ifdef RT_USING_UART2
struct serial_ringbuffer uart2_int_rx;
struct am33xx_uart uart2 = struct am33xx_uart uart2 =
{ {
UART2_BASE, UART2_BASE,
...@@ -195,7 +192,6 @@ struct rt_serial_device serial2; ...@@ -195,7 +192,6 @@ struct rt_serial_device serial2;
#endif #endif
#ifdef RT_USING_UART3 #ifdef RT_USING_UART3
struct serial_ringbuffer uart3_int_rx;
struct am33xx_uart uart3 = struct am33xx_uart uart3 =
{ {
UART3_BASE, UART3_BASE,
...@@ -205,7 +201,6 @@ struct rt_serial_device serial3; ...@@ -205,7 +201,6 @@ struct rt_serial_device serial3;
#endif #endif
#ifdef RT_USING_UART4 #ifdef RT_USING_UART4
struct serial_ringbuffer uart4_int_rx;
struct am33xx_uart uart4 = struct am33xx_uart uart4 =
{ {
UART4_BASE, UART4_BASE,
...@@ -215,7 +210,6 @@ struct rt_serial_device serial4; ...@@ -215,7 +210,6 @@ struct rt_serial_device serial4;
#endif #endif
#ifdef RT_USING_UART5 #ifdef RT_USING_UART5
struct serial_ringbuffer uart5_int_rx;
struct am33xx_uart uart5 = struct am33xx_uart uart5 =
{ {
UART5_BASE, UART5_BASE,
...@@ -359,8 +353,9 @@ int rt_hw_serial_init(void) ...@@ -359,8 +353,9 @@ int rt_hw_serial_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial0.ops = &am33xx_uart_ops; serial0.ops = &am33xx_uart_ops;
serial0.int_rx = &uart0_int_rx;
serial0.config = config; serial0.config = config;
/* enable RX interrupt */ /* enable RX interrupt */
UART_IER_REG(uart0.base) = 0x01; UART_IER_REG(uart0.base) = 0x01;
...@@ -370,7 +365,7 @@ int rt_hw_serial_init(void) ...@@ -370,7 +365,7 @@ int rt_hw_serial_init(void)
rt_hw_interrupt_mask(uart0.irq); rt_hw_interrupt_mask(uart0.irq);
/* register UART0 device */ /* register UART0 device */
rt_hw_serial_register(&serial0, "uart0", rt_hw_serial_register(&serial0, "uart0",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
&uart0); &uart0);
#endif #endif
...@@ -381,8 +376,9 @@ int rt_hw_serial_init(void) ...@@ -381,8 +376,9 @@ int rt_hw_serial_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial1.ops = &am33xx_uart_ops; serial1.ops = &am33xx_uart_ops;
serial1.int_rx = &uart1_int_rx;
serial1.config = config; serial1.config = config;
/* enable RX interrupt */ /* enable RX interrupt */
UART_IER_REG(uart1.base) = 0x01; UART_IER_REG(uart1.base) = 0x01;
...@@ -392,7 +388,7 @@ int rt_hw_serial_init(void) ...@@ -392,7 +388,7 @@ int rt_hw_serial_init(void)
rt_hw_interrupt_mask(uart1.irq); rt_hw_interrupt_mask(uart1.irq);
/* register UART0 device */ /* register UART0 device */
rt_hw_serial_register(&serial1, "uart1", rt_hw_serial_register(&serial1, "uart1",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
&uart1); &uart1);
#endif #endif
...@@ -403,8 +399,9 @@ int rt_hw_serial_init(void) ...@@ -403,8 +399,9 @@ int rt_hw_serial_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial2.ops = &am33xx_uart_ops; serial2.ops = &am33xx_uart_ops;
serial2.int_rx = &uart2_int_rx;
serial2.config = config; serial2.config = config;
/* enable RX interrupt */ /* enable RX interrupt */
UART_IER_REG(uart2.base) = 0x01; UART_IER_REG(uart2.base) = 0x01;
...@@ -414,7 +411,7 @@ int rt_hw_serial_init(void) ...@@ -414,7 +411,7 @@ int rt_hw_serial_init(void)
rt_hw_interrupt_mask(uart2.irq); rt_hw_interrupt_mask(uart2.irq);
/* register UART2 device */ /* register UART2 device */
rt_hw_serial_register(&serial2, "uart2", rt_hw_serial_register(&serial2, "uart2",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
&uart2); &uart2);
#endif #endif
...@@ -425,8 +422,9 @@ int rt_hw_serial_init(void) ...@@ -425,8 +422,9 @@ int rt_hw_serial_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial3.ops = &am33xx_uart_ops; serial3.ops = &am33xx_uart_ops;
serial3.int_rx = &uart_3_int_rx;
serial3.config = config; serial3.config = config;
/* enable RX interrupt */ /* enable RX interrupt */
UART_IER_REG(uart3.base) = 0x01; UART_IER_REG(uart3.base) = 0x01;
...@@ -436,7 +434,7 @@ int rt_hw_serial_init(void) ...@@ -436,7 +434,7 @@ int rt_hw_serial_init(void)
rt_hw_interrupt_mask(uart3.irq); rt_hw_interrupt_mask(uart3.irq);
/* register UART3 device */ /* register UART3 device */
rt_hw_serial_register(&serial3, "uart3", rt_hw_serial_register(&serial3, "uart3",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
&uart3); &uart3);
#endif #endif
...@@ -447,9 +445,9 @@ int rt_hw_serial_init(void) ...@@ -447,9 +445,9 @@ int rt_hw_serial_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial4.ops = &am33xx_uart_ops; serial4.ops = &am33xx_uart_ops;
serial4.int_rx = &uart4_int_rx;
serial4.config = config; serial4.config = config;
/* enable RX interrupt */ /* enable RX interrupt */
UART_IER_REG(uart4.base) = 0x01; UART_IER_REG(uart4.base) = 0x01;
...@@ -459,7 +457,7 @@ int rt_hw_serial_init(void) ...@@ -459,7 +457,7 @@ int rt_hw_serial_init(void)
rt_hw_interrupt_mask(uart4.irq); rt_hw_interrupt_mask(uart4.irq);
/* register UART4 device */ /* register UART4 device */
rt_hw_serial_register(&serial4, "uart4", rt_hw_serial_register(&serial4, "uart4",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
&uart4); &uart4);
#endif #endif
...@@ -470,9 +468,9 @@ int rt_hw_serial_init(void) ...@@ -470,9 +468,9 @@ int rt_hw_serial_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial5.ops = &am33xx_uart_ops; serial5.ops = &am33xx_uart_ops;
serial5.int_rx = &uart5_int_rx;
serial5.config = config; serial5.config = config;
/* enable RX interrupt */ /* enable RX interrupt */
UART_IER_REG(uart5.base) = 0x01; UART_IER_REG(uart5.base) = 0x01;
...@@ -482,7 +480,7 @@ int rt_hw_serial_init(void) ...@@ -482,7 +480,7 @@ int rt_hw_serial_init(void)
rt_hw_interrupt_mask(uart5.irq); rt_hw_interrupt_mask(uart5.irq);
/* register UART4 device */ /* register UART4 device */
rt_hw_serial_register(&serial5, "uart5", rt_hw_serial_register(&serial5, "uart5",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
&uart5); &uart5);
#endif #endif
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include "drv_uart.h" #include "drv_uart.h"
static struct rt_serial_device _k64_serial; //abstracted serial for RTT static struct rt_serial_device _k64_serial; //abstracted serial for RTT
static struct serial_ringbuffer _k64_int_rx; //UART send buffer area
struct k64_serial_device struct k64_serial_device
{ {
...@@ -231,7 +230,7 @@ static const struct rt_uart_ops _k64_ops = ...@@ -231,7 +230,7 @@ static const struct rt_uart_ops _k64_ops =
void UART0_RX_TX_IRQHandler(void) void UART0_RX_TX_IRQHandler(void)
{ {
rt_interrupt_enter(); rt_interrupt_enter();
rt_hw_serial_isr((struct rt_serial_device*)&_k64_serial); rt_hw_serial_isr((struct rt_serial_device*)&_k64_serial, RT_SERIAL_EVENT_RX_IND);
rt_interrupt_leave(); rt_interrupt_leave();
} }
...@@ -247,9 +246,9 @@ void rt_hw_uart_init(void) ...@@ -247,9 +246,9 @@ void rt_hw_uart_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
_k64_serial.ops = &_k64_ops; _k64_serial.ops = &_k64_ops;
_k64_serial.int_rx = &_k64_int_rx;
_k64_serial.config = config; _k64_serial.config = config;
rt_hw_serial_register(&_k64_serial, "uart0", rt_hw_serial_register(&_k64_serial, "uart0",
......
...@@ -118,7 +118,6 @@ static const struct rt_uart_ops lpc_uart_ops = ...@@ -118,7 +118,6 @@ static const struct rt_uart_ops lpc_uart_ops =
#if defined(RT_USING_UART0) #if defined(RT_USING_UART0)
/* UART0 device driver structure */ /* UART0 device driver structure */
struct serial_ringbuffer uart0_int_rx;
struct lpc_uart uart0 = struct lpc_uart uart0 =
{ {
UART_0, UART_0,
...@@ -158,7 +157,7 @@ void UART0_IRQHandler(void) ...@@ -158,7 +157,7 @@ void UART0_IRQHandler(void)
// Receive Data Available or Character time-out // Receive Data Available or Character time-out
if ((tmp == UART_IIR_INTID_RDA) || (tmp == UART_IIR_INTID_CTI)) if ((tmp == UART_IIR_INTID_RDA) || (tmp == UART_IIR_INTID_CTI))
{ {
rt_hw_serial_isr(&serial0); rt_hw_serial_isr(&serial0, RT_SERIAL_EVENT_RX_IND);
} }
/* leave interrupt */ /* leave interrupt */
...@@ -167,7 +166,6 @@ void UART0_IRQHandler(void) ...@@ -167,7 +166,6 @@ void UART0_IRQHandler(void)
#endif #endif
#if defined(RT_USING_UART2) #if defined(RT_USING_UART2)
/* UART2 device driver structure */ /* UART2 device driver structure */
struct serial_ringbuffer uart2_int_rx;
struct lpc_uart uart2 = struct lpc_uart uart2 =
{ {
UART_2, UART_2,
...@@ -207,7 +205,7 @@ void UART2_IRQHandler(void) ...@@ -207,7 +205,7 @@ void UART2_IRQHandler(void)
// Receive Data Available or Character time-out // Receive Data Available or Character time-out
if ((tmp == UART_IIR_INTID_RDA) || (tmp == UART_IIR_INTID_CTI)) if ((tmp == UART_IIR_INTID_RDA) || (tmp == UART_IIR_INTID_CTI))
{ {
rt_hw_serial_isr(&serial2); rt_hw_serial_isr(&serial2, RT_SERIAL_EVENT_RX_IND);
} }
/* leave interrupt */ /* leave interrupt */
...@@ -227,9 +225,9 @@ void rt_hw_uart_init(void) ...@@ -227,9 +225,9 @@ void rt_hw_uart_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial0.ops = &lpc_uart_ops; serial0.ops = &lpc_uart_ops;
serial0.int_rx = &uart0_int_rx;
serial0.config = config; serial0.config = config;
/* /*
...@@ -259,9 +257,9 @@ void rt_hw_uart_init(void) ...@@ -259,9 +257,9 @@ void rt_hw_uart_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial2.ops = &lpc_uart_ops; serial2.ops = &lpc_uart_ops;
serial2.int_rx = &uart2_int_rx;
serial2.config = config; serial2.config = config;
/* /*
......
...@@ -97,7 +97,6 @@ static const struct rt_uart_ops lpc_uart_ops = ...@@ -97,7 +97,6 @@ static const struct rt_uart_ops lpc_uart_ops =
#if defined(RT_USING_UART0) #if defined(RT_USING_UART0)
/* UART0 device driver structure */ /* UART0 device driver structure */
struct serial_ringbuffer uart0_int_rx;
struct lpc_uart uart0 = struct lpc_uart uart0 =
{ {
LPC_USART0, LPC_USART0,
...@@ -136,7 +135,7 @@ void UART0_IRQHandler(void) ...@@ -136,7 +135,7 @@ void UART0_IRQHandler(void)
/* read the data to buffer */ /* read the data to buffer */
while (uart->USART->LSR & UART_LSR_RDR) while (uart->USART->LSR & UART_LSR_RDR)
{ {
rt_hw_serial_isr(&serial0); rt_hw_serial_isr(&serial0, RT_SERIAL_EVENT_RX_IND);
} }
break; break;
...@@ -150,7 +149,6 @@ void UART0_IRQHandler(void) ...@@ -150,7 +149,6 @@ void UART0_IRQHandler(void)
#endif #endif
#if defined(RT_USING_UART2) #if defined(RT_USING_UART2)
/* UART2 device driver structure */ /* UART2 device driver structure */
struct serial_ringbuffer uart2_int_rx;
struct lpc_uart uart2 = struct lpc_uart uart2 =
{ {
LPC_USART2, LPC_USART2,
...@@ -189,7 +187,7 @@ void UART2_IRQHandler(void) ...@@ -189,7 +187,7 @@ void UART2_IRQHandler(void)
/* read the data to buffer */ /* read the data to buffer */
while (uart->USART->LSR & UART_LSR_RDR) while (uart->USART->LSR & UART_LSR_RDR)
{ {
rt_hw_serial_isr(&serial0); rt_hw_serial_isr(&serial0, RT_SERIAL_EVENT_RX_IND);
} }
break; break;
...@@ -214,9 +212,9 @@ void rt_hw_uart_init(void) ...@@ -214,9 +212,9 @@ void rt_hw_uart_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial0.ops = &lpc_uart_ops; serial0.ops = &lpc_uart_ops;
serial0.int_rx = &uart0_int_rx;
serial0.config = config; serial0.config = config;
/* Enable GPIO register interface clock */ /* Enable GPIO register interface clock */
...@@ -256,7 +254,7 @@ void rt_hw_uart_init(void) ...@@ -256,7 +254,7 @@ void rt_hw_uart_init(void)
/* register UART1 device */ /* register UART1 device */
rt_hw_serial_register(&serial0, "uart0", rt_hw_serial_register(&serial0, "uart0",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
uart); uart);
#endif #endif
#ifdef RT_USING_UART2 #ifdef RT_USING_UART2
...@@ -267,9 +265,9 @@ void rt_hw_uart_init(void) ...@@ -267,9 +265,9 @@ void rt_hw_uart_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial2.ops = &lpc_uart_ops; serial2.ops = &lpc_uart_ops;
serial2.int_rx = &uart2_int_rx;
serial2.config = config; serial2.config = config;
/* Enable GPIO register interface clock */ /* Enable GPIO register interface clock */
...@@ -309,7 +307,7 @@ void rt_hw_uart_init(void) ...@@ -309,7 +307,7 @@ void rt_hw_uart_init(void)
/* register UART1 device */ /* register UART1 device */
rt_hw_serial_register(&serial2, "uart2", rt_hw_serial_register(&serial2, "uart2",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
uart); uart);
#endif #endif
} }
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#if (defined(RT_USING_UART0_0) || defined(RT_USING_UART0_1)) #if (defined(RT_USING_UART0_0) || defined(RT_USING_UART0_1))
/* UART0 device driver structure */ /* UART0 device driver structure */
struct serial_ringbuffer uart0_int_rx;
struct uart03_device uart0 = struct uart03_device uart0 =
{ {
FM3_MFS0_UART, FM3_MFS0_UART,
...@@ -33,7 +32,7 @@ void MFS0RX_IRQHandler(void) ...@@ -33,7 +32,7 @@ void MFS0RX_IRQHandler(void)
{ {
/* enter interrupt */ /* enter interrupt */
rt_interrupt_enter(); rt_interrupt_enter();
rt_hw_serial_isr(&serial0); rt_hw_serial_isr(&serial0, RT_SERIAL_EVENT_RX_IND);
/* leave interrupt */ /* leave interrupt */
rt_interrupt_leave(); rt_interrupt_leave();
} }
...@@ -41,7 +40,6 @@ void MFS0RX_IRQHandler(void) ...@@ -41,7 +40,6 @@ void MFS0RX_IRQHandler(void)
#if (defined(RT_USING_UART1_0) || defined(RT_USING_UART1_1)) #if (defined(RT_USING_UART1_0) || defined(RT_USING_UART1_1))
/* UART1 device driver structure */ /* UART1 device driver structure */
struct serial_ringbuffer uart1_int_rx;
struct uart03_device uart1 = struct uart03_device uart1 =
{ {
FM3_MFS1_UART, FM3_MFS1_UART,
...@@ -54,7 +52,7 @@ void MFS1RX_IRQHandler(void) ...@@ -54,7 +52,7 @@ void MFS1RX_IRQHandler(void)
{ {
/* enter interrupt */ /* enter interrupt */
rt_interrupt_enter(); rt_interrupt_enter();
rt_hw_serial_isr(&serial1); rt_hw_serial_isr(&serial1, RT_SERIAL_EVENT_RX_IND);
/* leave interrupt */ /* leave interrupt */
rt_interrupt_leave(); rt_interrupt_leave();
} }
...@@ -62,7 +60,6 @@ void MFS1RX_IRQHandler(void) ...@@ -62,7 +60,6 @@ void MFS1RX_IRQHandler(void)
#if (defined(RT_USING_UART2_0) || defined(RT_USING_UART2_1) || defined(RT_USING_UART2_2)) #if (defined(RT_USING_UART2_0) || defined(RT_USING_UART2_1) || defined(RT_USING_UART2_2))
/* UART2 device driver structure */ /* UART2 device driver structure */
struct serial_ringbuffer uart2_int_rx;
struct uart03_device uart2 = struct uart03_device uart2 =
{ {
FM3_MFS2_UART, FM3_MFS2_UART,
...@@ -75,7 +72,7 @@ void MFS2RX_IRQHandler(void) ...@@ -75,7 +72,7 @@ void MFS2RX_IRQHandler(void)
{ {
/* enter interrupt */ /* enter interrupt */
rt_interrupt_enter(); rt_interrupt_enter();
rt_hw_serial_isr(&serial2); rt_hw_serial_isr(&serial2, RT_SERIAL_EVENT_RX_IND);
/* leave interrupt */ /* leave interrupt */
rt_interrupt_leave(); rt_interrupt_leave();
} }
...@@ -83,7 +80,6 @@ void MFS2RX_IRQHandler(void) ...@@ -83,7 +80,6 @@ void MFS2RX_IRQHandler(void)
#if (defined(RT_USING_UART3_0) || defined(RT_USING_UART3_1) || defined(RT_USING_UART3_2)) #if (defined(RT_USING_UART3_0) || defined(RT_USING_UART3_1) || defined(RT_USING_UART3_2))
/* UART3 device driver structure */ /* UART3 device driver structure */
struct serial_ringbuffer uart3_int_rx;
struct uart03_device uart3 = struct uart03_device uart3 =
{ {
FM3_MFS3_UART, FM3_MFS3_UART,
...@@ -96,7 +92,7 @@ void MFS3RX_IRQHandler(void) ...@@ -96,7 +92,7 @@ void MFS3RX_IRQHandler(void)
{ {
/* enter interrupt */ /* enter interrupt */
rt_interrupt_enter(); rt_interrupt_enter();
rt_hw_serial_isr(&serial3); rt_hw_serial_isr(&serial3, RT_SERIAL_EVENT_RX_IND);
/* leave interrupt */ /* leave interrupt */
rt_interrupt_leave(); rt_interrupt_leave();
} }
...@@ -104,7 +100,6 @@ void MFS3RX_IRQHandler(void) ...@@ -104,7 +100,6 @@ void MFS3RX_IRQHandler(void)
#if (defined(RT_USING_UART4_0) || defined(RT_USING_UART4_1) || defined(RT_USING_UART4_2)) #if (defined(RT_USING_UART4_0) || defined(RT_USING_UART4_1) || defined(RT_USING_UART4_2))
/* UART4 device driver structure */ /* UART4 device driver structure */
struct serial_ringbuffer uart4_int_rx;
struct uart47_device uart4 = struct uart47_device uart4 =
{ {
FM3_MFS4_UART, FM3_MFS4_UART,
...@@ -118,7 +113,7 @@ void MFS4RX_IRQHandler(void) ...@@ -118,7 +113,7 @@ void MFS4RX_IRQHandler(void)
{ {
/* enter interrupt */ /* enter interrupt */
rt_interrupt_enter(); rt_interrupt_enter();
rt_hw_serial_isr(&serial4); rt_hw_serial_isr(&serial4, RT_SERIAL_EVENT_RX_IND);
/* leave interrupt */ /* leave interrupt */
rt_interrupt_leave(); rt_interrupt_leave();
} }
...@@ -126,7 +121,6 @@ void MFS4RX_IRQHandler(void) ...@@ -126,7 +121,6 @@ void MFS4RX_IRQHandler(void)
#if (defined(RT_USING_UART5_0) || defined(RT_USING_UART5_1) || defined(RT_USING_UART5_2)) #if (defined(RT_USING_UART5_0) || defined(RT_USING_UART5_1) || defined(RT_USING_UART5_2))
/* UART5 device driver structure */ /* UART5 device driver structure */
struct serial_ringbuffer uart5_int_rx;
struct uart47_device uart5 = struct uart47_device uart5 =
{ {
FM3_MFS5_UART, FM3_MFS5_UART,
...@@ -140,7 +134,7 @@ void MFS5RX_IRQHandler(void) ...@@ -140,7 +134,7 @@ void MFS5RX_IRQHandler(void)
{ {
/* enter interrupt */ /* enter interrupt */
rt_interrupt_enter(); rt_interrupt_enter();
rt_hw_serial_isr(&serial5); rt_hw_serial_isr(&serial5, RT_SERIAL_EVENT_RX_IND);
/* leave interrupt */ /* leave interrupt */
rt_interrupt_leave(); rt_interrupt_leave();
} }
...@@ -148,7 +142,6 @@ void MFS5RX_IRQHandler(void) ...@@ -148,7 +142,6 @@ void MFS5RX_IRQHandler(void)
#if (defined(RT_USING_UART6_0) || defined(RT_USING_UART6_1)) #if (defined(RT_USING_UART6_0) || defined(RT_USING_UART6_1))
/* UART6 device driver structure */ /* UART6 device driver structure */
struct serial_ringbuffer uart6_int_rx;
struct uart47_device uart6 = struct uart47_device uart6 =
{ {
FM3_MFS6_UART, FM3_MFS6_UART,
...@@ -162,7 +155,7 @@ void MFS6RX_IRQHandler(void) ...@@ -162,7 +155,7 @@ void MFS6RX_IRQHandler(void)
{ {
/* enter interrupt */ /* enter interrupt */
rt_interrupt_enter(); rt_interrupt_enter();
rt_hw_serial_isr(&serial6); rt_hw_serial_isr(&serial6, RT_SERIAL_EVENT_RX_IND);
/* leave interrupt */ /* leave interrupt */
rt_interrupt_leave(); rt_interrupt_leave();
} }
...@@ -170,7 +163,6 @@ void MFS6RX_IRQHandler(void) ...@@ -170,7 +163,6 @@ void MFS6RX_IRQHandler(void)
#if (defined(RT_USING_UART7_0) || defined(RT_USING_UART7_1)) #if (defined(RT_USING_UART7_0) || defined(RT_USING_UART7_1))
/* UART7 device driver structure */ /* UART7 device driver structure */
struct serial_ringbuffer uart7_int_rx;
struct uart47_device uart7 = struct uart47_device uart7 =
{ {
FM3_MFS7_UART, FM3_MFS7_UART,
...@@ -184,7 +176,7 @@ void MFS7RX_IRQHandler(void) ...@@ -184,7 +176,7 @@ void MFS7RX_IRQHandler(void)
{ {
/* enter interrupt */ /* enter interrupt */
rt_interrupt_enter(); rt_interrupt_enter();
rt_hw_serial_isr(&serial7); rt_hw_serial_isr(&serial7, RT_SERIAL_EVENT_RX_IND);
/* leave interrupt */ /* leave interrupt */
rt_interrupt_leave(); rt_interrupt_leave();
} }
...@@ -796,9 +788,9 @@ void rt_hw_serial_init(void) ...@@ -796,9 +788,9 @@ void rt_hw_serial_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial0.ops = &uart03_ops; serial0.ops = &uart03_ops;
serial0.int_rx = &uart0_int_rx;
serial0.config = config; serial0.config = config;
/* register UART0 device */ /* register UART0 device */
...@@ -814,9 +806,9 @@ void rt_hw_serial_init(void) ...@@ -814,9 +806,9 @@ void rt_hw_serial_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial1.ops = &uart03_ops; serial1.ops = &uart03_ops;
serial1.int_rx = &uart1_int_rx;
serial1.config = config; serial1.config = config;
/* register UART1 device */ /* register UART1 device */
...@@ -833,9 +825,9 @@ void rt_hw_serial_init(void) ...@@ -833,9 +825,9 @@ void rt_hw_serial_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial2.ops = &uart03_ops; serial2.ops = &uart03_ops;
serial2.int_rx = &uart2_int_rx;
serial2.config = config; serial2.config = config;
/* register UART2 device */ /* register UART2 device */
...@@ -852,9 +844,9 @@ void rt_hw_serial_init(void) ...@@ -852,9 +844,9 @@ void rt_hw_serial_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial3.ops = &uart03_ops; serial3.ops = &uart03_ops;
serial3.int_rx = &uart3_int_rx;
serial3.config = config; serial3.config = config;
/* register UART3 device */ /* register UART3 device */
...@@ -871,9 +863,9 @@ void rt_hw_serial_init(void) ...@@ -871,9 +863,9 @@ void rt_hw_serial_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial4.ops = &uart47_ops; serial4.ops = &uart47_ops;
serial4.int_rx = &uart4_int_rx;
serial4.config = config; serial4.config = config;
/* register UART4 device */ /* register UART4 device */
...@@ -890,9 +882,9 @@ void rt_hw_serial_init(void) ...@@ -890,9 +882,9 @@ void rt_hw_serial_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial5.ops = &uart47_ops; serial5.ops = &uart47_ops;
serial5.int_rx = &uart5_int_rx;
serial5.config = config; serial5.config = config;
/* register UART5 device */ /* register UART5 device */
...@@ -909,9 +901,9 @@ void rt_hw_serial_init(void) ...@@ -909,9 +901,9 @@ void rt_hw_serial_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial6.ops = &uart47_ops; serial6.ops = &uart47_ops;
serial6.int_rx = &uart6_int_rx;
serial6.config = config; serial6.config = config;
/* register UART6 device */ /* register UART6 device */
...@@ -928,9 +920,9 @@ void rt_hw_serial_init(void) ...@@ -928,9 +920,9 @@ void rt_hw_serial_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial7.ops = &uart47_ops; serial7.ops = &uart47_ops;
serial7.int_rx = &uart7_int_rx;
serial7.config = config; serial7.config = config;
/* register UART7 device */ /* register UART7 device */
......
...@@ -58,7 +58,7 @@ static void rt_hw_uart_isr(int irqno, void *param) ...@@ -58,7 +58,7 @@ static void rt_hw_uart_isr(int irqno, void *param)
{ {
struct rt_serial_device *serial = (struct rt_serial_device *)param; struct rt_serial_device *serial = (struct rt_serial_device *)param;
rt_hw_serial_isr(serial); rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
} }
static rt_err_t uart_configure(struct rt_serial_device *serial, struct serial_configure *cfg) static rt_err_t uart_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
...@@ -131,7 +131,6 @@ static const struct rt_uart_ops _uart_ops = ...@@ -131,7 +131,6 @@ static const struct rt_uart_ops _uart_ops =
#ifdef RT_USING_UART0 #ifdef RT_USING_UART0
/* UART device driver structure */ /* UART device driver structure */
static struct serial_ringbuffer _uart0_int_rx;
static struct hw_uart_device _uart0_device = static struct hw_uart_device _uart0_device =
{ {
REALVIEW_UART0_BASE, REALVIEW_UART0_BASE,
...@@ -142,7 +141,6 @@ static struct rt_serial_device _serial0; ...@@ -142,7 +141,6 @@ static struct rt_serial_device _serial0;
#ifdef RT_USING_UART1 #ifdef RT_USING_UART1
/* UART1 device driver structure */ /* UART1 device driver structure */
static struct serial_ringbuffer _uart1_int_rx;
static struct hw_uart_device _uart1_device = static struct hw_uart_device _uart1_device =
{ {
REALVIEW_UART1_BASE, REALVIEW_UART1_BASE,
...@@ -167,7 +165,8 @@ int rt_hw_uart_init(void) ...@@ -167,7 +165,8 @@ int rt_hw_uart_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
#ifdef RT_USING_UART0 #ifdef RT_USING_UART0
uart = &_uart0_device; uart = &_uart0_device;
#ifdef RT_USING_VMM #ifdef RT_USING_VMM
...@@ -175,12 +174,11 @@ int rt_hw_uart_init(void) ...@@ -175,12 +174,11 @@ int rt_hw_uart_init(void)
#endif #endif
_serial0.ops = &_uart_ops; _serial0.ops = &_uart_ops;
_serial0.int_rx = &_uart0_int_rx;
_serial0.config = config; _serial0.config = config;
/* register UART1 device */ /* register UART1 device */
rt_hw_serial_register(&_serial0, "uart0", rt_hw_serial_register(&_serial0, "uart0",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
uart); uart);
/* enable Rx and Tx of UART */ /* enable Rx and Tx of UART */
UART_CR(uart->hw_base) = (1 << 0) | (1 << 8) | (1 << 9); UART_CR(uart->hw_base) = (1 << 0) | (1 << 8) | (1 << 9);
...@@ -192,12 +190,11 @@ int rt_hw_uart_init(void) ...@@ -192,12 +190,11 @@ int rt_hw_uart_init(void)
uart->hw_base = vmm_find_iomap("UART1"); uart->hw_base = vmm_find_iomap("UART1");
#endif #endif
_serial1.ops = &_uart_ops; _serial1.ops = &_uart_ops;
_serial1.int_rx = &_uart1_int_rx;
_serial1.config = config; _serial1.config = config;
/* register UART1 device */ /* register UART1 device */
rt_hw_serial_register(&_serial1, "uart1", rt_hw_serial_register(&_serial1, "uart1",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, uart); RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, uart);
/* enable Rx and Tx of UART */ /* enable Rx and Tx of UART */
UART_CR(uart->hw_base) = (1 << 0) | (1 << 8) | (1 << 9); UART_CR(uart->hw_base) = (1 << 0) | (1 << 8) | (1 << 9);
#endif #endif
......
...@@ -178,11 +178,10 @@ static const struct rt_uart_ops _sci_ops = ...@@ -178,11 +178,10 @@ static const struct rt_uart_ops _sci_ops =
static void _irq_wrapper(int vector, void *param) static void _irq_wrapper(int vector, void *param)
{ {
rt_hw_serial_isr((struct rt_serial_device*)param); rt_hw_serial_isr((struct rt_serial_device*)param, RT_SERIAL_EVENT_RX_IND);
} }
static struct rt_serial_device _sci2_serial; static struct rt_serial_device _sci2_serial;
static struct serial_ringbuffer _sci2_int_rx;
void rt_hw_uart_init(void) void rt_hw_uart_init(void)
{ {
...@@ -195,9 +194,9 @@ void rt_hw_uart_init(void) ...@@ -195,9 +194,9 @@ void rt_hw_uart_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
_sci2_serial.ops = &_sci_ops; _sci2_serial.ops = &_sci_ops;
_sci2_serial.int_rx = &_sci2_int_rx;
_sci2_serial.config = config; _sci2_serial.config = config;
rt_hw_serial_register(&_sci2_serial, "sci2", rt_hw_serial_register(&_sci2_serial, "sci2",
...@@ -208,3 +207,4 @@ void rt_hw_uart_init(void) ...@@ -208,3 +207,4 @@ void rt_hw_uart_init(void)
rt_hw_interrupt_install(SCI_INT_VEC, _irq_wrapper, &_sci2_serial, "sci2"); rt_hw_interrupt_install(SCI_INT_VEC, _irq_wrapper, &_sci2_serial, "sci2");
rt_hw_interrupt_umask(SCI_INT_VEC); rt_hw_interrupt_umask(SCI_INT_VEC);
} }
...@@ -134,7 +134,6 @@ static const struct rt_uart_ops stm32_uart_ops = ...@@ -134,7 +134,6 @@ static const struct rt_uart_ops stm32_uart_ops =
#if defined(RT_USING_UART1) #if defined(RT_USING_UART1)
/* UART1 device driver structure */ /* UART1 device driver structure */
struct serial_ringbuffer uart1_int_rx;
struct stm32_uart uart1 = struct stm32_uart uart1 =
{ {
USART1, USART1,
...@@ -152,7 +151,7 @@ void USART1_IRQHandler(void) ...@@ -152,7 +151,7 @@ void USART1_IRQHandler(void)
rt_interrupt_enter(); rt_interrupt_enter();
if(USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET) if(USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
{ {
rt_hw_serial_isr(&serial1); rt_hw_serial_isr(&serial1, RT_SERIAL_EVENT_RX_IND);
/* clear interrupt */ /* clear interrupt */
USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE); USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE);
} }
...@@ -169,7 +168,6 @@ void USART1_IRQHandler(void) ...@@ -169,7 +168,6 @@ void USART1_IRQHandler(void)
#if defined(RT_USING_UART2) #if defined(RT_USING_UART2)
/* UART2 device driver structure */ /* UART2 device driver structure */
struct serial_ringbuffer uart2_int_rx;
struct stm32_uart uart2 = struct stm32_uart uart2 =
{ {
USART2, USART2,
...@@ -187,7 +185,7 @@ void USART2_IRQHandler(void) ...@@ -187,7 +185,7 @@ void USART2_IRQHandler(void)
rt_interrupt_enter(); rt_interrupt_enter();
if(USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET) if(USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
{ {
rt_hw_serial_isr(&serial2); rt_hw_serial_isr(&serial2, RT_SERIAL_EVENT_RX_IND);
/* clear interrupt */ /* clear interrupt */
USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE); USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE);
} }
...@@ -281,14 +279,13 @@ void rt_hw_usart_init(void) ...@@ -281,14 +279,13 @@ void rt_hw_usart_init(void)
config.baud_rate = BAUD_RATE_115200; config.baud_rate = BAUD_RATE_115200;
serial1.ops = &stm32_uart_ops; serial1.ops = &stm32_uart_ops;
serial1.int_rx = &uart1_int_rx;
serial1.config = config; serial1.config = config;
NVIC_Configuration(&uart1); NVIC_Configuration(&uart1);
/* register UART1 device */ /* register UART1 device */
rt_hw_serial_register(&serial1, "uart1", rt_hw_serial_register(&serial1, "uart1",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
uart); uart);
#endif /* RT_USING_UART1 */ #endif /* RT_USING_UART1 */
...@@ -297,7 +294,6 @@ void rt_hw_usart_init(void) ...@@ -297,7 +294,6 @@ void rt_hw_usart_init(void)
config.baud_rate = BAUD_RATE_115200; config.baud_rate = BAUD_RATE_115200;
serial2.ops = &stm32_uart_ops; serial2.ops = &stm32_uart_ops;
serial2.int_rx = &uart2_int_rx;
serial2.config = config; serial2.config = config;
NVIC_Configuration(&uart2); NVIC_Configuration(&uart2);
......
...@@ -97,7 +97,6 @@ static const struct rt_uart_ops lpc_uart_ops = ...@@ -97,7 +97,6 @@ static const struct rt_uart_ops lpc_uart_ops =
#if defined(RT_USING_UART0) #if defined(RT_USING_UART0)
/* UART0 device driver structure */ /* UART0 device driver structure */
struct serial_ringbuffer uart0_int_rx;
struct lpc_uart uart0 = struct lpc_uart uart0 =
{ {
LPC_USART0, LPC_USART0,
...@@ -136,7 +135,7 @@ void UART0_IRQHandler(void) ...@@ -136,7 +135,7 @@ void UART0_IRQHandler(void)
/* read the data to buffer */ /* read the data to buffer */
while (uart->USART->LSR & UART_LSR_RDR) while (uart->USART->LSR & UART_LSR_RDR)
{ {
rt_hw_serial_isr(&serial0); rt_hw_serial_isr(&serial0, RT_SERIAL_EVENT_RX_IND);
} }
break; break;
...@@ -150,7 +149,6 @@ void UART0_IRQHandler(void) ...@@ -150,7 +149,6 @@ void UART0_IRQHandler(void)
#endif #endif
#if defined(RT_USING_UART2) #if defined(RT_USING_UART2)
/* UART2 device driver structure */ /* UART2 device driver structure */
struct serial_ringbuffer uart2_int_rx;
struct lpc_uart uart2 = struct lpc_uart uart2 =
{ {
LPC_USART2, LPC_USART2,
...@@ -189,7 +187,7 @@ void UART2_IRQHandler(void) ...@@ -189,7 +187,7 @@ void UART2_IRQHandler(void)
/* read the data to buffer */ /* read the data to buffer */
while (uart->USART->LSR & UART_LSR_RDR) while (uart->USART->LSR & UART_LSR_RDR)
{ {
rt_hw_serial_isr(&serial0); rt_hw_serial_isr(&serial0, RT_SERIAL_EVENT_RX_IND);
} }
break; break;
...@@ -214,9 +212,9 @@ void rt_hw_uart_init(void) ...@@ -214,9 +212,9 @@ void rt_hw_uart_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial0.ops = &lpc_uart_ops; serial0.ops = &lpc_uart_ops;
serial0.int_rx = &uart0_int_rx;
serial0.config = config; serial0.config = config;
/* Enable GPIO register interface clock */ /* Enable GPIO register interface clock */
...@@ -256,7 +254,7 @@ void rt_hw_uart_init(void) ...@@ -256,7 +254,7 @@ void rt_hw_uart_init(void)
/* register UART1 device */ /* register UART1 device */
rt_hw_serial_register(&serial0, "uart0", rt_hw_serial_register(&serial0, "uart0",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
uart); uart);
#endif #endif
#ifdef RT_USING_UART2 #ifdef RT_USING_UART2
...@@ -267,9 +265,9 @@ void rt_hw_uart_init(void) ...@@ -267,9 +265,9 @@ void rt_hw_uart_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
serial2.ops = &lpc_uart_ops; serial2.ops = &lpc_uart_ops;
serial2.int_rx = &uart2_int_rx;
serial2.config = config; serial2.config = config;
/* Enable GPIO register interface clock */ /* Enable GPIO register interface clock */
...@@ -309,7 +307,7 @@ void rt_hw_uart_init(void) ...@@ -309,7 +307,7 @@ void rt_hw_uart_init(void)
/* register UART1 device */ /* register UART1 device */
rt_hw_serial_register(&serial2, "uart2", rt_hw_serial_register(&serial2, "uart2",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
uart); uart);
#endif #endif
} }
...@@ -98,7 +98,7 @@ static void rt_hw_uart_isr(int irqno, void *param) ...@@ -98,7 +98,7 @@ static void rt_hw_uart_isr(int irqno, void *param)
{ {
struct rt_serial_device *serial = (struct rt_serial_device *)param; struct rt_serial_device *serial = (struct rt_serial_device *)param;
rt_hw_serial_isr(serial); rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
} }
static rt_err_t uart_configure(struct rt_serial_device *serial, struct serial_configure *cfg) static rt_err_t uart_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
...@@ -267,9 +267,7 @@ static struct hw_uart_device _uart_device1 = ...@@ -267,9 +267,7 @@ static struct hw_uart_device _uart_device1 =
.txmio = (rt_uint32_t*)(Zynq7000_SLCR_BASE+0x07C0), /* MIO48 */ .txmio = (rt_uint32_t*)(Zynq7000_SLCR_BASE+0x07C0), /* MIO48 */
}; };
static struct serial_ringbuffer _uart_int_rx0;
static struct rt_serial_device _serial0; static struct rt_serial_device _serial0;
static struct serial_ringbuffer _uart_int_rx1;
static struct rt_serial_device _serial1; static struct rt_serial_device _serial1;
int rt_hw_uart_init(void) int rt_hw_uart_init(void)
...@@ -282,21 +280,20 @@ int rt_hw_uart_init(void) ...@@ -282,21 +280,20 @@ int rt_hw_uart_init(void)
config.parity = PARITY_NONE; config.parity = PARITY_NONE;
config.stop_bits = STOP_BITS_1; config.stop_bits = STOP_BITS_1;
config.invert = NRZ_NORMAL; config.invert = NRZ_NORMAL;
config.bufsz = RT_SERIAL_RB_BUFSZ;
_serial0.ops = &_uart_ops; _serial0.ops = &_uart_ops;
_serial0.int_rx = &_uart_int_rx0;
_serial0.config = config; _serial0.config = config;
_serial1.ops = &_uart_ops; _serial1.ops = &_uart_ops;
_serial1.int_rx = &_uart_int_rx1;
_serial1.config = config; _serial1.config = config;
/* register uart device */ /* register uart device */
rt_hw_serial_register(&_serial0, "uart0", rt_hw_serial_register(&_serial0, "uart0",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
&_uart_device0); &_uart_device0);
rt_hw_serial_register(&_serial1, "uart1", rt_hw_serial_register(&_serial1, "uart1",
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX | RT_DEVICE_FLAG_STREAM, RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
&_uart_device1); &_uart_device1);
return 0; return 0;
} }
......
...@@ -70,6 +70,15 @@ ...@@ -70,6 +70,15 @@
#define RT_DEVICE_CTRL_CLR_INT 0x11 /* disable receive irq */ #define RT_DEVICE_CTRL_CLR_INT 0x11 /* disable receive irq */
#define RT_DEVICE_CTRL_GET_INT 0x12 #define RT_DEVICE_CTRL_GET_INT 0x12
#define RT_SERIAL_EVENT_RX_IND 0x01 /* Rx indication */
#define RT_SERIAL_EVENT_TX_DONE 0x02 /* Tx complete */
#define RT_SERIAL_EVENT_RX_DMADONE 0x03 /* Rx DMA transfer done */
#define RT_SERIAL_EVENT_TX_DMADONE 0x04 /* Tx DMA transfer done */
#define RT_SERIAL_EVENT_RX_TIMEOUT 0x05 /* Rx timeout */
#define RT_SERIAL_DMA_RX 0x01
#define RT_SERIAL_DMA_TX 0x02
#define RT_SERIAL_RX_INT 0x01 #define RT_SERIAL_RX_INT 0x01
#define RT_SERIAL_TX_INT 0x02 #define RT_SERIAL_TX_INT 0x02
...@@ -89,24 +98,51 @@ ...@@ -89,24 +98,51 @@
PARITY_NONE, /* No parity */ \ PARITY_NONE, /* No parity */ \
BIT_ORDER_LSB, /* LSB first sent */ \ BIT_ORDER_LSB, /* LSB first sent */ \
NRZ_NORMAL, /* Normal mode */ \ NRZ_NORMAL, /* Normal mode */ \
RT_SERIAL_RB_BUFSZ, /* Buffer size */ \
0 \ 0 \
} }
struct serial_ringbuffer
{
rt_uint8_t buffer[RT_SERIAL_RB_BUFSZ];
rt_uint16_t put_index, get_index;
};
struct serial_configure struct serial_configure
{ {
rt_uint32_t baud_rate; rt_uint32_t baud_rate;
rt_uint32_t data_bits :4; rt_uint32_t data_bits :4;
rt_uint32_t stop_bits :2; rt_uint32_t stop_bits :2;
rt_uint32_t parity :2; rt_uint32_t parity :2;
rt_uint32_t bit_order :1; rt_uint32_t bit_order :1;
rt_uint32_t invert :1; rt_uint32_t invert :1;
rt_uint32_t reserved :20; rt_uint32_t bufsz :16;
rt_uint32_t reserved :4;
};
/*
* Serial FIFO mode
*/
struct rt_serial_rx_fifo
{
/* software fifo */
rt_uint8_t *buffer;
rt_uint16_t put_index, get_index;
};
struct rt_serial_tx_fifo
{
struct rt_completion completion;
};
/*
* Serial DMA mode
*/
struct rt_serial_rx_dma
{
rt_bool_t activated;
};
struct rt_serial_tx_dma
{
rt_bool_t activated;
struct rt_data_queue data_queue;
}; };
struct rt_serial_device struct rt_serial_device
...@@ -116,14 +152,8 @@ struct rt_serial_device ...@@ -116,14 +152,8 @@ struct rt_serial_device
const struct rt_uart_ops *ops; const struct rt_uart_ops *ops;
struct serial_configure config; struct serial_configure config;
/* rx structure */ void *serial_rx;
struct serial_ringbuffer *int_rx; void *serial_tx;
/* tx structure */
struct serial_ringbuffer *int_tx;
struct rt_data_queue tx_dq; /* tx dataqueue */
volatile rt_bool_t dma_flag; /* dma transfer flag */
}; };
typedef struct rt_serial_device rt_serial_t; typedef struct rt_serial_device rt_serial_t;
...@@ -138,14 +168,15 @@ struct rt_uart_ops ...@@ -138,14 +168,15 @@ struct rt_uart_ops
int (*putc)(struct rt_serial_device *serial, char c); int (*putc)(struct rt_serial_device *serial, char c);
int (*getc)(struct rt_serial_device *serial); int (*getc)(struct rt_serial_device *serial);
rt_size_t (*dma_transmit)(struct rt_serial_device *serial, const char *buf, rt_size_t size); rt_size_t (*dma_transmit)(struct rt_serial_device *serial, const rt_uint8_t *buf, rt_size_t size, int direction);
}; };
void rt_hw_serial_isr(struct rt_serial_device *serial); void rt_hw_serial_isr(struct rt_serial_device *serial, int event);
void rt_hw_serial_dma_tx_isr(struct rt_serial_device *serial);
rt_err_t rt_hw_serial_register(struct rt_serial_device *serial, rt_err_t rt_hw_serial_register(struct rt_serial_device *serial,
const char *name, const char *name,
rt_uint32_t flag, rt_uint32_t flag,
void *data); void *data);
#endif #endif
此差异已折叠。
...@@ -306,8 +306,8 @@ void finsh_thread_entry(void* parameter) ...@@ -306,8 +306,8 @@ void finsh_thread_entry(void* parameter)
#ifdef RT_USING_CONSOLE #ifdef RT_USING_CONSOLE
shell->device = rt_console_get_device(); shell->device = rt_console_get_device();
RT_ASSERT(shell->device); RT_ASSERT(shell->device);
rt_device_open(shell->device, RT_DEVICE_OFLAG_RDWR);
rt_device_set_rx_indicate(shell->device, finsh_rx_ind); rt_device_set_rx_indicate(shell->device, finsh_rx_ind);
rt_device_open(shell->device, RT_DEVICE_OFLAG_RDWR | RT_DEVICE_FLAG_INT_RX);
#else #else
RT_ASSERT(shell->device); RT_ASSERT(shell->device);
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册