Example #1
0
/*..........................................................................*/
int main(
#ifdef WIN32
    int argc, char *argv[]
#endif
) {
    uint8_t i;
    for(i = 0; i < N_CLOOP; ++i) {/* Instantiate the control loop active
                                  objects; this is unnecessary in C++, as the
                                  ctor is called even for a static object */
        CLoop_ctor(&l_cloop[i]);
    }

#ifdef WIN32
    BSP_init(argc, argv);           /* initialize the Board Support Package */
#elif defined(__MICROBLAZE__)
    BSP_init();
#endif
    QF_init();     /* initialize the framework and the underlying RT kernel */
    declareQSDictionary();/* TODO: send object dictionaries on (re)connection
                           * with QSpy */
    QF_psInit(l_subscrSto, Q_DIM(l_subscrSto));   /* init publish-subscribe */
                                    /* initialize event pools; NOTE: plural */
    QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));

    for(i = 0; i < N_CLOOP; ++i) {           /* start the active objects... */
        QActive_start((QActive*)&l_cloop[i], i+1   /* lowest AO priority: 1 */
                      , l_cloopQueueSto[i], Q_DIM(l_cloopQueueSto[i])
                      , NULL/* I don't supply stack */, BSP_STACK_SIZE
                      , NULL/* no data to supply to initial transition */);
    }

    return QF_run();                              /* run the QF application */
}
Example #2
0
/*..........................................................................*/
int main() {
    Blinky_ctor();                             /* instantiate the Blinky AO */

    BSP_init();                                     /* initialize the board */

    return QF_run();                         /* transfer control to QF-nano */
}
Example #3
0
/*..........................................................................*/
int main (void) {
    Sensor_ctor();

    BSP_init();                                     /* initialize the board */

    return QF_run();                         /* transfer control to QF-nano */
}
Example #4
0
int main(void) {
	BSP_init();

	for(;;) {
		hw_ctr = EQep1Regs.QPOSCNT;
	}
}
/*..........................................................................*/
int main(void) {
    uint8_t n;

    Philo_ctor();             /* instantiate all Philosopher active objects */
    Table_ctor();                    /* instantiate the Table active object */

    BSP_init();           /* initialize the Board Support Package */

    QF_init();     /* initialize the framework and the underlying RT kernel */

                                                  /* object dictionaries... */
    QS_OBJ_DICTIONARY(l_smlPoolSto);
    QS_OBJ_DICTIONARY(l_tableQueueSto);
    QS_OBJ_DICTIONARY(l_philoQueueSto[0]);
    QS_OBJ_DICTIONARY(l_philoQueueSto[1]);
    QS_OBJ_DICTIONARY(l_philoQueueSto[2]);
    QS_OBJ_DICTIONARY(l_philoQueueSto[3]);
    QS_OBJ_DICTIONARY(l_philoQueueSto[4]);

    //QF_psInit(l_subscrSto, Q_DIM(l_subscrSto));  /* init publish-subscribe */

                                                /* initialize event pools... */
    QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));

    for (n = 0; n < N_PHILO; ++n) {           /* start the active objects... */
        QActive_start(AO_Philo[n], (uint8_t)(n + 1),
                      l_philoQueueSto[n], Q_DIM(l_philoQueueSto[n]),
                      (void *)0, 0, (QEvt *)0);
    }
    QActive_start(AO_Table, (uint8_t)(N_PHILO + 1),
                  l_tableQueueSto, Q_DIM(l_tableQueueSto),
                  (void *)0, 0, (QEvt *)0);

    return QF_run();                              /* run the QF application */
}
Example #6
0
//............................................................................
int main(int argc, char *argv[]) {

    BSP_init(argc, argv);                               // initialize the BSP

    QF::init();       // initialize the framework and the underlying RT kernel

    QF::psInit(l_subscrSto, Q_DIM(l_subscrSto));     // init publish-subscribe

                                                  // initialize event pools...
    QF::poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));

                                                // start the active objects...
    uint8_t n;
    for (n = 0; n < N_PHILO; ++n) {
        AO_Philo[n]->start((uint8_t)(n + 1),
                           l_philoQueueSto[n], Q_DIM(l_philoQueueSto[n]),
                           (void *)0, 0, (QEvent *)0);
    }
    AO_Table->start((uint8_t)(N_PHILO + 1),
                    l_tableQueueSto, Q_DIM(l_tableQueueSto),
                    (void *)0, 0, (QEvent *)0);

    QF::run();                                       // run the QF application

    return 0;
}
Example #7
0
/* the main function -------------------------------------------------------*/
int main(void) {
    QF_init(Q_DIM(QF_active)); /* initialize the QF-nano framework */
    BSP_init(); /* initialize the Board Support Package */

    Blinky_ctor(); /* in C you must explicitly call the Blinky constructor */
    return QF_run(); /* transfer control to QF-nano */
}
Example #8
0
File: hc.c Project: russells/hc2
int main(void)
{
	/**
	 * Reserve this space for recording assertions.  We don't touch this
	 * memory here, and assume that it will be in the same place on every
	 * run, and that it isn't cleared by hardware or by startup code.  If
	 * those are true, then after a reset caused by an assertion, it will
	 * contain the values as filled in by QF_onAssert() at the end of the
	 * previous run (before the reset).
	 *
	 * FIXME: test the assumptions.  Also test hardware reset.
	 */
	struct AssertionBuffer assertion_buffer;
	BSP_set_assertion_buffer(&assertion_buffer);

 startmain:
	BSP_init();
	serial_init();
	SERIALSTR("\r\n\r\n*** Hots and Colds ***\r\n");
	buttons_ctor();
	rtc_ctor();
	lcd_init();
	recorder_ctor();
	ui_ctor();
	SERIALSTR("Let's go...\r\n");
	QF_run();
	goto startmain;

	return 0;
}
Example #9
0
void BSP_ambientalInit(void) {
    BSP_init();
    // Initializes mote API
    XBee_init();
//    // Enable sensor board
    SensorProxy_init();
}
Example #10
0
/*..........................................................................*/
void main (void) {
    TServer_ctor();

    BSP_init();                                     /* initialize the board */

    QF_run();                                /* transfer control to QF-nano */
}
Example #11
0
/*..........................................................................*/
int main(int argc, char *argv[]) {
    UI_ctor();                          /* instantiate the UI Active Object */

    BSP_init(argc, argv);           /* initialize the Board Support Package */

    QF_init();     /* initialize the framework and the underlying RT kernel */

                                           /* initialize the event pools... */
    QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));
