54 #ifndef QF_EVENT_SIZ_SIZE
56 #define QF_EVENT_SIZ_SIZE 2U
61 #define QF_MAX_EPOOL 3U
64 #ifndef QF_MAX_TICK_RATE
67 #define QF_MAX_TICK_RATE 1U
68 #elif (QF_MAX_TICK_RATE > 15U)
69 #error "QF_MAX_TICK_RATE exceeds the maximum of 15U"
72 #ifndef QF_TIMEEVT_CTR_SIZE
75 #define QF_TIMEEVT_CTR_SIZE 2U
82 #if (QF_EVENT_SIZ_SIZE == 1U)
84 #elif (QF_EVENT_SIZ_SIZE == 2U)
91 #elif (QF_EVENT_SIZ_SIZE == 4U)
94 #error "QF_EVENT_SIZ_SIZE defined incorrectly, expected 1U, 2U, or 4U"
98 #if (QF_TIMEEVT_CTR_SIZE == 1U)
100 #elif (QF_TIMEEVT_CTR_SIZE == 2U)
110 #elif (QF_TIMEEVT_CTR_SIZE == 4U)
113 #error "QF_TIMEEVT_CTR_SIZE defined incorrectly, expected 1U, 2U, or 4U"
146 #ifdef QF_EQUEUE_TYPE
160 #ifdef QF_OS_OBJECT_TYPE
170 #ifdef QF_THREAD_TYPE
181 std::uint8_t m_dynPrio;
197 void const *
const par);
204 this->
start(prio, qSto, qLen, stkSto, stkSize,
nullptr);
207 #ifdef QF_ACTIVE_STOP
225 void const *
const sender) noexcept;
263 #ifdef QF_OS_OBJECT_TYPE
269 #ifdef QF_THREAD_TYPE
276 QEvt
const *
get_(
void) noexcept;
281 virtual bool postFromISR_(QEvt
const *
const e,
283 void const *
const sender) noexcept;
285 virtual bool postFromISR_(QEvt
const *
const e,
333 void init(
void const *
const e,
442 bool disarm(
void) noexcept;
505 static void init(
void);
509 enum_t const maxSignal) noexcept;
512 static void poolInit(
void *
const poolSto,
531 static void stop(
void);
539 void const *
const sender,
544 void const *
const sender) noexcept;
564 enum_t const sig) noexcept;
567 static void gc(
QEvt const *
const e) noexcept;
571 QEvt const *
const evtRef) noexcept;
589 static void bzero(
void *
const start,
595 static void publishFromISR_(
QEvt const *e,
void *par,
596 void const *sender) noexcept;
598 void const *
const sender) noexcept;
600 static void publishFromISR_(
QEvt const *e,
void *par) noexcept;
607 enum_t const sig) noexcept;
608 static void gcFromISR(
QEvt const *e) noexcept;
644 void init(
void const *
const e,
656 void const *
const sender) noexcept
override;
664 #ifndef QF_CRIT_EXIT_NOP
674 #define QF_CRIT_EXIT_NOP() (static_cast<void>(0))
681 #define Q_NEW(evtT_, sig_, ...) \
682 (new(QP::QF::newX_(sizeof(evtT_), QP::QF_NO_MARGIN, 0)) \
683 evtT_((sig_), ##__VA_ARGS__))
685 #define Q_NEW_X(e_, evtT_, margin_, sig_, ...) do { \
686 (e_) = static_cast<evtT_ *>( \
687 QP::QF::newX_(sizeof(evtT_), (margin_), 0)); \
688 if ((e_) != nullptr) { \
689 new((e_)) evtT_((sig_), ##__VA_ARGS__); \
715 #define Q_NEW(evtT_, sig_) (static_cast<evtT_ *>( \
716 QP::QF::newX_(sizeof(evtT_), QP::QF_NO_MARGIN, (sig_))))
743 #define Q_NEW_X(e_, evtT_, margin_, sig_) \
744 ((e_) = static_cast<evtT_ *>(QP::QF::newX_( \
745 sizeof(evtT_), (margin_), (sig_))))
767 #define Q_NEW_REF(evtRef_, evtT_) \
768 ((evtRef_) = static_cast<evtT_ const *>(QP::QF::newRef_(e, (evtRef_))))
784 #define Q_DELETE_REF(evtRef_) do { \
785 QP::QF::deleteRef_((evtRef_)); \
816 #define TICK_X(tickRate_, sender_) tickX_((tickRate_), (sender_))
839 #define PUBLISH(e_, sender_) \
840 publish_((e_), (sender_), (sender_)->getPrio())
862 #define POST(e_, sender_) post_((e_), QP::QF_NO_MARGIN, (sender_))
896 #define POST_X(e_, margin_, sender_) \
897 post_((e_), (margin_), (sender_))
901 #define PUBLISH(e_, dummy_) publish_((e_))
902 #define POST(e_, dummy_) post_((e_), QP::QF_NO_MARGIN)
903 #define POST_X(e_, margin_, dummy_) post_((e_), (margin_))
904 #define TICK_X(tickRate_, dummy_) tickX_((tickRate_))
910 #define TICK(sender_) TICK_X(0U, (sender_))
unsigned int uint16_t
exact-width 16-bit unsigned int
unsigned int uint_fast16_t
fast at-least 16-bit unsigned int
unsigned long int uint32_t
exact-width 32-bit unsigned int
unsigned char uint8_t
exact-width 8-bit unsigned int
unsigned int uint_fast8_t
fast at-least 8-bit unsigned int
unsigned long uint_fast32_t
fast at-least 32-bit unsigned int
Dummy Active Object class.
QActive active object (based on QP::QHsm implementation)
std::uint8_t m_prio
QF priority (1..QF_MAX_ACTIVE) of this active object.
void setAttr(std::uint32_t attr1, void const *attr2=nullptr)
Generic setting of additional attributes (useful in QP ports)
virtual void postLIFO(QEvt const *const e) noexcept
Posts an event directly to the event queue of the active object using the Last-In-First-Out (LIFO) po...
virtual void start(std::uint_fast8_t const prio, QEvt const **const qSto, std::uint_fast16_t const qLen, void *const stkSto, std::uint_fast16_t const stkSize)
Overloaded start function (no initialization event)
bool defer(QEQueue *const eq, QEvt const *const e) const noexcept
Defer an event to a given separate event queue.
virtual bool post_(QEvt const *const e, std::uint_fast16_t const margin, void const *const sender) noexcept
void unsubscribeAll(void) const noexcept
Un-subscribes from the delivery of all signals to the active object.
void subscribe(enum_t const sig) const noexcept
Subscribes for delivery of signal sig to the active object.
std::uint_fast8_t getPrio(void) const noexcept
Get the priority of the active object.
bool recall(QEQueue *const eq) noexcept
Recall a deferred event from a given event queue.
void stop(void)
Stops execution of an active object and removes it from the framework's supervision.
virtual void start(std::uint_fast8_t const prio, QEvt const **const qSto, std::uint_fast16_t const qLen, void *const stkSto, std::uint_fast16_t const stkSize, void const *const par)
Starts execution of an active object and registers the object with the framework.
std::uint_fast16_t flushDeferred(QEQueue *const eq) const noexcept
Flush the specified deferred queue 'eq'.
void unsubscribe(enum_t const sig) const noexcept
Un-subscribes from the delivery of signal sig to the active object.
QEvt const * get_(void) noexcept
Get an event from the event queue of an active object.
void setPrio(std::uint_fast8_t const prio)
Set the priority of the active object.
Native QF Event Queue class.
static std::uint_fast16_t getPoolMin(std::uint_fast8_t const poolId) noexcept
This function returns the minimum of free entries of the given event pool.
static void onStartup(void)
Startup QF callback.
static void psInit(QSubscrList *const subscrSto, enum_t const maxSignal) noexcept
Publish-subscribe initialization.
static std::uint_fast16_t getQueueMin(std::uint_fast8_t const prio) noexcept
This function returns the minimum of free entries of the given event queue.
static void init(void)
QF initialization.
static void onCleanup(void)
Cleanup QF callback.
static void thread_(QActive *act)
Thread routine for executing an active object act.
static bool noTimeEvtsActiveX(std::uint_fast8_t const tickRate) noexcept
Returns true if all time events are inactive and false any time event is active.
static int_t run(void)
Transfers control to QF to run the application.
static char_t const * getVersion(void) noexcept
get the current QF version number string of the form X.Y.Z
static QTimeEvt timeEvtHead_[QF_MAX_TICK_RATE]
heads of linked lists of time events, one for every clock tick rate
static void gc(QEvt const *const e) noexcept
Recycle a dynamic event.
static void deleteRef_(QEvt const *const evtRef) noexcept
Internal QF implementation of deleting event reference.
static QEvt * newX_(std::uint_fast16_t const evtSize, std::uint_fast16_t const margin, enum_t const sig) noexcept
Internal QF implementation of creating new dynamic event.
static void bzero(void *const start, std::uint_fast16_t const len) noexcept
Clear a specified region of memory to zero.
static void add_(QActive *const a) noexcept
Register an active object to be managed by the framework.
static void stop(void)
Function invoked by the application layer to stop the QF application and return control to the OS/Ker...
static QActive * active_[QF_MAX_ACTIVE+1U]
array of registered active objects
static std::uint_fast16_t poolGetMaxBlockSize(void) noexcept
Obtain the block size of any registered event pools.
static void remove_(QActive *const a) noexcept
Remove the active object from the framework.
static void poolInit(void *const poolSto, std::uint_fast32_t const poolSize, std::uint_fast16_t const evtSize) noexcept
Event pool initialization for dynamic allocation of events.
static QEvt const * newRef_(QEvt const *const e, QEvt const *const evtRef) noexcept
Internal QF implementation of creating new event reference.
static void tickX_(std::uint_fast8_t const tickRate, void const *const sender) noexcept
Processes all armed time events at every clock tick.
static void publish_(QEvt const *const e, void const *const sender, std::uint_fast8_t const qs_id) noexcept
Publish event to the framework.
Hierarchical State Machine base class.
QStateHandler childState(QStateHandler const parent) noexcept
Obtain the current active child state of a given parent.
QHsmAttr m_state
current active state (state-variable)
QStateHandler state(void) const noexcept
Obtain the current state (state handler function)
bool isIn(QStateHandler const s) noexcept
Tests if a given state is part of the current active state configuration.
QMActive active object (based on QP::QMsm implementation)
QStateHandler getStateHandler() noexcept override
Get the current state handler of the QMsm.
QMState const * stateObj(void) const noexcept
Return the current active state object (read only)
void dispatch(QEvt const *const e, std::uint_fast8_t const qs_id) override
Dispatches an event to QHsm.
QMState const * childStateObj(QMState const *const parent) const noexcept
Obtain the current active child state of a given parent (read only)
void init(void const *const e, std::uint_fast8_t const qs_id) override
executes the top-most initial transition in QP::QHsm
bool isInState(QMState const *const st) const noexcept
Tests if a given state is part of the active state configuration.
Ticker Active Object class.
void init(void const *const e, std::uint_fast8_t const qs_id) noexcept override
executes the top-most initial transition in QP::QHsm
void postLIFO(QEvt const *const e) noexcept override
Posts an event directly to the event queue of the active object using the Last-In-First-Out (LIFO) po...
void init(std::uint_fast8_t const qs_id) noexcept override
overloaded init(qs_id)
bool post_(QEvt const *const e, std::uint_fast16_t const margin, void const *const sender) noexcept override
void dispatch(QEvt const *const e, std::uint_fast8_t const qs_id) noexcept override
Dispatches an event to QHsm.
QTimeEvt * toTimeEvt(void) noexcept
encapsulate the cast the m_act attribute to QTimeEvt*
QTimeEvtCtr currCtr(void) const noexcept
Get the current value of the down-counter of a time event.
QTimeEvtCtr volatile m_ctr
the internal down-counter of the time event.
QActive * toActive(void) noexcept
encapsulate the cast the m_act attribute to QActive*
QTimeEvtCtr m_interval
the interval for the periodic time event (zero for the one-shot time event).
QTimeEvt(void) noexcept
private default constructor only for friends
QTimeEvt *volatile m_next
link to the next time event in the list
QTimeEvt(QTimeEvt const &)=delete
private copy constructor to disallow copying of QTimeEvts
void armX(QTimeEvtCtr const nTicks, QTimeEvtCtr const interval=0U) noexcept
Arm a time event (one shot or periodic) for event posting.
QTimeEvt & operator=(QTimeEvt const &)=delete
private assignment operator to disallow assigning of QTimeEvts
bool disarm(void) noexcept
Disarm a time event.
bool wasDisarmed(void) noexcept
Check the "was disarmed" status of a time event.
bool rearm(QTimeEvtCtr const nTicks) noexcept
Rearm a time event.
void *volatile m_act
the active object that receives the time events
Priority Ceiling Mutex the QXK preemptive kernel.
Counting Semaphore of the QXK preemptive kernel.
Extended (blocking) thread of the QXK preemptive kernel.
#define QF_OS_OBJECT_TYPE
This macro defines the type of the OS-Object used for blocking.
#define QF_THREAD_TYPE
This macro defines the type of the thread handle used for AOs.
#define QF_EQUEUE_TYPE
This macro defines the type of the event-queue used for AOs.
namespace associated with the QP/C++ framework
std::uint_fast16_t const QF_NO_MARGIN
special value of margin that causes asserting failure in case event allocation or event posting fails
QMState const * obj
pointer to QMState object
constexpr char_t const versionStr[]
the current QP version number string based on QP_VERSION_STR
QState(*)(void *const me, QEvt const *const e) QStateHandler
Pointer to state-handler function.
State object for the QP::QMsm class (QM State Machine).
char char_t
typedef for character strings.
int int_t
typedef for assertions-ids and line numbers in assertions.
int enum_t
alias for enumerations used for event signals
platform-independent priority sets of 8 or 64 elements.
#define QF_MAX_ACTIVE
The maximum number of active objects in the application.
void QXK_activate_(void)
QXK activator activates the next active object. The activated AO preempts.
Priority Set of up to 32 elements */.