diff options
author | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-12-20 10:39:36 +0000 |
---|---|---|
committer | Giovanni Di Sirio <gdisirio@gmail.com> | 2015-12-20 10:39:36 +0000 |
commit | a10028c175769e8d7a03c1f0f963b878a83deac1 (patch) | |
tree | 06e3548dae11eed4d4ddd09f268f4165c00480b1 /os | |
parent | a952f3cfafaf147df144cd37cc017ed46aac9c6b (diff) | |
download | ChibiOS-a10028c175769e8d7a03c1f0f963b878a83deac1.tar.gz ChibiOS-a10028c175769e8d7a03c1f0f963b878a83deac1.tar.bz2 ChibiOS-a10028c175769e8d7a03c1f0f963b878a83deac1.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8621 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r-- | os/hal/src/hal_buffers.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/os/hal/src/hal_buffers.c b/os/hal/src/hal_buffers.c index 286f3cf50..fe23c5ba1 100644 --- a/os/hal/src/hal_buffers.c +++ b/os/hal/src/hal_buffers.c @@ -127,9 +127,12 @@ void ibqPostBufferI(io_buffers_queue_t *ibqp, size_t size) { /**
* @brief Gets the next filled buffer from the queue.
* @note The function always returns the same buffer if called repeatedly.
+ * @post After calling the function the fields @p ptr and @p top are set
+ * at beginning and end of the buffer data or @NULL if the queue
+ * is empty.
*
* @param[out] ibqp pointer to the @p input_buffers_queue_t object
- * @return A pointer to the next buffer to be filled.
+ * @return A pointer to filled buffer area.
* @retval NULL if the queue is empty.
*
* @iclass
@@ -139,10 +142,14 @@ uint8_t *ibqGetFullBufferI(input_buffers_queue_t *ibqp) { osalDbgCheckClassI();
if (ibqIsEmptyI(ibqp)) {
+ ibqp->ptr = NULL;
+ ibqp->top = NULL;
return NULL;
}
- return ibqp->brdptr + sizeof (size_t);
+ ibqp->ptr = ibqp->brdptr + sizeof (size_t);
+ ibqp->top = ibqp->ptr + *((size_t *)ibqp->brdptr);
+ return ibqp->brdptr;
}
/**
@@ -199,7 +206,7 @@ msg_t ibqGetTimeout(input_buffers_queue_t *ibqp, systime_t timeout) { if (msg < MSG_OK) {
return msg;
}
- ibqp->ptr = ibqGetFullBufferI(ibqp);
+ (void) ibqGetFullBufferI(ibqp);
}
/* Next byte from the buffer.*/
|