//  QF_poolInit(l_medPoolSto, sizeof(l_medPoolSto), sizeof(l_medPoolSto[0]));

    QF_psInit(l_subscrSto, Q_DIM(l_subscrSto));   /* init publish-subscribe */

                                                 /* setup the QS filters... */
                            /* send object dictionaries for event queues... */
    QS_OBJ_DICTIONARY(l_uiQueueSto);

                             /* send object dictionaries for event pools... */
    QS_OBJ_DICTIONARY(l_smlPoolSto);
//    QS_OBJ_DICTIONARY(l_medPoolSto);

               /* send signal dictionaries for globally published events... */
    QS_SIG_DICTIONARY(QUIT_SIG, 0);

                                             /* start the active objects... */
    QActive_start(AO_UI,
                  1,                                            /* priority */
                  l_uiQueueSto, Q_DIM(l_uiQueueSto),           /* evt queue */
                  (void *)0, 0,                      /* no per-thread stack */
                  (QEvt *)0);                  /* no initialization event */

    return QF_run();                              /* run the QF application */
}
Example #12
0
/*..........................................................................*/
int main (void) {
    Pelican_ctor();                          /* instantiate the  Pelican AO */

    BSP_init();                                     /* initialize the board */

    return QF_run();                         /* transfer control to QF-nano */
}
Example #13
0
/*..........................................................................*/
int main (void) {
    Tunnel_ctor();
    Ship_ctor();
    Missile_ctor(GAME_MISSILE_SPEED_X);

    BSP_init();                                     /* initialize the board */

    return QF_run();                         /* transfer control to QF-nano */
}
Example #14
0
int main(int argc, char* argv[]) {
	(void)argc;
	(void)argv;

	BSP_init();
    QF_init();

	return QF_run();
}
Example #15
0
/*..........................................................................*/
int_t main (void) {
    Pelican_ctor();  /* instantiate the  Pelican AO */
    Ped_ctor();      /* instantiate the  Ped     AO */

    QF_init(Q_DIM(QF_active)); /* initialize the QF-nano framework */
    BSP_init();      /* initialize the Board Support Package */

    return QF_run(); /* transfer control to QF-nano */
}
Example #16
0
/*..........................................................................*/
int main() {
    static QEvt const *tableQueueSto[N_PHILO];
    static QEvt const *philoQueueSto[N_PHILO][N_PHILO];
    static QSubscrList subscrSto[MAX_PUB_SIG];
    static QF_MPOOL_EL(TableEvt) smlPoolSto[2*N_PHILO]; /* small pool */
    uint8_t n;

    Philo_ctor(); /* instantiate all Philosopher active objects */
    Table_ctor(); /* instantiate the Table active object */

    QF_init();    /* initialize the framework and the underlying RT kernel */
    BSP_init();   /* initialize the Board Support Package */

    /* object dictionaries... */
    QS_OBJ_DICTIONARY(smlPoolSto);
    QS_OBJ_DICTIONARY(tableQueueSto);
    QS_OBJ_DICTIONARY(philoQueueSto[0]);
    QS_OBJ_DICTIONARY(philoQueueSto[1]);
    QS_OBJ_DICTIONARY(philoQueueSto[2]);
    QS_OBJ_DICTIONARY(philoQueueSto[3]);
    QS_OBJ_DICTIONARY(philoQueueSto[4]);

    /* initialize publish-subscribe... */
    QF_psInit(subscrSto, Q_DIM(subscrSto));

    /* initialize event pools... */
    QF_poolInit(smlPoolSto, sizeof(smlPoolSto), sizeof(smlPoolSto[0]));

    /* start the active objects... */
    for (n = 0U; n < N_PHILO; ++n) {
        QACTIVE_START(AO_Philo[n],           /* AO to start */
                      (uint_fast8_t)(n + 1), /* QP priority of the AO */
                      philoQueueSto[n],      /* event queue storage */
                      Q_DIM(philoQueueSto[n]), /* queue length [events] */
                      (void *)0,             /* stack storage (not used) */
                      0U,                    /* size of the stack (default) */
                     (QEvt *)0);             /* initialization event */
    }

    /* Table AO uses the custom stack size.
    * NOTE: Remember to configure sufficient number of threads with
    * user-provided stack size OS_PRIVCNT in RTX_Conf_CM.c
    */
    QF_setRtxPrio(AO_Table, osPriorityHigh); /* set RTX priority */
    QACTIVE_START(AO_Table,                  /* AO to start */
                  (uint_fast8_t)(N_PHILO + 1), /* QP priority of the AO */
                  tableQueueSto,             /* event queue storage */
                  Q_DIM(tableQueueSto),      /* queue length [events] */
                  (void *)0,                 /* stack storage (not used) */
                  128U*4U,                   /* stack size [bytes] (or 0) */
                  (QEvt *)0);                /* initialization event */

    return QF_run(); /* run the QF application */
}
Example #17
0
/*..........................................................................*/
void main(int argc, char *argv[]) {
                          /* explicitly invoke the active objects' ctors... */
    Missile_ctor();
    Ship_ctor();
    Tunnel_ctor();

    BSP_init(argc, argv);           /* initialize the Board Support Package */

    QF_init();     /* initialize the framework and the underlying RT kernel */

                                           /* initialize the event pools... */
    QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));
    QF_poolInit(l_medPoolSto, sizeof(l_medPoolSto), sizeof(l_medPoolSto[0]));

    QF_psInit(l_subscrSto, Q_DIM(l_subscrSto));   /* init publish-subscribe */

                            /* send object dictionaries for event queues... */
    QS_OBJ_DICTIONARY(l_missileQueueSto);
    QS_OBJ_DICTIONARY(l_shipQueueSto);
    QS_OBJ_DICTIONARY(l_tunnelQueueSto);

                             /* send object dictionaries for event pools... */
    QS_OBJ_DICTIONARY(l_smlPoolSto);
    QS_OBJ_DICTIONARY(l_medPoolSto);

               /* send signal dictionaries for globally published events... */
    QS_SIG_DICTIONARY(TIME_TICK_SIG,      0);
    QS_SIG_DICTIONARY(PLAYER_TRIGGER_SIG, 0);
    QS_SIG_DICTIONARY(PLAYER_QUIT_SIG,    0);
    QS_SIG_DICTIONARY(GAME_OVER_SIG,      0);

                                             /* start the active objects... */
    QActive_start(AO_Missile,
                  1,                                            /* priority */
                  l_missileQueueSto, Q_DIM(l_missileQueueSto), /* evt queue */
                  (void *)0, 0,                      /* no per-thread stack */
                  (QEvent *)0);                  /* no initialization event */
    QActive_start(AO_Ship,
                  2,                                            /* priority */
                  l_shipQueueSto,    Q_DIM(l_shipQueueSto),    /* evt queue */
                  (void *)0, 0,                      /* no per-thread stack */
                  (QEvent *)0);                  /* no initialization event */
    QActive_start(AO_Tunnel,
                  3,                                            /* priority */
                  l_tunnelQueueSto,  Q_DIM(l_tunnelQueueSto),  /* evt queue */
                  (void *)0, 0,                      /* no per-thread stack */
                  (QEvent *)0);                  /* no initialization event */

    QF_run();                                     /* run the QF application */
}
Example #18
0
int main(int argc, char **argv)
{
	uint8_t mcusr;
	char startupmsg[17];

 startmain:
	cli();
	mcusr = MCUSR;
	MCUSR = 0;
	TOGGLE_BEGIN();
	BSP_startmain();	/* Disables the watchdog timer. */
	serial_init();
	serial_send_rom(startup_message);
	serial_drain();
	SERIALSTR("*** Reset reason:");
	if (mcusr & (1 << WDRF)) SERIALSTR(" WD");
	if (mcusr & (1 << BORF)) SERIALSTR(" BO");
	if (mcusr & (1 << EXTRF)) SERIALSTR(" EXT");
	if (mcusr & (1 << PORF)) SERIALSTR(" PO");
	SERIALSTR("\r\n");
	twi_ctor();
	timekeeper_ctor();
	lcd_init();
	// Show the startup reason on the LCD.
	strcpy(startupmsg, "Startup: ----");
	if (mcusr & (1<<3)) startupmsg[9] = 'W';
	if (mcusr & (1<<2)) startupmsg[10] = 'B';
	if (mcusr & (1<<1)) startupmsg[11] = 'X';
	if (mcusr & (1<<0)) startupmsg[12] = 'P';
	lcd_line1(startupmsg);
	_delay_ms(500);
	buttons_ctor();
	alarm_ctor();
	timedisplay_ctor();
	timesetter_ctor();

	/* Drain the serial output just before the watchdog timer is
	   reenabled. */
	serial_drain();
	/* Turn off interrrupts until we have initialised the rest of the
	   hardware, and after QF_run() has properly initialised the active
	   objects.  Interrupts go back on in QF_onStartup() */
	QF_INT_LOCK();
	/* Initialize the BSP.  Enables the watchdog timer. */
	BSP_init();

	QF_run();

	goto startmain;
}
Example #19
0
int main(void)
{
    // JTAG防写死,如果使用JTAG引脚作为GPIO,需要开启功能以便烧写调试
    //JTAG_Wait();

    // 芯片外设初始化
    BSP_init();

    // IPMI主任务开始运行
    ipmi_main_start();

    while(1)
    {
    }
}
Example #20
0
File: main.c Project: KnightSch/qpc
/*..........................................................................*/
int main() {
    static QEvt const *tableQueueSto[N_PHILO];
    static QEvt const *philoQueueSto[N_PHILO][N_PHILO];
    static QSubscrList subscrSto[MAX_PUB_SIG];
    static QF_MPOOL_EL(TableEvt) smlPoolSto[2*N_PHILO]; /* small pool */
    uint8_t n;

    Philo_ctor(); /* instantiate all Philosopher active objects */
    Table_ctor(); /* instantiate the Table active object */

    QF_init();    /* initialize the framework and the underlying RT kernel */
    BSP_init();   /* initialize the Board Support Package */

    /* object dictionaries... */
    QS_OBJ_DICTIONARY(smlPoolSto);
    QS_OBJ_DICTIONARY(tableQueueSto);
    QS_OBJ_DICTIONARY(philoQueueSto[0]);
    QS_OBJ_DICTIONARY(philoQueueSto[1]);
    QS_OBJ_DICTIONARY(philoQueueSto[2]);
    QS_OBJ_DICTIONARY(philoQueueSto[3]);
    QS_OBJ_DICTIONARY(philoQueueSto[4]);

    /* initialize publish-subscribe... */
    QF_psInit(subscrSto, Q_DIM(subscrSto));

    /* initialize event pools... */
    QF_poolInit(smlPoolSto, sizeof(smlPoolSto), sizeof(smlPoolSto[0]));

    /* start the active objects... */
    for (n = 0U; n < N_PHILO; ++n) {
        QACTIVE_START(AO_Philo[n],           /* AO to start */
                      (uint_fast8_t)(n + 1), /* QP priority of the AO */
                      philoQueueSto[n],      /* event queue storage */
                      Q_DIM(philoQueueSto[n]), /* queue length [events] */
                      (void *)0,             /* stack storage (not used) */
                      0U,                    /* size of the stack [bytes] */
                     (QEvt *)0);             /* initialization event */
    }
    QACTIVE_START(AO_Table,                  /* AO to start */
                  (uint_fast8_t)(N_PHILO + 1), /* QP priority of the AO */
                  tableQueueSto,             /* event queue storage */
                  Q_DIM(tableQueueSto),      /* queue length [events] */
                  (void *)0,                 /* stack storage (not used) */
                  0U,                        /* size of the stack [bytes] */
                  (QEvt *)0);                /* initialization event */

    return QF_run(); /* run the QF application */
}
Example #21
0
int main() {
    static QEvt const *blinkyQSto[10]; // Event queue storage for Blinky

    BSP_init(); // initialize the Board Support Package
    QF::init(); // initialize the framework and the underlying RT kernel

    // publish-subscribe not used, no call to QF::psInit()
    // dynamic event allocation not used, no call to QF::poolInit()

    // instantiate and start the active objects...
    AO_Blinky->start(1U,                            // priority
                     blinkyQSto, Q_DIM(blinkyQSto), // event queue
                     (void *)0, 0U);                // stack (unused)

    return QF::run(); // run the QF application
}
Example #22
0
/*..........................................................................*/
int main (void) {
    AlarmClock_ctor();

    printf("Orthogonal Component state pattern\nQP-nano version: %s\n"
           "Press 'o' to turn the Alarm ON\n"
           "Press 'f' to turn the Alarm OFF\n"
           "Press '0'..'9' to set the Alarm time\n"
           "Press 'A' to set the Clock in 12-hour mode\n"
           "Press 'B' to set the Clock in 24-hour mode\n"
           "Press ESC to quit...\n",
           QP_getVersion());


    BSP_init();                                     /* initialize the board */

    return QF_run();                         /* transfer control to QF-nano */
}
Example #23
0
//............................................................................
int main() {

    BSP_init();                        // initialize the Board Support Package

    QF::init();       // initialize the framework and the underlying RT kernel

                                              // initialize the event pools...
    QF::poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));
    QF::poolInit(l_medPoolSto, sizeof(l_medPoolSto), sizeof(l_medPoolSto[0]));

    QF::psInit(l_subscrSto, Q_DIM(l_subscrSto));     // init publish-subscribe

                               // send object dictionaries for event queues...
    QS_OBJ_DICTIONARY(l_missileQueueSto);
    QS_OBJ_DICTIONARY(l_shipQueueSto);
    QS_OBJ_DICTIONARY(l_tunnelQueueSto);

                                // send object dictionaries for event pools...
    QS_OBJ_DICTIONARY(l_smlPoolSto);
    QS_OBJ_DICTIONARY(l_medPoolSto);

                  // send signal dictionaries for globally published events...
    QS_SIG_DICTIONARY(TIME_TICK_SIG,      0);
    QS_SIG_DICTIONARY(PLAYER_TRIGGER_SIG, 0);
    QS_SIG_DICTIONARY(PLAYER_QUIT_SIG,    0);
    QS_SIG_DICTIONARY(GAME_OVER_SIG,      0);

                                                // start the active objects...
    AO_Missile->start(1,                                           // priority
                      l_missileQueueSto, Q_DIM(l_missileQueueSto),// evt queue
                      (void *)0, 0,                     // no per-thread stack
                      (QEvent *)0);                 // no initialization event
    AO_Ship   ->start(2,                                           // priority
                      l_shipQueueSto, Q_DIM(l_shipQueueSto),      // evt queue
                      (void *)0, 0,                     // no per-thread stack
                      (QEvent *)0);                 // no initialization event
    AO_Tunnel ->start(3,                                           // priority
                      l_tunnelQueueSto, Q_DIM(l_tunnelQueueSto),  // evt queue
                      (void *)0, 0,                     // no per-thread stack
                      (QEvent *)0);                 // no initialization event

    QF::run();                                       // run the QF application

    return 0;
}
Example #24
0
int main(void)
{
    Ble_ctor();
    Array_ctor();

    QF_init(Q_DIM(QF_active)); /* initialize the QF-nano framework */
    void BSP_init(); BSP_init(); /* initialize the Board Support Package */

    /* dictionaries... */
    QS_USR_DICTIONARY(TRACE_SDK_EVT);
    QS_USR_DICTIONARY(TRACE_PEER_EVT);
    QS_USR_DICTIONARY(TRACE_ADV_EVT);
    QS_USR_DICTIONARY(TRACE_BLE_EVT);
    QS_USR_DICTIONARY(TRACE_DM_EVT);
    QS_USR_DICTIONARY(TRACE_ANCS_EVT);

    return QF_run(); /* run the QF application */
}
Example #25
0
void setup(void) {
	BSP_init();
	printf("\n\rWelcome to USB-Host-Dock project!\n\r");

#ifdef USE_UHS20
	if (uhs_init() != -1)
		xprintf("\nUsb is initialized.\n");
#else
	USBH_Init(&USB_OTG_Core_dev,
#ifdef USE_USB_OTG_FS
			USB_OTG_FS_CORE_ID,
#else
			USB_OTG_HS_CORE_ID,
#endif
			&USB_Host,
			&HID_cb,
			&USR_Callbacks);

#endif
}
Example #26
0
/*..........................................................................*/
int main() {
    static QEvt const *tableQueueSto[N_PHILO];
    static QEvt const *philoQueueSto[N_PHILO][N_PHILO];
    static QSubscrList subscrSto[MAX_PUB_SIG];
    static QF_MPOOL_EL(TableEvt) smlPoolSto[2*N_PHILO];       /* small pool */
    uint8_t n;

    Philo_ctor();             /* instantiate all Philosopher active objects */
    Table_ctor();                    /* instantiate the Table active object */

    QF_init();     /* initialize the framework and the underlying RT kernel */
    BSP_init();                     /* initialize the Board Support Package */

                                                  /* object dictionaries... */
    QS_OBJ_DICTIONARY(smlPoolSto);
    QS_OBJ_DICTIONARY(tableQueueSto);
    QS_OBJ_DICTIONARY(philoQueueSto[0]);
    QS_OBJ_DICTIONARY(philoQueueSto[1]);
    QS_OBJ_DICTIONARY(philoQueueSto[2]);
    QS_OBJ_DICTIONARY(philoQueueSto[3]);
    QS_OBJ_DICTIONARY(philoQueueSto[4]);

    QF_psInit(subscrSto, Q_DIM(subscrSto));       /* init publish-subscribe */

                                               /* initialize event pools... */
    QF_poolInit(smlPoolSto, sizeof(smlPoolSto), sizeof(smlPoolSto[0]));

    for (n = 0U; n < N_PHILO; ++n) {         /* start the active objects... */
        QACTIVE_START(AO_Philo[n], (uint8_t)(n + 1),
                      philoQueueSto[n], Q_DIM(philoQueueSto[n]),
                      (void *)0, 0U, (QEvt *)0);
    }
    QACTIVE_START(AO_Table, (uint8_t)(N_PHILO + 1),
                  tableQueueSto, Q_DIM(tableQueueSto),
                  (void *)0, 0U, (QEvt *)0);

    return QF_run();                              /* run the QF application */
}
Example #27
0
/*..........................................................................*/
int main(int argc, char *argv[]) {
    printf("Reminder state pattern\nQEP version: %s\nQF  version: %s\n"
           "Press 'e' to echo the current value...\n"
           "Press ESC to quit...\n",
           QEP_getVersion(), QF_getVersion());

    Cruncher_ctor(&l_cruncher);

    BSP_init(argc, argv);                             /* initialize the BSP */

    QF_init();     /* initialize the framework and the underlying RT kernel */

    /* publish-subscribe not used, no call to QF_psInit() */

    QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));

                             /* instantiate and start the active objects... */
    QACTIVE_START((QActive *)&l_cruncher, 1,
                  l_cruncherQSto, Q_DIM(l_cruncherQSto),
                  (void *)0, 1024, (QEvt *)0);

    return QF_run();                              /* run the QF application */
}
Example #28
0
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];

    /* storage for event pools... */
    static QF_MPOOL_EL(TableEvt) l_smlPoolSto[2*N_PHILO]; /* small pool */

    uint8_t n;

    Philo_ctor(); /* instantiate all Philosopher active objects */
    Table_ctor(); /* instantiate the Table active object */

    QF_init();  /* initialize the framework and the underlying RT kernel */
    BSP_init(); /* initialize the BSP */

    /* send object dictionaries for event pools... */
    QS_OBJ_DICTIONARY(l_smlPoolSto);

   /* init publish-subscribe... */
    QF_psInit(l_subscrSto, Q_DIM(l_subscrSto));

    /* initialize event pools... */
    QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));

    /* start the active objects... */
    for (n = 0; n < N_PHILO; ++n) {
        QACTIVE_START(AO_Philo[n], (uint8_t)(n + 1),
                      l_philoQueueSto[n], Q_DIM(l_philoQueueSto[n]),
                      (void *)0, 0U, (QEvt *)0);
    }
    QACTIVE_START(AO_Table, (uint8_t)(N_PHILO + 1),
                  l_tableQueueSto, Q_DIM(l_tableQueueSto),
                  (void *)0, 0U, (QEvt *)0);

    return QF_run(); /* run the QF application, QF_run() does not return  */
}
Example #29
0
/*..........................................................................*/
int main(void) {

	/**初始化BSP*/
	BSP_init();

//	/**载入系统参数,如失败系统停止运行*/
//	if(!Load_Parameters())
//	{
//		//系统参数初始化失败,程序终止
//		return -1;
//	}

	/**初始化QP框架*/
	QF_init();

	/** 初始化事件池,用了小尺寸事件池和中尺寸事件池,未用大尺寸事件池,因为并没有字节数特别多的事件 */
	QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));
	QF_poolInit(l_medPoolSto, sizeof(l_medPoolSto), sizeof(l_medPoolSto[0]));
