Blinky example
: QActive(Q_STATE_CAST(&Blinky::initial)),
m_timeEvt(this, TIMEOUT_SIG, 0U)
m_timeEvt.armX(BSP_TICKS_PER_SEC/2, BSP_TICKS_PER_SEC/2);
(void)e; // unused parameter
BSP_ledOff();
BSP_ledOn();
#include "qpcpp.hpp"
#include <iostream>
#include <cstdlib> // for exit()
using namespace std;
using namespace QP;
#ifdef Q_SPY
#error Simple Blinky Application does not provide Spy build configuration
#endif
enum { BSP_TICKS_PER_SEC = 100 };
void BSP_ledOff(void) {
cout << "LED OFF" << endl;
}
void BSP_ledOn(void) {
cout << "LED ON" << endl;
}
extern "C" void Q_onAssert(char const * const module, int loc) {
cout << "Assertion failed in " << module << ':' << loc << endl;
exit(-1);
}
void QF::onStartup(void) {}
void QF::onCleanup(void) {}
void QF::onClockTick(void) {
QTimeEvt::TICK_X(0U, nullptr); // perform the QF clock tick processing
}
enum BlinkySignals {
TIMEOUT_SIG = Q_USER_SIG,
MAX_SIG
};
//=============== ask QM to declare the Blinky class ==================
$declare${AOs::Blinky}
static Blinky l_blinky;
QActive * const AO_Blinky = &l_blinky;
int main() {
// statically allocate event queue buffer for the Blinky AO
static QEvt const *blinky_queueSto[10];
QF::init(); // initialize the framework
AO_Blinky->start(1U, // priority
blinky_queueSto, Q_DIM(blinky_queueSto),
nullptr, 0U); // no stack
return QF::run(); // run the QF application
}
//================ ask QM to define the Blinky class ==================
$define${AOs::Blinky}