From 9057c6c72be213bb7f07929e2ddd1ab1e942a1de Mon Sep 17 00:00:00 2001 From: gdisirio Date: Mon, 18 Jun 2012 16:22:34 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4294 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/hal/include/io_channel.h | 73 ++------------------------------------------- os/hal/src/serial.c | 18 ++++------- os/hal/src/serial_usb.c | 10 +++---- 3 files changed, 12 insertions(+), 89 deletions(-) (limited to 'os/hal') diff --git a/os/hal/include/io_channel.h b/os/hal/include/io_channel.h index 2f2809bf8..5573184f5 100644 --- a/os/hal/include/io_channel.h +++ b/os/hal/include/io_channel.h @@ -44,14 +44,10 @@ */ #define _base_channel_methods \ _base_sequential_stream_methods \ - /* Channel output check.*/ \ - bool_t (*putwouldblock)(void *instance); \ - /* Channel input check.*/ \ - bool_t (*getwouldblock)(void *instance); \ /* Channel put method with timeout specification.*/ \ - msg_t (*put)(void *instance, uint8_t b, systime_t time); \ + msg_t (*putt)(void *instance, uint8_t b, systime_t time); \ /* Channel get method with timeout specification.*/ \ - msg_t (*get)(void *instance, systime_t time); \ + msg_t (*gett)(void *instance, systime_t time); \ /* Channel write method with timeout specification.*/ \ size_t (*writet)(void *instance, const uint8_t *bp, \ size_t n, systime_t time); \ @@ -92,56 +88,6 @@ typedef struct { * @name Macro Functions (BaseChannel) * @{ */ -/** - * @brief Channel output check. - * @details This function verifies if a subsequent put/write operation would - * block. - * - * @param[in] ip pointer to a @p BaseChannel or derived class - * - * @return The output queue status. - * @retval FALSE if the output queue has space and would not block a - * write operation. - * @retval TRUE if the output queue is full and would block a write - * operation. - * - * @api - */ -#define chnPutWouldBlock(ip) ((ip)->vmt->putwouldblock(ip)) - -/** - * @brief Channel input check. - * @details This function verifies if a subsequent get/read operation would - * block. - * - * @param[in] ip pointer to a @p BaseChannel or derived class - * - * @return The input queue status. - * @retval FALSE if the input queue contains data and would not block a - * read operation. - * @retval TRUE if the input queue is empty and would block a read - * operation. - * - * @api - */ -#define chnGetWouldBlock(ip) ((ip)->vmt->getwouldblock(ip)) - -/** - * @brief Channel blocking byte write. - * @details This function writes a byte value to a channel. If the channel - * is not ready to accept data then the calling thread is suspended. - * - * @param[in] ip pointer to a @p BaseChannel or derived class - * @param[in] b the byte value to be written to the channel - * - * @return The operation status. - * @retval Q_OK if the operation succeeded. - * @retval Q_RESET if the channel associated queue (if any) was reset. - * - * @api - */ -#define chnPut(ip, b) ((ip)->vmt->put(ip, b, TIME_INFINITE)) - /** * @brief Channel blocking byte write with timeout. * @details This function writes a byte value to a channel. If the channel @@ -163,21 +109,6 @@ typedef struct { */ #define chnPutTimeout(ip, b, time) ((ip)->vmt->put(ip, b, time)) -/** - * @brief Channel blocking byte read. - * @details This function reads a byte value from a channel. If the data - * is not available then the calling thread is suspended. - * - * @param[in] ip pointer to a @p BaseChannel or derived class - * - * @return A byte value from the queue. - * @retval Q_RESET if the channel associated queue (if any) has been - * reset. - * - * @api - */ -#define chnGet(ip) ((ip)->vmt->get(ip, TIME_INFINITE)) - /** * @brief Channel blocking byte read with timeout. * @details This function reads a byte value from a channel. If the data diff --git a/os/hal/src/serial.c b/os/hal/src/serial.c index 5b883e16a..8b0d7c8cf 100644 --- a/os/hal/src/serial.c +++ b/os/hal/src/serial.c @@ -64,22 +64,14 @@ static size_t reads(void *ip, uint8_t *bp, size_t n) { n, TIME_INFINITE); } -static bool_t putwouldblock(void *ip) { - bool_t b; +static msg_t put(void *ip, uint8_t b) { - chSysLock(); - b = chOQIsFullI(&((SerialDriver *)ip)->oqueue); - chSysUnlock(); - return b; + return chOQPutTimeout(&((SerialDriver *)ip)->oqueue, b, TIME_INFINITE); } -static bool_t getwouldblock(void *ip) { - bool_t b; +static msg_t get(void *ip) { - chSysLock(); - b = chIQIsEmptyI(&((SerialDriver *)ip)->iqueue); - chSysUnlock(); - return b; + return chIQGetTimeout(&((SerialDriver *)ip)->iqueue, TIME_INFINITE); } static msg_t putt(void *ip, uint8_t b, systime_t timeout) { @@ -107,7 +99,7 @@ static chnflags_t getflags(void *ip) { } static const struct SerialDriverVMT vmt = { - writes, reads, putwouldblock, getwouldblock, + writes, reads, put, get, putt, gett, writet, readt, getflags }; diff --git a/os/hal/src/serial_usb.c b/os/hal/src/serial_usb.c index 2b02ae02f..466b65b0a 100644 --- a/os/hal/src/serial_usb.c +++ b/os/hal/src/serial_usb.c @@ -73,14 +73,14 @@ static size_t reads(void *ip, uint8_t *bp, size_t n) { n, TIME_INFINITE); } -static bool_t putwouldblock(void *ip) { +static msg_t put(void *ip, uint8_t b) { - return chOQIsFullI(&((SerialUSBDriver *)ip)->oqueue); + return chOQPutTimeout(&((SerialUSBDriver *)ip)->oqueue, b, TIME_INFINITE); } -static bool_t getwouldblock(void *ip) { +static msg_t get(void *ip) { - return chIQIsEmptyI(&((SerialUSBDriver *)ip)->iqueue); + return chIQGetTimeout(&((SerialUSBDriver *)ip)->iqueue, TIME_INFINITE); } static msg_t putt(void *ip, uint8_t b, systime_t timeout) { @@ -108,7 +108,7 @@ static chnflags_t getflags(void *ip) { } static const struct SerialUSBDriverVMT vmt = { - writes, reads, putwouldblock, getwouldblock, + writes, reads, put, get, putt, gett, writet, readt, getflags }; -- cgit v1.2.3