QP/C 8.1.2
Real-Time Event Framework
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
44struct QEvt; // forward declaration
45
46//============================================================================
47//! @class QEQueue
48typedef struct QEQueue {
49 struct QEvt const *frontEvt; //!< @private @memberof QEQueue
50 struct QEvt const * *ring; //!< @private @memberof QEQueue
51 QEQueueCtr end; //!< @private @memberof QEQueue
52 QEQueueCtr head; //!< @private @memberof QEQueue
53 QEQueueCtr tail; //!< @private @memberof QEQueue
54 QEQueueCtr nFree; //!< @private @memberof QEQueue
55 QEQueueCtr nMin; //!< @private @memberof QEQueue
56} QEQueue;
57
58//! @public @memberof QEQueue
59void QEQueue_init(QEQueue * const me,
60 struct QEvt const * * const qSto,
61 uint_fast16_t const qLen);
62
63//! @public @memberof QEQueue
64bool QEQueue_post(QEQueue * const me,
65 struct QEvt const * const e,
66 uint_fast16_t const margin,
67 uint_fast8_t const qsId);
68
69//! @public @memberof QEQueue
70void QEQueue_postLIFO(QEQueue * const me,
71 struct QEvt const * const e,
72 uint_fast8_t const qsId);
73
74//! @public @memberof QEQueue
75struct QEvt const * QEQueue_get(QEQueue * const me,
76 uint_fast8_t const qsId);
77
78//! @public @memberof QEQueue
79uint16_t QEQueue_getFree(QEQueue const * const me);
80
81//! @public @memberof QEQueue
82uint16_t QEQueue_getUse(QEQueue const * const me);
83
84//! @public @memberof QEQueue
85uint16_t QEQueue_getMin(QEQueue const * const me);
86
87//! @public @memberof QEQueue
88bool QEQueue_isEmpty(QEQueue const * const me);
89
90#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:48
QEQueueCtr nFree
Number of free events in the ring buffer.
Definition qequeue.h:54
QEQueueCtr end
Offset of the end of the ring buffer from the start of the buffer.
Definition qequeue.h:51
struct QEvt const * frontEvt
Pointer to event at the front of the queue.
Definition qequeue.h:49
QEQueueCtr nMin
Minimum number of free events ever in the ring buffer.
Definition qequeue.h:55
QEQueueCtr tail
Offset of where next event will be extracted from the buffer.
Definition qequeue.h:53
struct QEvt const ** ring
Pointer to the start of the ring buffer.
Definition qequeue.h:50
QEQueueCtr head
Offset to where next event will be inserted into the buffer.
Definition qequeue.h:52
Event class.
Definition qp.h:100