QP/C  7.4.0-rc.3
Real-Time Embedded Framework
Loading...
Searching...
No Matches
qp.h
Go to the documentation of this file.
1//$file${include::qp.h} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
2//
3// Model: qpc.qm
4// File: ${include::qp.h}
5//
6// This code has been generated by QM 6.2.0 <www.state-machine.com/qm>.
7// DO NOT EDIT THIS FILE MANUALLY. All your changes will be lost.
8//
9// This code is covered by the following QP license:
10// License # : LicenseRef-QL-dual
11// Issued to : Any user of the QP/C real-time embedded framework
12// Framework(s) : qpc
13// Support ends : 2025-12-31
14// License scope:
15//
16// Copyright (C) 2005 Quantum Leaps, LLC <state-machine.com>.
17//
18// Q u a n t u m L e a P s
19// ------------------------
20// Modern Embedded Software
21//
22// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-QL-commercial
23//
24// This software is dual-licensed under the terms of the open source GNU
25// General Public License version 3 (or any later version), or alternatively,
26// under the terms of one of the closed source Quantum Leaps commercial
27// licenses.
28//
29// The terms of the open source GNU General Public License version 3
30// can be found at: <www.gnu.org/licenses/gpl-3.0>
31//
32// The terms of the closed source Quantum Leaps commercial licenses
33// can be found at: <www.state-machine.com/licensing>
34//
35// Redistributions in source code must retain this top-level comment block.
36// Plagiarizing this software to sidestep the license obligations is illegal.
37//
38// Contact information:
39// <www.state-machine.com/licensing>
40// <info@state-machine.com>
41//
42//$endhead${include::qp.h} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43#ifndef QP_H_
44#define QP_H_
45
46//============================================================================
47#define QP_VERSION_STR "7.4.0-rc.3"
48#define QP_VERSION 740U
49#define QP_RELEASE 0x7092C3BBU
50
51//============================================================================
52//! @cond INTERNAL
53
54#ifndef Q_SIGNAL_SIZE
55#define Q_SIGNAL_SIZE 2U
56#endif
57
58#ifndef QF_MAX_ACTIVE
59#define QF_MAX_ACTIVE 32U
60#endif
61
62#if (QF_MAX_ACTIVE > 64U)
63#error QF_MAX_ACTIVE exceeds the maximum of 64U;
64#endif
65
66#ifndef QF_MAX_TICK_RATE
67#define QF_MAX_TICK_RATE 1U
68#endif
69
70#if (QF_MAX_TICK_RATE > 15U)
71#error QF_MAX_TICK_RATE exceeds the maximum of 15U;
72#endif
73
74#ifndef QF_MAX_EPOOL
75#define QF_MAX_EPOOL 3U
76#endif
77
78#if (QF_MAX_EPOOL > 15U)
79#error QF_MAX_EPOOL exceeds the maximum of 15U;
80#endif
81
82#ifndef QF_TIMEEVT_CTR_SIZE
83#define QF_TIMEEVT_CTR_SIZE 4U
84#endif
85
86#if (QF_TIMEEVT_CTR_SIZE > 4U)
87#error QF_TIMEEVT_CTR_SIZE defined incorrectly, expected 1U, 2U, or 4U;
88#endif
89
90#ifndef QF_EVENT_SIZ_SIZE
91#define QF_EVENT_SIZ_SIZE 2U
92#endif
93
94#if (QF_EVENT_SIZ_SIZE > 4U)
95#error QF_EVENT_SIZ_SIZE defined incorrectly, expected 1U, 2U, or 4U;
96#endif
97
98//! @endcond
99//============================================================================
100
101//$declare${glob-types} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
102
103//${glob-types::int_t} .......................................................
104typedef int int_t;
105
106//${glob-types::enum_t} ......................................................
107typedef int enum_t;
108
109//${glob-types::float32_t} ...................................................
110typedef float float32_t;
111
112//${glob-types::float64_t} ...................................................
113typedef double float64_t;
114//$enddecl${glob-types} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
115
116//$declare${QEP} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
117
118//${QEP::QP_versionStr[16]} ..................................................
119//! the current QP version number string in ROM, based on #QP_VERSION_STR
120extern char const QP_versionStr[16];
121
122//${QEP::QSignal} ............................................................
123#if (Q_SIGNAL_SIZE == 1U)
124typedef uint8_t QSignal;
125#endif // (Q_SIGNAL_SIZE == 1U)
126
127//${QEP::QSignal} ............................................................
128#if (Q_SIGNAL_SIZE == 2U)
129typedef uint16_t QSignal;
130#endif // (Q_SIGNAL_SIZE == 2U)
131
132//${QEP::QSignal} ............................................................
133#if (Q_SIGNAL_SIZE == 4U)
134typedef uint32_t QSignal;
135#endif // (Q_SIGNAL_SIZE == 4U)
136
137//${QEP::QEVT_MARKER} ........................................................
138#define QEVT_MARKER 0xE0U
139
140//${QEP::QEVT_DYNAMIC} .......................................................
141#define QEVT_DYNAMIC 0U
142
143//${QEP::QEvt} ...............................................................
144//! @class QEvt
145typedef struct QEvt {
146// public:
147
148 //! @public @memberof QEvt
150
151// private:
152
153 //! @private @memberof QEvt
154 uint8_t volatile refCtr_;
155
156 //! @private @memberof QEvt
157 uint8_t evtTag_;
158} QEvt;
159
160extern QEvt const QEvt_reserved_[4];
161
162// public:
163
164//! @public @memberof QEvt
165static inline void QEvt_ctor(QEvt * const me,
166 enum_t const sig)
167{
168 me->sig = (QSignal)sig;
169 me->refCtr_ = 0U;
170 me->evtTag_ = QEVT_MARKER;
171}
172
173//! @public @memberof QEvt
174static inline QEvt * QEvt_init(QEvt * const me,
175 uint8_t dummy)
176{
177 (void)dummy;
178 return me;
179}
180
181// private:
182
183//! @private @memberof QEvt
184static inline bool QEvt_verify_(QEvt const * const me) {
185 return (me != (QEvt const *)0)
186 && ((me->evtTag_ & 0xF0U) == QEVT_MARKER);
187}
188
189//! @private @memberof QEvt
190static inline uint_fast8_t QEvt_getPoolNum_(QEvt const * const me) {
191 return (uint_fast8_t)me->evtTag_ & 0x0FU;
192}
193
194//${QEP::QStateRet} ..........................................................
195//! All possible values returned from state/action handlers
196//! @note
197//! The order of enumeration matters for algorithmic correctness.
199 // unhandled and need to "bubble up"
200 Q_RET_SUPER, //!< event passed to superstate to handle
201 Q_RET_SUPER_SUB, //!< event passed to submachine superstate
202 Q_RET_UNHANDLED, //!< event unhandled due to a guard
203
204 // handled and do not need to "bubble up"
205 Q_RET_HANDLED, //!< event handled (internal transition)
206 Q_RET_IGNORED, //!< event silently ignored (bubbled up to top)
207
208 // entry/exit
209 Q_RET_ENTRY, //!< state entry action executed
210 Q_RET_EXIT, //!< state exit action executed
211
212 // no side effects
213 Q_RET_NULL, //!< return value without any effect
214
215 // transitions need to execute transition-action table in ::QMsm
216 Q_RET_TRAN, //!< regular transition
217 Q_RET_TRAN_INIT, //!< initial transition in a state or submachine
218 Q_RET_TRAN_EP, //!< entry-point transition into a submachine
219
220 // transitions that additionally clobber me->state
221 Q_RET_TRAN_HIST, //!< transition to history of a given state
222 Q_RET_TRAN_XP //!< exit-point transition out of a submachine
224
225//${QEP::QState} .............................................................
226typedef enum QStateRet QState;
227
228//${QEP::QStateHandler} ......................................................
229typedef QState (* QStateHandler )(void * const me, QEvt const * const e);
230
231//${QEP::QActionHandler} .....................................................
232typedef QState (* QActionHandler )(void * const me);
233
234//${QEP::QXThread} ...........................................................
235// forward declaration
236struct QXThread;
237
238//${QEP::QXThreadHandler} ....................................................
239typedef void (* QXThreadHandler )(struct QXThread * const me);
240
241//${QEP::QMState} ............................................................
242typedef struct QMState {
243 struct QMState const *superstate; //!< @private @memberof QMState
244 QStateHandler const stateHandler; //!< @private @memberof QMState
245 QActionHandler const entryAction; //!< @private @memberof QMState
246 QActionHandler const exitAction; //!< @private @memberof QMState
247 QActionHandler const initAction; //!< @private @memberof QMState
248} QMState;
249
250//${QEP::QMTranActTable} .....................................................
251typedef struct QMTranActTable {
252 QMState const *target; //!< @private @memberof QMTranActTable
253 QActionHandler const act[1]; //!< @private @memberof QMTranActTable
255
256//${QEP::QReservedSig} .......................................................
257//! Reserved signals by the QHsm-style state machine implementation
259 Q_EMPTY_SIG, //!< signal to execute the default case
260 Q_ENTRY_SIG, //!< signal for coding entry actions
261 Q_EXIT_SIG, //!< signal for coding exit actions
262 Q_INIT_SIG, //!< signal for coding initial transitions
263 Q_USER_SIG //!< offset for the user signals (QP Application)
265
266//${QEP::QAsmAttr} ...........................................................
267union QAsmAttr {
268 QStateHandler fun; //!< @private @memberof QAsmAttr
269 QActionHandler act; //!< @private @memberof QAsmAttr
270 QXThreadHandler thr; //!< @private @memberof QAsmAttr
271 QMTranActTable const *tatbl; //!< @private @memberof QAsmAttr
272 struct QMState const *obj; //!< @private @memberof QAsmAttr
273#ifndef Q_UNSAFE
274 uintptr_t uint; //!< @private @memberof QAsmAttr
275#endif
276};
277
278//${QEP::QAsm} ...............................................................
279//! @class QAsm
280typedef struct {
281// private:
282
283 //! @protected @memberof QAsm
284 struct QAsmVtable const * vptr;
285
286// protected:
287
288 //! @protected @memberof QAsm
289 union QAsmAttr state;
290
291 //! @protected @memberof QAsm
292 union QAsmAttr temp;
293} QAsm;
294
295// protected:
296
297//! @protected @memberof QAsm
298void QAsm_ctor(QAsm * const me);
299
300//${QEP::QAsmVtable} .........................................................
302 void (*init)(QAsm * const me, void const * const e,
303 uint_fast8_t const qsId);
304 void (*dispatch)(QAsm * const me, QEvt const * const e,
305 uint_fast8_t const qsId);
306 bool (*isIn)(QAsm * const me, QStateHandler const s);
307
308#ifdef Q_SPY
310#endif // Q_SPY
311};
312
313//${QEP::QHsm} ...............................................................
314//! @class QHsm
315//! @extends QAsm
316typedef struct {
317// protected:
319} QHsm;
320
321// protected:
322
323//! @protected @memberof QHsm
324void QHsm_ctor(QHsm * const me,
325 QStateHandler const initial);
326
327// private:
328
329//! @private @memberof QHsm
330void QHsm_init_(
331 QAsm * const me,
332 void const * const e,
333 uint_fast8_t const qsId);
334
335//! @private @memberof QHsm
336void QHsm_dispatch_(
337 QAsm * const me,
338 QEvt const * const e,
339 uint_fast8_t const qsId);
340
341#ifdef Q_SPY
342//! @private @memberof QHsm
343QStateHandler QHsm_getStateHandler_(QAsm * const me);
344#endif // def Q_SPY
345
346// public:
347
348//! @private @memberof QHsm
349bool QHsm_isIn_(
350 QAsm * const me,
351 QStateHandler const state);
352
353//! @public @memberof QHsm
354static inline QStateHandler QHsm_state(QHsm const * const me) {
355 return me->super.state.fun;
356}
357
358//! @public @memberof QHsm
359QStateHandler QHsm_childState(QHsm * const me,
360 QStateHandler const parent);
361
362// private:
363
364//! @private @memberof QHsm
365int_fast8_t QHsm_tran_(
366 QAsm * const me,
367 QStateHandler * const path,
368 uint_fast8_t const qsId);
369
370// protected:
371
372//! @protected @memberof QAsm
373QState QHsm_top(QHsm const * const me,
374 QEvt const * const e);
375
376//${QEP::QMsm} ...............................................................
377//! @class QMsm
378//! @extends QAsm
379typedef struct {
380// protected:
382} QMsm;
383
384// protected:
385
386//! @protected @memberof QMsm
387void QMsm_ctor(QMsm * const me,
388 QStateHandler const initial);
389
390// public:
391
392//! @private @memberof QMsm
393void QMsm_init_(
394 QAsm * const me,
395 void const * const e,
396 uint_fast8_t const qsId);
397
398// private:
399
400//! @private @memberof QMsm
401void QMsm_dispatch_(
402 QAsm * const me,
403 QEvt const * const e,
404 uint_fast8_t const qsId);
405
406// public:
407
408#ifdef Q_SPY
409//! @public @memberof QMsm
410static inline QStateHandler QMsm_getStateHandler_(QAsm * const me) {
411 return me->state.obj->stateHandler;
412}
413#endif // def Q_SPY
414
415//! @private @memberof QMsm
416bool QMsm_isIn_(
417 QAsm * const me,
418 QStateHandler const state);
419
420//! @private @memberof QMsm
421//! @deprecated instead use: QASM_IS_IN()
422bool QMsm_isInState(QMsm const * const me,
423 QMState const * const stateObj);
424
425//! @public @memberof QMsm
426static inline QMState const * QMsm_stateObj(QMsm * const me) {
427 return me->super.state.obj;
428}
429
430//! @public @memberof QMsm
431QMState const * QMsm_childStateObj(QMsm const * const me,
432 QMState const * const parent);
433
434// private:
435
436//! @private @memberof QMsm
437QState QMsm_execTatbl_(
438 QAsm * const me,
439 QMTranActTable const * const tatbl,
440 uint_fast8_t const qsId);
441
442//! @private @memberof QMsm
443void QMsm_exitToTranSource_(
444 QAsm * const me,
445 QMState const * const cs,
446 QMState const * const ts,
447 uint_fast8_t const qsId);
448
449//! @private @memberof QMsm
450QState QMsm_enterHistory_(
451 QAsm * const me,
452 QMState const *const hist,
453 uint_fast8_t const qsId);
454//$enddecl${QEP} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
455
456//$declare${QEP-macros} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
457
458//${QEP-macros::QEVT_INITIALIZER} ............................................
459#define QEVT_INITIALIZER(sig_) { (QSignal)(sig_), 0U, QEVT_MARKER }
460
461//${QEP-macros::QASM_INIT} ...................................................
462#ifdef Q_SPY
463#define QASM_INIT(me_, par_, qsId_) do { \
464 Q_ASSERT(((QAsm *)(me_))->vptr); \
465 (*((QAsm *)(me_))->vptr->init)((QAsm *)(me_), (par_), (qsId_)); \
466} while (false)
467#endif // def Q_SPY
468
469//${QEP-macros::QASM_INIT} ...................................................
470#ifndef Q_SPY
471#define QASM_INIT(me_, par_, dummy) do { \
472 Q_ASSERT(((QAsm *)(me_))->vptr); \
473 (*((QAsm *)(me_))->vptr->init)((QAsm *)(me_), (par_), 0); \
474} while (false)
475#endif // ndef Q_SPY
476
477//${QEP-macros::QASM_DISPATCH} ...............................................
478#ifdef Q_SPY
479#define QASM_DISPATCH(me_, e_, qsId_) \
480 (*((QAsm *)(me_))->vptr->dispatch)((QAsm *)(me_), (e_), (qsId_))
481#endif // def Q_SPY
482
483//${QEP-macros::QASM_DISPATCH} ...............................................
484#ifndef Q_SPY
485#define QASM_DISPATCH(me_, e_, dummy) \
486 (*((QAsm *)(me_))->vptr->dispatch)((QAsm *)(me_), (e_), 0U)
487#endif // ndef Q_SPY
488
489//${QEP-macros::QASM_IS_IN} ..................................................
490#define QASM_IS_IN(me_, state_) \
491 (*((QAsm *)(me_))->vptr->isIn)((QAsm *)(me_), (state_))
492
493//${QEP-macros::Q_ASM_UPCAST} ................................................
494#define Q_ASM_UPCAST(ptr_) ((QAsm *)(ptr_))
495
496//${QEP-macros::Q_HSM_UPCAST} ................................................
497#define Q_HSM_UPCAST(ptr_) ((QHsm *)(ptr_))
498
499//${QEP-macros::Q_MSM_UPCAST} ................................................
500#define Q_MSM_UPCAST(ptr_) ((QMsm *)(ptr_))
501
502//${QEP-macros::Q_TRAN} ......................................................
503#define Q_TRAN(target_) \
504 ((Q_ASM_UPCAST(me))->temp.fun = Q_STATE_CAST(target_), \
505 (QState)Q_RET_TRAN)
506
507//${QEP-macros::Q_TRAN_HIST} .................................................
508#define Q_TRAN_HIST(hist_) \
509 ((Q_ASM_UPCAST(me))->temp.fun = (hist_), \
510 (QState)Q_RET_TRAN_HIST)
511
512//${QEP-macros::Q_SUPER} .....................................................
513#define Q_SUPER(super_) \
514 ((Q_ASM_UPCAST(me))->temp.fun = Q_STATE_CAST(super_), \
515 (QState)Q_RET_SUPER)
516
517//${QEP-macros::Q_HANDLED} ...................................................
518#define Q_HANDLED() ((QState)Q_RET_HANDLED)
519
520//${QEP-macros::Q_UNHANDLED} .................................................
521#define Q_UNHANDLED() ((QState)Q_RET_UNHANDLED)
522
523//${QEP-macros::Q_ACTION_NULL} ...............................................
524#define Q_ACTION_NULL ((QActionHandler)0)
525
526//${QEP-macros::Q_EVT_CAST} ..................................................
527#define Q_EVT_CAST(class_) ((class_ const *)(e))
528
529//${QEP-macros::Q_STATE_CAST} ................................................
530#define Q_STATE_CAST(handler_) ((QStateHandler)(handler_))
531
532//${QEP-macros::Q_ACTION_CAST} ...............................................
533#define Q_ACTION_CAST(action_) ((QActionHandler)(action_))
534
535//${QEP-macros::Q_UNUSED_PAR} ................................................
536#define Q_UNUSED_PAR(par_) ((void)(par_))
537
538//${QEP-macros::Q_DIM} .......................................................
539#define Q_DIM(array_) (sizeof(array_) / sizeof((array_)[0U]))
540
541//${QEP-macros::Q_UINT2PTR_CAST} .............................................
542#define Q_UINT2PTR_CAST(type_, uint_) ((type_ *)(uint_))
543
544//${QEP-macros::QM_ENTRY} ....................................................
545#ifdef Q_SPY
546#define QM_ENTRY(state_) \
547 ((Q_ASM_UPCAST(me))->temp.obj = (state_), \
548 (QState)Q_RET_ENTRY)
549#endif // def Q_SPY
550
551//${QEP-macros::QM_ENTRY} ....................................................
552#ifndef Q_SPY
553#define QM_ENTRY(dummy) ((QState)Q_RET_ENTRY)
554#endif // ndef Q_SPY
555
556//${QEP-macros::QM_EXIT} .....................................................
557#ifdef Q_SPY
558#define QM_EXIT(state_) \
559 ((Q_ASM_UPCAST(me))->temp.obj = (state_), \
560 (QState)Q_RET_EXIT)
561#endif // def Q_SPY
562
563//${QEP-macros::QM_EXIT} .....................................................
564#ifndef Q_SPY
565#define QM_EXIT(dummy) ((QState)Q_RET_EXIT)
566#endif // ndef Q_SPY
567
568//${QEP-macros::QM_SM_EXIT} ..................................................
569#define QM_SM_EXIT(state_) \
570 ((Q_ASM_UPCAST(me))->temp.obj = (state_), \
571 (QState)Q_RET_EXIT)
572
573//${QEP-macros::QM_TRAN} .....................................................
574#define QM_TRAN(tatbl_) ((Q_ASM_UPCAST(me))->temp.tatbl \
575 = (struct QMTranActTable const *)(tatbl_), \
576 (QState)Q_RET_TRAN)
577
578//${QEP-macros::QM_TRAN_INIT} ................................................
579#define QM_TRAN_INIT(tatbl_) ((Q_ASM_UPCAST(me))->temp.tatbl \
580 = (struct QMTranActTable const *)(tatbl_), \
581 (QState)Q_RET_TRAN_INIT)
582
583//${QEP-macros::QM_TRAN_HIST} ................................................
584#define QM_TRAN_HIST(history_, tatbl_) \
585 ((((Q_ASM_UPCAST(me))->state.obj = (history_)), \
586 ((Q_ASM_UPCAST(me))->temp.tatbl = \
587 (struct QMTranActTable const *)(tatbl_))), \
588 (QState)Q_RET_TRAN_HIST)
589
590//${QEP-macros::QM_TRAN_EP} ..................................................
591#define QM_TRAN_EP(tatbl_) ((Q_ASM_UPCAST(me))->temp.tatbl \
592 = (struct QMTranActTable const *)(tatbl_), \
593 (QState)Q_RET_TRAN_EP)
594
595//${QEP-macros::QM_TRAN_XP} ..................................................
596#define QM_TRAN_XP(xp_, tatbl_) \
597 ((((Q_ASM_UPCAST(me))->state.act = (xp_)), \
598 ((Q_ASM_UPCAST(me))->temp.tatbl = \
599 (struct QMTranActTable const *)(tatbl_))), \
600 (QState)Q_RET_TRAN_XP)
601
602//${QEP-macros::QM_HANDLED} ..................................................
603#define QM_HANDLED() ((QState)Q_RET_HANDLED)
604
605//${QEP-macros::QM_UNHANDLED} ................................................
606#define QM_UNHANDLED() ((QState)Q_RET_UNHANDLED)
607
608//${QEP-macros::QM_SUPER} ....................................................
609#define QM_SUPER() ((QState)Q_RET_SUPER)
610
611//${QEP-macros::QM_SUPER_SUB} ................................................
612#define QM_SUPER_SUB(host_) \
613 ((Q_ASM_UPCAST(me))->temp.obj = (host_), \
614 (QState)Q_RET_SUPER_SUB)
615
616//${QEP-macros::QM_STATE_NULL} ...............................................
617#define QM_STATE_NULL ((QMState *)0)
618//$enddecl${QEP-macros} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
619
620//$declare${QF::types} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
621
622//${QF::types::QPrioSpec} ....................................................
623typedef uint16_t QPrioSpec;
624
625//${QF::types::QTimeEvtCtr} ..................................................
626#if (QF_TIMEEVT_CTR_SIZE == 1U)
627typedef uint8_t QTimeEvtCtr;
628#endif // (QF_TIMEEVT_CTR_SIZE == 1U)
629
630//${QF::types::QTimeEvtCtr} ..................................................
631#if (QF_TIMEEVT_CTR_SIZE == 2U)
632typedef uint16_t QTimeEvtCtr;
633#endif // (QF_TIMEEVT_CTR_SIZE == 2U)
634
635//${QF::types::QTimeEvtCtr} ..................................................
636#if (QF_TIMEEVT_CTR_SIZE == 4U)
637typedef uint32_t QTimeEvtCtr;
638#endif // (QF_TIMEEVT_CTR_SIZE == 4U)
639
640//${QF::types::QPSetBits} ....................................................
641#if (QF_MAX_ACTIVE <= 8U)
642typedef uint8_t QPSetBits;
643#endif // (QF_MAX_ACTIVE <= 8U)
644
645//${QF::types::QPSetBits} ....................................................
646#if (8U < QF_MAX_ACTIVE) && (QF_MAX_ACTIVE <= 16U)
647typedef uint16_t QPSetBits;
648#endif // (8U < QF_MAX_ACTIVE) && (QF_MAX_ACTIVE <= 16U)
649
650//${QF::types::QPSetBits} ....................................................
651#if (16U < QF_MAX_ACTIVE)
652typedef uint32_t QPSetBits;
653#endif // (16U < QF_MAX_ACTIVE)
654
655//${QF::types::QF_LOG2} ......................................................
656#ifndef QF_LOG2
657uint_fast8_t QF_LOG2(QPSetBits const bitmask);
658#endif // ndef QF_LOG2
659
660//${QF::types::QPSet} ........................................................
661//! @class QPSet
662typedef struct {
663// private:
664
665 //! @private @memberof QPSet
666 QPSetBits bits[((QF_MAX_ACTIVE + (8U*sizeof(QPSetBits))) - 1U)/(8U*sizeof(QPSetBits))];
667} QPSet;
668
669// public:
670
671//! @public @memberof QPSet
672static inline void QPSet_setEmpty(QPSet * const me) {
673 me->bits[0] = 0U;
674 #if (QF_MAX_ACTIVE > 32)
675 me->bits[1] = 0U;
676 #endif
677}
678
679//! @public @memberof QPSet
680static inline bool QPSet_isEmpty(QPSet const * const me) {
681 #if (QF_MAX_ACTIVE <= 32U)
682 return (me->bits[0] == 0U);
683 #else
684 return (me->bits[0] == 0U) ? (me->bits[1] == 0U) : false;
685 #endif
686}
687
688//! @public @memberof QPSet
689static inline bool QPSet_notEmpty(QPSet const * const me) {
690 #if (QF_MAX_ACTIVE <= 32U)
691 return (me->bits[0] != 0U);
692 #else
693 return (me->bits[0] != 0U) ? true : (me->bits[1] != 0U);
694 #endif
695}
696
697//! @public @memberof QPSet
698static inline bool QPSet_hasElement(QPSet const * const me,
699 uint_fast8_t const n)
700{
701 #if (QF_MAX_ACTIVE <= 32U)
702 return (me->bits[0] & ((QPSetBits)1U << (n - 1U))) != 0U;
703 #else
704 return (n <= 32U)
705 ? ((me->bits[0] & ((QPSetBits)1U << (n - 1U))) != 0U)
706 : ((me->bits[1] & ((QPSetBits)1U << (n - 33U))) != 0U);
707 #endif
708}
709
710//! @public @memberof QPSet
711static inline void QPSet_insert(QPSet * const me,
712 uint_fast8_t const n)
713{
714 #if (QF_MAX_ACTIVE <= 32U)
715 me->bits[0] = (me->bits[0] | ((QPSetBits)1U << (n - 1U)));
716 #else
717 if (n <= 32U) {
718 me->bits[0] = (me->bits[0] | ((QPSetBits)1U << (n - 1U)));
719 }
720 else {
721 me->bits[1] = (me->bits[1] | ((QPSetBits)1U << (n - 33U)));
722 }
723 #endif
724}
725
726//! @public @memberof QPSet
727static inline void QPSet_remove(QPSet * const me,
728 uint_fast8_t const n)
729{
730 #if (QF_MAX_ACTIVE <= 32U)
731 me->bits[0] = (me->bits[0] & (QPSetBits)(~((QPSetBits)1U << (n - 1U))));
732 #else
733 if (n <= 32U) {
734 (me->bits[0] = (me->bits[0] & ~((QPSetBits)1U << (n - 1U))));
735 }
736 else {
737 (me->bits[1] = (me->bits[1] & ~((QPSetBits)1U << (n - 33U))));
738 }
739 #endif
740}
741
742//! @public @memberof QPSet
743static inline uint_fast8_t QPSet_findMax(QPSet const * const me) {
744 #if (QF_MAX_ACTIVE <= 32U)
745 return QF_LOG2(me->bits[0]);
746 #else
747 return (me->bits[1] != 0U)
748 ? (QF_LOG2(me->bits[1]) + 32U)
749 : (QF_LOG2(me->bits[0]));
750 #endif
751}
752
753// private:
754
755#ifndef Q_UNSAFE
756//! @private @memberof QPSet
757static inline void QPSet_update_(QPSet const * const me,
758 QPSet * const dis)
759{
760 dis->bits[0] = ~me->bits[0];
761 #if (QF_MAX_ACTIVE > 32U)
762 dis->bits[1] = ~me->bits[1];
763 #endif
764}
765#endif // ndef Q_UNSAFE
766
767#ifndef Q_UNSAFE
768//! @private @memberof QPSet
769static inline bool QPSet_verify_(QPSet const * const me,
770 QPSet const * const dis)
771{
772 #if (QF_MAX_ACTIVE <= 32U)
773 return me->bits[0] == (QPSetBits)(~dis->bits[0]);
774 #else
775 return (me->bits[0] == (QPSetBits)(~dis->bits[0]))
776 && (me->bits[1] == (QPSetBits)(~dis->bits[1]));
777 #endif
778}
779#endif // ndef Q_UNSAFE
780
781//${QF::types::QSubscrList} ..................................................
782// @struct QSubscrList
783typedef struct {
784// private:
785
786 //! @private @memberof QSubscrList
788
789#ifndef Q_UNSAFE
790 //! @private @memberof QSubscrList
792#endif // ndef Q_UNSAFE
794
795//${QF::types::QEQueue} ......................................................
796struct QEQueue;
797//$enddecl${QF::types} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
798
799//$declare${QF::QActive} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
800
801//${QF::QActive} .............................................................
802//! @class QActive
803//! @extends QAsm
804typedef struct QActive {
805// protected:
807
808 //! @protected @memberof QActive
809 uint8_t prio;
810
811 //! @protected @memberof QActive
812 uint8_t pthre;
813
814#ifdef QACTIVE_THREAD_TYPE
815 //! @protected @memberof QActive
817#endif // def QACTIVE_THREAD_TYPE
818
819#ifdef QACTIVE_OS_OBJ_TYPE
820 //! @protected @memberof QActive
822#endif // def QACTIVE_OS_OBJ_TYPE
823
824#ifdef QACTIVE_EQUEUE_TYPE
825 //! @protected @memberof QActive
827#endif // def QACTIVE_EQUEUE_TYPE
828
829#ifndef Q_UNSAFE
830 //! @protected @memberof QActive
831 uint8_t prio_dis;
832#endif // ndef Q_UNSAFE
833
834#ifndef Q_UNSAFE
835 //! @protected @memberof QActive
836 uint8_t pthre_dis;
837#endif // ndef Q_UNSAFE
838
839// private:
840} QActive;
841
842//! @static @private @memberof QActive
843extern QActive * QActive_registry_[QF_MAX_ACTIVE + 1U];
844
845//! @static @private @memberof QActive
847
848//! @static @private @memberof QActive
850
851// protected:
852
853//! @protected @memberof QActive
854void QActive_ctor(QActive * const me,
855 QStateHandler const initial);
856
857// public:
858
859//! @public @memberof QActive
860void QActive_setAttr(QActive * const me,
861 uint32_t attr1,
862 void const * attr2);
863
864// private:
865
866//! @private @memberof QActive
867void QActive_start_(QActive * const me,
868 QPrioSpec const prioSpec,
869 QEvt const * * const qSto,
870 uint_fast16_t const qLen,
871 void * const stkSto,
872 uint_fast16_t const stkSize,
873 void const * const par);
874
875// protected:
876
877#ifdef QACTIVE_CAN_STOP
878//! @protected @memberof QActive
879void QActive_stop(QActive * const me);
880#endif // def QACTIVE_CAN_STOP
881
882// private:
883
884//! @private @memberof QActive
885void QActive_register_(QActive * const me);
886
887//! @private @memberof QActive
888void QActive_unregister_(QActive * const me);
889
890//! @private @memberof QActive
891bool QActive_post_(QActive * const me,
892 QEvt const * const e,
893 uint_fast16_t const margin,
894 void const * const sender);
895
896//! @private @memberof QActive
897void QActive_postLIFO_(QActive * const me,
898 QEvt const * const e);
899
900//! @private @memberof QActive
901QEvt const * QActive_get_(QActive * const me);
902
903// public:
904
905//! @static @public @memberof QActive
907 QSubscrList * const subscrSto,
908 enum_t const maxSignal);
909
910// private:
911
912//! @static @private @memberof QActive
913void QActive_publish_(
914 QEvt const * const e,
915 void const * const sender,
916 uint_fast8_t const qsId);
917
918// protected:
919
920//! @protected @memberof QActive
921void QActive_subscribe(QActive const * const me,
922 enum_t const sig);
923
924//! @protected @memberof QActive
925void QActive_unsubscribe(QActive const * const me,
926 enum_t const sig);
927
928//! @protected @memberof QActive
929void QActive_unsubscribeAll(QActive const * const me);
930
931//! @protected @memberof QActive
932bool QActive_defer(QActive const * const me,
933 struct QEQueue * const eq,
934 QEvt const * const e);
935
936//! @protected @memberof QActive
937bool QActive_recall(QActive * const me,
938 struct QEQueue * const eq);
939
940//! @protected @memberof QActive
941uint_fast16_t QActive_flushDeferred(QActive const * const me,
942 struct QEQueue * const eq,
943 uint_fast16_t const num);
944
945// private:
946
947//! @private @memberof QActive
948void QActive_evtLoop_(QActive * const me);
949//$enddecl${QF::QActive} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
950
951//$declare${QF::QMActive} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
952
953//${QF::QMActive} ............................................................
954//! @class QMActive
955//! @extends QActive
956typedef struct {
957// protected:
959} QMActive;
960
961// protected:
962
963//! @protected @memberof QMActive
964void QMActive_ctor(QMActive * const me,
965 QStateHandler const initial);
966//$enddecl${QF::QMActive} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
967
968//$declare${QF::QTimeEvt} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
969
970//${QF::QTimeEvt} ............................................................
971//! @class QTimeEvt
972//! @extends QEvt
973typedef struct QTimeEvt {
974// protected:
976
977// private:
978
979 //! @private @memberof QTimeEvt
980 struct QTimeEvt * volatile next;
981
982 //! @private @memberof QTimeEvt
983 void * volatile act;
984
985 //! @private @memberof QTimeEvt
986 QTimeEvtCtr volatile ctr;
987
988 //! @private @memberof QTimeEvt
990} QTimeEvt;
991
992//! @static @private @memberof QTimeEvt
994
995// public:
996
997//! @public @memberof QTimeEvt
998void QTimeEvt_ctorX(QTimeEvt * const me,
999 QActive * const act,
1000 enum_t const sig,
1001 uint_fast8_t const tickRate);
1002
1003//! @public @memberof QTimeEvt
1004void QTimeEvt_armX(QTimeEvt * const me,
1005 QTimeEvtCtr const nTicks,
1006 QTimeEvtCtr const interval);
1007
1008//! @public @memberof QTimeEvt
1009bool QTimeEvt_disarm(QTimeEvt * const me);
1010
1011//! @public @memberof QTimeEvt
1012bool QTimeEvt_rearm(QTimeEvt * const me,
1013 QTimeEvtCtr const nTicks);
1014
1015//! @public @memberof QTimeEvt
1016bool QTimeEvt_wasDisarmed(QTimeEvt * const me);
1017
1018//! @public @memberof QTimeEvt
1019QTimeEvtCtr QTimeEvt_currCtr(QTimeEvt const * const me);
1020
1021//! @static @private @memberof QTimeEvt
1022void QTimeEvt_tick_(
1023 uint_fast8_t const tickRate,
1024 void const * const sender);
1025
1026// private:
1027
1028#ifdef Q_UTEST
1029//! @static @private @memberof QTimeEvt
1030void QTimeEvt_tick1_(
1031 uint_fast8_t const tickRate,
1032 void const * const sender);
1033#endif // def Q_UTEST
1034
1035// public:
1036
1037//! @static @public @memberof QTimeEvt
1038bool QTimeEvt_noActive(uint_fast8_t const tickRate);
1039//$enddecl${QF::QTimeEvt} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1040
1041//$declare${QF::QTicker} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
1042
1043//${QF::QTicker} .............................................................
1044//! @class QTicker
1045//! @extends QActive
1046typedef struct {
1047// protected:
1049} QTicker;
1050
1051// public:
1052
1053//! @public @memberof QTicker
1054void QTicker_ctor(QTicker * const me,
1055 uint_fast8_t const tickRate);
1056
1057// private:
1058
1059//! @private @memberof QTicker
1060void QTicker_init_(
1061 QAsm * const me,
1062 void const * const par,
1063 uint_fast8_t const qsId);
1064
1065//! @private @memberof QTicker
1066void QTicker_dispatch_(
1067 QAsm * const me,
1068 QEvt const * const e,
1069 uint_fast8_t const qsId);
1070
1071//! @private @memberof QTicker
1072void QTicker_trig_(
1073 QActive * const me,
1074 void const * const sender);
1075//$enddecl${QF::QTicker} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1076
1077//$declare${QF::QF-base} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
1078
1079//${QF::QF-base::init} .......................................................
1080//! @static @public @memberof QF
1081void QF_init(void);
1082
1083//${QF::QF-base::stop} .......................................................
1084//! @static @public @memberof QF
1085void QF_stop(void);
1086
1087//${QF::QF-base::run} ........................................................
1088//! @static @public @memberof QF
1089int_t QF_run(void);
1090
1091//${QF::QF-base::getQueueMin} ................................................
1092//! @static @public @memberof QF
1093uint_fast16_t QF_getQueueMin(uint_fast8_t const prio);
1094
1095//${QF::QF-base::onStartup} ..................................................
1096//! @static @public @memberof QF
1097void QF_onStartup(void);
1098
1099//${QF::QF-base::onCleanup} ..................................................
1100//! @static @public @memberof QF
1101void QF_onCleanup(void);
1102
1103//${QF::QF-base::onContextSw} ................................................
1104#ifdef QF_ON_CONTEXT_SW
1105//! @static @public @memberof QF
1107 QActive * prev,
1108 QActive * next);
1109#endif // def QF_ON_CONTEXT_SW
1110//$enddecl${QF::QF-base} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1111
1112//$declare${QF::QF-dyn} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
1113
1114//${QF::QF-dyn::poolInit} ....................................................
1115//! @static @public @memberof QF
1117 void * const poolSto,
1118 uint_fast32_t const poolSize,
1119 uint_fast16_t const evtSize);
1120
1121//${QF::QF-dyn::poolGetMaxBlockSize} .........................................
1122//! @static @public @memberof QF
1123uint_fast16_t QF_poolGetMaxBlockSize(void);
1124
1125//${QF::QF-dyn::getPoolMin} ..................................................
1126//! @static @public @memberof QF
1127uint_fast16_t QF_getPoolMin(uint_fast8_t const poolNum);
1128
1129//${QF::QF-dyn::newX_} .......................................................
1130//! @static @private @memberof QF
1131QEvt * QF_newX_(
1132 uint_fast16_t const evtSize,
1133 uint_fast16_t const margin,
1134 enum_t const sig);
1135
1136//${QF::QF-dyn::gc} ..........................................................
1137//! @static @public @memberof QF
1138void QF_gc(QEvt const * const e);
1139
1140//${QF::QF-dyn::newRef_} .....................................................
1141//! @static @private @memberof QF
1142QEvt const * QF_newRef_(
1143 QEvt const * const e,
1144 void const * const evtRef);
1145
1146//${QF::QF-dyn::deleteRef_} ..................................................
1147//! @static @private @memberof QF
1148void QF_deleteRef_(void const * const evtRef);
1149
1150//${QF::QF-dyn::gcFromISR} ...................................................
1151//! @static @public @memberof QF
1152void QF_gcFromISR(QEvt const * const e);
1153//$enddecl${QF::QF-dyn} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1154
1155//$declare${QF-macros} vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
1156
1157//${QF-macros::QF_NO_MARGIN} .................................................
1158#define QF_NO_MARGIN ((uint_fast16_t)0xFFFFU)
1159
1160//${QF-macros::Q_PRIO} .......................................................
1161#define Q_PRIO(prio_, pthre_) ((QPrioSpec)((prio_) | ((pthre_) << 8U)))
1162
1163//${QF-macros::Q_NEW} ........................................................
1164#ifndef QEVT_PAR_INIT
1165#define Q_NEW(evtT_, sig_) ((evtT_ *)QF_newX_((uint_fast16_t)sizeof(evtT_), \
1166 QF_NO_MARGIN, (enum_t)(sig_)))
1167#endif // ndef QEVT_PAR_INIT
1168
1169//${QF-macros::Q_NEW} ........................................................
1170#ifdef QEVT_PAR_INIT
1171#define Q_NEW(evtT_, sig_, ...) \
1172 (evtT_##_init((evtT_ *)QF_newX_((uint_fast16_t)sizeof(evtT_), \
1173 QF_NO_MARGIN, (sig_)), __VA_ARGS__))
1174#endif // def QEVT_PAR_INIT
1175
1176//${QF-macros::Q_NEW_X} ......................................................
1177#ifndef QEVT_PAR_INIT
1178#define Q_NEW_X(evtT_, margin_, sig_) \
1179 ((evtT_ *)QF_newX_((uint_fast16_t)sizeof(evtT_), \
1180 (margin_), (enum_t)(sig_)))
1181#endif // ndef QEVT_PAR_INIT
1182
1183//${QF-macros::Q_NEW_X} ......................................................
1184#ifdef QEVT_PAR_INIT
1185#define Q_NEW_X(evtT_, margin_, sig_, ...) \
1186 (evtT_##_init((evtT_ *)QF_newX_((uint_fast16_t)sizeof(evtT_), \
1187 (margin_), (sig_)), __VA_ARGS__))
1188#endif // def QEVT_PAR_INIT
1189
1190//${QF-macros::Q_NEW_REF} ....................................................
1191#define Q_NEW_REF(evtRef_, evtT_) \
1192 ((evtRef_) = (evtT_ const *)QF_newRef_(e, (evtRef_)))
1193
1194//${QF-macros::Q_DELETE_REF} .................................................
1195#define Q_DELETE_REF(evtRef_) do { \
1196 QF_deleteRef_((evtRef_)); \
1197 (evtRef_) = (void *)0; \
1198} while (false)
1199
1200//${QF-macros::QACTIVE_START} ................................................
1201#define QACTIVE_START(me_, prioSpec_, qSto_, qLen_, stkSto_, stkSize_, par_) \
1202 (QActive_start_((QActive *)(me_), (prioSpec_), \
1203 (qSto_), (qLen_), (stkSto_), (stkSize_), (par_)))
1204
1205//${QF-macros::QACTIVE_POST} .................................................
1206#ifdef Q_SPY
1207#define QACTIVE_POST(me_, e_, sender_) \
1208 ((void)QActive_post_((me_), (e_), QF_NO_MARGIN, (sender_)))
1209#endif // def Q_SPY
1210
1211//${QF-macros::QACTIVE_POST} .................................................
1212#ifndef Q_SPY
1213#define QACTIVE_POST(me_, e_, dummy) \
1214 ((void)QActive_post_((me_), (e_), QF_NO_MARGIN, (void *)0))
1215#endif // ndef Q_SPY
1216
1217//${QF-macros::QACTIVE_POST_X} ...............................................
1218#ifdef Q_SPY
1219#define QACTIVE_POST_X(me_, e_, margin_, sender_) \
1220 (QActive_post_((me_), (e_), (margin_), (sender_)))
1221#endif // def Q_SPY
1222
1223//${QF-macros::QACTIVE_POST_X} ...............................................
1224#ifndef Q_SPY
1225#define QACTIVE_POST_X(me_, e_, margin_, dummy) \
1226 (QActive_post_((me_), (e_), (margin_), (void *)0))
1227#endif // ndef Q_SPY
1228
1229//${QF-macros::QACTIVE_POST_LIFO} ............................................
1230#define QACTIVE_POST_LIFO(me_, e_) \
1231 (QActive_postLIFO_((me_), (e_)))
1232
1233//${QF-macros::QACTIVE_PUBLISH} ..............................................
1234#ifdef Q_SPY
1235#define QACTIVE_PUBLISH(e_, sender_) \
1236 (QActive_publish_((e_), (void const *)(sender_), (sender_)->prio))
1237#endif // def Q_SPY
1238
1239//${QF-macros::QACTIVE_PUBLISH} ..............................................
1240#ifndef Q_SPY
1241#define QACTIVE_PUBLISH(e_, dummy) (QActive_publish_((e_), (void *)0, 0U))
1242#endif // ndef Q_SPY
1243
1244//${QF-macros::QTIMEEVT_TICK_X} ..............................................
1245#ifdef Q_SPY
1246#define QTIMEEVT_TICK_X(tickRate_, sender_) (QTimeEvt_tick_((tickRate_), (sender_)))
1247#endif // def Q_SPY
1248
1249//${QF-macros::QTIMEEVT_TICK_X} ..............................................
1250#ifndef Q_SPY
1251#define QTIMEEVT_TICK_X(tickRate_, dummy) (QTimeEvt_tick_((tickRate_), (void *)0))
1252#endif // ndef Q_SPY
1253
1254//${QF-macros::QTIMEEVT_TICK} ................................................
1255#define QTIMEEVT_TICK(sender_) QTIMEEVT_TICK_X(0U, (sender_))
1256
1257//${QF-macros::QTICKER_TRIG} .................................................
1258#ifdef Q_SPY
1259#define QTICKER_TRIG(ticker_, sender_) (QTicker_trig_((ticker_), (sender_)))
1260#endif // def Q_SPY
1261
1262//${QF-macros::QTICKER_TRIG} .................................................
1263#ifndef Q_SPY
1264#define QTICKER_TRIG(ticker_, sender_) (QTicker_trig_((ticker_), (void *)0))
1265#endif // ndef Q_SPY
1266
1267//${QF-macros::QF_CRIT_EXIT_NOP} .............................................
1268#ifndef QF_CRIT_EXIT_NOP
1269#define QF_CRIT_EXIT_NOP() ((void)0)
1270#endif // ndef QF_CRIT_EXIT_NOP
1271
1272//${QF-macros::QF_TICK_X} ....................................................
1273#define QF_TICK_X(tickRate_, sender_) QTIMEEVT_TICK_X((tickRate_), (sender_))
1274
1275//${QF-macros::QF_TICK} ......................................................
1276#define QF_TICK(sender_) QTIMEEVT_TICK(sender_)
1277
1278//${QF-macros::QF_PUBLISH} ...................................................
1279#define QF_PUBLISH(e_, sender_) QACTIVE_PUBLISH((e_), (sender_))
1280
1281//${QF-macros::QF_MEM_SYS} ...................................................
1282#ifndef QF_MEM_SYS
1283#define QF_MEM_SYS() ((void)0)
1284#endif // ndef QF_MEM_SYS
1285
1286//${QF-macros::QF_MEM_APP} ...................................................
1287#ifndef QF_MEM_APP
1288#define QF_MEM_APP() ((void)0)
1289#endif // ndef QF_MEM_APP
1290//$enddecl${QF-macros} ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1291
1292#endif // QP_H_
void QF_onStartup(void)
Startup QF callback.
void QF_poolInit(void *const poolSto, uint_fast32_t const poolSize, uint_fast16_t const evtSize)
Event pool initialization for dynamic allocation of events.
void QF_onCleanup(void)
Cleanup QF callback.
void QF_onContextSw(QActive *prev, QActive *next)
QF context switch callback used in built-in kernels (QV/QK/QXK)
void QF_gcFromISR(QEvt const *const e)
QStateRet
Definition qp.h:198
@ Q_RET_ENTRY
state entry action executed
Definition qp.h:209
@ Q_RET_HANDLED
event handled (internal transition)
Definition qp.h:205
@ Q_RET_TRAN_XP
exit-point transition out of a submachine
Definition qp.h:222
@ Q_RET_IGNORED
event silently ignored (bubbled up to top)
Definition qp.h:206
@ Q_RET_TRAN_INIT
initial transition in a state or submachine
Definition qp.h:217
@ Q_RET_TRAN
regular transition
Definition qp.h:216
@ Q_RET_UNHANDLED
event unhandled due to a guard
Definition qp.h:202
@ Q_RET_SUPER
event passed to superstate to handle
Definition qp.h:200
@ Q_RET_NULL
return value without any effect
Definition qp.h:213
@ Q_RET_TRAN_HIST
transition to history of a given state
Definition qp.h:221
@ Q_RET_SUPER_SUB
event passed to submachine superstate
Definition qp.h:201
@ Q_RET_TRAN_EP
entry-point transition into a submachine
Definition qp.h:218
@ Q_RET_EXIT
state exit action executed
Definition qp.h:210
QEvt const QEvt_reserved_[4]
char const QP_versionStr[16]
the current QP version number string in ROM, based on QP_VERSION_STR
float float32_t
Alias for IEEE 754 32-bit floating point number.
Definition qp.h:110
void(* QXThreadHandler)(struct QXThread *const me)
Pointer to an extended-thread handler function.
Definition qp.h:239
uint32_t QPSetBits
Bitmask for the internal representation of QPSet elements.
Definition qp.h:652
QState(* QStateHandler)(void *const me, QEvt const *const e)
Pointer to a state-handler function.
Definition qp.h:229
#define QEVT_MARKER
QEvt memory marker (for internal integrity checks)
Definition qp.h:138
enum QStateRet QState
Type returned from state-handler functions.
Definition qp.h:226
uint32_t QTimeEvtCtr
Data type to store the block-size defined based on the macro QF_TIMEEVT_CTR_SIZE.
Definition qp.h:637
uint_fast8_t QF_LOG2(QPSetBits const bitmask)
Log-base-2 calculation when hardware acceleration is NOT provided (QF_LOG2 not defined)
Definition qf_act.c:90
QReservedSig
Reserved signals by the QHsm-style state machine implementation.
Definition qp.h:258
@ Q_INIT_SIG
signal for coding initial transitions
Definition qp.h:262
@ Q_EMPTY_SIG
signal to execute the default case
Definition qp.h:259
@ Q_USER_SIG
offset for the user signals (QP Application)
Definition qp.h:263
@ Q_EXIT_SIG
signal for coding exit actions
Definition qp.h:261
@ Q_ENTRY_SIG
signal for coding entry actions
Definition qp.h:260
int int_t
Alias for assertion-ID numbers in QP assertions and return from QF_run()
Definition qp.h:104
double float64_t
Alias for IEEE 754 64-bit floating point number.
Definition qp.h:113
int enum_t
Definition qp.h:107
QState(* QActionHandler)(void *const me)
Pointer to an action-handler function.
Definition qp.h:232
uint16_t QSignal
The signal of event QEvt.
Definition qp.h:129
uint16_t QPrioSpec
Priority specification for Active Objects in QP.
Definition qp.h:623
#define QF_MAX_TICK_RATE
Maximum # clock tick rates in the system (0..15)
Definition qp_config.h:138
#define QF_MAX_ACTIVE
Maximum # Active Objects in the system (1..64)
Definition qp_config.h:118
#define QACTIVE_OS_OBJ_TYPE
QActive "OS-object" type used in various QP/C ports.
Definition qp_port.h:30
#define QACTIVE_EQUEUE_TYPE
QActive event queue type used in various QP/C ports.
Definition qp_port.h:27
#define QACTIVE_THREAD_TYPE
QActive "thread" type used in various QP/C ports.
Definition qp_port.h:33
int_t QF_run(void)
Definition qutest.c:190
void QF_init(void)
Definition qutest.c:171
void QF_stop(void)
Definition qutest.c:185
Active object class (based on the QHsm implementation strategy)
Definition qp.h:804
QSubscrList * QActive_subscrList_
Static (one per-class) pointer to all subscriber AOs for a given event signal.
Definition qp.h:846
QACTIVE_THREAD_TYPE thread
Port-dependent representation of the thread of the active object.
Definition qp.h:816
bool QActive_post_(QActive *const me, QEvt const *const e, uint_fast16_t const margin, void const *const sender)
Posts an event e directly to the event queue of the active object using the First-In-First-Out (FIFO)...
uint8_t pthre_dis
Definition qp.h:836
void QActive_ctor(QActive *const me, QStateHandler const initial)
QActive constructor (abstract base class)
bool QActive_defer(QActive const *const me, struct QEQueue *const eq, QEvt const *const e)
Defer an event to a given separate event queue.
void QActive_setAttr(QActive *const me, uint32_t attr1, void const *attr2)
enum_t QActive_maxPubSignal_
Static (one per-class) maximum published signal (the size of the subscrList_ array)
Definition qp.h:849
uint8_t prio_dis
Definition qp.h:831
QACTIVE_OS_OBJ_TYPE osObject
Port-dependent per-thread object.
Definition qp.h:821
QACTIVE_EQUEUE_TYPE eQueue
Port-dependent event-queue type (often QEQueue)
Definition qp.h:826
QAsm super
Definition qp.h:806
uint8_t prio
QF-priority [1..QF_MAX_ACTIVE] of this AO.
Definition qp.h:809
void QActive_psInit(QSubscrList *const subscrSto, enum_t const maxSignal)
Publish event to all subscribers of a given signal e->sig
uint8_t pthre
Preemption-threshold [1..QF_MAX_ACTIVE] of this AO.
Definition qp.h:812
void QActive_evtLoop_(QActive *const me)
Event loop thread routine for executing an active object act (defined some in QP ports)
Abstract State Machine class (state machine interface)
Definition qp.h:280
struct QAsmVtable const * vptr
Virtual pointer inherited by all QAsm subclasses (see also Object Orientation)
Definition qp.h:284
void QAsm_ctor(QAsm *const me)
Constructor of the QAsm base class.
union QAsmAttr state
Current state (pointer to the current state-handler function)
Definition qp.h:289
Virtual table for the QAsm class.
Definition qp.h:301
void(* init)(QAsm *const me, void const *const e, uint_fast8_t const qsId)
Virtual function to take the top-most initial transition in the state machine.
Definition qp.h:302
bool(* isIn)(QAsm *const me, QStateHandler const s)
Virtual function to check whether the state machine is in a given state.
Definition qp.h:306
QStateHandler(* getStateHandler)(QAsm *const me)
Virtual function to get the current state handler of the state machine.
Definition qp.h:309
void(* dispatch)(QAsm *const me, QEvt const *const e, uint_fast8_t const qsId)
Virtual function to dispatch an event to the state machine.
Definition qp.h:304
Native QF Event Queue.
Definition qequeue.h:66
Event class.
Definition qp.h:145
static QEvt * QEvt_init(QEvt *const me, uint8_t dummy)
Event without parameters initialization.
Definition qp.h:174
QSignal sig
Signal of the event (see Event Signal)
Definition qp.h:149
uint8_t evtTag_
Event "tag" containing pool-ID (indicating which event pool it came from) plus event marker.
Definition qp.h:157
uint8_t volatile refCtr_
Reference counter (for mutable events and 0 for immutable (static) events)
Definition qp.h:154
static uint_fast8_t QEvt_getPoolNum_(QEvt const *const me)
Internal function to get the event pool-number of the given event.
Definition qp.h:190
static void QEvt_ctor(QEvt *const me, enum_t const sig)
Definition qp.h:165
static bool QEvt_verify_(QEvt const *const me)
Internal function to verify the event pointer and the memory marker in the event (QP FuSa Subsystem)
Definition qp.h:184
Hierarchical State Machine class (QHsm-style state machine implementation strategy)
Definition qp.h:316
QAsm super
Definition qp.h:318
static QStateHandler QHsm_state(QHsm const *const me)
Obtain the current active state from a HSM (read only)
Definition qp.h:354
Active object class (based on QMsm implementation strategy)
Definition qp.h:956
QActive super
Definition qp.h:958
State object for the QMsm class (QM State Machine)
Definition qp.h:242
struct QMState const * superstate
Definition qp.h:243
QActionHandler const entryAction
Definition qp.h:245
QActionHandler const initAction
Definition qp.h:247
QActionHandler const exitAction
Definition qp.h:246
QStateHandler const stateHandler
Definition qp.h:244
Transition-Action Table for the QMsm State Machine.
Definition qp.h:251
QActionHandler const act[1]
Definition qp.h:253
QMState const * target
Definition qp.h:252
Hierarchical State Machine class (QMsm-style state machine implementation strategy)
Definition qp.h:379
static QStateHandler QMsm_getStateHandler_(QAsm *const me)
Implementation of getting the state handler in a QMsm subclass.
Definition qp.h:410
QAsm super
Definition qp.h:381
static QMState const * QMsm_stateObj(QMsm *const me)
Obtain the current active state from a MSM (read only)
Definition qp.h:426
Set of Active Objects of up to QF_MAX_ACTIVE elements.
Definition qp.h:662
static uint_fast8_t QPSet_findMax(QPSet const *const me)
Find the maximum element in the set–returns zero if the set is empty.
Definition qp.h:743
static bool QPSet_notEmpty(QPSet const *const me)
Find out whether the priority-set is NOT empty.
Definition qp.h:689
static bool QPSet_verify_(QPSet const *const me, QPSet const *const dis)
Verify the Duplicate Inverse Storage (QP FuSa Subsystem)
Definition qp.h:769
static bool QPSet_hasElement(QPSet const *const me, uint_fast8_t const n)
Find out whether the priority-set has element n
Definition qp.h:698
static void QPSet_setEmpty(QPSet *const me)
Make the priority set empty.
Definition qp.h:672
static void QPSet_insert(QPSet *const me, uint_fast8_t const n)
Insert element n into the priority-set (n = 1..QF_MAX_ACTIVE)
Definition qp.h:711
QPSetBits bits[((QF_MAX_ACTIVE+(8U *sizeof(QPSetBits))) - 1U)/(8U *sizeof(QPSetBits))]
Bitmask with a bit for each element.
Definition qp.h:666
static void QPSet_remove(QPSet *const me, uint_fast8_t const n)
Remove element n from the priority-set (n = 1..QF_MAX_ACTIVE)
Definition qp.h:727
static void QPSet_update_(QPSet const *const me, QPSet *const dis)
Update the Duplicate Inverse Storage of QPSet (QP FuSa Subsystem)
Definition qp.h:757
static bool QPSet_isEmpty(QPSet const *const me)
Find out whether the priority-set is empty.
Definition qp.h:680
Subscriber List (for publish-subscribe)
Definition qp.h:783
QPSet set_dis
Duplicate inverse storage for the AO set.
Definition qp.h:791
QPSet set
The set of AOs that subscribed to a given event signal.
Definition qp.h:787
"Ticker" Active Object class
Definition qp.h:1046
QActive super
Definition qp.h:1048
Time Event class.
Definition qp.h:973
void QTimeEvt_ctorX(QTimeEvt *const me, QActive *const act, enum_t const sig, uint_fast8_t const tickRate)
The "extended" constructor to initialize a Time Event.
struct QTimeEvt *volatile next
Link to the next time event in the list.
Definition qp.h:980
void *volatile act
Active object that receives the time events.
Definition qp.h:983
QTimeEvtCtr volatile ctr
Down-counter of the time event.
Definition qp.h:986
bool QTimeEvt_noActive(uint_fast8_t const tickRate)
Check if any time events are active at a given clock tick rate.
Definition qf_time.c:433
void QTimeEvt_tick1_(uint_fast8_t const tickRate, void const *const sender)
Processes one clock tick for QUTest.
Definition qutest.c:251
bool QTimeEvt_rearm(QTimeEvt *const me, QTimeEvtCtr const nTicks)
Rearm a time event.
Definition qf_time.c:202
void QTimeEvt_tick_(uint_fast8_t const tickRate, void const *const sender)
Processes all armed time events at every clock tick.
Definition qf_time.c:295
QTimeEvtCtr interval
Interval for periodic time event (zero for one-shot time event)
Definition qp.h:989
QTimeEvtCtr QTimeEvt_currCtr(QTimeEvt const *const me)
Get the current value of the down-counter of a time event.
Definition qf_time.c:284
QTimeEvt QTimeEvt_timeEvtHead_[QF_MAX_TICK_RATE]
Array of heads of linked lists of time events (one for every clock tick rate)
Definition qp.h:993
QEvt super
Definition qp.h:975
bool QTimeEvt_wasDisarmed(QTimeEvt *const me)
Check the "was disarmed" status of a time event.
Definition qf_time.c:268
void QTimeEvt_armX(QTimeEvt *const me, QTimeEvtCtr const nTicks, QTimeEvtCtr const interval)
Arm a time event (extended version for one shot or periodic time event)
Definition qf_time.c:96
bool QTimeEvt_disarm(QTimeEvt *const me)
Disarm a time event.
Definition qf_time.c:156
eXtended (blocking) thread of the QXK preemptive kernel
Definition qxk.h:145
Attribute of for the QAsm class (Abstract State Machine)
Definition qp.h:267
uintptr_t uint
Definition qp.h:274
QMTranActTable const * tatbl
Definition qp.h:271
QXThreadHandler thr
Definition qp.h:270
QStateHandler fun
Definition qp.h:268
struct QMState const * obj
Definition qp.h:272
QActionHandler act
Definition qp.h:269