git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11834 110e8d01-0319-4d1e-a829-52ad28d1bb01
This commit is contained in:
parent
a28b3e44ca
commit
ef83e007f1
|
@ -97,7 +97,7 @@ struct memory_heap {
|
|||
memgetfunc2_t provider; /**< @brief Memory blocks provider for
|
||||
this heap. */
|
||||
heap_header_t header; /**< @brief Free blocks list header. */
|
||||
#if CH_CFG_USE_MUTEXES == TRUE
|
||||
#if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
|
||||
mutex_t mtx; /**< @brief Heap access mutex. */
|
||||
#else
|
||||
semaphore_t sem; /**< @brief Heap access semaphore. */
|
||||
|
|
|
@ -60,6 +60,11 @@ typedef struct {
|
|||
bool reset; /**< @brief True if in reset state. */
|
||||
threads_queue_t qw; /**< @brief Queued writers. */
|
||||
threads_queue_t qr; /**< @brief Queued readers. */
|
||||
#if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
|
||||
mutex_t mtx; /**< @brief Heap access mutex. */
|
||||
#else
|
||||
semaphore_t sem; /**< @brief Heap access semaphore. */
|
||||
#endif
|
||||
} pipe_t;
|
||||
|
||||
/*===========================================================================*/
|
||||
|
@ -75,6 +80,7 @@ typedef struct {
|
|||
* @param[in] buffer pointer to the pipe buffer array of @p uint8_t
|
||||
* @param[in] size number of @p uint8_t elements in the buffer array
|
||||
*/
|
||||
#if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
|
||||
#define _PIPE_DATA(name, buffer, size) { \
|
||||
(uint8_t *)(buffer), \
|
||||
(uint8_t *)(buffer) + size, \
|
||||
|
@ -84,7 +90,21 @@ typedef struct {
|
|||
false, \
|
||||
_THREADS_QUEUE_DATA(name.qw), \
|
||||
_THREADS_QUEUE_DATA(name.qr), \
|
||||
_MUTEX_DATA(name.mtx), \
|
||||
}
|
||||
#else /* CH_CFG_USE_MUTEXES == FALSE */
|
||||
#define _PIPE_DATA(name, buffer, size) { \
|
||||
(uint8_t *)(buffer), \
|
||||
(uint8_t *)(buffer) + size, \
|
||||
(uint8_t *)(buffer), \
|
||||
(uint8_t *)(buffer), \
|
||||
(size_t)0, \
|
||||
false, \
|
||||
_THREADS_QUEUE_DATA(name.qw), \
|
||||
_THREADS_QUEUE_DATA(name.qr), \
|
||||
_SEMAPHORE_DATA(name.sem, (cnt_t)1), \
|
||||
}
|
||||
#endif /* CH_CFG_USE_MUTEXES == FALSE */
|
||||
|
||||
/**
|
||||
* @brief Static pipe initializer.
|
||||
|
@ -107,17 +127,10 @@ extern "C" {
|
|||
#endif
|
||||
void chPipeObjectInit(pipe_t *pp, uint8_t *buf, size_t n);
|
||||
void chPipeReset(pipe_t *pp);
|
||||
void chPipeResetI(pipe_t *pp);
|
||||
size_t chPipeReadI(pipe_t *pp, uint8_t *bp, size_t n);
|
||||
size_t chPipeReadTimeoutS(pipe_t *pp, uint8_t *bp,
|
||||
size_t chPipeWriteTimeout(pipe_t *pp, const uint8_t *bp,
|
||||
size_t n, sysinterval_t timeout);
|
||||
size_t chPipeReadTimeout(pipe_t *pp, uint8_t *bp,
|
||||
size_t n, sysinterval_t timeout);
|
||||
size_t chPipeWriteI(pipe_t *pp, const uint8_t *bp, size_t n);
|
||||
size_t chPipeWriteTimeoutS(pipe_t *pp, const uint8_t *bp,
|
||||
size_t n, sysinterval_t timeout);
|
||||
size_t chPipeWriteTimeout(pipe_t *pp, const uint8_t *bp,
|
||||
size_t n, sysinterval_t timeout);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -41,6 +41,21 @@
|
|||
|
||||
#if (CH_CFG_USE_PIPES == TRUE) || defined(__DOXYGEN__)
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module local definitions. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/*
|
||||
* Defaults on the best synchronization mechanism available.
|
||||
*/
|
||||
#if (CH_CFG_USE_MUTEXES == TRUE) || defined(__DOXYGEN__)
|
||||
#define P_LOCK(p) chMtxLock(&(p)->mtx)
|
||||
#define P_UNLOCK(p) chMtxUnlock(&(p)->mtx)
|
||||
#else
|
||||
#define P_LOCK(p) (void) chSemWait(&(p)->sem)
|
||||
#define P_UNLOCK(p) chSemSignal(&(p)->sem)
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Module exported variables. */
|
||||
/*===========================================================================*/
|
||||
|
@ -97,67 +112,77 @@ void chPipeObjectInit(pipe_t *pp, uint8_t *buf, size_t n) {
|
|||
*
|
||||
* @api
|
||||
*/
|
||||
void chPipeReset(mailbox_t *mbp) {
|
||||
void chPipeReset(pipe_t *pp) {
|
||||
|
||||
chDbgCheck(pp != NULL);
|
||||
|
||||
P_LOCK(pp);
|
||||
chSysLock();
|
||||
chMBResetI(mbp);
|
||||
chSchRescheduleS();
|
||||
chSysUnlock();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Resets a @p pipe_t object.
|
||||
* @details All the waiting threads are resumed with status @p MSG_RESET and
|
||||
* the queued data is lost.
|
||||
* @post The pipe is in reset state, all operations will fail and
|
||||
* return @p MSG_RESET until the mailbox is enabled again using
|
||||
* @p chPipeResumeX().
|
||||
*
|
||||
* @param[in] pp the pointer to an initialized @p pipe_t object
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
void chPipeResetI(pipe_t *pp) {
|
||||
|
||||
chDbgCheckClassI();
|
||||
chDbgCheck(pipe_t != NULL);
|
||||
|
||||
pipe_t->wrptr = pipe_t->buffer;
|
||||
pipe_t->rdptr = pipe_t->buffer;
|
||||
pipe_t->cnt = (size_t)0;
|
||||
pipe_t->reset = true;
|
||||
chThdDequeueAllI(&pipe_t->qw, MSG_RESET);
|
||||
chThdDequeueAllI(&pipe_t->qr, MSG_RESET);
|
||||
chSchRescheduleS();
|
||||
chSysUnlock();
|
||||
P_UNLOCK();
|
||||
}
|
||||
|
||||
size_t chPipeReadI(pipe_t *pp, uint8_t *bp, size_t n) {
|
||||
|
||||
}
|
||||
|
||||
size_t chPipeReadTimeoutS(pipe_t *pp, uint8_t *bp,
|
||||
size_t n, sysinterval_t timeout) {
|
||||
|
||||
}
|
||||
|
||||
size_t chPipeReadTimeout(pipe_t *pp, uint8_t *bp,
|
||||
size_t n, sysinterval_t timeout) {
|
||||
|
||||
}
|
||||
|
||||
size_t chPipeWriteI(pipe_t *pp, const uint8_t *bp, size_t n) {
|
||||
|
||||
}
|
||||
|
||||
size_t chPipeWriteTimeoutS(pipe_t *pp, const uint8_t *bp,
|
||||
size_t n, sysinterval_t timeout) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Pipe write with timeout.
|
||||
* @details The function writes data from a buffer to a pipe. The
|
||||
* operation completes when the specified amount of data has been
|
||||
* transferred or after the specified timeout or if the pipe has
|
||||
* been reset.
|
||||
*
|
||||
* @param[in] pp the pointer to an initialized @p pipe_t object
|
||||
* @param[in] bp pointer to the data buffer
|
||||
* @param[in] n the maximum amount of data to be transferred, the
|
||||
* value 0 is reserved
|
||||
* @param[in] timeout 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.
|
||||
* @retval MSG_RESET if the mailbox has been reset.
|
||||
* @retval MSG_TIMEOUT if the operation has timed out.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
size_t chPipeWriteTimeout(pipe_t *pp, const uint8_t *bp,
|
||||
size_t n, sysinterval_t timeout) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Pipe read with timeout.
|
||||
* @details The function reads data from a pipe into a buffer. The
|
||||
* operation completes when the specified amount of data has been
|
||||
* transferred or after the specified timeout or if the pipe has
|
||||
* been reset.
|
||||
*
|
||||
* @param[in] pp the pointer to an initialized @p pipe_t object
|
||||
* @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] timeout 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.
|
||||
* @retval MSG_RESET if the mailbox has been reset.
|
||||
* @retval MSG_TIMEOUT if the operation has timed out.
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
size_t chPipeReadTimeout(pipe_t *pp, uint8_t *bp,
|
||||
size_t n, sysinterval_t timeout) {
|
||||
|
||||
}
|
||||
|
||||
#endif /* CH_CFG_USE_MAILBOXES == TRUE */
|
||||
|
||||
/** @} */
|
||||
|
|
Loading…
Reference in New Issue