Skip to content

Commit

Permalink
[STM32] Serial interrupt TC vs. TXE
Browse files Browse the repository at this point in the history
Reported in Issue #2119

There was some inconsistency in serial interrupt handling accross STM32
serial_api.c implementation. In case application wants to be notified of
Tx interrupt, it is mainly interested in transmission complete information,
which is the _TC interrupt.

The _TXE (Transmit Data REgister Empty) is used only within driver
in case SERIAL_ASYNCH is being supported to make the transmission
more efficient.
  • Loading branch information
Laurent MEUNIER committed Jul 8, 2016
1 parent 57c28a9 commit 9c33f70
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions hal/targets/hal/TARGET_STM/TARGET_STM32F4/serial_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
NVIC_EnableIRQ(irq_n);
#endif
} else { // TxIrq
__HAL_UART_ENABLE_IT(handle, UART_IT_TXE);
__HAL_UART_ENABLE_IT(handle, UART_IT_TC);
NVIC_SetVector(irq_n, vector);
NVIC_EnableIRQ(irq_n);
#if DEVICE_SERIAL_ASYNCH_DMA
Expand All @@ -788,7 +788,7 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
// Check if TxIrq is disabled too
if ((handle->Instance->CR1 & USART_CR1_TXEIE) == 0) all_disabled = 1;
} else { // TxIrq
__HAL_UART_DISABLE_IT(handle, UART_IT_TXE);
__HAL_UART_DISABLE_IT(handle, UART_IT_TC);
// Check if RxIrq is disabled too
if ((handle->Instance->CR1 & USART_CR1_RXNEIE) == 0) all_disabled = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion hal/targets/hal/TARGET_STM/TARGET_STM32F7/serial_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
// Check if TxIrq is disabled too
if ((UartHandle.Instance->CR1 & USART_CR1_TXEIE) == 0) all_disabled = 1;
} else { // TxIrq
__HAL_UART_DISABLE_IT(&UartHandle, UART_IT_TXE);
__HAL_UART_DISABLE_IT(&UartHandle, UART_IT_TC);
// Check if RxIrq is disabled too
if ((UartHandle.Instance->CR1 & USART_CR1_RXNEIE) == 0) all_disabled = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion hal/targets/hal/TARGET_STM/TARGET_STM32L1/serial_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
// Check if TxIrq is disabled too
if ((UartHandle.Instance->CR1 & USART_CR1_TXEIE) == 0) all_disabled = 1;
} else { // TxIrq
__HAL_UART_DISABLE_IT(&UartHandle, UART_IT_TXE);
__HAL_UART_DISABLE_IT(&UartHandle, UART_IT_TC);
// Check if RxIrq is disabled too
if ((UartHandle.Instance->CR1 & USART_CR1_RXNEIE) == 0) all_disabled = 1;
}
Expand Down
2 changes: 1 addition & 1 deletion hal/targets/hal/TARGET_STM/TARGET_STM32L4/serial_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
// Check if TxIrq is disabled too
if ((UartHandle.Instance->CR1 & USART_CR1_TXEIE) == 0) all_disabled = 1;
} else { // TxIrq
__HAL_UART_DISABLE_IT(&UartHandle, UART_IT_TXE);
__HAL_UART_DISABLE_IT(&UartHandle, UART_IT_TC);
// Check if RxIrq is disabled too
if ((UartHandle.Instance->CR1 & USART_CR1_RXNEIE) == 0) all_disabled = 1;
}
Expand Down

0 comments on commit 9c33f70

Please sign in to comment.