QP/C Real-Time Event Framework 8.1.5
Loading...
Searching...
No Matches
qequeue.h
Go to the documentation of this file.
1//============================================================================
2// QP/C Real-Time Event Framework (RTEF)
3//
4// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
5//
6// Q u a n t u m L e a P s
7// ------------------------
8// Modern Embedded Software
9//
10// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
11//
12// This software is dual-licensed under the terms of the open-source GNU
13// General Public License (GPL) or under the terms of one of the closed-
14// source Quantum Leaps commercial licenses.
15//
16// Redistributions in source code must retain this top-level comment block.
17// Plagiarizing this software to sidestep the license obligations is illegal.
18//
19// NOTE:
20// The GPL does NOT permit the incorporation of this code into proprietary
21// programs. Please contact Quantum Leaps for commercial licensing options,
22// which expressly supersede the GPL and are designed explicitly for
23// closed-source distribution.
24//
25// Quantum Leaps contact information:
26// <www.state-machine.com/licensing>
27// <info@state-machine.com>
28//============================================================================
29#ifndef QEQUEUE_H_
30#define QEQUEUE_H_
31
32#ifndef QF_EQUEUE_CTR_SIZE
33 #define QF_EQUEUE_CTR_SIZE 1U
34#endif
35
36#if (QF_EQUEUE_CTR_SIZE == 1U)
37 typedef uint8_t QEQueueCtr;
38#elif (QF_EQUEUE_CTR_SIZE == 2U)
39 typedef uint16_t QEQueueCtr;
40#else
41 #error QF_EQUEUE_CTR_SIZE defined incorrectly, expected 1U or 2U
42#endif
43
44// forward declarations (NOTE must be consistent with "qp.h")
45struct QEvt;
46typedef struct {
47 struct QEvt const *e;
48} QEvtPtr;
49
50//============================================================================
51//! @class QEQueue
52typedef struct QEQueue {
53 QEvtPtr frontEvt; //!< @private @memberof QEQueue
54 QEvtPtr *ring; //!< @private @memberof QEQueue
55 QEQueueCtr end; //!< @private @memberof QEQueue
56 QEQueueCtr head; //!< @private @memberof QEQueue
57 QEQueueCtr tail; //!< @private @memberof QEQueue
58 QEQueueCtr nFree; //!< @private @memberof QEQueue
59 QEQueueCtr nMin; //!< @private @memberof QEQueue
60} QEQueue;
61
62//! @public @memberof QEQueue
63void QEQueue_init(QEQueue * const me,
64 QEvtPtr * const qSto,
65 uint_fast16_t const qLen);
66
67//! @public @memberof QEQueue
68bool QEQueue_post(QEQueue * const me,
69 struct QEvt const * const e,
70 uint_fast16_t const margin,
71 uint_fast8_t const qsId);
72
73//! @public @memberof QEQueue
74void QEQueue_postLIFO(QEQueue * const me,
75 struct QEvt const * const e,
76 uint_fast8_t const qsId);
77
78//! @public @memberof QEQueue
79struct QEvt const * QEQueue_get(QEQueue * const me,
80 uint_fast8_t const qsId);
81
82//! @public @memberof QEQueue
83uint16_t QEQueue_getFree(QEQueue const * const me);
84
85//! @public @memberof QEQueue
86uint16_t QEQueue_getUse(QEQueue const * const me);
87
88//! @public @memberof QEQueue
89uint16_t QEQueue_getMin(QEQueue const * const me);
90
91//! @public @memberof QEQueue
92bool QEQueue_isEmpty(QEQueue const * const me);
93
94#endif // QEQUEUE_H_
uint16_t QEQueueCtr
The data type to store the ring-buffer counters.
Definition qequeue.h:39
Native QF Event Queue.
Definition qequeue.h:52
QEQueueCtr nFree
Number of free events in the ring buffer.
Definition qequeue.h:58
QEQueueCtr end
Offset of the end of the ring buffer from the start of the buffer.
Definition qequeue.h:55
QEQueueCtr nMin
Minimum number of free events ever in the ring buffer.
Definition qequeue.h:59
QEQueueCtr tail
Offset of where next event will be extracted from the buffer.
Definition qequeue.h:57
QEvtPtr * ring
Pointer to the start of the ring buffer.
Definition qequeue.h:54
QEQueueCtr head
Offset to where next event will be inserted into the buffer.
Definition qequeue.h:56
QEvtPtr frontEvt
Pointer to event at the front of the queue.
Definition qequeue.h:53
Event class.
Definition qp.h:100
The data type to store in the event queue ring-buffer.
Definition qequeue.h:46
struct QEvt const * e
Definition qequeue.h:47