aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-12-23 14:21:42 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-12-23 14:21:42 +0000
commitd9973ea126e8eb0a740312e70b8b41efe12f1112 (patch)
tree5128f204f4d91170614a9e09c36a92b2f1315d40 /os
parenta71da8de12fd7e8f68cbaca3cd2d929107b7192a (diff)
downloadChibiOS-d9973ea126e8eb0a740312e70b8b41efe12f1112.tar.gz
ChibiOS-d9973ea126e8eb0a740312e70b8b41efe12f1112.tar.bz2
ChibiOS-d9973ea126e8eb0a740312e70b8b41efe12f1112.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8636 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os')
-rw-r--r--os/hal/src/hal_buffers.c62
1 files changed, 42 insertions, 20 deletions
diff --git a/os/hal/src/hal_buffers.c b/os/hal/src/hal_buffers.c
index 7c309305f..a7cc5c79a 100644
--- a/os/hal/src/hal_buffers.c
+++ b/os/hal/src/hal_buffers.c
@@ -295,6 +295,7 @@ msg_t ibqGetTimeout(input_buffers_queue_t *ibqp, systime_t timeout) {
* - @a TIME_INFINITE no timeout.
* .
* @return The number of bytes effectively transferred.
+ * @retval 0 if a timeout occurred.
*
* @api
*/
@@ -316,20 +317,30 @@ size_t ibqReadTimeout(input_buffers_queue_t *ibqp, uint8_t *bp,
/* This condition indicates that a new buffer must be acquired.*/
if (ibqp->ptr == NULL) {
- systime_t next_timeout = deadline - osalOsGetSystemTimeX();
+ msg_t msg;
- /* Handling the case where the system time went past the deadline,
- in this case next becomes a very high number because the system
- time is an unsigned type.*/
- if (next_timeout > timeout) {
- ibqp->accessed = false;
- return MSG_TIMEOUT;
+ if (timeout == TIME_IMMEDIATE) {
+ msg = MSG_TIMEOUT;
+ }
+ else if (timeout == TIME_INFINITE) {
+ msg = ibqGetFullBufferTimeout(ibqp, timeout);
+ }
+ else {
+ systime_t next_timeout = deadline - osalOsGetSystemTimeX();
+
+ /* Handling the case where the system time went past the deadline,
+ in this case next becomes a very high number because the system
+ time is an unsigned type.*/
+ if (next_timeout > timeout) {
+ msg = MSG_TIMEOUT;
+ }
+ else {
+ msg = ibqGetFullBufferTimeout(ibqp, next_timeout);
+ }
}
-
- msg_t msg = ibqGetFullBufferTimeout(ibqp, next_timeout);
if (msg != MSG_OK) {
ibqp->accessed = false;
- return msg;
+ return 0;
}
}
@@ -611,6 +622,7 @@ msg_t obqPutTimeout(output_buffers_queue_t *obqp, uint8_t b,
* - @a TIME_INFINITE no timeout.
* .
* @return The number of bytes effectively transferred.
+ * @retval 0 if a timeout occurred.
*
* @api
*/
@@ -632,20 +644,30 @@ size_t obqWriteTimeout(output_buffers_queue_t *obqp, const uint8_t *bp,
/* This condition indicates that a new buffer must be acquired.*/
if (obqp->ptr == NULL) {
- systime_t next_timeout = deadline - osalOsGetSystemTimeX();
+ msg_t msg;
- /* Handling the case where the system time went past the deadline,
- in this case next becomes a very high number because the system
- time is an unsigned type.*/
- if (next_timeout > timeout) {
- obqp->accessed = false;
- return MSG_TIMEOUT;
+ if (timeout == TIME_IMMEDIATE) {
+ msg = MSG_TIMEOUT;
+ }
+ else if (timeout == TIME_INFINITE) {
+ msg = obqGetEmptyBufferTimeout(obqp, timeout);
+ }
+ else {
+ systime_t next_timeout = deadline - osalOsGetSystemTimeX();
+
+ /* Handling the case where the system time went past the deadline,
+ in this case next becomes a very high number because the system
+ time is an unsigned type.*/
+ if (next_timeout > timeout) {
+ msg = MSG_TIMEOUT;
+ }
+ else {
+ msg = obqGetEmptyBufferTimeout(obqp, next_timeout);
+ }
}
-
- msg_t msg = obqGetEmptyBufferTimeout(obqp, next_timeout);
if (msg != MSG_OK) {
obqp->accessed = false;
- return msg;
+ return 0;
}
}