You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by ma...@apache.org on 2016/04/13 00:57:23 UTC
incubator-mynewt-core git commit: stm32f4;
UART would sometimes stall the system at the end of TX.
Repository: incubator-mynewt-core
Updated Branches:
refs/heads/develop aefda63ff -> f536eec79
stm32f4; UART would sometimes stall the system at the end of TX.
Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/commit/f536eec7
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/tree/f536eec7
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/diff/f536eec7
Branch: refs/heads/develop
Commit: f536eec79286747caecefc63bdf582b96574ca21
Parents: aefda63
Author: Marko Kiiskila <ma...@runtime.io>
Authored: Tue Apr 12 15:56:41 2016 -0700
Committer: Marko Kiiskila <ma...@runtime.io>
Committed: Tue Apr 12 15:56:41 2016 -0700
----------------------------------------------------------------------
hw/mcu/stm/stm32f4xx/src/hal_uart.c | 33 ++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-mynewt-core/blob/f536eec7/hw/mcu/stm/stm32f4xx/src/hal_uart.c
----------------------------------------------------------------------
diff --git a/hw/mcu/stm/stm32f4xx/src/hal_uart.c b/hw/mcu/stm/stm32f4xx/src/hal_uart.c
index aab0e6c..3b2868f 100644
--- a/hw/mcu/stm/stm32f4xx/src/hal_uart.c
+++ b/hw/mcu/stm/stm32f4xx/src/hal_uart.c
@@ -72,6 +72,7 @@ uart_irq_handler(int num)
struct hal_uart *u;
USART_TypeDef *regs;
uint32_t isr;
+ uint32_t cr1;
int data;
int rc;
@@ -90,22 +91,26 @@ uart_irq_handler(int num)
u->u_rx_stall = 1;
}
}
- if (isr & USART_SR_TXE) {
- data = u->u_tx_func(u->u_func_arg);
- if (data < 0) {
- regs->CR1 &= ~USART_CR1_TXEIE;
- regs->CR1 |= USART_CR1_TCIE;
- u->u_tx_end = 1;
- } else {
- regs->DR = data;
+ if (isr & (USART_SR_TXE | USART_SR_TC)) {
+ cr1 = regs->CR1;
+ if (isr & USART_SR_TXE) {
+ data = u->u_tx_func(u->u_func_arg);
+ if (data < 0) {
+ cr1 &= ~USART_CR1_TXEIE;
+ cr1 |= USART_CR1_TCIE;
+ u->u_tx_end = 1;
+ } else {
+ regs->DR = data;
+ }
}
- }
- if (u->u_tx_end == 1 && isr & USART_SR_TC) {
- if (u->u_tx_done) {
- u->u_tx_done(u->u_func_arg);
+ if (u->u_tx_end == 1 && isr & USART_SR_TC) {
+ if (u->u_tx_done) {
+ u->u_tx_done(u->u_func_arg);
+ }
+ u->u_tx_end = 0;
+ cr1 &= ~USART_CR1_TCIE;
}
- u->u_tx_end = 0;
- regs->CR1 &= ~USART_CR1_TCIE;
+ regs->CR1 = cr1;
}
}