From 94ab7ac7e989e3c1f6723e6f6ed91df5f6dc019c Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Thu, 21 Jul 2016 10:07:25 +0000 Subject: [PATCH] git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9716 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/hal_uart.h | 1 - os/hal/ports/STM32/LLD/USARTv2/hal_uart_lld.c | 6 ++++-- os/hal/src/hal_uart.c | 6 ++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/os/hal/include/hal_uart.h b/os/hal/include/hal_uart.h index 677224541..5523b82f1 100644 --- a/os/hal/include/hal_uart.h +++ b/os/hal/include/hal_uart.h @@ -315,7 +315,6 @@ typedef enum { (uartp)->config->rxchar_cb(uartp, (uartp)->rxbuf); \ } - /** * @brief Timeout ISR code for receiver. * @details This code handles the portable part of the ISR code: diff --git a/os/hal/ports/STM32/LLD/USARTv2/hal_uart_lld.c b/os/hal/ports/STM32/LLD/USARTv2/hal_uart_lld.c index 0012ef259..e74f8b553 100644 --- a/os/hal/ports/STM32/LLD/USARTv2/hal_uart_lld.c +++ b/os/hal/ports/STM32/LLD/USARTv2/hal_uart_lld.c @@ -243,7 +243,7 @@ static void usart_start(UARTDriver *uartp) { cr1 = USART_CR1_UE | USART_CR1_PEIE | USART_CR1_TE | USART_CR1_RE; u->CR1 = uartp->config->cr1 | cr1; - /* Set receive timeout and check it appliance */ + /* Set receive timeout and checks if it is really applied.*/ if (tmo > 0) { osalDbgAssert(tmo <= USART_RTOR_RTO, "Timeout overflow"); u->RTOR = tmo; @@ -334,7 +334,9 @@ static void serve_usart_irq(UARTDriver *uartp) { _uart_tx2_isr_code(uartp); } - if ((isr & USART_ISR_IDLE) || (isr & USART_ISR_RTOF)) { + /* Timeout interrupt sources are only checked if enabled in CR1.*/ + if (((cr1 & USART_CR1_IDLEIE) && (isr & USART_ISR_IDLE)) || + ((cr1 & USART_CR1_RTOIE) && (isr & USART_ISR_RTOF))) { _uart_timeout_isr_code(uartp); } } diff --git a/os/hal/src/hal_uart.c b/os/hal/src/hal_uart.c index 72d6221dd..8df77adb5 100644 --- a/os/hal/src/hal_uart.c +++ b/os/hal/src/hal_uart.c @@ -352,6 +352,8 @@ size_t uartStopReceiveI(UARTDriver *uartp) { * sent to the UART or on timeout. * @note The buffers are organized as uint8_t arrays for data sizes below * or equal to 8 bits else it is organized as uint16_t arrays. + * @note This function implements a software timeout, it does not use + * any underlying HW timeout mechanism. * * @param[in] uartp pointer to the @p UARTDriver object * @param[in,out] np number of data frames to transmit, on exit the number @@ -395,6 +397,8 @@ msg_t uartSendTimeout(UARTDriver *uartp, size_t *np, * physically transmitted or on timeout. * @note The buffers are organized as uint8_t arrays for data sizes below * or equal to 8 bits else it is organized as uint16_t arrays. + * @note This function implements a software timeout, it does not use + * any underlying HW timeout mechanism. * * @param[in] uartp pointer to the @p UARTDriver object * @param[in,out] np number of data frames to transmit, on exit the number @@ -438,6 +442,8 @@ msg_t uartSendFullTimeout(UARTDriver *uartp, size_t *np, * received or on error/timeout. * @note The buffers are organized as uint8_t arrays for data sizes below * or equal to 8 bits else it is organized as uint16_t arrays. + * @note This function implements a software timeout, it does not use + * any underlying HW timeout mechanism. * * @param[in] uartp pointer to the @p UARTDriver object * @param[in,out] np number of data frames to receive, on exit the number