qpc/doxygen/snippets/qf_main.c

42 lines
1.3 KiB
C
Raw Normal View History

2019-02-10 21:00:39 -05:00
#include "qpc.h"
Q_DEFINE_THIS_FILE
2015-04-28 13:45:35 -04:00
int main(void) {
static QEvt const *l_tableQueueSto[N_PHILO];
static QEvt const *l_philoQueueSto[N_PHILO][N_PHILO];
static QSubscrList l_subscrSto[MAX_PUB_SIG];
2013-09-23 14:34:35 -04:00
2015-04-28 13:45:35 -04:00
/* storage for event pools... */
static QF_MPOOL_EL(TableEvt) l_smlPoolSto[2*N_PHILO]; /* small pool */
2012-08-14 18:07:04 -04:00
uint8_t n;
2015-04-28 13:45:35 -04:00
Philo_ctor(); /* instantiate all Philosopher active objects */
Table_ctor(); /* instantiate the Table active object */
2012-08-14 18:07:04 -04:00
2015-04-28 13:45:35 -04:00
QF_init(); /* initialize the framework and the underlying RT kernel */
BSP_init(); /* initialize the BSP */
2013-09-23 14:34:35 -04:00
2015-04-28 13:45:35 -04:00
/* send object dictionaries for event pools... */
2013-09-23 14:34:35 -04:00
QS_OBJ_DICTIONARY(l_smlPoolSto);
2012-08-14 18:07:04 -04:00
2015-04-28 13:45:35 -04:00
/* init publish-subscribe... */
QF_psInit(l_subscrSto, Q_DIM(l_subscrSto));
2012-08-14 18:07:04 -04:00
2015-04-28 13:45:35 -04:00
/* initialize event pools... */
2012-08-14 18:07:04 -04:00
QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));
2015-04-28 13:45:35 -04:00
/* start the active objects... */
for (n = 0; n < N_PHILO; ++n) {
2015-12-24 14:33:20 -05:00
QACTIVE_START(AO_Philo[n], (uint8_t)(n + 1),
2012-08-14 18:07:04 -04:00
l_philoQueueSto[n], Q_DIM(l_philoQueueSto[n]),
2013-09-23 14:34:35 -04:00
(void *)0, 0U, (QEvt *)0);
2012-08-14 18:07:04 -04:00
}
2015-12-24 14:33:20 -05:00
QACTIVE_START(AO_Table, (uint8_t)(N_PHILO + 1),
2012-08-14 18:07:04 -04:00
l_tableQueueSto, Q_DIM(l_tableQueueSto),
2013-09-23 14:34:35 -04:00
(void *)0, 0U, (QEvt *)0);
2012-08-14 18:07:04 -04:00
2015-04-28 13:45:35 -04:00
return QF_run(); /* run the QF application, QF_run() does not return */
2012-08-14 18:07:04 -04:00
}