qpc/include/qequeue.h

133 lines
3.7 KiB
C
Raw Normal View History

//$file${include::qequeue.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//
// Model: qpc.qm
// File: ${include::qequeue.h}
//
// This code has been generated by QM 5.3.0 <www.state-machine.com/qm>.
// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
//
// This code is covered by the following QP license:
// License # : LicenseRef-QL-dual
// Issued to : Any user of the QP/C real-time embedded framework
// Framework(s) : qpc
// Support ends : 2024-12-31
// License scope:
//
// Copyright (C) 2005 Quantum Leaps, LLC <state-machine.com>.
//
// Q u a n t u m L e a P s
// ------------------------
// Modern Embedded Software
//
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
//
// This software is dual-licensed under the terms of the open source GNU
// General Public License version 3 (or any later version), or alternatively,
// under the terms of one of the closed source Quantum Leaps commercial
// licenses.
//
// The terms of the open source GNU General Public License version 3
// can be found at: <www.gnu.org/licenses/gpl-3.0>
//
// The terms of the closed source Quantum Leaps commercial licenses
// can be found at: <www.state-machine.com/licensing>
//
// Redistributions in source code must retain this top-level comment block.
// Plagiarizing this software to sidestep the license obligations is illegal.
//
// Contact information:
// <www.state-machine.com/licensing>
// <info@state-machine.com>
//
//$endhead${include::qequeue.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#ifndef QEQUEUE_H_
#define QEQUEUE_H_
2012-08-14 18:07:04 -04:00
#ifndef QF_EQUEUE_CTR_SIZE
2020-03-17 21:33:20 -04:00
#define QF_EQUEUE_CTR_SIZE 1U
2012-08-14 18:07:04 -04:00
#endif
#if (QF_EQUEUE_CTR_SIZE == 1U)
2017-12-11 12:13:22 -05:00
typedef uint8_t QEQueueCtr;
2020-03-17 21:33:20 -04:00
#elif (QF_EQUEUE_CTR_SIZE == 2U)
2017-12-11 12:13:22 -05:00
typedef uint16_t QEQueueCtr;
2020-03-17 21:33:20 -04:00
#elif (QF_EQUEUE_CTR_SIZE == 4U)
2017-12-11 12:13:22 -05:00
typedef uint32_t QEQueueCtr;
2012-08-14 18:07:04 -04:00
#else
2020-03-17 21:33:20 -04:00
#error "QF_EQUEUE_CTR_SIZE defined incorrectly, expected 1U, 2U, or 4U"
2012-08-14 18:07:04 -04:00
#endif
struct QEvt; // forward declaration
//$declare${QF::QEQueue} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//${QF::QEQueue} .............................................................
//! @class QEQueue
typedef struct QEQueue {
// private:
2012-08-14 18:07:04 -04:00
//! @private @memberof QEQueue
struct QEvt const * volatile frontEvt;
2012-08-14 18:07:04 -04:00
//! @private @memberof QEQueue
struct QEvt const ** ring;
//! @private @memberof QEQueue
2012-08-14 18:07:04 -04:00
QEQueueCtr end;
//! @private @memberof QEQueue
2013-09-23 14:34:35 -04:00
QEQueueCtr volatile head;
2012-08-14 18:07:04 -04:00
//! @private @memberof QEQueue
2013-09-23 14:34:35 -04:00
QEQueueCtr volatile tail;
2012-08-14 18:07:04 -04:00
//! @private @memberof QEQueue
2013-09-23 14:34:35 -04:00
QEQueueCtr volatile nFree;
2012-08-14 18:07:04 -04:00
//! @private @memberof QEQueue
2012-08-14 18:07:04 -04:00
QEQueueCtr nMin;
// public:
2012-08-14 18:07:04 -04:00
} QEQueue;
extern QEQueue QEQueue_dummy;
2012-08-14 18:07:04 -04:00
// public:
2012-08-14 18:07:04 -04:00
//! @public @memberof QEQueue
2012-08-14 18:07:04 -04:00
void QEQueue_init(QEQueue * const me,
struct QEvt const ** const qSto,
uint_fast16_t const qLen);
2013-09-23 14:34:35 -04:00
//! @public @memberof QEQueue
bool QEQueue_post(QEQueue * const me,
struct QEvt const * const e,
uint_fast16_t const margin,
uint_fast8_t const qs_id);
2012-08-14 18:07:04 -04:00
//! @public @memberof QEQueue
void QEQueue_postLIFO(QEQueue * const me,
struct QEvt const * const e,
uint_fast8_t const qs_id);
2012-08-14 18:07:04 -04:00
//! @public @memberof QEQueue
struct QEvt const * QEQueue_get(QEQueue * const me,
uint_fast8_t const qs_id);
2012-08-14 18:07:04 -04:00
//! @public @memberof QEQueue
static inline QEQueueCtr QEQueue_getNFree(QEQueue const * const me) {
return me->nFree;
}
2012-08-14 18:07:04 -04:00
//! @public @memberof QEQueue
static inline QEQueueCtr QEQueue_getNMin(QEQueue const * const me) {
return me->nMin;
}
2015-04-28 13:45:35 -04:00
//! @public @memberof QEQueue
static inline bool QEQueue_isEmpty(QEQueue const * const me) {
return me->frontEvt == (struct QEvt *)0;
}
//$enddecl${QF::QEQueue} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2012-12-10 16:00:27 -05:00
#endif // QEQUEUE_H_