aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/include
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-12-21 16:49:54 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-12-21 16:49:54 +0000
commit2f7be482b19d34ec9bc86ce31d589430e2737e29 (patch)
treee314d0af4a4bf51029915e01e12686cb6970baa9 /os/hal/include
parent7979de69537f45600e5e926dcdf5e302b09af61b (diff)
downloadChibiOS-2f7be482b19d34ec9bc86ce31d589430e2737e29.tar.gz
ChibiOS-2f7be482b19d34ec9bc86ce31d589430e2737e29.tar.bz2
ChibiOS-2f7be482b19d34ec9bc86ce31d589430e2737e29.zip
Changes to Serial_USB, unfinished.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8630 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/include')
-rw-r--r--os/hal/include/hal_buffers.h56
-rw-r--r--os/hal/include/serial_usb.h20
2 files changed, 63 insertions, 13 deletions
diff --git a/os/hal/include/hal_buffers.h b/os/hal/include/hal_buffers.h
index a256f02e2..e5d5fa7b9 100644
--- a/os/hal/include/hal_buffers.h
+++ b/os/hal/include/hal_buffers.h
@@ -51,7 +51,7 @@ typedef struct io_buffers_queue io_buffers_queue_t;
*
* @param[in] iodbp the buffers queue pointer
*/
-typedef void (*dbnotify_t)(io_buffers_queue_t *bqp);
+typedef void (*bqnotify_t)(io_buffers_queue_t *bqp);
/**
* @brief Structure of a generic buffers queue.
@@ -104,7 +104,7 @@ struct io_buffers_queue {
/**
* @brief Data notification callback.
*/
- dbnotify_t notify;
+ bqnotify_t notify;
/**
* @brief Application defined field.
*/
@@ -171,7 +171,7 @@ typedef io_buffers_queue_t output_buffers_queue_t;
#define bqGetLinkX(bqp) ((bqp)->link)
/**
- * @brief Evaluates to @p TRUE if the specified input buffered queue is empty.
+ * @brief Evaluates to @p TRUE if the specified input buffers queue is empty.
*
* @param[in] ibqp pointer to an @p input_buffers_queue_t structure
* @return The queue status.
@@ -183,7 +183,7 @@ typedef io_buffers_queue_t output_buffers_queue_t;
#define ibqIsEmptyI(ibqp) ((bool)(bqSpaceI(ibqp) == 0U))
/**
- * @brief Evaluates to @p TRUE if the specified input buffered queue is full.
+ * @brief Evaluates to @p TRUE if the specified input buffers queue is full.
*
* @param[in] ibqp pointer to an @p input_buffers_queue_t structure
* @return The queue status.
@@ -194,6 +194,31 @@ typedef io_buffers_queue_t output_buffers_queue_t;
*/
#define ibqIsFullI(ibqp) ((bool)(((ibqp)->bwrptr == (ibqp)->brdptr) && \
((ibqp)->bcounter != 0U)))
+
+/**
+ * @brief Evaluates to @p true if the specified output buffers queue is empty.
+ *
+ * @param[in] obqp pointer to an @p output_buffers_queue_t structure
+ * @return The queue status.
+ * @retval false if the queue is not empty.
+ * @retval true if the queue is empty.
+ *
+ * @iclass
+ */
+#define obqIsEmptyI(oqp) ((bool)(((obqp)->bwrptr == (obqp)->brdptr) && \
+ ((obqp)->bcounter != 0U)))
+
+/**
+ * @brief Evaluates to @p true if the specified output buffers queue is full.
+ *
+ * @param[in] obqp pointer to an @p output_buffers_queue_t structure
+ * @return The queue status.
+ * @retval false if the queue is not full.
+ * @retval true if the queue is full.
+ *
+ * @iclass
+ */
+#define obqIsFullI(obqp) ((bool)(bqSpaceI(obqp) == 0U))
/** @} */
/*===========================================================================*/
@@ -205,15 +230,30 @@ extern "C" {
#endif
void ibqObjectInit(io_buffers_queue_t *ibqp, uint8_t *bp,
size_t size, size_t n,
- dbnotify_t infy, void *link);
+ bqnotify_t infy, void *link);
void ibqResetI(input_buffers_queue_t *ibqp);
uint8_t *ibqGetEmptyBufferI(input_buffers_queue_t *ibqp);
- void ibqPostBufferI(input_buffers_queue_t *ibqp, size_t size);
- msg_t ibqGetDataTimeoutI(input_buffers_queue_t *ibqp, systime_t timeout);
- void ibqReleaseDataI(input_buffers_queue_t *ibqp);
+ void ibqPostFullBufferI(input_buffers_queue_t *ibqp, size_t size);
+ msg_t ibqGetFullBufferTimeoutS(input_buffers_queue_t *ibqp,
+ systime_t timeout);
+ void ibqReleaseEmptyBufferI(input_buffers_queue_t *ibqp);
msg_t ibqGetTimeout(input_buffers_queue_t *ibqp, systime_t timeout);
size_t ibqReadTimeout(input_buffers_queue_t *ibqp, uint8_t *bp,
size_t n, systime_t timeout);
+ void obqObjectInit(output_buffers_queue_t *obqp, uint8_t *bp,
+ size_t size, size_t n,
+ bqnotify_t onfy, void *link);
+ void obqResetI(output_buffers_queue_t *obqp);
+ uint8_t *obqGetFullBufferI(output_buffers_queue_t *obqp,
+ size_t *sizep);
+ void obqReleaseEmptyBufferI(output_buffers_queue_t *obqp);
+ msg_t obqGetEmptyBufferTimeoutS(output_buffers_queue_t *obqp,
+ systime_t timeout);
+ void obqPostFullBufferI(output_buffers_queue_t *obqp, size_t size);
+ msg_t obqPutTimeout(output_buffers_queue_t *obqp, uint8_t b,
+ systime_t timeout);
+ size_t obqWriteTimeout(output_buffers_queue_t *obqp, const uint8_t *bp,
+ size_t n, systime_t timeout);
#ifdef __cplusplus
}
#endif
diff --git a/os/hal/include/serial_usb.h b/os/hal/include/serial_usb.h
index 22e873ea1..fca8d56ea 100644
--- a/os/hal/include/serial_usb.h
+++ b/os/hal/include/serial_usb.h
@@ -121,6 +121,14 @@
#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__)
#define SERIAL_USB_BUFFERS_SIZE 256
#endif
+
+/**
+ * @brief Serial over USB number of buffers.
+ * @note The default is 2 buffers.
+ */
+#if !defined(SERIAL_USB_BUFFERS_NUMBER) || defined(__DOXYGEN__)
+#define SERIAL_USB_BUFFERS_NUMBER 2
+#endif
/** @} */
/*===========================================================================*/
@@ -192,14 +200,16 @@ typedef struct {
_base_asynchronous_channel_data \
/* Driver state.*/ \
sdustate_t state; \
- /* Input queue.*/ \
- input_queue_t iqueue; \
+ /* Input buffers queue.*/ \
+ input_buffers_queue_t ibqueue; \
/* Output queue.*/ \
- output_queue_t oqueue; \
+ output_buffers_queue_t obqueue; \
/* Input buffer.*/ \
- uint8_t ib[SERIAL_USB_BUFFERS_SIZE]; \
+ uint8_t ib[BQ_BUFFER_SIZE(SERIAL_USB_BUFFERS_NUMBER, \
+ SERIAL_USB_BUFFERS_SIZE)]; \
/* Output buffer.*/ \
- uint8_t ob[SERIAL_USB_BUFFERS_SIZE]; \
+ uint8_t ob[BQ_BUFFER_SIZE(SERIAL_USB_BUFFERS_NUMBER, \
+ SERIAL_USB_BUFFERS_SIZE)]; \
/* End of the mandatory fields.*/ \
/* Current configuration data.*/ \
const SerialUSBConfig *config;