33#define QP_VERSION_STR "8.1.5"
34#define QP_VERSION 815U
36#define QP_RELEASE 0x648C4D80U
43#define QF_MAX_ACTIVE 32U
46#if (QF_MAX_ACTIVE > 64U)
47#error QF_MAX_ACTIVE exceeds the maximum of 64U;
50#ifndef QF_MAX_TICK_RATE
51#define QF_MAX_TICK_RATE 1U
54#if (QF_MAX_TICK_RATE > 15U)
55#error QF_MAX_TICK_RATE exceeds the maximum of 15U;
59#define QF_MAX_EPOOL 3U
62#if (QF_MAX_EPOOL > 15U)
63#error QF_MAX_EPOOL exceeds the maximum of 15U;
66#ifndef QF_TIMEEVT_CTR_SIZE
67#define QF_TIMEEVT_CTR_SIZE 4U
70#if (QF_TIMEEVT_CTR_SIZE > 4U)
71#error QF_TIMEEVT_CTR_SIZE defined incorrectly, expected 1U, 2U, or 4U;
74#ifndef QF_EVENT_SIZ_SIZE
75#define QF_EVENT_SIZ_SIZE 2U
78#if (QF_EVENT_SIZ_SIZE > 4U)
79#error QF_EVENT_SIZ_SIZE defined incorrectly, expected 1U, 2U, or 4U;
90#define Q_UNUSED_PAR(par_) ((void)(par_))
91#define Q_DIM(array_) (sizeof(array_) / sizeof((array_)[0U]))
92#define Q_UINT2PTR_CAST(type_, uint_) ((type_ *)(uint_))
107#define QEVT_INITIALIZER(sig_) { \
111 (uint32_t)0xE0E0E0E0U }
114void QEvt_ctor(
QEvt *
const me,
enum_t const sig);
117QEvt *QEvt_init(
QEvt *
const me, uint8_t
const dummy);
120void QEvt_refCtr_inc_(
QEvt const*
const me);
123void QEvt_refCtr_dec_(
QEvt const*
const me);
140#define QEVT_DYNAMIC ((uint8_t)0)
141#define Q_EVT_CAST(class_) ((class_ const *)(e))
175#define Q_USER_SIG ((enum_t)4)
177#define Q_STATE_CAST(handler_) ((QStateHandler)(handler_))
178#define Q_ACTION_CAST(action_) ((QActionHandler)(action_))
179#define Q_ACTION_NULL ((QActionHandler)0)
191#define Q_RET_SUPER ((QState)0U)
192#define Q_RET_UNHANDLED ((QState)1U)
193#define Q_RET_HANDLED ((QState)2U)
194#define Q_RET_TRAN ((QState)3U)
195#define Q_RET_TRAN_HIST ((QState)4U)
198#define Q_RET_IGNORED ((QState)5U)
201#define Q_RET_ENTRY ((QState)6U)
202#define Q_RET_EXIT ((QState)7U)
203#define Q_RET_TRAN_INIT ((QState)8U)
206#define Q_EMPTY_SIG ((QSignal)0U)
207#define Q_ENTRY_SIG ((QSignal)1U)
208#define Q_EXIT_SIG ((QSignal)2U)
209#define Q_INIT_SIG ((QSignal)3U)
214 void (*
init)(
QAsm *
const me,
void const *
const e,
215 uint_fast8_t
const qsId);
217 uint_fast8_t
const qsId);
223 #define QASM_INIT(me_, par_, qsId_) \
224 (*((QAsm *)(me_))->vptr->init)((QAsm *)(me_), (par_), (qsId_))
225 #define QASM_DISPATCH(me_, e_, qsId_) \
226 (*((QAsm *)(me_))->vptr->dispatch)((QAsm *)(me_), (e_), (qsId_))
227 #define QASM_IS_IN(me_, stateHndl_) \
228 (*((QAsm *)(me_))->vptr->isIn)((QAsm *)(me_), (stateHndl_))
230 #define QASM_INIT(me_, par_, dummy) \
231 (*((QAsm *)(me_))->vptr->init)((QAsm *)(me_), (par_), 0U)
232 #define QASM_DISPATCH(me_, e_, dummy) \
233 (*((QAsm *)(me_))->vptr->dispatch)((QAsm *)(me_), (e_), 0U)
236#define QASM_GET_STATE_HANDLER(me_) \
237 (*((QAsm *)(me_))->vptr->getStateHandler)((QAsm *)(me_))
239#define Q_ASM_UPCAST(ptr_) ((QAsm *)(ptr_))
249void QHsm_ctor(
QHsm *
const me,
253void QHsm_init_(
QAsm *
const me,
254 void const *
const e,
255 uint_fast8_t
const qsId);
258void QHsm_dispatch_(
QAsm *
const me,
259 QEvt const *
const e,
260 uint_fast8_t
const qsId);
272 QEvt const *
const e);
282size_t QHsm_tran_simple_(
285 uint_fast8_t
const qsId);
288size_t QHsm_tran_complex_(
291 uint_fast8_t
const qsId);
294void QHsm_enter_target_(
298 uint_fast8_t
const qsId);
300#define Q_HSM_UPCAST(ptr_) ((QHsm *)(ptr_))
302#define Q_TRAN(target_) \
303 ((Q_ASM_UPCAST(me))->temp.fun = Q_STATE_CAST(target_), \
305#define Q_TRAN_HIST(hist_) \
306 ((Q_ASM_UPCAST(me))->temp.fun = (hist_), \
307 (QState)Q_RET_TRAN_HIST)
308#define Q_SUPER(super_) \
309 ((Q_ASM_UPCAST(me))->temp.fun = Q_STATE_CAST(super_), \
311#define Q_HANDLED() ((QState)Q_RET_HANDLED)
312#define Q_UNHANDLED() ((QState)Q_RET_UNHANDLED)
322void QMsm_ctor(
QMsm *
const me,
328 void const *
const e,
329 uint_fast8_t
const qsId);
334 QEvt const *
const e,
335 uint_fast8_t
const qsId);
346QMState const * QMsm_topQMState(
void);
349QMState const * QMsm_stateObj(
QMsm const *
const me);
352QMState const * QMsm_childStateObj(
QMsm const *
const me,
353 QMState const *
const parentHndl);
358#define Q_MSM_UPCAST(ptr_) ((QMsm *)(ptr_))
360 #define QM_ENTRY(state_) \
361 ((Q_ASM_UPCAST(me))->temp.obj = (state_), (QState)Q_RET_ENTRY)
362 #define QM_EXIT(state_) \
363 ((Q_ASM_UPCAST(me))->temp.obj = (state_), (QState)Q_RET_EXIT)
365 #define QM_ENTRY(dummy) ((QState)Q_RET_ENTRY)
366 #define QM_EXIT(dummy) ((QState)Q_RET_EXIT)
369#define QM_TRAN(tatbl_) ((Q_ASM_UPCAST(me))->temp.tatbl \
370 = (struct QMTranActTable const *)(tatbl_), (QState)Q_RET_TRAN)
372#define QM_TRAN_INIT(tatbl_) ((Q_ASM_UPCAST(me))->temp.tatbl \
373 = (struct QMTranActTable const *)(tatbl_), (QState)Q_RET_TRAN_INIT)
375#define QM_TRAN_HIST(history_, tatbl_) \
376 ((((Q_ASM_UPCAST(me))->state.obj = (history_)), \
377 ((Q_ASM_UPCAST(me))->temp.tatbl = \
378 (struct QMTranActTable const *)(tatbl_))), (QState)Q_RET_TRAN_HIST)
380#define QM_HANDLED() ((QState)Q_RET_HANDLED)
381#define QM_UNHANDLED() ((QState)Q_RET_UNHANDLED)
382#define QM_SUPER() ((QState)Q_RET_SUPER)
383#define QM_STATE_NULL ((QMState *)0)
390#if (QF_TIMEEVT_CTR_SIZE == 1U)
392#elif (QF_TIMEEVT_CTR_SIZE == 2U)
394#elif (QF_TIMEEVT_CTR_SIZE == 4U)
398#if (QF_MAX_ACTIVE <= 8U)
400#elif (8U < QF_MAX_ACTIVE) && (QF_MAX_ACTIVE <= 16U)
402#elif (16U < QF_MAX_ACTIVE)
415#if (QF_MAX_ACTIVE > 32U)
422void QPSet_setEmpty(
QPSet *
const me);
425bool QPSet_isEmpty(
QPSet const *
const me);
428bool QPSet_notEmpty(
QPSet const *
const me);
431bool QPSet_hasElement(
QPSet const *
const me, uint_fast8_t
const n);
434void QPSet_insert(
QPSet *
const me, uint_fast8_t
const n);
437void QPSet_remove(
QPSet *
const me, uint_fast8_t
const n);
440uint_fast8_t QPSet_findMax(
QPSet const *
const me);
457#ifdef QACTIVE_THREAD_TYPE
461#ifdef QACTIVE_OS_OBJ_TYPE
465#ifdef QACTIVE_EQUEUE_TYPE
471void QActive_ctor(
QActive *
const me,
483 uint_fast16_t
const qLen,
485 uint_fast16_t
const stkSize,
486 void const *
const par);
488#ifdef QACTIVE_CAN_STOP
501 QEvt const *
const e,
502 uint_fast16_t
const margin,
503 void const *
const sender);
507 QEvt const *
const e);
519 QEvt const *
const e,
520 void const *
const sender,
521 uint_fast8_t
const qsId);
546 QEvt const *
const e);
555 uint_fast16_t
const num);
560#define Q_ACTIVE_UPCAST(ptr_) ((QActive *)(ptr_))
570void QMActive_ctor(
QMActive *
const me,
574#if (QF_MAX_TICK_RATE > 0U)
597 uint32_t
const nTicks,
605 uint32_t
const nTicks);
619 void const *
const sender);
631 void const *
const sender);
645void QTicker_ctor(
QTicker *
const me,
646 uint_fast8_t
const tickRate);
649void QTicker_init_(
QAsm *
const me,
650 void const *
const par,
651 uint_fast8_t
const qsId);
654void QTicker_dispatch_(
QAsm *
const me,
655 QEvt const *
const e,
656 uint_fast8_t
const qsId);
659void QTicker_trig_(
QTicker *
const me,
660 void const *
const sender);
682#ifdef QF_ON_CONTEXT_SW
691 return (
QPrioSpec)((uint32_t)prio | ((uint32_t)pthre << 8U));
694#define QF_NO_MARGIN ((uint_fast16_t)0xFFFFU)
701 void *
const poolSto,
702 uint_fast32_t
const poolSize,
703 uint_fast16_t
const evtSize);
706uint16_t QF_poolGetMaxBlockSize(
void);
719 uint_fast16_t
const evtSize,
720 uint_fast16_t
const margin,
728 QEvt const *
const e,
729 void const *
const evtRef);
738 #define Q_NEW(evtT_, sig_, ...) \
739 (evtT_##_init((evtT_ *)QF_newX_((uint_fast16_t)sizeof(evtT_), \
740 QF_NO_MARGIN, (sig_)), __VA_ARGS__))
741 #define Q_NEW_X(evtT_, margin_, sig_, ...) \
742 (evtT_##_init((evtT_ *)QF_newX_((uint_fast16_t)sizeof(evtT_), \
743 (margin_), (sig_)), __VA_ARGS__))
745 #define Q_NEW(evtT_, sig_) \
746 ((evtT_ *)QF_newX_((uint_fast16_t)sizeof(evtT_), \
747 QF_NO_MARGIN, (enum_t)(sig_)))
748 #define Q_NEW_X(evtT_, margin_, sig_) \
749 ((evtT_ *)QF_newX_((uint_fast16_t)sizeof(evtT_), \
750 (margin_), (enum_t)(sig_)))
753#define Q_NEW_REF(evtRef_, evtT_) \
754 ((evtRef_) = (evtT_ const *)QF_newRef_(e, (evtRef_)))
755#define Q_DELETE_REF(evtRef_) do { \
756 QF_deleteRef_((evtRef_)); \
757 (evtRef_) = (void *)0; \
761 #define QACTIVE_POST(me_, e_, sender_) \
762 ((void)QActive_post_((me_), (e_), QF_NO_MARGIN, (sender_)))
763 #define QACTIVE_POST_X(me_, e_, margin_, sender_) \
764 (QActive_post_((me_), (e_), (margin_), (sender_)))
765 #define QACTIVE_PUBLISH(e_, sender_) \
766 (QActive_publish_((e_), (void const *)(sender_), (sender_)->prio))
767 #define QTIMEEVT_TICK_X(tickRate_, sender_) (QTimeEvt_tick_((tickRate_), (sender_)))
768 #define QTICKER_TRIG(ticker_, sender_) (QTicker_trig_((ticker_), (sender_)))
770 #define QACTIVE_POST(me_, e_, dummy) \
771 ((void)QActive_post_((me_), (e_), QF_NO_MARGIN, (void *)0))
772 #define QACTIVE_POST_X(me_, e_, margin_, dummy) \
773 (QActive_post_((me_), (e_), (margin_), (void *)0))
774 #define QACTIVE_PUBLISH(e_, dummy) (QActive_publish_((e_), (void *)0, 0U))
775 #define QTIMEEVT_TICK_X(tickRate_, dummy) (QTimeEvt_tick_((tickRate_), (void *)0))
776 #define QTICKER_TRIG(ticker_, sender_) (QTicker_trig_((ticker_), (void *)0))
779#define QACTIVE_POST_LIFO(me_, e_) (QActive_postLIFO_((me_), (e_)))
780#define QTIMEEVT_TICK(sender_) QTIMEEVT_TICK_X(0U, (sender_))
782#ifndef QF_CRIT_EXIT_NOP
783 #define QF_CRIT_EXIT_NOP() ((void)0)
void QF_onStartup(void)
Startup callback.
void QF_onCleanup(void)
Cleanup QF callback.
uint16_t QF_getPoolFree(uint_fast8_t const poolNum)
void QF_gc(QEvt const *const e)
Recycle a mutable (mutable) event.
void QF_onContextSw(QActive *prev, QActive *next)
QF context switch callback used in built-in kernels (QV/QK/QXK).
uint16_t QF_getPoolMin(uint_fast8_t const poolNum)
Obtain the minimum of free entries of the given event pool.
uint16_t QF_getPoolUse(uint_fast8_t const poolNum)
QEvt * QF_newX_(uint_fast16_t const evtSize, uint_fast16_t const margin, enum_t const sig)
Internal QF implementation of creating new mutable (dynamic) event.
void QF_gcFromISR(QEvt const *const e)
void QF_deleteRef_(void const *const evtRef)
Internal QF implementation of deleting event reference.
QEvt const * QF_newRef_(QEvt const *const e, void const *const evtRef)
Internal QF implementation of creating new event reference.
void(* QXThreadHandler)(struct QXThread *const me)
Pointer to an extended-thread handler function.
uint32_t QPSetBits
Bitmask for the internal representation of QPSet elements.
QState(* QStateHandler)(void *const me, QEvt const *const e)
Pointer to a state-handler function.
uint32_t QTimeEvtCtr
Data type to store the block-size defined based on the macro QF_TIMEEVT_CTR_SIZE.
int int_t
Alias for assertion-ID numbers in QP assertions and return from QF_run().
uint_fast8_t QState
Type returned from state-handler functions.
char const QP_versionStr[24]
static QPrioSpec Q_PRIO(uint8_t const prio, uint8_t const pthre)
QState(* QActionHandler)(void *const me)
Pointer to an action-handler function.
uint16_t QSignal
The signal of event QEvt.
uint16_t QPrioSpec
Priority specification for Active Objects in QP.
#define QACTIVE_OS_OBJ_TYPE
Port-specific QActive "OS-object" type.
#define QACTIVE_EQUEUE_TYPE
Port-specific QActive event queue type.
#define QACTIVE_THREAD_TYPE
Port-specific QActive thread type.
#define QF_LOG2(bitmask_)
Port-specific integer log-base-2 of a 32-bit bitmask.
Active object class (based on the QHsm implementation strategy).
void QActive_unsubscribe(QActive const *const me, enum_t const sig)
Unsubscribes from the delivery of signal sig to the active object.
void QActive_unregister_(QActive *const me)
Un-register the active object from the framework.
QACTIVE_THREAD_TYPE thread
Port-dependent representation of the thread of the active object.
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)...
QEvt const * QActive_get_(QActive *const me)
Get an event from the event queue of an active object.
uint16_t QActive_getQueueFree(uint_fast8_t const prio)
void QActive_postLIFO_(QActive *const me, QEvt const *const e)
Posts an event e directly to the event queue of the active object using the Last-In-First-Out (LIFO) ...
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)
Generic setting of additional attributes (defined in some QP ports).
QACTIVE_OS_OBJ_TYPE osObject
Port-dependent per-thread object.
uint16_t QActive_flushDeferred(QActive const *const me, struct QEQueue *const eq, uint_fast16_t const num)
Flush the specified number of events from the deferred queue eq.
bool QActive_recall(QActive *const me, struct QEQueue *const eq)
Recall a deferred event from a given event queue.
QACTIVE_EQUEUE_TYPE eQueue
Port-dependent event-queue type (often QEQueue).
void QActive_publish_(QEvt const *const e, void const *const sender, uint_fast8_t const qsId)
Publish event to all subscribers of a given signal e->sig.
void QActive_stop(QActive *const me)
Stops execution of an active object and removes it from the framework's supervision.
void QActive_register_(QActive *const me)
Register this active object to be managed by the framework.
uint8_t prio
QF-priority [1..QF_MAX_ACTIVE] of this AO.
void QActive_subscribe(QActive const *const me, enum_t const sig)
Subscribes for delivery of signal sig to the active object.
void QActive_start(QActive *const me, QPrioSpec const prioSpec, QEvtPtr *const qSto, uint_fast16_t const qLen, void *const stkSto, uint_fast16_t const stkSize, void const *const par)
Starts execution of an active object and registers the object with the framework.
uint16_t QActive_getQueueUse(uint_fast8_t const prio)
void QActive_unsubscribeAll(QActive const *const me)
Unsubscribes from the delivery of all signals to the active object.
void QActive_psInit(QSubscrList *const subscrSto, enum_t const maxSignal)
Initializes the publish-subscribe facility for the application.
uint8_t pthre
Preemption-threshold [1..QF_MAX_ACTIVE] of this AO.
uint16_t QActive_getQueueMin(uint_fast8_t const prio)
This function returns the minimum of free entries of the given event queue.
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).
struct QAsmVtable const * vptr
Virtual pointer inherited by all QAsm subclasses (see also ARCH_QP_OOA).
union QAsmAttr state
Current state (pointer to the current state-handler function).
union QAsmAttr temp
Temporary storage for target/act-table etc..
Virtual table for the QAsm class.
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.
QStateHandler(* getStateHandler)(QAsm const *const me)
Virtual function to get the current state handler of the state machine.
bool(* isIn)(QAsm *const me, QStateHandler const stateHndl)
Virtual function to check whether the state machine is in a given state.
void(* dispatch)(QAsm *const me, QEvt const *const e, uint_fast8_t const qsId)
Virtual function to dispatch an event to the state machine.
uint32_t filler_
Member of QEvt to make it identical size in QP/C and SafeQP/C.
bool QEvt_verify_(QEvt const *const me)
void QEvt_update_(QEvt *const me)
uint32_t refCtr_
Event reference counter.
uint32_t poolNum_
Event pool number of this event.
uint32_t sig
Event signal (see Event Signal).
The data type to store in the event queue ring-buffer.
Hierarchical State Machine class (QHsm-style state machine implementation strategy).
Active object class (based on QMsm implementation strategy).
State object for the QMsm class (QM State Machine).
struct QMState const * superstate
QActionHandler const entryAction
QActionHandler const initAction
QActionHandler const exitAction
QStateHandler const stateHandler
Transition-Action Table for the QMsm State Machine.
QActionHandler const act[1]
Hierarchical State Machine class (QMsm-style state machine implementation strategy).
Set of Active Objects of up to QF_MAX_ACTIVE elements.
QPSetBits bits0
Bitmask for elements 1..32.
QPSetBits bits1
Bitmask for elements 33..64.
Subscriber List (for publish-subscribe).
QPSet set
The set of AOs that subscribed to a given event signal.
"Ticker" Active Object class
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.
QTimeEvtCtr ctr
Down-counter of the time event.
bool QTimeEvt_noActive(uint_fast8_t const tickRate)
Check if any time events are active at a given clock tick rate.
void QTimeEvt_tick1_(uint_fast8_t const tickRate, void const *const sender)
Processes one (the next upcoming) 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).
void QTimeEvt_tick_(uint_fast8_t const tickRate, void const *const sender)
Processes all armed time events at every clock tick.
QTimeEvt * QTimeEvt_expire_(QTimeEvt *const me, QTimeEvt *const prev_link, QActive const *const act, uint_fast8_t const tickRate)
QTimeEvtCtr interval
Interval for periodic time event (zero for one-shot time event).
bool QTimeEvt_rearm(QTimeEvt *const me, uint32_t const nTicks)
Rearm a time event.
QTimeEvtCtr QTimeEvt_getCtr(QTimeEvt const *const me)
Get the current value of the down-counter of a time event.
bool QTimeEvt_wasDisarmed(QTimeEvt *const me)
Check the "was disarmed" status of a time event.
bool QTimeEvt_disarm(QTimeEvt *const me)
Disarm a time event.
struct QTimeEvt * next
Link to the next time event in the list.
void * act
Active object that receives the time events.
eXtended (blocking) thread of the QXK preemptive kernel
Attribute of for the QAsm class (Abstract State Machine).
QMTranActTable const * tatbl
struct QMState const * obj