From ca59ce3238108443bf04729f717f9c37d3472937 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Sun, 1 Nov 2015 10:56:12 +0000 Subject: Fixed bug #659. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8415 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/serial.h | 26 ++------------------------ os/hal/src/serial.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 24 deletions(-) (limited to 'os') diff --git a/os/hal/include/serial.h b/os/hal/include/serial.h index 23dc7efc6..de5c911c0 100644 --- a/os/hal/include/serial.h +++ b/os/hal/include/serial.h @@ -131,30 +131,6 @@ struct SerialDriver { * @name Macro Functions * @{ */ -/** - * @brief Direct output check on a @p SerialDriver. - * @note This function bypasses the indirect access to the channel and - * checks directly the output queue. This is faster but cannot - * be used to check different channels implementations. - * - * @deprecated - * - * @api - */ -#define sdPutWouldBlock(sdp) oqIsFullI(&(sdp)->oqueue) - -/** - * @brief Direct input check on a @p SerialDriver. - * @note This function bypasses the indirect access to the channel and - * checks directly the input queue. This is faster but cannot - * be used to check different channels implementations. - * - * @deprecated - * - * @api - */ -#define sdGetWouldBlock(sdp) iqIsEmptyI(&(sdp)->iqueue) - /** * @brief Direct write to a @p SerialDriver. * @note This function bypasses the indirect access to the channel and @@ -297,6 +273,8 @@ extern "C" { void sdStop(SerialDriver *sdp); void sdIncomingDataI(SerialDriver *sdp, uint8_t b); msg_t sdRequestDataI(SerialDriver *sdp); + bool sdPutWouldBlock(SerialDriver *sdp); + bool sdGetWouldBlock(SerialDriver *sdp); #ifdef __cplusplus } #endif diff --git a/os/hal/src/serial.c b/os/hal/src/serial.c index 4b3111412..609e5a348 100644 --- a/os/hal/src/serial.c +++ b/os/hal/src/serial.c @@ -234,6 +234,55 @@ msg_t sdRequestDataI(SerialDriver *sdp) { return b; } +/** + * @brief Direct output check on a @p SerialDriver. + * @note This function bypasses the indirect access to the channel and + * checks directly the output queue. This is faster but cannot + * be used to check different channels implementations. + * + * @param[in] sdp pointer to a @p SerialDriver structure + * @return The queue status. + * @retval false if the next write operation would not block. + * @retval true if the next write operation would block. + * + * @deprecated + * + * @api + */ +bool sdPutWouldBlock(SerialDriver *sdp) { + bool b; + + osalSysLock(); + b = oqIsFullI(&sdp->oqueue); + osalSysUnlock(); + + return b; +} + +/** + * @brief Direct input check on a @p SerialDriver. + * @note This function bypasses the indirect access to the channel and + * checks directly the input queue. This is faster but cannot + * be used to check different channels implementations. + * + * @return The queue status. + * @retval false if the next write operation would not block. + * @retval true if the next write operation would block. + * + * @deprecated + * + * @api + */ +bool sdGetWouldBlock(SerialDriver *sdp) { + bool b; + + osalSysLock(); + b = iqIsEmptyI(&sdp->iqueue); + osalSysUnlock(); + + return b; +} + #endif /* HAL_USE_SERIAL == TRUE */ /** @} */ -- cgit v1.2.3