[STM32. USARTv2] Added synchronous API support for timeout feature.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9714 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Uladzimir Pylinski 2016-07-20 18:41:06 +00:00
parent 0edf3f363b
commit 97f803c392
2 changed files with 23 additions and 2 deletions

View File

@ -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 timeout.
*
* @param[in] uartp pointer to the @p UARTDriver object
*
* @notapi
*/
#define _uart_wakeup_rx_timeout_isr(uartp) { \
osalSysLockFromISR(); \
osalThreadResumeI(&(uartp)->threadrx, MSG_TIMEOUT); \
osalSysUnlockFromISR(); \
}
#else /* !UART_USE_WAIT */
#define _uart_wakeup_rx_timeout_isr(uartp)
#endif /* !UART_USE_WAIT */
/**
* @brief Common ISR code for early TX.
* @details This code handles the portable part of the ISR code:
@ -314,8 +331,10 @@ typedef enum {
* @notapi
*/
#define _uart_timeout_isr_code(uartp) { \
if ((uartp)->config->timeout_cb != NULL) \
if ((uartp)->config->timeout_cb != NULL) { \
(uartp)->config->timeout_cb(uartp); \
} \
_uart_wakeup_rx_timeout_isr(uartp); \
}
/** @} */

View File

@ -587,11 +587,13 @@ typedef struct {
/* End of the mandatory fields.*/
/**
* @brief Receiver timeout callback.
* @details Handles both idle and timeout interrupts depending on configured
* flags in CR registers and supported hardware features.
*/
uartcb_t timeout_cb;
/**
* @brief Receiver timeout value in terms of number of bit duration.
* @details Set it to 0 when you want to handle IDLE interrupt instead of
* @details Set it to 0 when you want to handle idle interrupt instead of
* hardware timeout.
*/
uint32_t timeout;