[Drivers] re-write serial framework.
This commit is contained in:
parent
a83558e0e2
commit
74377b2650
|
@ -137,7 +137,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,
|
||||||
|
@ -155,7 +154,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);
|
||||||
}
|
}
|
||||||
|
@ -172,7 +171,6 @@ void USART1_IRQHandler(void)
|
||||||
|
|
||||||
#if defined(RT_USING_UART2)
|
#if defined(RT_USING_UART2)
|
||||||
/* UART1 device driver structure */
|
/* UART1 device driver structure */
|
||||||
struct serial_ringbuffer uart2_int_rx;
|
|
||||||
struct stm32_uart uart2 =
|
struct stm32_uart uart2 =
|
||||||
{
|
{
|
||||||
USART2,
|
USART2,
|
||||||
|
@ -190,7 +188,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);
|
||||||
}
|
}
|
||||||
|
@ -207,7 +205,6 @@ void USART2_IRQHandler(void)
|
||||||
|
|
||||||
#if defined(RT_USING_UART3)
|
#if defined(RT_USING_UART3)
|
||||||
/* UART1 device driver structure */
|
/* UART1 device driver structure */
|
||||||
struct serial_ringbuffer uart3_int_rx;
|
|
||||||
struct stm32_uart uart3 =
|
struct stm32_uart uart3 =
|
||||||
{
|
{
|
||||||
USART3,
|
USART3,
|
||||||
|
@ -225,7 +222,7 @@ void USART3_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(&serial3);
|
rt_hw_serial_isr(&serial3, 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);
|
||||||
}
|
}
|
||||||
|
@ -329,14 +326,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 */
|
||||||
|
|
||||||
|
@ -345,7 +341,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);
|
||||||
|
@ -362,7 +357,6 @@ void rt_hw_usart_init(void)
|
||||||
config.baud_rate = BAUD_RATE_115200;
|
config.baud_rate = BAUD_RATE_115200;
|
||||||
|
|
||||||
serial3.ops = &stm32_uart_ops;
|
serial3.ops = &stm32_uart_ops;
|
||||||
serial3.int_rx = &uart3_int_rx;
|
|
||||||
serial3.config = config;
|
serial3.config = config;
|
||||||
|
|
||||||
NVIC_Configuration(&uart3);
|
NVIC_Configuration(&uart3);
|
||||||
|
|
Loading…
Reference in New Issue