From 0e34cd051ed686263001af3a721f6858db94d072 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 9 Aug 2013 08:25:09 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6109 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/src/hal_queues.c | 402 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 402 insertions(+) create mode 100644 os/hal/src/hal_queues.c (limited to 'os/hal/src/hal_queues.c') diff --git a/os/hal/src/hal_queues.c b/os/hal/src/hal_queues.c new file mode 100644 index 000000000..36016a1e9 --- /dev/null +++ b/os/hal/src/hal_queues.c @@ -0,0 +1,402 @@ +/* + ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, + 2011,2012,2013 Giovanni Di Sirio. + + This file is part of ChibiOS/RT. + + ChibiOS/RT is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + ChibiOS/RT is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +/** + * @file hal_queues.c + * @brief I/O Queues code. + * + * @addtogroup io_queues + * @details ChibiOS/RT queues are mostly used in serial-like device drivers. + * The device drivers are usually designed to have a lower side + * (lower driver, it is usually an interrupt service routine) and an + * upper side (upper driver, accessed by the application threads).
+ * There are several kind of queues:
+ * - Input queue, unidirectional queue where the writer is the + * lower side and the reader is the upper side. + * - Output queue, unidirectional queue where the writer is the + * upper side and the reader is the lower side. + * - Full duplex queue, bidirectional queue. Full duplex queues + * are implemented by pairing an input queue and an output queue + * together. + * . + * @{ + */ + +#include "hal.h" + +#if !defined(_CHIBIOS_RT_) || !CH_USE_QUEUES || defined(__DOXYGEN__) + +/** + * @brief Initializes an input queue. + * @details A Semaphore is internally initialized and works as a counter of + * the bytes contained in the queue. + * @note The callback is invoked from within the S-Locked system state, + * see @ref system_states. + * + * @param[out] iqp pointer to an @p InputQueue structure + * @param[in] bp pointer to a memory area allocated as queue buffer + * @param[in] size size of the queue buffer + * @param[in] infy pointer to a callback function that is invoked when + * data is read from the queue. The value can be @p NULL. + * @param[in] link application defined pointer + * + * @init + */ +void iqInit(InputQueue *iqp, uint8_t *bp, size_t size, qnotify_t infy, + void *link) { + + osalQueueObjectInit(&iqp->q_waiting); + iqp->q_counter = 0; + iqp->q_buffer = iqp->q_rdptr = iqp->q_wrptr = bp; + iqp->q_top = bp + size; + iqp->q_notify = infy; + iqp->q_link = link; +} + +/** + * @brief Resets an input queue. + * @details All the data in the input queue is erased and lost, any waiting + * thread is resumed with status @p Q_RESET. + * @note A reset operation can be used by a low level driver in order to + * obtain immediate attention from the high level layers. + * + * @param[in] iqp pointer to an @p InputQueue structure + * + * @iclass + */ +void iqResetI(InputQueue *iqp) { + + osalDbgCheckClassI(); + + iqp->q_rdptr = iqp->q_wrptr = iqp->q_buffer; + iqp->q_counter = 0; + osalQueueWakeupAllI(&iqp->q_waiting, Q_RESET); +} + +/** + * @brief Input queue write. + * @details A byte value is written into the low end of an input queue. + * + * @param[in] iqp pointer to an @p InputQueue structure + * @param[in] b the byte value to be written in the queue + * @return The operation status. + * @retval Q_OK if the operation has been completed with success. + * @retval Q_FULL if the queue is full and the operation cannot be + * completed. + * + * @iclass + */ +msg_t iqPutI(InputQueue *iqp, uint8_t b) { + + osalDbgCheckClassI(); + + if (iqIsFullI(iqp)) + return Q_FULL; + + iqp->q_counter++; + *iqp->q_wrptr++ = b; + if (iqp->q_wrptr >= iqp->q_top) + iqp->q_wrptr = iqp->q_buffer; + + osalQueueWakeupOneI(&iqp->q_waiting, Q_OK); + + return Q_OK; +} + +/** + * @brief Input queue read with timeout. + * @details This function reads a byte value from an input queue. If the queue + * is empty then the calling thread is suspended until a byte arrives + * in the queue or a timeout occurs. + * @note The callback is invoked before reading the character from the + * buffer or before entering the state @p THD_STATE_WTQUEUE. + * + * @param[in] iqp pointer to an @p InputQueue structure + * @param[in] time the number of ticks before the operation timeouts, + * the following special values are allowed: + * - @a TIME_IMMEDIATE immediate timeout. + * - @a TIME_INFINITE no timeout. + * . + * @return A byte value from the queue. + * @retval Q_TIMEOUT if the specified time expired. + * @retval Q_RESET if the queue has been reset. + * + * @api + */ +msg_t iqGetTimeout(InputQueue *iqp, systime_t time) { + uint8_t b; + + osalSysLock(); + if (iqp->q_notify) + iqp->q_notify(iqp); + + while (iqIsEmptyI(iqp)) { + msg_t msg; + if ((msg = osalQueueGoSleepTimeoutS(&iqp->q_waiting, time)) < Q_OK) { + osalSysUnlock(); + return msg; + } + } + + iqp->q_counter--; + b = *iqp->q_rdptr++; + if (iqp->q_rdptr >= iqp->q_top) + iqp->q_rdptr = iqp->q_buffer; + + osalSysUnlock(); + return b; +} + +/** + * @brief Input queue read with timeout. + * @details The function reads data from an input queue into a buffer. The + * operation completes when the specified amount of data has been + * transferred or after the specified timeout or if the queue has + * been reset. + * @note The function is not atomic, if you need atomicity it is suggested + * to use a semaphore or a mutex for mutual exclusion. + * @note The callback is invoked before reading each character from the + * buffer or before entering the state @p THD_STATE_WTQUEUE. + * + * @param[in] iqp pointer to an @p InputQueue structure + * @param[out] bp pointer to the data buffer + * @param[in] n the maximum amount of data to be transferred, the + * value 0 is reserved + * @param[in] time the number of ticks before the operation timeouts, + * the following special values are allowed: + * - @a TIME_IMMEDIATE immediate timeout. + * - @a TIME_INFINITE no timeout. + * . + * @return The number of bytes effectively transferred. + * + * @api + */ +size_t iqReadTimeout(InputQueue *iqp, uint8_t *bp, + size_t n, systime_t time) { + qnotify_t nfy = iqp->q_notify; + size_t r = 0; + + osalDbgCheck(n > 0); + + osalSysLock(); + while (TRUE) { + if (nfy) + nfy(iqp); + + while (iqIsEmptyI(iqp)) { + if (osalQueueGoSleepTimeoutS(&iqp->q_waiting, time) != Q_OK) { + osalSysUnlock(); + return r; + } + } + + iqp->q_counter--; + *bp++ = *iqp->q_rdptr++; + if (iqp->q_rdptr >= iqp->q_top) + iqp->q_rdptr = iqp->q_buffer; + + osalSysUnlock(); /* Gives a preemption chance in a controlled point.*/ + r++; + if (--n == 0) + return r; + + osalSysLock(); + } +} + +/** + * @brief Initializes an output queue. + * @details A Semaphore is internally initialized and works as a counter of + * the free bytes in the queue. + * @note The callback is invoked from within the S-Locked system state, + * see @ref system_states. + * + * @param[out] oqp pointer to an @p OutputQueue structure + * @param[in] bp pointer to a memory area allocated as queue buffer + * @param[in] size size of the queue buffer + * @param[in] onfy pointer to a callback function that is invoked when + * data is written to the queue. The value can be @p NULL. + * @param[in] link application defined pointer + * + * @init + */ +void oqInit(OutputQueue *oqp, uint8_t *bp, size_t size, qnotify_t onfy, + void *link) { + + osalQueueObjectInit(&oqp->q_waiting); + oqp->q_counter = size; + oqp->q_buffer = oqp->q_rdptr = oqp->q_wrptr = bp; + oqp->q_top = bp + size; + oqp->q_notify = onfy; + oqp->q_link = link; +} + +/** + * @brief Resets an output queue. + * @details All the data in the output queue is erased and lost, any waiting + * thread is resumed with status @p Q_RESET. + * @note A reset operation can be used by a low level driver in order to + * obtain immediate attention from the high level layers. + * + * @param[in] oqp pointer to an @p OutputQueue structure + * + * @iclass + */ +void oqResetI(OutputQueue *oqp) { + + osalDbgCheckClassI(); + + oqp->q_rdptr = oqp->q_wrptr = oqp->q_buffer; + oqp->q_counter = qSizeI(oqp); + osalQueueWakeupAllI(&oqp->q_waiting, Q_RESET); +} + +/** + * @brief Output queue write with timeout. + * @details This function writes a byte value to an output queue. If the queue + * is full then the calling thread is suspended until there is space + * in the queue or a timeout occurs. + * @note The callback is invoked after writing the character into the + * buffer. + * + * @param[in] oqp pointer to an @p OutputQueue structure + * @param[in] b the byte value to be written in the queue + * @param[in] time the number of ticks before the operation timeouts, + * the following special values are allowed: + * - @a TIME_IMMEDIATE immediate timeout. + * - @a TIME_INFINITE no timeout. + * . + * @return The operation status. + * @retval Q_OK if the operation succeeded. + * @retval Q_TIMEOUT if the specified time expired. + * @retval Q_RESET if the queue has been reset. + * + * @api + */ +msg_t oqPutTimeout(OutputQueue *oqp, uint8_t b, systime_t time) { + + osalSysLock(); + while (oqIsFullI(oqp)) { + msg_t msg; + + if ((msg = osalQueueGoSleepTimeoutS(&oqp->q_waiting, time)) < Q_OK) { + osalSysUnlock(); + return msg; + } + } + + oqp->q_counter--; + *oqp->q_wrptr++ = b; + if (oqp->q_wrptr >= oqp->q_top) + oqp->q_wrptr = oqp->q_buffer; + + if (oqp->q_notify) + oqp->q_notify(oqp); + + osalSysUnlock(); + return Q_OK; +} + +/** + * @brief Output queue read. + * @details A byte value is read from the low end of an output queue. + * + * @param[in] oqp pointer to an @p OutputQueue structure + * @return The byte value from the queue. + * @retval Q_EMPTY if the queue is empty. + * + * @iclass + */ +msg_t oqGetI(OutputQueue *oqp) { + uint8_t b; + + osalDbgCheckClassI(); + + if (oqIsEmptyI(oqp)) + return Q_EMPTY; + + oqp->q_counter++; + b = *oqp->q_rdptr++; + if (oqp->q_rdptr >= oqp->q_top) + oqp->q_rdptr = oqp->q_buffer; + + osalQueueWakeupOneI(&oqp->q_waiting, Q_OK); + + return b; +} + +/** + * @brief Output queue write with timeout. + * @details The function writes data from a buffer to an output queue. The + * operation completes when the specified amount of data has been + * transferred or after the specified timeout or if the queue has + * been reset. + * @note The function is not atomic, if you need atomicity it is suggested + * to use a semaphore or a mutex for mutual exclusion. + * @note The callback is invoked after writing each character into the + * buffer. + * + * @param[in] oqp pointer to an @p OutputQueue structure + * @param[out] bp pointer to the data buffer + * @param[in] n the maximum amount of data to be transferred, the + * value 0 is reserved + * @param[in] time the number of ticks before the operation timeouts, + * the following special values are allowed: + * - @a TIME_IMMEDIATE immediate timeout. + * - @a TIME_INFINITE no timeout. + * . + * @return The number of bytes effectively transferred. + * + * @api + */ +size_t oqWriteTimeout(OutputQueue *oqp, const uint8_t *bp, + size_t n, systime_t time) { + qnotify_t nfy = oqp->q_notify; + size_t w = 0; + + osalDbgCheck(n > 0); + + osalSysLock(); + while (TRUE) { + while (oqIsFullI(oqp)) { + if (osalQueueGoSleepTimeoutS(&oqp->q_waiting, time) != Q_OK) { + osalSysUnlock(); + return w; + } + } + oqp->q_counter--; + *oqp->q_wrptr++ = *bp++; + if (oqp->q_wrptr >= oqp->q_top) + oqp->q_wrptr = oqp->q_buffer; + + if (nfy) + nfy(oqp); + + osalSysUnlock(); /* Gives a preemption chance in a controlled point.*/ + w++; + if (--n == 0) + return w; + osalSysLock(); + } +} + +#endif /* !defined(_CHIBIOS_RT_) || !CH_USE_QUEUES */ + +/** @} */ -- cgit v1.2.3 From 8576e8da6ab76f07fb877b89f0a3e6afc9bced0c Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 9 Aug 2013 12:57:40 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6111 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/src/hal_queues.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'os/hal/src/hal_queues.c') diff --git a/os/hal/src/hal_queues.c b/os/hal/src/hal_queues.c index 36016a1e9..5a4465652 100644 --- a/os/hal/src/hal_queues.c +++ b/os/hal/src/hal_queues.c @@ -41,7 +41,7 @@ #include "hal.h" -#if !defined(_CHIBIOS_RT_) || !CH_USE_QUEUES || defined(__DOXYGEN__) +#if !defined(_CHIBIOS_RT_) || !CH_CFG_USE_QUEUES || defined(__DOXYGEN__) /** * @brief Initializes an input queue. -- cgit v1.2.3 From 7b51712449ffa10f260f60e6968257230fe63f15 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 9 Aug 2013 13:43:56 +0000 Subject: Updated queues. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6112 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/src/hal_queues.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'os/hal/src/hal_queues.c') diff --git a/os/hal/src/hal_queues.c b/os/hal/src/hal_queues.c index 5a4465652..71330854e 100644 --- a/os/hal/src/hal_queues.c +++ b/os/hal/src/hal_queues.c @@ -59,8 +59,8 @@ * * @init */ -void iqInit(InputQueue *iqp, uint8_t *bp, size_t size, qnotify_t infy, - void *link) { +void iqObjectInit(InputQueue *iqp, uint8_t *bp, size_t size, + qnotify_t infy, void *link) { osalQueueObjectInit(&iqp->q_waiting); iqp->q_counter = 0; @@ -237,8 +237,8 @@ size_t iqReadTimeout(InputQueue *iqp, uint8_t *bp, * * @init */ -void oqInit(OutputQueue *oqp, uint8_t *bp, size_t size, qnotify_t onfy, - void *link) { +void oqObjectInit(OutputQueue *oqp, uint8_t *bp, size_t size, + qnotify_t onfy, void *link) { osalQueueObjectInit(&oqp->q_waiting); oqp->q_counter = size; -- cgit v1.2.3 From 44f6cc630876bfa5311b1c7e196a6ae5b5806b73 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Fri, 9 Aug 2013 13:56:40 +0000 Subject: HAL queues updated. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6113 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/src/hal_queues.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) (limited to 'os/hal/src/hal_queues.c') diff --git a/os/hal/src/hal_queues.c b/os/hal/src/hal_queues.c index 71330854e..89dc03911 100644 --- a/os/hal/src/hal_queues.c +++ b/os/hal/src/hal_queues.c @@ -50,7 +50,7 @@ * @note The callback is invoked from within the S-Locked system state, * see @ref system_states. * - * @param[out] iqp pointer to an @p InputQueue structure + * @param[out] iqp pointer to an @p input_queue_t structure * @param[in] bp pointer to a memory area allocated as queue buffer * @param[in] size size of the queue buffer * @param[in] infy pointer to a callback function that is invoked when @@ -59,7 +59,7 @@ * * @init */ -void iqObjectInit(InputQueue *iqp, uint8_t *bp, size_t size, +void iqObjectInit(input_queue_t *iqp, uint8_t *bp, size_t size, qnotify_t infy, void *link) { osalQueueObjectInit(&iqp->q_waiting); @@ -77,11 +77,11 @@ void iqObjectInit(InputQueue *iqp, uint8_t *bp, size_t size, * @note A reset operation can be used by a low level driver in order to * obtain immediate attention from the high level layers. * - * @param[in] iqp pointer to an @p InputQueue structure + * @param[in] iqp pointer to an @p input_queue_t structure * * @iclass */ -void iqResetI(InputQueue *iqp) { +void iqResetI(input_queue_t *iqp) { osalDbgCheckClassI(); @@ -94,7 +94,7 @@ void iqResetI(InputQueue *iqp) { * @brief Input queue write. * @details A byte value is written into the low end of an input queue. * - * @param[in] iqp pointer to an @p InputQueue structure + * @param[in] iqp pointer to an @p input_queue_t structure * @param[in] b the byte value to be written in the queue * @return The operation status. * @retval Q_OK if the operation has been completed with success. @@ -103,7 +103,7 @@ void iqResetI(InputQueue *iqp) { * * @iclass */ -msg_t iqPutI(InputQueue *iqp, uint8_t b) { +msg_t iqPutI(input_queue_t *iqp, uint8_t b) { osalDbgCheckClassI(); @@ -128,7 +128,7 @@ msg_t iqPutI(InputQueue *iqp, uint8_t b) { * @note The callback is invoked before reading the character from the * buffer or before entering the state @p THD_STATE_WTQUEUE. * - * @param[in] iqp pointer to an @p InputQueue structure + * @param[in] iqp pointer to an @p input_queue_t structure * @param[in] time the number of ticks before the operation timeouts, * the following special values are allowed: * - @a TIME_IMMEDIATE immediate timeout. @@ -140,7 +140,7 @@ msg_t iqPutI(InputQueue *iqp, uint8_t b) { * * @api */ -msg_t iqGetTimeout(InputQueue *iqp, systime_t time) { +msg_t iqGetTimeout(input_queue_t *iqp, systime_t time) { uint8_t b; osalSysLock(); @@ -175,7 +175,7 @@ msg_t iqGetTimeout(InputQueue *iqp, systime_t time) { * @note The callback is invoked before reading each character from the * buffer or before entering the state @p THD_STATE_WTQUEUE. * - * @param[in] iqp pointer to an @p InputQueue structure + * @param[in] iqp pointer to an @p input_queue_t structure * @param[out] bp pointer to the data buffer * @param[in] n the maximum amount of data to be transferred, the * value 0 is reserved @@ -188,8 +188,8 @@ msg_t iqGetTimeout(InputQueue *iqp, systime_t time) { * * @api */ -size_t iqReadTimeout(InputQueue *iqp, uint8_t *bp, - size_t n, systime_t time) { +size_t iqReadTimeout(input_queue_t *iqp, uint8_t *bp, + size_t n, systime_t time) { qnotify_t nfy = iqp->q_notify; size_t r = 0; @@ -228,7 +228,7 @@ size_t iqReadTimeout(InputQueue *iqp, uint8_t *bp, * @note The callback is invoked from within the S-Locked system state, * see @ref system_states. * - * @param[out] oqp pointer to an @p OutputQueue structure + * @param[out] oqp pointer to an @p output_queue_t structure * @param[in] bp pointer to a memory area allocated as queue buffer * @param[in] size size of the queue buffer * @param[in] onfy pointer to a callback function that is invoked when @@ -237,7 +237,7 @@ size_t iqReadTimeout(InputQueue *iqp, uint8_t *bp, * * @init */ -void oqObjectInit(OutputQueue *oqp, uint8_t *bp, size_t size, +void oqObjectInit(output_queue_t *oqp, uint8_t *bp, size_t size, qnotify_t onfy, void *link) { osalQueueObjectInit(&oqp->q_waiting); @@ -255,11 +255,11 @@ void oqObjectInit(OutputQueue *oqp, uint8_t *bp, size_t size, * @note A reset operation can be used by a low level driver in order to * obtain immediate attention from the high level layers. * - * @param[in] oqp pointer to an @p OutputQueue structure + * @param[in] oqp pointer to an @p output_queue_t structure * * @iclass */ -void oqResetI(OutputQueue *oqp) { +void oqResetI(output_queue_t *oqp) { osalDbgCheckClassI(); @@ -276,7 +276,7 @@ void oqResetI(OutputQueue *oqp) { * @note The callback is invoked after writing the character into the * buffer. * - * @param[in] oqp pointer to an @p OutputQueue structure + * @param[in] oqp pointer to an @p output_queue_t structure * @param[in] b the byte value to be written in the queue * @param[in] time the number of ticks before the operation timeouts, * the following special values are allowed: @@ -290,7 +290,7 @@ void oqResetI(OutputQueue *oqp) { * * @api */ -msg_t oqPutTimeout(OutputQueue *oqp, uint8_t b, systime_t time) { +msg_t oqPutTimeout(output_queue_t *oqp, uint8_t b, systime_t time) { osalSysLock(); while (oqIsFullI(oqp)) { @@ -318,13 +318,13 @@ msg_t oqPutTimeout(OutputQueue *oqp, uint8_t b, systime_t time) { * @brief Output queue read. * @details A byte value is read from the low end of an output queue. * - * @param[in] oqp pointer to an @p OutputQueue structure + * @param[in] oqp pointer to an @p output_queue_t structure * @return The byte value from the queue. * @retval Q_EMPTY if the queue is empty. * * @iclass */ -msg_t oqGetI(OutputQueue *oqp) { +msg_t oqGetI(output_queue_t *oqp) { uint8_t b; osalDbgCheckClassI(); @@ -353,7 +353,7 @@ msg_t oqGetI(OutputQueue *oqp) { * @note The callback is invoked after writing each character into the * buffer. * - * @param[in] oqp pointer to an @p OutputQueue structure + * @param[in] oqp pointer to an @p output_queue_t structure * @param[out] bp pointer to the data buffer * @param[in] n the maximum amount of data to be transferred, the * value 0 is reserved @@ -366,8 +366,8 @@ msg_t oqGetI(OutputQueue *oqp) { * * @api */ -size_t oqWriteTimeout(OutputQueue *oqp, const uint8_t *bp, - size_t n, systime_t time) { +size_t oqWriteTimeout(output_queue_t *oqp, const uint8_t *bp, + size_t n, systime_t time) { qnotify_t nfy = oqp->q_notify; size_t w = 0; -- cgit v1.2.3 From 7d2ebae5ebb3ae7b1e662a7443cc09e27007995a Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 19 Aug 2013 12:43:49 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6176 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/src/hal_queues.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'os/hal/src/hal_queues.c') diff --git a/os/hal/src/hal_queues.c b/os/hal/src/hal_queues.c index 89dc03911..52b9daf6c 100644 --- a/os/hal/src/hal_queues.c +++ b/os/hal/src/hal_queues.c @@ -23,8 +23,8 @@ * @brief I/O Queues code. * * @addtogroup io_queues - * @details ChibiOS/RT queues are mostly used in serial-like device drivers. - * The device drivers are usually designed to have a lower side + * @details Queues are mostly used in serial-like device drivers. + * Serial device drivers are usually designed to have a lower side * (lower driver, it is usually an interrupt service routine) and an * upper side (upper driver, accessed by the application threads).
* There are several kind of queues:
-- cgit v1.2.3 From 1b6619e5ccd8ee5a28968c5e703b334ce3738d7a Mon Sep 17 00:00:00 2001 From: gdisirio Date: Thu, 14 Nov 2013 11:01:51 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6474 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/src/hal_queues.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'os/hal/src/hal_queues.c') diff --git a/os/hal/src/hal_queues.c b/os/hal/src/hal_queues.c index 52b9daf6c..dac58a155 100644 --- a/os/hal/src/hal_queues.c +++ b/os/hal/src/hal_queues.c @@ -62,7 +62,7 @@ void iqObjectInit(input_queue_t *iqp, uint8_t *bp, size_t size, qnotify_t infy, void *link) { - osalQueueObjectInit(&iqp->q_waiting); + osalThreadQueueObjectInit(&iqp->q_waiting); iqp->q_counter = 0; iqp->q_buffer = iqp->q_rdptr = iqp->q_wrptr = bp; iqp->q_top = bp + size; @@ -87,7 +87,7 @@ void iqResetI(input_queue_t *iqp) { iqp->q_rdptr = iqp->q_wrptr = iqp->q_buffer; iqp->q_counter = 0; - osalQueueWakeupAllI(&iqp->q_waiting, Q_RESET); + osalThreadDequeueAllI(&iqp->q_waiting, Q_RESET); } /** @@ -115,7 +115,7 @@ msg_t iqPutI(input_queue_t *iqp, uint8_t b) { if (iqp->q_wrptr >= iqp->q_top) iqp->q_wrptr = iqp->q_buffer; - osalQueueWakeupOneI(&iqp->q_waiting, Q_OK); + osalThreadDequeueNextI(&iqp->q_waiting, Q_OK); return Q_OK; } @@ -149,7 +149,7 @@ msg_t iqGetTimeout(input_queue_t *iqp, systime_t time) { while (iqIsEmptyI(iqp)) { msg_t msg; - if ((msg = osalQueueGoSleepTimeoutS(&iqp->q_waiting, time)) < Q_OK) { + if ((msg = osalThreadEnqueueTimeoutS(&iqp->q_waiting, time)) < Q_OK) { osalSysUnlock(); return msg; } @@ -201,7 +201,7 @@ size_t iqReadTimeout(input_queue_t *iqp, uint8_t *bp, nfy(iqp); while (iqIsEmptyI(iqp)) { - if (osalQueueGoSleepTimeoutS(&iqp->q_waiting, time) != Q_OK) { + if (osalThreadEnqueueTimeoutS(&iqp->q_waiting, time) != Q_OK) { osalSysUnlock(); return r; } @@ -240,7 +240,7 @@ size_t iqReadTimeout(input_queue_t *iqp, uint8_t *bp, void oqObjectInit(output_queue_t *oqp, uint8_t *bp, size_t size, qnotify_t onfy, void *link) { - osalQueueObjectInit(&oqp->q_waiting); + osalThreadQueueObjectInit(&oqp->q_waiting); oqp->q_counter = size; oqp->q_buffer = oqp->q_rdptr = oqp->q_wrptr = bp; oqp->q_top = bp + size; @@ -265,7 +265,7 @@ void oqResetI(output_queue_t *oqp) { oqp->q_rdptr = oqp->q_wrptr = oqp->q_buffer; oqp->q_counter = qSizeI(oqp); - osalQueueWakeupAllI(&oqp->q_waiting, Q_RESET); + osalThreadDequeueAllI(&oqp->q_waiting, Q_RESET); } /** @@ -296,7 +296,7 @@ msg_t oqPutTimeout(output_queue_t *oqp, uint8_t b, systime_t time) { while (oqIsFullI(oqp)) { msg_t msg; - if ((msg = osalQueueGoSleepTimeoutS(&oqp->q_waiting, time)) < Q_OK) { + if ((msg = osalThreadEnqueueTimeoutS(&oqp->q_waiting, time)) < Q_OK) { osalSysUnlock(); return msg; } @@ -337,7 +337,7 @@ msg_t oqGetI(output_queue_t *oqp) { if (oqp->q_rdptr >= oqp->q_top) oqp->q_rdptr = oqp->q_buffer; - osalQueueWakeupOneI(&oqp->q_waiting, Q_OK); + osalThreadDequeueNextI(&oqp->q_waiting, Q_OK); return b; } @@ -376,7 +376,7 @@ size_t oqWriteTimeout(output_queue_t *oqp, const uint8_t *bp, osalSysLock(); while (TRUE) { while (oqIsFullI(oqp)) { - if (osalQueueGoSleepTimeoutS(&oqp->q_waiting, time) != Q_OK) { + if (osalThreadEnqueueTimeoutS(&oqp->q_waiting, time) != Q_OK) { osalSysUnlock(); return w; } -- cgit v1.2.3