qpcpp/doxygen/snippets/qep_qinit.cpp

31 lines
780 B
C++
Raw Normal View History

// initial pseudostate of the Blinky HSM ......................................
Q_STATE_DEF(Blinky, initial) {
static_cast<void>(e); // unused parameter
// arm the time event to expire in half a second and every half second
m_timeEvt.armX(BSP_TICKS_PER_SEC/2U, BSP_TICKS_PER_SEC/2U);
return tran(&off);
2012-08-14 18:00:48 -04:00
}
// state handler for the Blinky HSM ..................................
Q_STATE_DEF(Blinky, off) {
QState status;
2012-08-14 18:00:48 -04:00
switch (e->sig) {
case Q_ENTRY_SIG: {
BSP_ledOff();
status = Q_RET_HANDLED;
break;
}
case TIMEOUT_SIG: {
status = tran(&on);
break;
}
default: {
status = super(&top);
break;
2012-08-14 18:00:48 -04:00
}
}
return status;
2012-08-14 18:00:48 -04:00
}