Deleted
Revision 4:55515daba6d8, committed 2012-09-05
- Comitter:
- QL
- Date:
- Wed Sep 05 16:31:41 2012 +0000
- Parent:
- 3:079273bb29a2
- Commit message:
- Removed code and redirected to qp_dpp.
Changed in this revision
diff -r 079273bb29a2 -r 55515daba6d8 bsp.cpp --- a/bsp.cpp Mon Sep 26 03:27:47 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,272 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// Product: BSP for PELICAN crossing example, QK kernel -// Last Updated for Version: 4.1.06 -// Date of the Last Update: Feb 15, 2011 -// -// Q u a n t u m L e a P s -// --------------------------- -// innovating embedded systems -// -// Copyright (C) 2002-2011 Quantum Leaps, LLC. All rights reserved. -// -// This software may be distributed and modified under the terms of the GNU -// General Public License version 2 (GPL) as published by the Free Software -// Foundation and appearing in the file GPL.TXT included in the packaging of -// this file. Please note that GPL Section 2[b] requires that all works based -// on this software must also be made publicly available under the terms of -// the GPL ("Copyleft"). -// -// Alternatively, this software may be distributed and modified under the -// terms of Quantum Leaps commercial licenses, which expressly supersede -// the GPL and are specifically designed for licensees interested in -// retaining the proprietary status of their code. -// -// Contact information: -// Quantum Leaps Web site: http://www.quantum-leaps.com -// e-mail: info@quantum-leaps.com -////////////////////////////////////////////////////////////////////////////// -#include "qp_port.h" -#include "pelican.h" -#include "bsp.h" -#include "LPC17xx.h" - -Q_DEFINE_THIS_FILE - -// Local-scope objects ------------------------------------------------------- -enum ISR_Priorities { // ISR priorities starting from the highest urgency - GPIOPORTA_PRIO, - SYSTICK_PRIO, - // ... -}; - -#define LED_PORT LPC_GPIO1 -#define LED1_BIT (1U << 18) -#define LED2_BIT (1U << 20) -#define LED3_BIT (1U << 21) -#define LED4_BIT (1U << 23) - -#ifdef Q_SPY - #include "mbed.h" // mbed is used only for the built-in serial - - QSTimeCtr l_tickTime; - QSTimeCtr l_tickPeriod; - static uint8_t l_SysTick_Handler; - - #define QSPY_BAUD_RATE 115200 - - enum AppRecords { // application-specific trace records - PELICAN_STAT = QS_USER - }; - - Serial l_qspy(USBTX, USBRX); -#endif - -//............................................................................ -extern "C" void SysTick_Handler(void) { - QK_ISR_ENTRY(); // inform the QK kernel of entering the ISR - -#ifdef Q_SPY - uint32_t volatile dummy = SysTick->CTRL; // clear the COUNTFLAG in SysTick - l_tickTime += l_tickPeriod; // account for the clock rollover -#endif - - QF::TICK(&l_SysTick_Handler); // process all armed time events - - QK_ISR_EXIT(); // inform the QK kernel of exiting the ISR -} - -//............................................................................ -void BSP_init(void) { - SystemInit(); // initialize the clocking system - - // set LED port to output - LED_PORT->FIODIR |= (LED1_BIT | LED2_BIT | LED3_BIT | LED4_BIT); - - // clear the LEDs - LED_PORT->FIOCLR = (LED1_BIT | LED2_BIT | LED3_BIT | LED4_BIT); - - if (QS_INIT((void *)0) == 0) { // initialize the QS software tracing - Q_ERROR(); - } - QS_OBJ_DICTIONARY(&l_SysTick_Handler); -} -//............................................................................ -void BSP_signalCars(BSP_CarsSignal sig) { - switch (sig) { - case CARS_RED: - LED_PORT->FIOSET = LED1_BIT; // turn the LED1 on - LED_PORT->FIOCLR = LED2_BIT | LED3_BIT; // turn the LED2&3 off - break; - case CARS_YELLOW: - LED_PORT->FIOSET = LED2_BIT; // turn the LED2 on - LED_PORT->FIOCLR = LED1_BIT | LED3_BIT; // turn the LED1&3 off - break; - case CARS_GREEN: - LED_PORT->FIOSET = LED3_BIT; // turn the LED3 on - LED_PORT->FIOCLR = LED1_BIT | LED2_BIT; // turn the LED1&2 off - break; - case CARS_BLANK: - LED_PORT->FIOCLR = LED1_BIT | LED2_BIT | LED3_BIT; //turn all off - break; - } -} -//............................................................................ -void BSP_signalPeds(BSP_PedsSignal sig) { - switch (sig) { - case PEDS_DONT_WALK: - LED_PORT->FIOSET = LED4_BIT; // turn the LED4 on - break; - case PEDS_WALK: - LED_PORT->FIOCLR = LED4_BIT; // turn the LED4 off - break; - case PEDS_BLANK: - LED_PORT->FIOCLR = LED4_BIT; // turn the LED4 off - break; - } -} -//............................................................................ -void BSP_showState(char const *state) { - QS_BEGIN(PELICAN_STAT, AO_Pelican) // application-specific record - QS_STR(state); // state string - QS_END() -} - -//............................................................................ -void QF::onStartup(void) { - // set up the SysTick timer to fire at BSP_TICKS_PER_SEC rate - SysTick_Config(SystemCoreClock / BSP_TICKS_PER_SEC); - - // set priorities of all interrupts in the system... - NVIC_SetPriority(SysTick_IRQn, SYSTICK_PRIO); - NVIC_SetPriority(EINT0_IRQn, GPIOPORTA_PRIO); - - NVIC_EnableIRQ(EINT0_IRQn); -} -//............................................................................ -void QF::onCleanup(void) { -} -//............................................................................ -void QK::onIdle(void) { -#ifdef Q_SPY - if (l_qspy.writeable()) { - QF_INT_LOCK(dummy); - uint16_t b = QS::getByte(); - QF_INT_UNLOCK(dummy); - if (b != QS_EOD) { - l_qspy.putc((uint8_t)b); - } - } -#else - // put the CPU and peripherals to the low-power mode - // you might need to customize the clock management for your application, - // see the datasheet for your particular Cortex-M3 MCU. - __WFI(); -#endif -} - -//............................................................................ -void Q_onAssert(char const Q_ROM * const Q_ROM_VAR file, int line) { - (void)file; // avoid compiler warning - (void)line; // avoid compiler warning - QS_BEGIN_(QS_ASSERT, 0, 0) - QS_TIME_(); // time stamp - QS_U16_((uint16_t)line); // the line number - QS_STR_(file); // the file name - QS_END_() - QS_FLUSH(); - - QF_INT_LOCK(dummy); // make sure that all interrupts are disabled - // light up all LEDs - LED_PORT->FIOSET = (LED1_BIT | LED2_BIT | LED3_BIT | LED4_BIT); - - for (;;) { // NOTE: replace the loop with reset for final version - } -} - -//---------------------------------------------------------------------------- -#ifdef Q_SPY -//............................................................................ -uint8_t QS::onStartup(void const *arg) { - static uint8_t qsBuf[6*256]; // buffer for Quantum Spy - initBuf(qsBuf, sizeof(qsBuf)); - - l_qspy.baud(QSPY_BAUD_RATE); - - l_tickPeriod = SystemCoreClock / BSP_TICKS_PER_SEC; - l_tickTime = l_tickPeriod; // to start the timestamp at zero - - // setup the QS filters... - QS_FILTER_ON(QS_ALL_RECORDS); - -// QS_FILTER_OFF(QS_QEP_STATE_EMPTY); -// QS_FILTER_OFF(QS_QEP_STATE_ENTRY); -// QS_FILTER_OFF(QS_QEP_STATE_EXIT); -// QS_FILTER_OFF(QS_QEP_STATE_INIT); -// QS_FILTER_OFF(QS_QEP_INIT_TRAN); -// QS_FILTER_OFF(QS_QEP_INTERN_TRAN); -// QS_FILTER_OFF(QS_QEP_TRAN); -// QS_FILTER_OFF(QS_QEP_IGNORED); - -// QS_FILTER_OFF(QS_QF_ACTIVE_ADD); -// QS_FILTER_OFF(QS_QF_ACTIVE_REMOVE); -// QS_FILTER_OFF(QS_QF_ACTIVE_SUBSCRIBE); -// QS_FILTER_OFF(QS_QF_ACTIVE_UNSUBSCRIBE); -// QS_FILTER_OFF(QS_QF_ACTIVE_POST_FIFO); -// QS_FILTER_OFF(QS_QF_ACTIVE_POST_LIFO); -// QS_FILTER_OFF(QS_QF_ACTIVE_GET); -// QS_FILTER_OFF(QS_QF_ACTIVE_GET_LAST); -// QS_FILTER_OFF(QS_QF_EQUEUE_INIT); -// QS_FILTER_OFF(QS_QF_EQUEUE_POST_FIFO); -// QS_FILTER_OFF(QS_QF_EQUEUE_POST_LIFO); -// QS_FILTER_OFF(QS_QF_EQUEUE_GET); -// QS_FILTER_OFF(QS_QF_EQUEUE_GET_LAST); -// QS_FILTER_OFF(QS_QF_MPOOL_INIT); -// QS_FILTER_OFF(QS_QF_MPOOL_GET); -// QS_FILTER_OFF(QS_QF_MPOOL_PUT); -// QS_FILTER_OFF(QS_QF_PUBLISH); -// QS_FILTER_OFF(QS_QF_NEW); -// QS_FILTER_OFF(QS_QF_GC_ATTEMPT); -// QS_FILTER_OFF(QS_QF_GC); - QS_FILTER_OFF(QS_QF_TICK); -// QS_FILTER_OFF(QS_QF_TIMEEVT_ARM); -// QS_FILTER_OFF(QS_QF_TIMEEVT_AUTO_DISARM); -// QS_FILTER_OFF(QS_QF_TIMEEVT_DISARM_ATTEMPT); -// QS_FILTER_OFF(QS_QF_TIMEEVT_DISARM); -// QS_FILTER_OFF(QS_QF_TIMEEVT_REARM); -// QS_FILTER_OFF(QS_QF_TIMEEVT_POST); - QS_FILTER_OFF(QS_QF_INT_LOCK); - QS_FILTER_OFF(QS_QF_INT_UNLOCK); - QS_FILTER_OFF(QS_QF_ISR_ENTRY); - QS_FILTER_OFF(QS_QF_ISR_EXIT); - -// QS_FILTER_OFF(QS_QK_MUTEX_LOCK); -// QS_FILTER_OFF(QS_QK_MUTEX_UNLOCK); -// QS_FILTER_OFF(QS_QK_SCHEDULE); - - return (uint8_t)1; // return success -} -//............................................................................ -void QS::onCleanup(void) { -} -//............................................................................ -QSTimeCtr QS::onGetTime(void) { // invoked with interrupts locked - if ((SysTick->CTRL & 0x00000100) == 0) { // COUNTFLAG no set? - return l_tickTime - (QSTimeCtr)SysTick->VAL; - } - else { // the rollover occured, but the SysTick_ISR did not run yet - return l_tickTime + l_tickPeriod - (QSTimeCtr)SysTick->VAL; - } -} -//............................................................................ -void QS::onFlush(void) { - uint16_t b; - QF_INT_LOCK(dummy); - while ((b = QS::getByte()) != QS_EOD) { - while (!l_qspy.writeable()) { // wait until serial port is writable - } - l_qspy.putc((uint8_t)b); - } - QF_INT_UNLOCK(dummy); -} -#endif // Q_SPY -//----------------------------------------------------------------------------
diff -r 079273bb29a2 -r 55515daba6d8 bsp.h --- a/bsp.h Mon Sep 26 03:27:47 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// Product: DPP example, Board Support Package -// Last Updated for Version: 4.1.06 -// Date of the Last Update: Feb 15, 2011 -// -// Q u a n t u m L e a P s -// --------------------------- -// innovating embedded systems -// -// Copyright (C) 2002-2011 Quantum Leaps, LLC. All rights reserved. -// -// This software may be distributed and modified under the terms of the GNU -// General Public License version 2 (GPL) as published by the Free Software -// Foundation and appearing in the file GPL.TXT included in the packaging of -// this file. Please note that GPL Section 2[b] requires that all works based -// on this software must also be made publicly available under the terms of -// the GPL ("Copyleft"). -// -// Alternatively, this software may be distributed and modified under the -// terms of Quantum Leaps commercial licenses, which expressly supersede -// the GPL and are specifically designed for licensees interested in -// retaining the proprietary status of their code. -// -// Contact information: -// Quantum Leaps Web site: http://www.quantum-leaps.com -// e-mail: info@quantum-leaps.com -////////////////////////////////////////////////////////////////////////////// -#ifndef bsp_h -#define bsp_h - // System clock tick rate [Hz] -#define BSP_TICKS_PER_SEC 100 - -enum BSP_CarsSignal { - CARS_RED, CARS_YELLOW, CARS_GREEN, CARS_BLANK -}; - -enum BSP_PedsSignal { - PEDS_DONT_WALK, PEDS_WALK, PEDS_BLANK -}; - -void BSP_init(void); -void BSP_signalCars(BSP_CarsSignal sig); -void BSP_signalPeds(BSP_PedsSignal sig); -void BSP_showState(char const *state); - -#endif // bsp_h - -
diff -r 079273bb29a2 -r 55515daba6d8 main.cpp --- a/main.cpp Mon Sep 26 03:27:47 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// Product: PELICAN crossing example -// Last Updated for Version: 4.2.04 -// Date of the Last Update: Sep 25, 2011 -// -// Q u a n t u m L e a P s -// --------------------------- -// innovating embedded systems -// -// Copyright (C) 2002-2011 Quantum Leaps, LLC. All rights reserved. -// -// This software may be distributed and modified under the terms of the GNU -// General Public License version 2 (GPL) as published by the Free Software -// Foundation and appearing in the file GPL.TXT included in the packaging of -// this file. Please note that GPL Section 2[b] requires that all works based -// on this software must also be made publicly available under the terms of -// the GPL ("Copyleft"). -// -// Alternatively, this software may be distributed and modified under the -// terms of Quantum Leaps commercial licenses, which expressly supersede -// the GPL and are specifically designed for licensees interested in -// retaining the proprietary status of their code. -// -// Contact information: -// Quantum Leaps Web site: http://www.quantum-leaps.com -// e-mail: info@quantum-leaps.com -////////////////////////////////////////////////////////////////////////////// -#include "qp_port.h" -#include "pelican.h" -#include "bsp.h" - -// Local-scope objects ------------------------------------------------------- -static QEvent const *l_pelicanQueueSto[5]; -static QEvent const *l_pedQueueSto[5]; -static QSubscrList l_subscrSto[MAX_PUB_SIG]; -static union { - void *m0; - QEvent m1; -} l_smlPoolSto[10]; // storage for the small event pool - -//............................................................................ -int main(void) { - BSP_init(); // initialize the BSP - QF::init(); // initialize the framework and the underlying RT kernel - // object dictionaries... - QS_OBJ_DICTIONARY(l_smlPoolSto); - QS_OBJ_DICTIONARY(l_pelicanQueueSto); - QS_OBJ_DICTIONARY(l_pedQueueSto); - - 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... - AO_Pelican->start(1, l_pelicanQueueSto, Q_DIM(l_pelicanQueueSto), 0, 0); - AO_Ped ->start(2, l_pedQueueSto, Q_DIM(l_pedQueueSto), 0, 0); - - QF::run(); // run the QF application - - return 0; -}
diff -r 079273bb29a2 -r 55515daba6d8 mbed.bld --- a/mbed.bld Mon Sep 26 03:27:47 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912
diff -r 079273bb29a2 -r 55515daba6d8 note.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/note.h Wed Sep 05 16:31:41 2012 +0000 @@ -0,0 +1,7 @@ +// This program is no longer up to date with the current version of the +// QP library and is no longer supported. +// +// Please refer to the program qp_dpp for the supported version, which +// includes the QM model and automatically generated code. +// +// QL 05-Sep-2012 \ No newline at end of file
diff -r 079273bb29a2 -r 55515daba6d8 ped.cpp --- a/ped.cpp Mon Sep 26 03:27:47 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// Product: PELICAN crossing example -// Last Updated for Version: 4.2.04 -// Date of the Last Update: Sep 25, 2011 -// -// Q u a n t u m L e a P s -// --------------------------- -// innovating embedded systems -// -// Copyright (C) 2002-2011 Quantum Leaps, LLC. All rights reserved. -// -// This software may be distributed and modified under the terms of the GNU -// General Public License version 2 (GPL) as published by the Free Software -// Foundation and appearing in the file GPL.TXT included in the packaging of -// this file. Please note that GPL Section 2[b] requires that all works based -// on this software must also be made publicly available under the terms of -// the GPL ("Copyleft"). -// -// Alternatively, this software may be distributed and modified under the -// terms of Quantum Leaps commercial licenses, which expressly supersede -// the GPL and are specifically designed for licensees interested in -// retaining the proprietary status of their code. -// -// Contact information: -// Quantum Leaps Web site: http://www.quantum-leaps.com -// e-mail: info@quantum-leaps.com -////////////////////////////////////////////////////////////////////////////// -#include "qp_port.h" -#include "bsp.h" -#include "pelican.h" - -Q_DEFINE_THIS_FILE - -// Ped (Pedestrian) class ---------------------------------------------------- -class Ped : public QActive { // derived from QActive */ - QTimeEvt m_timeout; // time event to generate timeouts - uint8_t m_retryCtr; - -public: - Ped(); - -private: - static QState initial(Ped *me, QEvent const *e); - static QState wait (Ped *me, QEvent const *e); - static QState off (Ped *me, QEvent const *e); -}; - -enum PedTimeouts { // various timeouts in ticks - N_ATTEMPTS = 10, // number of PED_WAITING attempts - WAIT_TOUT = BSP_TICKS_PER_SEC * 3, // wait between posting PED_WAITING - OFF_TOUT = BSP_TICKS_PER_SEC * 8 // wait time after posting OFF_SIG -}; - -// Local objects ------------------------------------------------------------- -static Ped l_Ped; // the single instance of Ped active object - -// Global objects ------------------------------------------------------------ -QActive * const AO_Ped = &l_Ped; // the opaque pointer - -//............................................................................ -Ped::Ped() - : QActive((QStateHandler)&Ped::initial), - m_timeout(TIMEOUT_SIG) -{} - -// HSM definition ------------------------------------------------------------ -QState Ped::initial(Ped *me, QEvent const *) { - QS_OBJ_DICTIONARY(&l_Ped); - QS_OBJ_DICTIONARY(&l_Ped.m_timeout); - - QS_FUN_DICTIONARY(&Ped::initial); - QS_FUN_DICTIONARY(&Ped::wait); - QS_FUN_DICTIONARY(&Ped::off); - - QS_SIG_DICTIONARY(TIMEOUT_SIG, &l_Ped); // just for Ped - - return Q_TRAN(&Ped::wait); -} -//............................................................................ -QState Ped::wait(Ped *me, QEvent const *e) { - switch (e->sig) { - case Q_ENTRY_SIG: { - me->m_retryCtr = N_ATTEMPTS; - me->m_timeout.postEvery(me, WAIT_TOUT); - return Q_HANDLED(); - } - case Q_EXIT_SIG: { - me->m_timeout.disarm(); - return Q_HANDLED(); - } - case TIMEOUT_SIG: { - if ((--me->m_retryCtr) != 0) { - QF::PUBLISH(Q_NEW(QEvent, PEDS_WAITING_SIG), me); - } - else { - return Q_TRAN(&Ped::off); - } - return Q_HANDLED(); - } - } - return Q_SUPER(&QHsm::top); -} -//............................................................................ -QState Ped::off(Ped *me, QEvent const *e) { - switch (e->sig) { - case Q_ENTRY_SIG: { - me->m_timeout.postEvery(me, OFF_TOUT); - AO_Pelican->POST(Q_NEW(QEvent, OFF_SIG), me); - return Q_HANDLED(); - } - case Q_EXIT_SIG: { - me->m_timeout.disarm(); - return Q_HANDLED(); - } - case TIMEOUT_SIG: { - AO_Pelican->POST(Q_NEW(QEvent, ON_SIG), me); - return Q_TRAN(&Ped::wait); - } - } - return Q_SUPER(&QHsm::top); -}
diff -r 079273bb29a2 -r 55515daba6d8 pelican.cpp --- a/pelican.cpp Mon Sep 26 03:27:47 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,316 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// Product: PELICAN crossing example -// Last Updated for Version: 4.1.06 -// Date of the Last Update: Jan 04, 2011 -// -// Q u a n t u m L e a P s -// --------------------------- -// innovating embedded systems -// -// Copyright (C) 2002-2011 Quantum Leaps, LLC. All rights reserved. -// -// This software may be distributed and modified under the terms of the GNU -// General Public License version 2 (GPL) as published by the Free Software -// Foundation and appearing in the file GPL.TXT included in the packaging of -// this file. Please note that GPL Section 2[b] requires that all works based -// on this software must also be made publicly available under the terms of -// the GPL ("Copyleft"). -// -// Alternatively, this software may be distributed and modified under the -// terms of Quantum Leaps commercial licenses, which expressly supersede -// the GPL and are specifically designed for licensees interested in -// retaining the proprietary status of their code. -// -// Contact information: -// Quantum Leaps Web site: http://www.quantum-leaps.com -// e-mail: info@quantum-leaps.com -////////////////////////////////////////////////////////////////////////////// -#include "qp_port.h" -#include "bsp.h" -#include "pelican.h" - -Q_DEFINE_THIS_FILE - -// Pelican class ------------------------------------------------------------- -class Pelican : public QActive { // derived from QActive - QTimeEvt m_timeout; // time event to generate timeouts - uint8_t m_flashCtr; // pedestrian flash counter - -public: - Pelican(); - -private: - static QState initial (Pelican *me, QEvent const *e); - static QState offline (Pelican *me, QEvent const *e); - static QState operational (Pelican *me, QEvent const *e); - static QState carsEnabled (Pelican *me, QEvent const *e); - static QState carsGreen (Pelican *me, QEvent const *e); - static QState carsGreenNoPed (Pelican *me, QEvent const *e); - static QState carsGreenPedWait(Pelican *me, QEvent const *e); - static QState carsGreenInt (Pelican *me, QEvent const *e); - static QState carsYellow (Pelican *me, QEvent const *e); - static QState pedsEnabled (Pelican *me, QEvent const *e); - static QState pedsWalk (Pelican *me, QEvent const *e); - static QState pedsFlash (Pelican *me, QEvent const *e); -}; - -enum PelicanTimeouts { // various timeouts in ticks - CARS_GREEN_MIN_TOUT = BSP_TICKS_PER_SEC * 8, // min green for cars - CARS_YELLOW_TOUT = BSP_TICKS_PER_SEC * 3, // yellow for cars - PEDS_WALK_TOUT = BSP_TICKS_PER_SEC * 3, // walking time for peds - PEDS_FLASH_TOUT = BSP_TICKS_PER_SEC / 5, // flashing timeout for peds - PEDS_FLASH_NUM = 5*2, // number of flashes for peds - OFF_FLASH_TOUT = BSP_TICKS_PER_SEC / 2 // flashing timeout when off -}; - -// Local objects ------------------------------------------------------------- -static Pelican l_Pelican; // the single instance of Pelican active object - -// Global objects ------------------------------------------------------------ -QActive * const AO_Pelican = &l_Pelican; // the opaque pointer - -//............................................................................ -Pelican::Pelican() - : QActive((QStateHandler)&Pelican::initial), - m_timeout(TIMEOUT_SIG) -{} - -// HSM definition ------------------------------------------------------------ -QState Pelican::initial(Pelican *me, QEvent const *e) { - me->subscribe(PEDS_WAITING_SIG); - - QS_OBJ_DICTIONARY(&l_Pelican); - QS_OBJ_DICTIONARY(&l_Pelican.m_timeout); - - QS_FUN_DICTIONARY(&QHsm::top); - QS_FUN_DICTIONARY(&Pelican::initial); - QS_FUN_DICTIONARY(&Pelican::offline); - QS_FUN_DICTIONARY(&Pelican::operational); - QS_FUN_DICTIONARY(&Pelican::carsEnabled); - QS_FUN_DICTIONARY(&Pelican::carsGreen); - QS_FUN_DICTIONARY(&Pelican::carsGreenNoPed); - QS_FUN_DICTIONARY(&Pelican::carsGreenPedWait); - QS_FUN_DICTIONARY(&Pelican::carsGreenInt); - QS_FUN_DICTIONARY(&Pelican::carsYellow); - QS_FUN_DICTIONARY(&Pelican::pedsEnabled); - QS_FUN_DICTIONARY(&Pelican::pedsWalk); - QS_FUN_DICTIONARY(&Pelican::pedsFlash); - - QS_SIG_DICTIONARY(PEDS_WAITING_SIG, 0); // global signals - QS_SIG_DICTIONARY(ON_SIG, 0); - QS_SIG_DICTIONARY(OFF_SIG, 0); - - QS_SIG_DICTIONARY(TIMEOUT_SIG, &l_Pelican); // just for Peican - - return Q_TRAN(&Pelican::operational); -} -//............................................................................ -QState Pelican::operational(Pelican *me, QEvent const *e) { - switch (e->sig) { - case Q_ENTRY_SIG: { - BSP_signalCars(CARS_RED); - BSP_signalPeds(PEDS_DONT_WALK); - return Q_HANDLED(); - } - case Q_INIT_SIG: { - return Q_TRAN(&Pelican::carsEnabled); - } - case OFF_SIG: { - return Q_TRAN(&Pelican::offline); - } - // uncomment this case to test assertion failure... - /* - case ON_SIG: { - Q_ERROR(); - return Q_HANDLED(); - } - */ - } - return Q_SUPER(&QHsm::top); -} -//............................................................................ -QState Pelican::carsEnabled(Pelican *me, QEvent const *e) { - switch (e->sig) { - case Q_EXIT_SIG: { - BSP_signalCars(CARS_RED); - return Q_HANDLED(); - } - case Q_INIT_SIG: { - return Q_TRAN(&Pelican::carsGreen); - } - } - return Q_SUPER(&Pelican::operational); -} -//............................................................................ -QState Pelican::carsGreen(Pelican *me, QEvent const *e) { - switch (e->sig) { - case Q_ENTRY_SIG: { - BSP_signalCars(CARS_GREEN); - me->m_timeout.postIn(me, CARS_GREEN_MIN_TOUT); - return Q_HANDLED(); - } - case Q_EXIT_SIG: { - me->m_timeout.disarm(); - return Q_HANDLED(); - } - case Q_INIT_SIG: { - return Q_TRAN(&Pelican::carsGreenNoPed); - } - } - return Q_SUPER(&Pelican::carsEnabled); -} -//............................................................................ -QState Pelican::carsGreenNoPed(Pelican *me, QEvent const *e) { - switch (e->sig) { - case Q_ENTRY_SIG: { - BSP_showState("carsGreenNoPed"); - return Q_HANDLED(); - } - case PEDS_WAITING_SIG: { - return Q_TRAN(&Pelican::carsGreenPedWait); - } - case TIMEOUT_SIG: { - return Q_TRAN(&Pelican::carsGreenInt); - } - } - return Q_SUPER(&Pelican::carsGreen); -} -//............................................................................ -QState Pelican::carsGreenPedWait(Pelican *me, QEvent const *e) { - switch (e->sig) { - case Q_ENTRY_SIG: { - BSP_showState("carsGreenPedWait"); - return Q_HANDLED(); - } - case TIMEOUT_SIG: { - return Q_TRAN(&Pelican::carsYellow); - } - } - return Q_SUPER(&Pelican::carsGreen); -} -//............................................................................ -QState Pelican::carsGreenInt(Pelican *me, QEvent const *e) { - switch (e->sig) { - case Q_ENTRY_SIG: { - BSP_showState("carsGreenInt"); - return Q_HANDLED(); - } - case PEDS_WAITING_SIG: { - return Q_TRAN(&Pelican::carsYellow); - } - } - return Q_SUPER(&Pelican::carsGreen); -} -//............................................................................ -QState Pelican::carsYellow(Pelican *me, QEvent const *e) { - switch (e->sig) { - case Q_ENTRY_SIG: { - BSP_showState("carsYellow"); - BSP_signalCars(CARS_YELLOW); - me->m_timeout.postIn(me, CARS_YELLOW_TOUT); - return Q_HANDLED(); - } - case Q_EXIT_SIG: { - me->m_timeout.disarm(); - return Q_HANDLED(); - } - case TIMEOUT_SIG: { - return Q_TRAN(&Pelican::pedsEnabled); - } - } - return Q_SUPER(&Pelican::carsEnabled); -} -//............................................................................ -QState Pelican::pedsEnabled(Pelican *me, QEvent const *e) { - switch (e->sig) { - case Q_EXIT_SIG: { - BSP_signalPeds(PEDS_DONT_WALK); - return Q_HANDLED(); - } - case Q_INIT_SIG: { - return Q_TRAN(&Pelican::pedsWalk); - } - } - return Q_SUPER(&Pelican::operational); -} -//............................................................................ -QState Pelican::pedsWalk(Pelican *me, QEvent const *e) { - switch (e->sig) { - case Q_ENTRY_SIG: { - BSP_showState("pedsWalk"); - BSP_signalPeds(PEDS_WALK); - me->m_timeout.postIn(me, PEDS_WALK_TOUT); - return Q_HANDLED(); - } - case Q_EXIT_SIG: { - me->m_timeout.disarm(); - return Q_HANDLED(); - } - case TIMEOUT_SIG: { - return Q_TRAN(&Pelican::pedsFlash); - } - } - return Q_SUPER(&Pelican::pedsEnabled); -} -//............................................................................ -QState Pelican::pedsFlash(Pelican *me, QEvent const *e) { - switch (e->sig) { - case Q_ENTRY_SIG: { - BSP_showState("pedsWalk"); - me->m_timeout.postEvery(me, PEDS_FLASH_TOUT); - me->m_flashCtr = PEDS_FLASH_NUM*2 + 1; - return Q_HANDLED(); - } - case Q_EXIT_SIG: { - me->m_timeout.disarm(); - return Q_HANDLED(); - } - case TIMEOUT_SIG: { - if (me->m_flashCtr != 0) { // still flashing? - if ((me->m_flashCtr & 1) == 0) { // even counter? - BSP_signalPeds(PEDS_DONT_WALK); - } - else { // must be odd counter - BSP_signalPeds(PEDS_BLANK); - } - --me->m_flashCtr; - } - else { // done flashing - return Q_TRAN(&Pelican::carsEnabled); - } - return Q_HANDLED(); - } - } - return Q_SUPER(&Pelican::pedsEnabled); -} -//............................................................................ -QState Pelican::offline(Pelican *me, QEvent const *e) { - switch (e->sig) { - case Q_ENTRY_SIG: { - BSP_showState("offline"); - me->m_timeout.postEvery(me, OFF_FLASH_TOUT); - me->m_flashCtr = 0; - return Q_HANDLED(); - } - case Q_EXIT_SIG: { - me->m_timeout.disarm(); - return Q_HANDLED(); - } - case TIMEOUT_SIG: { - if ((me->m_flashCtr & 1) == 0) { // even counter? - BSP_signalCars(CARS_RED); - BSP_signalPeds(PEDS_DONT_WALK); - } - else { - BSP_signalCars(CARS_BLANK); - BSP_signalPeds(PEDS_BLANK); - } - me->m_flashCtr ^= 1; // toggle the flash counter - return Q_HANDLED(); - } - case ON_SIG: { - return Q_TRAN(&Pelican::operational); - } - } - return Q_SUPER(&QHsm::top); -}
diff -r 079273bb29a2 -r 55515daba6d8 pelican.h --- a/pelican.h Mon Sep 26 03:27:47 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,44 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// Product: PELICAN crossing example -// Last Updated for Version: 4.1.06 -// Date of the Last Update: Feb 15, 2011 -// -// Q u a n t u m L e a P s -// --------------------------- -// innovating embedded systems -// -// Copyright (C) 2002-2011 Quantum Leaps, LLC. All rights reserved. -// -// This software may be distributed and modified under the terms of the GNU -// General Public License version 2 (GPL) as published by the Free Software -// Foundation and appearing in the file GPL.TXT included in the packaging of -// this file. Please note that GPL Section 2[b] requires that all works based -// on this software must also be made publicly available under the terms of -// the GPL ("Copyleft"). -// -// Alternatively, this software may be distributed and modified under the -// terms of Quantum Leaps commercial licenses, which expressly supersede -// the GPL and are specifically designed for licensees interested in -// retaining the proprietary status of their code. -// -// Contact information: -// Quantum Leaps Web site: http://www.quantum-leaps.com -// e-mail: info@quantum-leaps.com -////////////////////////////////////////////////////////////////////////////// -#ifndef pelican_h -#define pelican_h - -enum PelicanSignals { - PEDS_WAITING_SIG = Q_USER_SIG, - MAX_PUB_SIG, // the last published signal - - ON_SIG, - OFF_SIG, - TIMEOUT_SIG, -}; - -// active objects ............................................................ -extern QActive * const AO_Pelican; // "opaque" pointer to Pelican AO -extern QActive * const AO_Ped; // "opaque" pointer to Ped AO - -#endif // pelican_h
diff -r 079273bb29a2 -r 55515daba6d8 qp.lib --- a/qp.lib Mon Sep 26 03:27:47 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/QL/code/qp/#934bb9eea80b
diff -r 079273bb29a2 -r 55515daba6d8 qp_config.h --- a/qp_config.h Mon Sep 26 03:27:47 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,48 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// Product: QP-mbed configuration file -// Last Updated for Version: 4.2.04 -// Date of the Last Update: Sep 25, 2011 -// -// Q u a n t u m L e a P s -// --------------------------- -// innovating embedded systems -// -// Copyright (C) 2002-2011 Quantum Leaps, LLC. All rights reserved. -// -// This software may be distributed and modified under the terms of the GNU -// General Public License version 2 (GPL) as published by the Free Software -// Foundation and appearing in the file GPL.TXT included in the packaging of -// this file. Please note that GPL Section 2[b] requires that all works based -// on this software must also be made publicly available under the terms of -// the GPL ("Copyleft"). -// -// Alternatively, this software may be distributed and modified under the -// terms of Quantum Leaps commercial licenses, which expressly supersede -// the GPL and are specifically designed for licensees interested in -// retaining the proprietary status of their code. -// -// Contact information: -// Quantum Leaps Web site: http://www.quantum-leaps.com -// e-mail: info@quantum-leaps.com -////////////////////////////////////////////////////////////////////////////// -#ifndef qp_config_h -#define qp_config_h - -// enable the Q-SPY software tracing instrumentation -#define Q_SPY - -// enable preemptive QK kernel (cooperative kernel is used when not defined) -#define QK_PREEMPTIVE - -// The maximum number of active objects in the application (could be up to 63) -#define QF_MAX_ACTIVE 16 - -// Uncomment the following macros only if you want to change the given default -//#define Q_SIGNAL_SIZE 1 -//#define QF_EVENT_SIZ_SIZE 2 -//#define QF_EQUEUE_CTR_SIZE 1 -//#define QF_MPOOL_SIZ_SIZE 2 -//#define QF_MPOOL_CTR_SIZE 2 -//#define QF_TIMEEVT_CTR_SIZE 2 - -#endif // qp_config_h