summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryaoyufan <[email protected]>2021-04-23 10:21:10 +0800
committeryaoyufan <[email protected]>2021-04-23 10:21:10 +0800
commite2d4a912beb77f55b12920ef2402b3e472dc2962 (patch)
treebff3ae0053569754b441a219cc67ec0fd11752cb
parente3c19a846348adc6b66a1cc449cbbd26622eee45 (diff)
fix bluetrum uart1 and uart2 cannot recv data
-rw-r--r--bsp/bluetrum/libraries/hal_drivers/drv_usart.c39
1 files changed, 30 insertions, 9 deletions
diff --git a/bsp/bluetrum/libraries/hal_drivers/drv_usart.c b/bsp/bluetrum/libraries/hal_drivers/drv_usart.c
index f09cffee61..16dd7f9366 100644
--- a/bsp/bluetrum/libraries/hal_drivers/drv_usart.c
+++ b/bsp/bluetrum/libraries/hal_drivers/drv_usart.c
@@ -221,18 +221,39 @@ void uart_irq_process(struct rt_serial_device *serial)
rt_hw_interrupt_enable(level);
}
- rt_size_t rx_length;
+ if(serial == &uart_obj[0].serial)
+ {
+ rt_size_t rx_length;
- /* get rx length */
- level = rt_hw_interrupt_disable();
- rx_length = (rx_fifo->put_index >= rx_fifo->get_index)? (rx_fifo->put_index - rx_fifo->get_index):
- (serial->config.bufsz - (rx_fifo->get_index - rx_fifo->put_index));
- rt_hw_interrupt_enable(level);
+ /* get rx length */
+ level = rt_hw_interrupt_disable();
+ rx_length = (rx_fifo->put_index >= rx_fifo->get_index)? (rx_fifo->put_index - rx_fifo->get_index):
+ (serial->config.bufsz - (rx_fifo->get_index - rx_fifo->put_index));
+ rt_hw_interrupt_enable(level);
- if (rx_length)
- {
- shell_rx_ind();
+ if (rx_length)
+ {
+ shell_rx_ind();
+ }
+ }else {
+ /* invoke callback */
+ if (serial->parent.rx_indicate != RT_NULL)
+ {
+ rt_size_t rx_length;
+
+ /* get rx length */
+ level = rt_hw_interrupt_disable();
+ rx_length = (rx_fifo->put_index >= rx_fifo->get_index)? (rx_fifo->put_index - rx_fifo->get_index):
+ (serial->config.bufsz - (rx_fifo->get_index - rx_fifo->put_index));
+ rt_hw_interrupt_enable(level);
+
+ if (rx_length)
+ {
+ serial->parent.rx_indicate(&serial->parent, rx_length);
+ }
+ }
}
+
}
RT_SECTION(".irq.usart")