2023-01-19 21:13:24 -05:00
|
|
|
//$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
|
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
#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
|
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
struct QEvt; // forward declaration
|
2022-04-19 19:18:37 -04:00
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
//$declare${QF::QEQueue} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
|
2022-04-30 18:29:48 -04:00
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
//${QF::QEQueue} .............................................................
|
|
|
|
//! @class QEQueue
|
|
|
|
typedef struct QEQueue {
|
|
|
|
// private:
|
2012-08-14 18:07:04 -04:00
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
//! @private @memberof QEQueue
|
|
|
|
struct QEvt const * volatile frontEvt;
|
2012-08-14 18:07:04 -04:00
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
//! @private @memberof QEQueue
|
|
|
|
struct QEvt const ** ring;
|
|
|
|
|
|
|
|
//! @private @memberof QEQueue
|
2012-08-14 18:07:04 -04:00
|
|
|
QEQueueCtr end;
|
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
//! @private @memberof QEQueue
|
2013-09-23 14:34:35 -04:00
|
|
|
QEQueueCtr volatile head;
|
2012-08-14 18:07:04 -04:00
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
//! @private @memberof QEQueue
|
2013-09-23 14:34:35 -04:00
|
|
|
QEQueueCtr volatile tail;
|
2012-08-14 18:07:04 -04:00
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
//! @private @memberof QEQueue
|
2013-09-23 14:34:35 -04:00
|
|
|
QEQueueCtr volatile nFree;
|
2012-08-14 18:07:04 -04:00
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
//! @private @memberof QEQueue
|
2012-08-14 18:07:04 -04:00
|
|
|
QEQueueCtr nMin;
|
2023-01-19 21:13:24 -05:00
|
|
|
|
|
|
|
// public:
|
2012-08-14 18:07:04 -04:00
|
|
|
} QEQueue;
|
2023-01-19 21:13:24 -05:00
|
|
|
extern QEQueue QEQueue_dummy;
|
2012-08-14 18:07:04 -04:00
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
// public:
|
2012-08-14 18:07:04 -04:00
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
//! @public @memberof QEQueue
|
2012-08-14 18:07:04 -04:00
|
|
|
void QEQueue_init(QEQueue * const me,
|
2023-01-19 21:13:24 -05:00
|
|
|
struct QEvt const ** const qSto,
|
2022-04-30 18:29:48 -04:00
|
|
|
uint_fast16_t const qLen);
|
2013-09-23 14:34:35 -04:00
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
//! @public @memberof QEQueue
|
2022-04-30 18:29:48 -04:00
|
|
|
bool QEQueue_post(QEQueue * const me,
|
2023-01-19 21:13:24 -05:00
|
|
|
struct QEvt const * const e,
|
2022-04-30 18:29:48 -04:00
|
|
|
uint_fast16_t const margin,
|
|
|
|
uint_fast8_t const qs_id);
|
2012-08-14 18:07:04 -04:00
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
//! @public @memberof QEQueue
|
2022-04-30 18:29:48 -04:00
|
|
|
void QEQueue_postLIFO(QEQueue * const me,
|
2023-01-19 21:13:24 -05:00
|
|
|
struct QEvt const * const e,
|
2022-04-30 18:29:48 -04:00
|
|
|
uint_fast8_t const qs_id);
|
2012-08-14 18:07:04 -04:00
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
//! @public @memberof QEQueue
|
|
|
|
struct QEvt const * QEQueue_get(QEQueue * const me,
|
2022-04-30 18:29:48 -04:00
|
|
|
uint_fast8_t const qs_id);
|
2012-08-14 18:07:04 -04:00
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
//! @public @memberof QEQueue
|
2022-04-30 18:29:48 -04:00
|
|
|
static inline QEQueueCtr QEQueue_getNFree(QEQueue const * const me) {
|
2022-04-19 19:18:37 -04:00
|
|
|
return me->nFree;
|
|
|
|
}
|
2012-08-14 18:07:04 -04:00
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
//! @public @memberof QEQueue
|
2022-04-30 18:29:48 -04:00
|
|
|
static inline QEQueueCtr QEQueue_getNMin(QEQueue const * const me) {
|
2022-04-19 19:18:37 -04:00
|
|
|
return me->nMin;
|
|
|
|
}
|
2015-04-28 13:45:35 -04:00
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
//! @public @memberof QEQueue
|
2022-04-30 18:29:48 -04:00
|
|
|
static inline bool QEQueue_isEmpty(QEQueue const * const me) {
|
2023-01-19 21:13:24 -05:00
|
|
|
return me->frontEvt == (struct QEvt *)0;
|
2022-04-19 19:18:37 -04:00
|
|
|
}
|
2023-01-19 21:13:24 -05:00
|
|
|
//$enddecl${QF::QEQueue} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
2012-12-10 16:00:27 -05:00
|
|
|
|
2023-01-19 21:13:24 -05:00
|
|
|
#endif // QEQUEUE_H_
|