2018-03-19 14:51:26 -04:00
|
|
|
#include "qpc.h"
|
2013-10-10 20:01:51 -04:00
|
|
|
#include "dpp.h"
|
|
|
|
#include "bsp.h"
|
|
|
|
|
|
|
|
namespace DPP {
|
|
|
|
|
2012-08-14 18:00:48 -04:00
|
|
|
//............................................................................
|
2015-12-31 14:56:37 -05:00
|
|
|
int_t main(void) {
|
|
|
|
// statically allocated storage for various QP facilities
|
|
|
|
static QP::QEvt const *tableQueueSto[N_PHILO];
|
|
|
|
static QP::QEvt const *philoQueueSto[N_PHILO][N_PHILO];
|
|
|
|
static QP::QSubscrList subscrSto[MAX_PUB_SIG];
|
|
|
|
static QF_MPOOL_EL(TableEvt) smlPoolSto[2*N_PHILO];
|
2012-08-14 18:00:48 -04:00
|
|
|
|
2013-10-10 20:01:51 -04:00
|
|
|
QP::QF::init(); // initialize the framework and the underlying RT kernel
|
2012-08-14 18:00:48 -04:00
|
|
|
|
2015-12-31 14:56:37 -05:00
|
|
|
BSP::init(); // initialize the BSP
|
2012-08-14 18:00:48 -04:00
|
|
|
|
2015-12-31 14:56:37 -05:00
|
|
|
// object dictionaries...
|
2018-10-25 11:13:01 -04:00
|
|
|
QS_OBJ_DICTIONARY(AO_Table);
|
|
|
|
QS_OBJ_DICTIONARY(AO_Philo[0]);
|
|
|
|
QS_OBJ_DICTIONARY(AO_Philo[1]);
|
|
|
|
QS_OBJ_DICTIONARY(AO_Philo[2]);
|
|
|
|
QS_OBJ_DICTIONARY(AO_Philo[3]);
|
|
|
|
QS_OBJ_DICTIONARY(AO_Philo[4]);
|
2013-10-10 20:01:51 -04:00
|
|
|
|
2015-12-31 14:56:37 -05:00
|
|
|
QP::QF::psInit(subscrSto, Q_DIM(subscrSto)); // init publish-subscribe
|
2012-08-14 18:00:48 -04:00
|
|
|
|
2015-12-31 14:56:37 -05:00
|
|
|
// initialize event pools...
|
|
|
|
QP::QF::poolInit(smlPoolSto,
|
|
|
|
sizeof(smlPoolSto), sizeof(smlPoolSto[0]));
|
2012-08-14 18:00:48 -04:00
|
|
|
|
2015-12-31 14:56:37 -05:00
|
|
|
// start the active objects...
|
2013-10-10 20:01:51 -04:00
|
|
|
for (uint8_t n = 0U; n < N_PHILO; ++n) {
|
|
|
|
AO_Philo[n]->start((uint8_t)(n + 1U),
|
2015-12-31 14:56:37 -05:00
|
|
|
philoQueueSto[n], Q_DIM(philoQueueSto[n]),
|
2013-10-10 20:01:51 -04:00
|
|
|
(void *)0, 0U);
|
2012-08-14 18:00:48 -04:00
|
|
|
}
|
2013-10-10 20:01:51 -04:00
|
|
|
AO_Table->start((uint8_t)(N_PHILO + 1U),
|
2015-12-31 14:56:37 -05:00
|
|
|
tableQueueSto, Q_DIM(tableQueueSto),
|
2013-10-10 20:01:51 -04:00
|
|
|
(void *)0, 0U);
|
2012-08-14 18:00:48 -04:00
|
|
|
|
2015-12-31 14:56:37 -05:00
|
|
|
return QP::QF::run(); // run the QF application
|
2012-08-14 18:00:48 -04:00
|
|
|
}
|
2013-10-10 20:01:51 -04:00
|
|
|
|
|
|
|
} // namespace DPP
|