diff --git a/os/hal/include/hal_uart.h b/os/hal/include/hal_uart.h index a0683592c..9e5d2a373 100644 --- a/os/hal/include/hal_uart.h +++ b/os/hal/include/hal_uart.h @@ -185,6 +185,23 @@ typedef enum { #define _uart_wakeup_rx_error_isr(uartp) #endif /* !UART_USE_WAIT */ +#if (UART_USE_WAIT == TRUE) || defined(__DOXYGEN__) +/** + * @brief Wakes up the waiting thread in case of RX character match. + * + * @param[in] uartp pointer to the @p UARTDriver object + * + * @notapi + */ +#define _uart_wakeup_rx_cm_isr(uartp) { \ + osalSysLockFromISR(); \ + osalThreadResumeI(&(uartp)->threadrx, MSG_TIMEOUT); \ + osalSysUnlockFromISR(); \ +} +#else /* !UART_USE_WAIT */ +#define _uart_wakeup_rx_cm_isr(uartp) +#endif /* !UART_USE_WAIT */ + #if (UART_USE_WAIT == TRUE) || defined(__DOXYGEN__) /** * @brief Wakes up the waiting thread in case of RX timeout. @@ -336,6 +353,27 @@ typedef enum { _uart_wakeup_rx_timeout_isr(uartp); \ } +/** + * @brief Character match ISR code for receiver. + * @details This code handles the portable part of the ISR code: + * - Callback invocation. + * - Waiting thread wakeup, if any. + * - Driver state transitions. + * . + * @note This macro is meant to be used in the low level drivers + * implementation only. + * + * @param[in] uartp pointer to the @p UARTDriver object + * + * @notapi + */ +#define _uart_rx_char_match_isr_code(uartp) { \ + if ((uartp)->config->rx_cm_cb != NULL) { \ + (uartp)->config->rx_cm_cb(uartp); \ + } \ + _uart_wakeup_rx_cm_isr(uartp); \ +} + /** @} */ /*===========================================================================*/ diff --git a/readme.txt b/readme.txt index 338a2d26b..56f1419a1 100644 --- a/readme.txt +++ b/readme.txt @@ -91,6 +91,8 @@ ***************************************************************************** *** Next *** +- NEW: Added optional support for character match callback in the UART + high level driver. - NEW: Change, chMtxGetNextMutexS() renamed to chMtxGetNextMutexX(). - NEW: RT C++ wrapper reworked, now it is mostly inline code, added some new wrappers and methods. Added wrappers for more API functions. BaseThreads