aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2018-05-06 14:56:30 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2018-05-06 14:56:30 +0000
commit0c9f553e4fed400108f90f1504e88d1882c097e6 (patch)
treedb9b19303defdb8352a8f20fb4847582bfa6197d /os
parenta0c253d44da778e359c507c529a319f3f4d18b25 (diff)
downloadChibiOS-0c9f553e4fed400108f90f1504e88d1882c097e6.tar.gz
ChibiOS-0c9f553e4fed400108f90f1504e88d1882c097e6.tar.bz2
ChibiOS-0c9f553e4fed400108f90f1504e88d1882c097e6.zip
Char match support in UART driver.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12009 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'os')
-rw-r--r--os/hal/include/hal_uart.h38
1 files changed, 38 insertions, 0 deletions
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
@@ -187,6 +187,23 @@ typedef enum {
#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.
*
* @param[in] uartp pointer to the @p UARTDriver object
@@ -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); \
+}
+
/** @} */
/*===========================================================================*/