Removed queues from C++ wrapper.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9201 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
9fd8d44b06
commit
109a347ca4
|
@ -550,114 +550,6 @@ namespace chibios_rt {
|
||||||
}
|
}
|
||||||
#endif /* CH_CFG_USE_EVENTS */
|
#endif /* CH_CFG_USE_EVENTS */
|
||||||
|
|
||||||
#if CH_CFG_USE_QUEUES
|
|
||||||
/*------------------------------------------------------------------------*
|
|
||||||
* chibios_rt::InQueue *
|
|
||||||
*------------------------------------------------------------------------*/
|
|
||||||
InQueue::InQueue(uint8_t *bp, size_t size, qnotify_t infy, void *link) {
|
|
||||||
|
|
||||||
chIQObjectInit(&iq, bp, size, infy, link);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t InQueue::getFullI(void) {
|
|
||||||
|
|
||||||
return chIQGetFullI(&iq);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t InQueue::getEmptyI(void) {
|
|
||||||
|
|
||||||
return chIQGetEmptyI(&iq);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool InQueue::isEmptyI(void) {
|
|
||||||
|
|
||||||
return (bool)chIQIsEmptyI(&iq);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool InQueue::isFullI(void) {
|
|
||||||
|
|
||||||
return (bool)chIQIsFullI(&iq);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InQueue::resetI(void) {
|
|
||||||
|
|
||||||
chIQResetI(&iq);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg_t InQueue::putI(uint8_t b) {
|
|
||||||
|
|
||||||
return chIQPutI(&iq, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg_t InQueue::get() {
|
|
||||||
|
|
||||||
return chIQGet(&iq);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg_t InQueue::get(systime_t time) {
|
|
||||||
|
|
||||||
return chIQGetTimeout(&iq, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t InQueue::read(uint8_t *bp, size_t n, systime_t time) {
|
|
||||||
|
|
||||||
return chIQReadTimeout(&iq, bp, n, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*
|
|
||||||
* chibios_rt::OutQueue *
|
|
||||||
*------------------------------------------------------------------------*/
|
|
||||||
OutQueue::OutQueue(uint8_t *bp, size_t size, qnotify_t onfy, void *link) {
|
|
||||||
|
|
||||||
chOQObjectInit(&oq, bp, size, onfy, link);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t OutQueue::getFullI(void) {
|
|
||||||
|
|
||||||
return chOQGetFullI(&oq);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t OutQueue::getEmptyI(void) {
|
|
||||||
|
|
||||||
return chOQGetEmptyI(&oq);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OutQueue::isEmptyI(void) {
|
|
||||||
|
|
||||||
return (bool)chOQIsEmptyI(&oq);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OutQueue::isFullI(void) {
|
|
||||||
|
|
||||||
return (bool)chOQIsFullI(&oq);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OutQueue::resetI(void) {
|
|
||||||
|
|
||||||
chOQResetI(&oq);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg_t OutQueue::put(uint8_t b) {
|
|
||||||
|
|
||||||
return chOQPut(&oq, b);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg_t OutQueue::put(uint8_t b, systime_t time) {
|
|
||||||
|
|
||||||
return chOQPutTimeout(&oq, b, time);
|
|
||||||
}
|
|
||||||
|
|
||||||
msg_t OutQueue::getI(void) {
|
|
||||||
|
|
||||||
return chOQGetI(&oq);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t OutQueue::write(const uint8_t *bp, size_t n, systime_t time) {
|
|
||||||
|
|
||||||
return chOQWriteTimeout(&oq, bp, n, time);
|
|
||||||
}
|
|
||||||
#endif /* CH_CFG_USE_QUEUES */
|
|
||||||
|
|
||||||
#if CH_CFG_USE_MEMPOOLS
|
#if CH_CFG_USE_MEMPOOLS
|
||||||
/*------------------------------------------------------------------------*
|
/*------------------------------------------------------------------------*
|
||||||
* chibios_rt::MemoryPool *
|
* chibios_rt::MemoryPool *
|
||||||
|
|
|
@ -1590,372 +1590,6 @@ namespace chibios_rt {
|
||||||
};
|
};
|
||||||
#endif /* CH_CFG_USE_EVENTS */
|
#endif /* CH_CFG_USE_EVENTS */
|
||||||
|
|
||||||
#if CH_CFG_USE_QUEUES || defined(__DOXYGEN__)
|
|
||||||
/*------------------------------------------------------------------------*
|
|
||||||
* chibios_rt::InQueue *
|
|
||||||
*------------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* @brief Class encapsulating an input queue.
|
|
||||||
*/
|
|
||||||
class InQueue {
|
|
||||||
private:
|
|
||||||
/**
|
|
||||||
* @brief Embedded @p ::InputQueue structure.
|
|
||||||
*/
|
|
||||||
::input_queue_t iq;
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief InQueue constructor.
|
|
||||||
*
|
|
||||||
* @param[in] bp pointer to a memory area allocated as queue buffer
|
|
||||||
* @param[in] size size of the queue buffer
|
|
||||||
* @param[in] infy pointer to a callback function that is invoked when
|
|
||||||
* data is read from the queue. The value can be
|
|
||||||
* @p NULL.
|
|
||||||
* @param[in] link application defined pointer
|
|
||||||
*
|
|
||||||
* @init
|
|
||||||
*/
|
|
||||||
InQueue(uint8_t *bp, size_t size, qnotify_t infy, void *link);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the filled space into an input queue.
|
|
||||||
*
|
|
||||||
* @return The number of full bytes in the queue.
|
|
||||||
* @retval 0 if the queue is empty.
|
|
||||||
*
|
|
||||||
* @iclass
|
|
||||||
*/
|
|
||||||
size_t getFullI(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the empty space into an input queue.
|
|
||||||
*
|
|
||||||
* @return The number of empty bytes in the queue.
|
|
||||||
* @retval 0 if the queue is full.
|
|
||||||
*
|
|
||||||
* @iclass
|
|
||||||
*/
|
|
||||||
size_t getEmptyI(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Evaluates to @p TRUE if the specified input queue is empty.
|
|
||||||
*
|
|
||||||
* @return The queue status.
|
|
||||||
* @retval false if the queue is not empty.
|
|
||||||
* @retval true if the queue is empty.
|
|
||||||
*
|
|
||||||
* @iclass
|
|
||||||
*/
|
|
||||||
bool isEmptyI(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Evaluates to @p TRUE if the specified input queue is full.
|
|
||||||
*
|
|
||||||
* @return The queue status.
|
|
||||||
* @retval FALSE if the queue is not full.
|
|
||||||
* @retval TRUE if the queue is full.
|
|
||||||
*
|
|
||||||
* @iclass
|
|
||||||
*/
|
|
||||||
bool isFullI(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Resets an input queue.
|
|
||||||
* @details All the data in the input queue is erased and lost, any waiting
|
|
||||||
* thread is resumed with status @p Q_RESET.
|
|
||||||
* @note A reset operation can be used by a low level driver in order to
|
|
||||||
* obtain immediate attention from the high level layers.
|
|
||||||
* @iclass
|
|
||||||
*/
|
|
||||||
void resetI(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Input queue write.
|
|
||||||
* @details A byte value is written into the low end of an input queue.
|
|
||||||
*
|
|
||||||
* @param[in] b the byte value to be written in the queue
|
|
||||||
* @return The operation status.
|
|
||||||
* @retval Q_OK if the operation has been completed with success.
|
|
||||||
* @retval Q_FULL if the queue is full and the operation cannot be
|
|
||||||
* completed.
|
|
||||||
*
|
|
||||||
* @iclass
|
|
||||||
*/
|
|
||||||
msg_t putI(uint8_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Input queue read.
|
|
||||||
* @details This function reads a byte value from an input queue. If the
|
|
||||||
* queue is empty then the calling thread is suspended until a
|
|
||||||
* byte arrives in the queue.
|
|
||||||
*
|
|
||||||
* @return A byte value from the queue.
|
|
||||||
* @retval Q_RESET if the queue has been reset.
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
msg_t get();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Input queue read with timeout.
|
|
||||||
* @details This function reads a byte value from an input queue. If the
|
|
||||||
* queue is empty then the calling thread is suspended until a
|
|
||||||
* byte arrives in the queue or a timeout occurs.
|
|
||||||
* @note The callback is invoked before reading the character from the
|
|
||||||
* buffer or before entering the state @p THD_STATE_WTQUEUE.
|
|
||||||
*
|
|
||||||
* @param[in] time 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 A byte value from the queue.
|
|
||||||
* @retval Q_TIMEOUT if the specified time expired.
|
|
||||||
* @retval Q_RESET if the queue has been reset.
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
msg_t get(systime_t time);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Input queue read with timeout.
|
|
||||||
* @details The function reads data from an input queue into a buffer. The
|
|
||||||
* operation completes when the specified amount of data has been
|
|
||||||
* transferred or after the specified timeout or if the queue has
|
|
||||||
* been reset.
|
|
||||||
* @note The function is not atomic, if you need atomicity it is
|
|
||||||
* suggested to use a semaphore or a mutex for mutual exclusion.
|
|
||||||
* @note The callback is invoked before reading each character from the
|
|
||||||
* buffer or before entering the state @p THD_STATE_WTQUEUE.
|
|
||||||
*
|
|
||||||
* @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] time 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.
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
size_t read(uint8_t *bp, size_t n, systime_t time);
|
|
||||||
};
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*
|
|
||||||
* chibios_rt::InQueueBuffer *
|
|
||||||
*------------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* @brief Template class encapsulating an input queue and its buffer.
|
|
||||||
*
|
|
||||||
* @param N size of the input queue
|
|
||||||
*/
|
|
||||||
template <int N>
|
|
||||||
class InQueueBuffer : public InQueue {
|
|
||||||
private:
|
|
||||||
uint8_t iq_buf[N];
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief InQueueBuffer constructor.
|
|
||||||
*
|
|
||||||
* @param[in] infy input notify callback function
|
|
||||||
* @param[in] link parameter to be passed to the callback
|
|
||||||
*
|
|
||||||
* @init
|
|
||||||
*/
|
|
||||||
InQueueBuffer(qnotify_t infy, void *link) : InQueue(iq_buf, N,
|
|
||||||
infy, link) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*
|
|
||||||
* chibios_rt::OutQueue *
|
|
||||||
*------------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* @brief Class encapsulating an output queue.
|
|
||||||
*/
|
|
||||||
class OutQueue {
|
|
||||||
private:
|
|
||||||
/**
|
|
||||||
* @brief Embedded @p ::OutputQueue structure.
|
|
||||||
*/
|
|
||||||
::output_queue_t oq;
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief OutQueue constructor.
|
|
||||||
*
|
|
||||||
* @param[in] bp pointer to a memory area allocated as queue buffer
|
|
||||||
* @param[in] size size of the queue buffer
|
|
||||||
* @param[in] onfy pointer to a callback function that is invoked when
|
|
||||||
* data is written to the queue. The value can be
|
|
||||||
* @p NULL.
|
|
||||||
* @param[in] link application defined pointer
|
|
||||||
*
|
|
||||||
* @init
|
|
||||||
*/
|
|
||||||
OutQueue(uint8_t *bp, size_t size, qnotify_t onfy, void *link);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the filled space into an output queue.
|
|
||||||
*
|
|
||||||
* @return The number of full bytes in the queue.
|
|
||||||
* @retval 0 if the queue is empty.
|
|
||||||
*
|
|
||||||
* @iclass
|
|
||||||
*/
|
|
||||||
size_t getFullI(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Returns the empty space into an output queue.
|
|
||||||
*
|
|
||||||
* @return The number of empty bytes in the queue.
|
|
||||||
* @retval 0 if the queue is full.
|
|
||||||
*
|
|
||||||
* @iclass
|
|
||||||
*/
|
|
||||||
size_t getEmptyI(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Evaluates to @p TRUE if the specified output queue is empty.
|
|
||||||
*
|
|
||||||
* @return The queue status.
|
|
||||||
* @retval false if the queue is not empty.
|
|
||||||
* @retval true if the queue is empty.
|
|
||||||
*
|
|
||||||
* @iclass
|
|
||||||
*/
|
|
||||||
bool isEmptyI(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Evaluates to @p TRUE if the specified output queue is full.
|
|
||||||
*
|
|
||||||
* @return The queue status.
|
|
||||||
* @retval FALSE if the queue is not full.
|
|
||||||
* @retval TRUE if the queue is full.
|
|
||||||
*
|
|
||||||
* @iclass
|
|
||||||
*/
|
|
||||||
bool isFullI(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Resets an output queue.
|
|
||||||
* @details All the data in the output queue is erased and lost, any
|
|
||||||
* waiting thread is resumed with status @p Q_RESET.
|
|
||||||
* @note A reset operation can be used by a low level driver in order
|
|
||||||
* to obtain immediate attention from the high level layers.
|
|
||||||
*
|
|
||||||
* @iclass
|
|
||||||
*/
|
|
||||||
void resetI(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Output queue write.
|
|
||||||
* @details This function writes a byte value to an output queue. If the
|
|
||||||
* queue is full then the calling thread is suspended until there
|
|
||||||
* is space in the queue.
|
|
||||||
*
|
|
||||||
* @param[in] b the byte value to be written in the queue
|
|
||||||
* @return The operation status.
|
|
||||||
* @retval Q_OK if the operation succeeded.
|
|
||||||
* @retval Q_RESET if the queue has been reset.
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
msg_t put(uint8_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Output queue write with timeout.
|
|
||||||
* @details This function writes a byte value to an output queue. If the
|
|
||||||
* queue is full then the calling thread is suspended until there
|
|
||||||
* is space in the queue or a timeout occurs.
|
|
||||||
* @note The callback is invoked after writing the character into the
|
|
||||||
* buffer.
|
|
||||||
*
|
|
||||||
* @param[in] b the byte value to be written in the queue
|
|
||||||
* @param[in] time 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 operation status.
|
|
||||||
* @retval Q_OK if the operation succeeded.
|
|
||||||
* @retval Q_TIMEOUT if the specified time expired.
|
|
||||||
* @retval Q_RESET if the queue has been reset.
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
msg_t put(uint8_t b, systime_t time);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Output queue read.
|
|
||||||
* @details A byte value is read from the low end of an output queue.
|
|
||||||
*
|
|
||||||
* @return The byte value from the queue.
|
|
||||||
* @retval Q_EMPTY if the queue is empty.
|
|
||||||
*
|
|
||||||
* @iclass
|
|
||||||
*/
|
|
||||||
msg_t getI(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Output queue write with timeout.
|
|
||||||
* @details The function writes data from a buffer to an output queue. The
|
|
||||||
* operation completes when the specified amount of data has been
|
|
||||||
* transferred or after the specified timeout or if the queue has
|
|
||||||
* been reset.
|
|
||||||
* @note The function is not atomic, if you need atomicity it is
|
|
||||||
* suggested to use a semaphore or a mutex for mutual exclusion.
|
|
||||||
* @note The callback is invoked after writing each character into the
|
|
||||||
* buffer.
|
|
||||||
*
|
|
||||||
* @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] time 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.
|
|
||||||
*
|
|
||||||
* @api
|
|
||||||
*/
|
|
||||||
size_t write(const uint8_t *bp, size_t n, systime_t time);
|
|
||||||
};
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------*
|
|
||||||
* chibios_rt::OutQueueBuffer *
|
|
||||||
*------------------------------------------------------------------------*/
|
|
||||||
/**
|
|
||||||
* @brief Template class encapsulating an output queue and its buffer.
|
|
||||||
*
|
|
||||||
* @param N size of the output queue
|
|
||||||
*/
|
|
||||||
template <int N>
|
|
||||||
class OutQueueBuffer : public OutQueue {
|
|
||||||
private:
|
|
||||||
uint8_t oq_buf[N];
|
|
||||||
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* @brief OutQueueBuffer constructor.
|
|
||||||
*
|
|
||||||
* @param[in] onfy output notify callback function
|
|
||||||
* @param[in] link parameter to be passed to the callback
|
|
||||||
*
|
|
||||||
* @init
|
|
||||||
*/
|
|
||||||
OutQueueBuffer(qnotify_t onfy, void *link) : OutQueue(oq_buf, N,
|
|
||||||
onfy, link) {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#endif /* CH_CFG_USE_QUEUES */
|
|
||||||
|
|
||||||
#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
|
#if CH_CFG_USE_MAILBOXES || defined(__DOXYGEN__)
|
||||||
/*------------------------------------------------------------------------*
|
/*------------------------------------------------------------------------*
|
||||||
* chibios_rt::Mailbox *
|
* chibios_rt::Mailbox *
|
||||||
|
|
Loading…
Reference in New Issue