From 0c9f553e4fed400108f90f1504e88d1882c097e6 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sun, 6 May 2018 14:56:30 +0000 Subject: Char match support in UART driver. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12009 110e8d01-0319-4d1e-a829-52ad28d1bb01 --- os/hal/include/hal_uart.h | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'os') 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); \ +} + /** @} */ /*===========================================================================*/ -- cgit v1.2.3