diff --git a/os/hal/include/hal_uart.h b/os/hal/include/hal_uart.h index 9e5d2a373..a07464993 100644 --- a/os/hal/include/hal_uart.h +++ b/os/hal/include/hal_uart.h @@ -43,6 +43,13 @@ #define UART_BREAK_DETECTED 64 /**< @brief Break detected. */ /** @} */ +/** + * @name UART error conditions + * @{ + */ +#define UART_ERR_NOT_ACTIVE (size_t)-1 +/** @} */ + /*===========================================================================*/ /* Driver pre-compile time settings. */ /*===========================================================================*/ diff --git a/os/hal/src/hal_uart.c b/os/hal/src/hal_uart.c index dd9f4a6d2..2d6a4c408 100644 --- a/os/hal/src/hal_uart.c +++ b/os/hal/src/hal_uart.c @@ -188,7 +188,7 @@ void uartStartSendI(UARTDriver *uartp, size_t n, const void *txbuf) { * * @return The number of data frames not transmitted by the * stopped transmit operation. - * @retval 0 There was no transmit operation in progress. + * @retval UART_ERR_NOT_ACTIVE if there was no transmit operation in progress. * * @api */ @@ -205,7 +205,7 @@ size_t uartStopSend(UARTDriver *uartp) { uartp->txstate = UART_TX_IDLE; } else { - n = 0; + n = UART_ERR_NOT_ACTIVE; } osalSysUnlock(); @@ -221,7 +221,7 @@ size_t uartStopSend(UARTDriver *uartp) { * * @return The number of data frames not transmitted by the * stopped transmit operation. - * @retval 0 There was no transmit operation in progress. + * @retval UART_ERR_NOT_ACTIVE if there was no transmit operation in progress. * * @iclass */ @@ -236,7 +236,7 @@ size_t uartStopSendI(UARTDriver *uartp) { uartp->txstate = UART_TX_IDLE; return n; } - return 0; + return UART_ERR_NOT_ACTIVE; } /** @@ -294,7 +294,7 @@ void uartStartReceiveI(UARTDriver *uartp, size_t n, void *rxbuf) { * * @return The number of data frames not received by the * stopped receive operation. - * @retval 0 There was no receive operation in progress. + * @retval UART_ERR_NOT_ACTIVE if there was no receive operation in progress. * * @api */ @@ -311,7 +311,7 @@ size_t uartStopReceive(UARTDriver *uartp) { uartp->rxstate = UART_RX_IDLE; } else { - n = 0; + n = UART_ERR_NOT_ACTIVE; } osalSysUnlock(); @@ -327,7 +327,7 @@ size_t uartStopReceive(UARTDriver *uartp) { * * @return The number of data frames not received by the * stopped receive operation. - * @retval 0 There was no receive operation in progress. + * @retval UART_ERR_NOT_ACTIVE if there was no receive operation in progress. * * @iclass */ @@ -342,7 +342,7 @@ size_t uartStopReceiveI(UARTDriver *uartp) { uartp->rxstate = UART_RX_IDLE; return n; } - return 0; + return UART_ERR_NOT_ACTIVE; } #if (UART_USE_WAIT == TRUE) || defined(__DOXYGEN__) diff --git a/readme.txt b/readme.txt index 746c2d37e..f8708db89 100644 --- a/readme.txt +++ b/readme.txt @@ -126,6 +126,8 @@ - EX: Updated LIS302DL to 1.1.0 (backported to 18.2.1). - EX: Updated LPS25H to 1.1.0 (backported to 18.2.1). - EX: Updated LSM303DLHC to 1.1.0 (backported to 18.2.1). +- HAL: Fixed missing definition in UART driver (bug #948)(backported + to 18.2.2). - OTH: Fixed wrong macro check in GCC Cortex-M startup files (bug #947) (backported to 18.2.2 and 17.6.5). - HAL: Fixed binary instead of logic operator in STM32F4 HAL (bug #946)