Added chMBResetI().

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7313 35acf78f-673a-0410-8e92-d51de3d6d3f4
master
gdisirio 2014-09-24 14:01:10 +00:00
parent 844094dc44
commit 419dd123e7
2 changed files with 19 additions and 3 deletions

View File

@ -110,6 +110,7 @@ extern "C" {
#endif #endif
void chMBObjectInit(mailbox_t *mbp, msg_t *buf, cnt_t n); void chMBObjectInit(mailbox_t *mbp, msg_t *buf, cnt_t n);
void chMBReset(mailbox_t *mbp); void chMBReset(mailbox_t *mbp);
void chMBResetI(mailbox_t *mbp);
msg_t chMBPost(mailbox_t *mbp, msg_t msg, systime_t timeout); msg_t chMBPost(mailbox_t *mbp, msg_t msg, systime_t timeout);
msg_t chMBPostS(mailbox_t *mbp, msg_t msg, systime_t timeout); msg_t chMBPostS(mailbox_t *mbp, msg_t msg, systime_t timeout);
msg_t chMBPostI(mailbox_t *mbp, msg_t msg); msg_t chMBPostI(mailbox_t *mbp, msg_t msg);

View File

@ -105,14 +105,29 @@ void chMBObjectInit(mailbox_t *mbp, msg_t *buf, cnt_t n) {
*/ */
void chMBReset(mailbox_t *mbp) { void chMBReset(mailbox_t *mbp) {
chSysLock();
chMBResetI(mbp);
chSchRescheduleS();
chSysUnlock();
}
/**
* @brief Resets a @p mailbox_t object.
* @details All the waiting threads are resumed with status @p MSG_RESET and
* the queued messages are lost.
*
* @param[in] mbp the pointer to an initialized @p mailbox_t object
*
* @api
*/
void chMBResetI(mailbox_t *mbp) {
chDbgCheckClassI();
chDbgCheck(mbp != NULL); chDbgCheck(mbp != NULL);
chSysLock();
mbp->mb_wrptr = mbp->mb_rdptr = mbp->mb_buffer; mbp->mb_wrptr = mbp->mb_rdptr = mbp->mb_buffer;
chSemResetI(&mbp->mb_emptysem, mbp->mb_top - mbp->mb_buffer); chSemResetI(&mbp->mb_emptysem, mbp->mb_top - mbp->mb_buffer);
chSemResetI(&mbp->mb_fullsem, 0); chSemResetI(&mbp->mb_fullsem, 0);
chSchRescheduleS();
chSysUnlock();
} }
/** /**