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