33#define QP_VERSION_STR "8.1.2"
34#define QP_VERSION 812U
36#define QP_RELEASE 0x64F71D43U
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);
135#define QEVT_DYNAMIC ((uint8_t)0)
136#define Q_EVT_CAST(class_) ((class_ const *)(e))
170#define Q_USER_SIG ((enum_t)4)
172#define Q_STATE_CAST(handler_) ((QStateHandler)(handler_))
173#define Q_ACTION_CAST(action_) ((QActionHandler)(action_))
174#define Q_ACTION_NULL ((QActionHandler)0)
186#define Q_RET_SUPER ((QState)0U)
187#define Q_RET_UNHANDLED ((QState)1U)
188#define Q_RET_HANDLED ((QState)2U)
189#define Q_RET_TRAN ((QState)3U)
190#define Q_RET_TRAN_HIST ((QState)4U)
193#define Q_RET_IGNORED ((QState)5U)
196#define Q_RET_ENTRY ((QState)6U)
197#define Q_RET_EXIT ((QState)7U)
198#define Q_RET_TRAN_INIT ((QState)8U)
201#define Q_EMPTY_SIG ((QSignal)0U)
202#define Q_ENTRY_SIG ((QSignal)1U)
203#define Q_EXIT_SIG ((QSignal)2U)
204#define Q_INIT_SIG ((QSignal)3U)
209 void (*
init)(
QAsm *
const me,
void const *
const e,
210 uint_fast8_t
const qsId);
212 uint_fast8_t
const qsId);
218 #define QASM_INIT(me_, par_, qsId_) \
219 (*((QAsm *)(me_))->vptr->init)((QAsm *)(me_), (par_), (qsId_))
220 #define QASM_DISPATCH(me_, e_, qsId_) \
221 (*((QAsm *)(me_))->vptr->dispatch)((QAsm *)(me_), (e_), (qsId_))
222 #define QASM_IS_IN(me_, stateHndl_) \
223 (*((QAsm *)(me_))->vptr->isIn)((QAsm *)(me_), (stateHndl_))
225 #define QASM_INIT(me_, par_, dummy) \
226 (*((QAsm *)(me_))->vptr->init)((QAsm *)(me_), (par_), 0U)
227 #define QASM_DISPATCH(me_, e_, dummy) \
228 (*((QAsm *)(me_))->vptr->dispatch)((QAsm *)(me_), (e_), 0U)
231#define QASM_GET_STATE_HANDLER(me_) \
232 (*((QAsm *)(me_))->vptr->getStateHandler)((QAsm *)(me_))
234#define Q_ASM_UPCAST(ptr_) ((QAsm *)(ptr_))
244void QHsm_ctor(
QHsm *
const me,
248void QHsm_init_(
QAsm *
const me,
249 void const *
const e,
250 uint_fast8_t
const qsId);
253void QHsm_dispatch_(
QAsm *
const me,
254 QEvt const *
const e,
255 uint_fast8_t
const qsId);
267 QEvt const *
const e);
277size_t QHsm_tran_simple_(
280 uint_fast8_t
const qsId);
283size_t QHsm_tran_complex_(
286 uint_fast8_t
const qsId);
289void QHsm_enter_target_(
293 uint_fast8_t
const qsId);
295#define Q_HSM_UPCAST(ptr_) ((QHsm *)(ptr_))
297#define Q_TRAN(target_) \
298 ((Q_ASM_UPCAST(me))->temp.fun = Q_STATE_CAST(target_), \
300#define Q_TRAN_HIST(hist_) \
301 ((Q_ASM_UPCAST(me))->temp.fun = (hist_), \
302 (QState)Q_RET_TRAN_HIST)
303#define Q_SUPER(super_) \
304 ((Q_ASM_UPCAST(me))->temp.fun = Q_STATE_CAST(super_), \
306#define Q_HANDLED() ((QState)Q_RET_HANDLED)
307#define Q_UNHANDLED() ((QState)Q_RET_UNHANDLED)
317void QMsm_ctor(
QMsm *
const me,
323 void const *
const e,
324 uint_fast8_t
const qsId);
329 QEvt const *
const e,
330 uint_fast8_t
const qsId);
341QMState const * QMsm_topQMState(
void);
344QMState const * QMsm_stateObj(
QMsm const *
const me);
347QMState const * QMsm_childStateObj(
QMsm const *
const me,
348 QMState const *
const parentHndl);
353#define Q_MSM_UPCAST(ptr_) ((QMsm *)(ptr_))
355 #define QM_ENTRY(state_) \
356 ((Q_ASM_UPCAST(me))->temp.obj = (state_), (QState)Q_RET_ENTRY)
357 #define QM_EXIT(state_) \
358 ((Q_ASM_UPCAST(me))->temp.obj = (state_), (QState)Q_RET_EXIT)
360 #define QM_ENTRY(dummy) ((QState)Q_RET_ENTRY)
361 #define QM_EXIT(dummy) ((QState)Q_RET_EXIT)
364#define QM_TRAN(tatbl_) ((Q_ASM_UPCAST(me))->temp.tatbl \
365 = (struct QMTranActTable const *)(tatbl_), (QState)Q_RET_TRAN)
367#define QM_TRAN_INIT(tatbl_) ((Q_ASM_UPCAST(me))->temp.tatbl \
368 = (struct QMTranActTable const *)(tatbl_), (QState)Q_RET_TRAN_INIT)
370#define QM_TRAN_HIST(history_, tatbl_) \
371 ((((Q_ASM_UPCAST(me))->state.obj = (history_)), \
372 ((Q_ASM_UPCAST(me))->temp.tatbl = \
373 (struct QMTranActTable const *)(tatbl_))), (QState)Q_RET_TRAN_HIST)
375#define QM_HANDLED() ((QState)Q_RET_HANDLED)
376#define QM_UNHANDLED() ((QState)Q_RET_UNHANDLED)
377#define QM_SUPER() ((QState)Q_RET_SUPER)
378#define QM_STATE_NULL ((QMState *)0)
385#if (QF_TIMEEVT_CTR_SIZE == 1U)
387#elif (QF_TIMEEVT_CTR_SIZE == 2U)
389#elif (QF_TIMEEVT_CTR_SIZE == 4U)
393#if (QF_MAX_ACTIVE <= 8U)
395#elif (8U < QF_MAX_ACTIVE) && (QF_MAX_ACTIVE <= 16U)
397#elif (16U < QF_MAX_ACTIVE)
410#if (QF_MAX_ACTIVE > 32U)
417void QPSet_setEmpty(
QPSet *
const me);
420bool QPSet_isEmpty(
QPSet const *
const me);
423bool QPSet_notEmpty(
QPSet const *
const me);
426bool QPSet_hasElement(
QPSet const *
const me, uint_fast8_t
const n);
429void QPSet_insert(
QPSet *
const me, uint_fast8_t
const n);
432void QPSet_remove(
QPSet *
const me, uint_fast8_t
const n);
435uint_fast8_t QPSet_findMax(
QPSet const *
const me);
452#ifdef QACTIVE_THREAD_TYPE
456#ifdef QACTIVE_OS_OBJ_TYPE
460#ifdef QACTIVE_EQUEUE_TYPE
466void QActive_ctor(
QActive *
const me,
478 uint_fast16_t
const qLen,
480 uint_fast16_t
const stkSize,
481 void const *
const par);
483#ifdef QACTIVE_CAN_STOP
496 QEvt const *
const e,
497 uint_fast16_t
const margin,
498 void const *
const sender);
502 QEvt const *
const e);
514 QEvt const *
const e,
515 void const *
const sender,
516 uint_fast8_t
const qsId);
541 QEvt const *
const e);
550 uint_fast16_t
const num);
555#define Q_ACTIVE_UPCAST(ptr_) ((QActive *)(ptr_))
565void QMActive_ctor(
QMActive *
const me,
569#if (QF_MAX_TICK_RATE > 0U)
592 uint32_t
const nTicks,
600 uint32_t
const nTicks);
614 void const *
const sender);
626 void const *
const sender);
640void QTicker_ctor(
QTicker *
const me,
641 uint_fast8_t
const tickRate);
644void QTicker_init_(
QAsm *
const me,
645 void const *
const par,
646 uint_fast8_t
const qsId);
649void QTicker_dispatch_(
QAsm *
const me,
650 QEvt const *
const e,
651 uint_fast8_t
const qsId);
654void QTicker_trig_(
QTicker *
const me,
655 void const *
const sender);
659void QTimeEvt_init(
void);
681#ifdef QF_ON_CONTEXT_SW
690 return (
QPrioSpec)((uint32_t)prio | ((uint32_t)pthre << 8U));
693#define QF_NO_MARGIN ((uint_fast16_t)0xFFFFU)
700 void *
const poolSto,
701 uint_fast32_t
const poolSize,
702 uint_fast16_t
const evtSize);
705uint16_t QF_poolGetMaxBlockSize(
void);
718 uint_fast16_t
const evtSize,
719 uint_fast16_t
const margin,
727 QEvt const *
const e,
728 void const *
const evtRef);
737 #define Q_NEW(evtT_, sig_, ...) \
738 (evtT_##_init((evtT_ *)QF_newX_((uint_fast16_t)sizeof(evtT_), \
739 QF_NO_MARGIN, (sig_)), __VA_ARGS__))
740 #define Q_NEW_X(evtT_, margin_, sig_, ...) \
741 (evtT_##_init((evtT_ *)QF_newX_((uint_fast16_t)sizeof(evtT_), \
742 (margin_), (sig_)), __VA_ARGS__))
744 #define Q_NEW(evtT_, sig_) \
745 ((evtT_ *)QF_newX_((uint_fast16_t)sizeof(evtT_), \
746 QF_NO_MARGIN, (enum_t)(sig_)))
747 #define Q_NEW_X(evtT_, margin_, sig_) \
748 ((evtT_ *)QF_newX_((uint_fast16_t)sizeof(evtT_), \
749 (margin_), (enum_t)(sig_)))
752#define Q_NEW_REF(evtRef_, evtT_) \
753 ((evtRef_) = (evtT_ const *)QF_newRef_(e, (evtRef_)))
754#define Q_DELETE_REF(evtRef_) do { \
755 QF_deleteRef_((evtRef_)); \
756 (evtRef_) = (void *)0; \
760 #define QACTIVE_POST(me_, e_, sender_) \
761 ((void)QActive_post_((me_), (e_), QF_NO_MARGIN, (sender_)))
762 #define QACTIVE_POST_X(me_, e_, margin_, sender_) \
763 (QActive_post_((me_), (e_), (margin_), (sender_)))
764 #define QACTIVE_PUBLISH(e_, sender_) \
765 (QActive_publish_((e_), (void const *)(sender_), (sender_)->prio))
766 #define QTIMEEVT_TICK_X(tickRate_, sender_) (QTimeEvt_tick_((tickRate_), (sender_)))
767 #define QTICKER_TRIG(ticker_, sender_) (QTicker_trig_((ticker_), (sender_)))
769 #define QACTIVE_POST(me_, e_, dummy) \
770 ((void)QActive_post_((me_), (e_), QF_NO_MARGIN, (void *)0))
771 #define QACTIVE_POST_X(me_, e_, margin_, dummy) \
772 (QActive_post_((me_), (e_), (margin_), (void *)0))
773 #define QACTIVE_PUBLISH(e_, dummy) (QActive_publish_((e_), (void *)0, 0U))
774 #define QTIMEEVT_TICK_X(tickRate_, dummy) (QTimeEvt_tick_((tickRate_), (void *)0))
775 #define QTICKER_TRIG(ticker_, sender_) (QTicker_trig_((ticker_), (void *)0))
778#define QACTIVE_POST_LIFO(me_, e_) (QActive_postLIFO_((me_), (e_)))
779#define QTIMEEVT_TICK(sender_) QTIMEEVT_TICK_X(0U, (sender_))
781#ifndef QF_CRIT_EXIT_NOP
782 #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.
QEvt const * QEvtPtr
Pointer to const event instances passed around in QP/C Framework.
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)
Publish event to all subscribers of a given signal e->sig.
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 SAS_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).
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 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