//	QF_poolInit(l_largePoolSto, sizeof(l_largePoolSto), sizeof(l_largePoolSto[0]));

	/**初始化publish-subscribe缓区*/
	QF_psInit(l_subscrSto, Q_DIM(l_subscrSto));

	/**创建内存池,预分配一个块。只能调用一次*/
	if (MP_Create() < 0) {
		/**内存池创建失败,程序终止*/
		return -1;
	}

#ifdef GPRS
	/**GPRS状态机初始化*/
	QGprs_ctor();

	/**启动GPRS状态机*/
	QActive_start(AO_Gprs, AO_PRIO_GPRS, l_GPRSQueueSto, Q_DIM(l_GPRSQueueSto),
			(void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef GPS
	/**GPS状态机初始化*/
	QGps_ctor();

	/**启动状态机*/
	QActive_start(AO_Gps, AO_PRIO_GPS, l_GPSQueueSto, Q_DIM(l_GPSQueueSto),
			(void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef ACCDET
	/**ACC检测状态机初始化*/
	QACCDetector_ctor();

	/**启动ACC检测状态机*/
	QActive_start(AO_ACCDetector, AO_PRIO_ACCDET, l_ACCQueueSto,
			Q_DIM(l_ACCQueueSto), (void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef CAN
	/**CAN状态机初始化*/
	QCAN_ctor();

	/**启动CAN状态机*/
	QActive_start(AO_Can, AO_PRIO_CAN, l_CANQueueSto, Q_DIM(l_CANQueueSto),
			(void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef LCD
	/**LCD屏状态机初始化 */
	QLCD_ctor();

	/**启动状态机*/
	QActive_start(AO_LCD, AO_PRIO_LCD, l_LCDQueueSto, Q_DIM(l_LCDQueueSto),
			(void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef SENSOR
	/**LCD屏状态机初始化 */
	Q3DSensor_ctor();

	/**启动状态机*/
	QActive_start(AO_3DSensor, AO_PRIO_SENSOR, l_SENSORQueueSto,
			Q_DIM(l_SENSORQueueSto), (void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef VIDEO
	/**摄像头状态机初始化 */
	QVideo_ctor();

	/**启动状态机*/
	QActive_start(AO_Video, AO_PRIO_VIDEO, l_VIDEOQueueSto,
			Q_DIM(l_VIDEOQueueSto), (void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef TTS
	/**TTS状态机初始化 */
	QTTS_ctor();

	/**启动状态机*/
	QActive_start(AO_TTS, AO_PRIO_TTS, l_TTSQueueSto, Q_DIM(l_TTSQueueSto),
			(void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef RECORDER
	/**TTS状态机初始化 */
	QRecorder_ctor();

	/**启动状态机*/
	QActive_start(AO_Recorder, AO_PRIO_RECORDER, l_RECORDQueueSto,
			Q_DIM(l_RECORDQueueSto), (void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef ICCARD
	/**IC卡状态机初始化 */
	QICcard_ctor();

	/**启动状态机*/
	QActive_start(AO_ICCard, AO_PRIO_IC, l_ICCARDQueueSto,
			Q_DIM(l_ICCARDQueueSto), (void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef PRINTER
	/**IC卡状态机初始化 */
	QPrinter_ctor();

	/**启动状态机*/
	QActive_start(AO_Printer, AO_PRIO_PRINTER, l_PRINTERQueueSto,
			Q_DIM(l_PRINTERQueueSto), (void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef IR
	/**IC卡状态机初始化 */
	QIR_ctor();

	/**启动状态机*/
	QActive_start(AO_IR, AO_PRIO_IR, l_IRQueueSto, Q_DIM(l_IRQueueSto),
			(void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef USB
	/**IC卡状态机初始化 */
	QUSB_ctor();

	/**启动状态机*/
	QActive_start(AO_USB, AO_PRIO_USB, l_USBQueueSto, Q_DIM(l_USBQueueSto),
			(void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef AUDIO
	/**IC卡状态机初始化 */
	QAudio_ctor();

	/**启动状态机*/
	QActive_start(AO_Audio, AO_PRIO_AUDIO, l_AUDIOQueueSto,
			Q_DIM(l_AUDIOQueueSto), (void *) 0, 0U, (QEvt *) 0);
#endif

#ifdef UPGRADE
	/**SD卡升级状态机初始化*/
	QUpgrade_ctor();

	/**启动升级状态机*/
	QActive_start(AO_Upgrade, AO_PRIO_UPGRADE, l_UPGRADEQueueSto,
			Q_DIM(l_UPGRADEQueueSto), (void *) 0, 0U, (QEvt *) 0);
#endif

	/**系统时间状态机初始化*/
	QSystick_ctor();

	/**启动系统时钟状态机*/
	QActive_start(AO_Systick, AO_PRIO_SYSTICK, l_SYSTICKQueueSto,
			Q_DIM(l_SYSTICKQueueSto), (void *) 0, 0U, (QEvt *) 0);

	/**载入系统参数,如失败系统停止运行*/
//	if (!Load_Parameters()) {
//		/**系统参数初始化失败,程序终止*/
//		return -1;
//	}

	/**嵌套中断向量初始化*/
	NVIC_Configuration();

	/**启动QP框架,程序开始运行*/
	return QF_run();
}
Example #30
0
/*............................................................................*/
int main(void)
{
   /*!< At this stage the microcontroller clock setting is already configured,
       this is done through SystemInit() function which is called from startup
       files (startup_stm32f40_41xxx.s/startup_stm32f427_437xx.s/
       startup_stm32f429_439xx.s/startup_stm32f401xx.s) before to branch to
       application main. To reconfigure the default setting of SystemInit()
       function, refer to system_stm32f4xx.c file
    */

   /* Enable debugging for select modules - Note: this has no effect in rel
    * builds since all DBG level logging is disabled and only LOG and up msgs
    * will get printed. */
   DBG_setDefaults();

   /* initialize the Board Support Package */
   BSP_init();

   dbg_slow_printf("Initialized BSP\n");
   log_slow_printf("Starting Bootloader version %s built on %s\n", FW_VER, BUILD_DATE);

   /* Instantiate the Active objects by calling their "constructors"         */
   dbg_slow_printf("Initializing AO constructors\n");

   /* Make sure the comm interfaces are up first */
   SerialMgr_ctor();
   LWIPMgr_ctor();

   /* Iterate though the available I2C busses on the system and call the ctor()
    * for each instance of the I2CBusMgr AO for each bus. */
   for( uint8_t i = 0; i < MAX_I2C_BUS; ++i ) {
      I2CBusMgr_ctor( i );      /* Start this instance of AO for this bus. */
   }

   I2C1DevMgr_ctor();
   CommMgr_ctor();
   FlashMgr_ctor();
   SysMgr_ctor();

   dbg_slow_printf("Initializing QF\n");
   QF_init();       /* initialize the framework and the underlying RT kernel */

   /* object dictionaries... */
   dbg_slow_printf("Initializing object dictionaries for QSPY\n");
   QS_OBJ_DICTIONARY(l_smlPoolSto);
   QS_OBJ_DICTIONARY(l_medPoolSto);
   QS_OBJ_DICTIONARY(l_lrgPoolSto);
   QS_OBJ_DICTIONARY(l_SerialMgrQueueSto);
   QS_OBJ_DICTIONARY(l_LWIPMgrQueueSto);
   QS_OBJ_DICTIONARY(l_I2CBusMgrQueueSto);
   QS_OBJ_DICTIONARY(l_I2C1DevMgrQueueSto);
   QS_OBJ_DICTIONARY(l_CommMgrQueueSto);
   QS_OBJ_DICTIONARY(l_FlashMgrQueueSto);
   QS_OBJ_DICTIONARY(l_SysMgrQueueSto);

   QF_psInit(l_subscrSto, Q_DIM(l_subscrSto));     /* init publish-subscribe */

   /* initialize the general memory pool */
   dbg_slow_printf("Initializing general purpose memory pool in CCMRAM\n");
   QMPool_init(
         p_glbMemPool,
         l_memPoolSto,
         sizeof(l_memPoolSto),
         DC3_MAX_MEM_BLK_SIZE
   );

   /* initialize event pools... */
   dbg_slow_printf("Initializing small event storage pool\n");
   QF_poolInit(l_smlPoolSto, sizeof(l_smlPoolSto), sizeof(l_smlPoolSto[0]));
   dbg_slow_printf("Initializing medium event storage pool\n");
   QF_poolInit(l_medPoolSto, sizeof(l_medPoolSto), sizeof(l_medPoolSto[0]));
   dbg_slow_printf("Initializing large event storage pool\n");
   QF_poolInit(l_lrgPoolSto, sizeof(l_lrgPoolSto), sizeof(l_lrgPoolSto[0]));

   /* Start Active objects */
   dbg_slow_printf("Starting Active Objects\n");

   QACTIVE_START(AO_SerialMgr,
         SERIAL_MGR_PRIORITY,                                    /* priority */
         l_SerialMgrQueueSto, Q_DIM(l_SerialMgrQueueSto),       /* evt queue */
         (void *)0, 0,                              /* per-thread stack size */
         (QEvt *)0,                               /* no initialization event */
         "SerialMgr"                                     /* Name of the task */
   );

   QACTIVE_START(AO_LWIPMgr,
         ETH_PRIORITY,                                           /* priority */
         l_LWIPMgrQueueSto, Q_DIM(l_LWIPMgrQueueSto),           /* evt queue */
         (void *)0, 0,                              /* per-thread stack size */
         (QEvt *)0,                               /* no initialization event */
         "LWIPMgr"                                       /* Name of the task */
   );

   /* Iterate though the available I2C busses on the system and start an
    * instance of the I2CBusMgr AO for each bus.
    * WARNING!!!: make sure that the priorities for them are all together since
    * this loop will iterates through them and will take another AO's priority.
    * You will end up with clashing priorities for your AOs.*/
   for( uint8_t i = 0; i < MAX_I2C_BUS; ++i ) {
      QACTIVE_START(AO_I2CBusMgr[i],
            I2CBUS1MGR_PRIORITY + i,                                /* priority */
            l_I2CBusMgrQueueSto[i], Q_DIM(l_I2CBusMgrQueueSto[i]), /* evt queue */
            (void *)0, 0,                              /* per-thread stack size */
            (QEvt *)0,                               /* no initialization event */
            "I2CBusMgr"                                     /* Name of the task */
      );
   }

   QACTIVE_START(AO_I2C1DevMgr,
         I2C1DEVMGR_PRIORITY,                                    /* priority */
         l_I2C1DevMgrQueueSto, Q_DIM(l_I2C1DevMgrQueueSto),     /* evt queue */
         (void *)0, 0,                              /* per-thread stack size */
         (QEvt *)0,                               /* no initialization event */
         "I2CDevMgr"                                     /* Name of the task */
   );

   QACTIVE_START(AO_CommMgr,
         COMM_MGR_PRIORITY,                                      /* priority */
         l_CommMgrQueueSto, Q_DIM(l_CommMgrQueueSto),           /* evt queue */
         (void *)0, 0,                              /* per-thread stack size */
         (QEvt *)0,                               /* no initialization event */
         "CommMgr"                                       /* Name of the task */
   );

   QACTIVE_START(AO_FlashMgr,
         FLASH_MGR_PRIORITY,                                     /* priority */
         l_FlashMgrQueueSto, Q_DIM(l_FlashMgrQueueSto),         /* evt queue */
         (void *)0, 0,                              /* per-thread stack size */
         (QEvt *)0,                               /* no initialization event */
         "FlashMgr"                                      /* Name of the task */
   );

   QACTIVE_START(AO_SysMgr,
         SYS_MGR_PRIORITY,                                       /* priority */
         l_SysMgrQueueSto, Q_DIM(l_SysMgrQueueSto),             /* evt queue */
         (void *)0, 0,                              /* per-thread stack size */
         (QEvt *)0,                               /* no initialization event */
         "SysMgr"                                        /* Name of the task */
   );
   log_slow_printf("Starting QPC. All logging from here on out shouldn't show 'SLOW'!!!\n\n");
   QF_run();                                       /* run the QF application */

   return(0);
}