About this model:
-----------------
The TimeBomb example from the video course "Modern Embedded Systems Programming":
https://www.youtube.com/c/StateMachineCOM
This example demonstrates:
- Active object TimeBomb) with hierarchical state machine
- Automatic code genertation from the model
- Integration between the generated code and other code, such as the Board Support Package (BSP)
Building and running the example:
This example builds with the uVision project "lesson" and is designed to run on the TivaC LaunchPad board.
QActive_ctor(&me->super, (QStateHandler)&TimeBomb_initial);
QTimeEvt_ctorX(&me->te, &me->super, TIMEOUT_SIG, 0U);
BSP_ledBlueOn();
BSP_ledBlueOff();
Q_ERROR_ID(100);
BSP_ledRedOff();
BSP_ledGreenOff();
BSP_ledBlueOff();
BSP_ledGreenOn();
BSP_ledGreenOff();
me->blink_ctr = 5U;
BSP_ledRedOn();
QTimeEvt_armX(&me->te, BSP_TICKS_PER_SEC/2, 0U);
BSP_ledRedOff();
QTimeEvt_armX(&me->te, BSP_TICKS_PER_SEC/2, 0U);
--me->blink_ctr;
me->blink_ctr > 0U
BSP_ledRedOn();
BSP_ledGreenOn();
BSP_ledBlueOn();
QS_BEGIN_ID(QS_USER, 0)
QS_STR("*** Boom!!!");
QS_END()
/* TimeBomb/Button with QP/C framework */
#include "qpc.h" /* QP/C API */
#include "bsp.h"
Q_DEFINE_THIS_MODULE("main") /* this module name for Q_ASSERT() */
/* The TimeBomb AO =======================================================*/
$declare${AOs::TimeBomb}
$define${AOs::TimeBomb}
static QEvt const *timeBomb_queue[10];
static TimeBomb timeBomb;
QActive *AO_TimeBomb = &timeBomb.super;
/* the main function =========================================================*/
int main() {
BSP_init(); /* initialize the BSP */
QF_init(); /* initialize QP/C */
/* create AO and start it */
TimeBomb_ctor(&timeBomb);
QACTIVE_START(AO_TimeBomb,
2U,
timeBomb_queue,
sizeof(timeBomb_queue)/sizeof(timeBomb_queue[0]),
(void *)0, 0U,
(void *)0);
QF_run(); /* run QP/C... */
return 0; /* NOTE: the scheduler does NOT return */
}