QP/C  8.0.0
Real-Time Embedded Framework
Loading...
Searching...
No Matches
qequeue.h
Go to the documentation of this file.
1//$file${include::qequeue.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
2//
3// Model: qpc.qm
4// File: ${include::qequeue.h}
5//
6// This code has been generated by QM 7.0.0 <www.state-machine.com/qm>.
7// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
8//
9// Copyright (C) 2005 Quantum Leaps, LLC. All rights reserved.
10//
11// Q u a n t u m L e a P s
12// ------------------------
13// Modern Embedded Software
14//
15// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
16//
17// The QP/C software is dual-licensed under the terms of the open-source GNU
18// General Public License (GPL) or under the terms of one of the closed-
19// source Quantum Leaps commercial licenses.
20//
21// Redistributions in source code must retain this top-level comment block.
22// Plagiarizing this software to sidestep the license obligations is illegal.
23//
24// NOTE:
25// The GPL does NOT permit the incorporation of this code into proprietary
26// programs. Please contact Quantum Leaps for commercial licensing options,
27// which expressly supersede the GPL and are designed explicitly for
28// closed-source distribution.
29//
30// Quantum Leaps contact information:
31// <www.state-machine.com/licensing>
32// <info@state-machine.com>
33//
34//$endhead${include::qequeue.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
35#ifndef QEQUEUE_H_
36#define QEQUEUE_H_
37
38#ifndef QF_EQUEUE_CTR_SIZE
39 #define QF_EQUEUE_CTR_SIZE 1U
40#endif
41
42#if (QF_EQUEUE_CTR_SIZE == 1U)
43 typedef uint8_t QEQueueCtr;
44#elif (QF_EQUEUE_CTR_SIZE == 2U)
45 typedef uint16_t QEQueueCtr;
46#else
47 #error "QF_EQUEUE_CTR_SIZE defined incorrectly, expected 1U or 2U"
48#endif
49
50struct QEvt; // forward declartion
51
52//$declare${QF::QEQueue} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
53
54//${QF::QEQueue} .............................................................
55//! @class QEQueue
56typedef struct QEQueue {
57// private:
58
59 //! @private @memberof QEQueue
60 struct QEvt const * volatile frontEvt;
61
62 //! @private @memberof QEQueue
63 struct QEvt const * * ring;
64
65 //! @private @memberof QEQueue
67
68 //! @private @memberof QEQueue
69 QEQueueCtr volatile head;
70
71 //! @private @memberof QEQueue
72 QEQueueCtr volatile tail;
73
74 //! @private @memberof QEQueue
75 QEQueueCtr volatile nFree;
76
77#ifndef Q_UNSAFE
78 //! @private @memberof QEQueue
79 uintptr_t frontEvt_dis;
80#endif // ndef Q_UNSAFE
81
82#ifndef Q_UNSAFE
83 //! @private @memberof QEQueue
85#endif // ndef Q_UNSAFE
86
87#ifndef Q_UNSAFE
88 //! @private @memberof QEQueue
90#endif // ndef Q_UNSAFE
91
92#ifndef Q_UNSAFE
93 //! @private @memberof QEQueue
95#endif // ndef Q_UNSAFE
96
97#ifndef Q_UNSAFE
98 //! @private @memberof QEQueue
100#endif // ndef Q_UNSAFE
101
102// type:
103} QEQueue;
104
105// dummy static member to force generating 'struct QEQueue {...}'
106extern QEQueue * QEQueue_dummy;
107
108// public:
109
110//! @public @memberof QEQueue
111void QEQueue_init(QEQueue * const me,
112 struct QEvt const * * const qSto,
113 uint_fast16_t const qLen);
114
115//! @public @memberof QEQueue
116bool QEQueue_post(QEQueue * const me,
117 struct QEvt const * const e,
118 uint_fast16_t const margin,
119 uint_fast8_t const qsId);
120
121//! @public @memberof QEQueue
122void QEQueue_postLIFO(QEQueue * const me,
123 struct QEvt const * const e,
124 uint_fast8_t const qsId);
125
126//! @public @memberof QEQueue
127struct QEvt const * QEQueue_get(QEQueue * const me,
128 uint_fast8_t const qsId);
129
130//! @public @memberof QEQueue
131static inline QEQueueCtr QEQueue_getNFree(QEQueue const * const me) {
132 return me->nFree;
133}
134
135//! @public @memberof QEQueue
136static inline QEQueueCtr QEQueue_getNMin(QEQueue const * const me) {
137 #ifndef Q_UNSAFE
138 return me->nMin;
139 #else
140 return 0U;
141 #endif
142}
143
144//! @public @memberof QEQueue
145static inline bool QEQueue_isEmpty(QEQueue const * const me) {
146 return me->frontEvt == (struct QEvt *)0;
147}
148//$enddecl${QF::QEQueue} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
149
150#endif // QEQUEUE_H_
QEQueue * QEQueue_dummy
uint16_t QEQueueCtr
Definition qequeue.h:45
Native QF Event Queue.
Definition qequeue.h:56
QEQueueCtr tail_dis
Definition qequeue.h:89
QEQueueCtr volatile tail
Offset of where next event will be extracted from the buffer.
Definition qequeue.h:72
QEQueueCtr nFree_dis
Definition qequeue.h:94
static bool QEQueue_isEmpty(QEQueue const *const me)
Find out if the queue is empty.
Definition qequeue.h:145
QEQueueCtr volatile head
Offset to where next event will be inserted into the buffer.
Definition qequeue.h:69
QEQueueCtr end
Offset of the end of the ring buffer from the start of the buffer.
Definition qequeue.h:66
static QEQueueCtr QEQueue_getNFree(QEQueue const *const me)
Obtain the number of free entries still available in the queue.
Definition qequeue.h:131
QEQueueCtr nMin
Minimum number of free events ever in the ring buffer.
Definition qequeue.h:99
QEQueueCtr volatile nFree
Number of free events in the ring buffer.
Definition qequeue.h:75
struct QEvt const ** ring
Pointer to the start of the ring buffer.
Definition qequeue.h:63
void QEQueue_init(QEQueue *const me, struct QEvt const **const qSto, uint_fast16_t const qLen)
QEQueueCtr head_dis
Definition qequeue.h:84
uintptr_t frontEvt_dis
Definition qequeue.h:79
struct QEvt const *volatile frontEvt
Pointer to event at the front of the queue.
Definition qequeue.h:60
static QEQueueCtr QEQueue_getNMin(QEQueue const *const me)
Obtain the minimum number of free entries ever in the queue (a.k.a. "low-watermark")
Definition qequeue.h:136
Event class.
Definition qp.h:131