Simple "Blinky" example for the QP active object framework
Fork of qp_dpp by
Revision 3:81ceb3127876, committed 2011-09-26
- Comitter:
- QL
- Date:
- Mon Sep 26 02:21:01 2011 +0000
- Parent:
- 2:2e62e514f323
- Child:
- 4:6189d844a1a2
- Commit message:
- Updated for QP 4.2.04
Changed in this revision
--- a/bsp.cpp Wed Feb 16 17:12:38 2011 +0000 +++ b/bsp.cpp Mon Sep 26 02:21:01 2011 +0000 @@ -1,7 +1,7 @@ ////////////////////////////////////////////////////////////////////////////// // Product: BSP for "Dining Philosophers Problem" example, QK kernel -// Last Updated for Version: 4.1.06 -// Date of the Last Update: Feb 16, 2011 +// 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 // --------------------------- @@ -50,6 +50,7 @@ QSTimeCtr l_tickTime; QSTimeCtr l_tickPeriod; + static uint8_t l_SysTick_Handler; #define QSPY_BAUD_RATE 115200 @@ -69,7 +70,7 @@ l_tickTime += l_tickPeriod; // account for the clock rollover #endif - QF::tick(); // process all armed time events + QF::TICK(&l_SysTick_Handler); // process all armed time events QK_ISR_EXIT(); // inform the QK kernel of exiting the ISR } @@ -87,6 +88,7 @@ if (QS_INIT((void *)0) == 0) { // initialize the QS software tracing Q_ERROR(); } + QS_OBJ_DICTIONARY(&l_SysTick_Handler); } //............................................................................ void BSP_displyPhilStat(uint8_t n, char const *stat) {
--- a/main.cpp Wed Feb 16 17:12:38 2011 +0000 +++ b/main.cpp Mon Sep 26 02:21:01 2011 +0000 @@ -1,13 +1,13 @@ ////////////////////////////////////////////////////////////////////////////// // Product: DPP example -// Last Updated for Version: 4.0.00 -// Date of the Last Update: May 28, 2008 +// Last Updated for Version: 4.2.00 +// Date of the Last Update: Jul 23, 2011 // // Q u a n t u m L e a P s // --------------------------- // innovating embedded systems // -// Copyright (C) 2002-2008 Quantum Leaps, LLC. All rights reserved. +// 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 @@ -35,15 +35,18 @@ static QSubscrList l_subscrSto[MAX_PUB_SIG]; static union SmallEvents { - void *min_size; - TableEvt te; - // other event types to go into this pool + void *e0; // minimum event size + uint8_t e1[sizeof(TableEvt)]; + // ... other event types to go into this pool } l_smlPoolSto[2*N_PHILO]; // storage for the small event pool //............................................................................ -int main(void) { +int main() { + 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_tableQueueSto); @@ -54,6 +57,7 @@ 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])); @@ -72,4 +76,3 @@ return 0; } -
--- a/philo.cpp Wed Feb 16 17:12:38 2011 +0000 +++ b/philo.cpp Mon Sep 26 02:21:01 2011 +0000 @@ -1,13 +1,13 @@ ////////////////////////////////////////////////////////////////////////////// // Product: DPP example -// Last Updated for Version: 4.0.00 -// Date of the Last Update: Apr 06, 2008 +// Last Updated for Version: 4.2.00 +// Date of the Last Update: Jul 15, 2011 // // Q u a n t u m L e a P s // --------------------------- // innovating embedded systems // -// Copyright (C) 2002-2008 Quantum Leaps, LLC. All rights reserved. +// 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 @@ -49,8 +49,9 @@ // Local objects ------------------------------------------------------------- static Philo l_philo[N_PHILO]; // storage for all Philos -#define THINK_TIME 23 -#define EAT_TIME 19 +#define THINK_TIME (BSP_TICKS_PER_SEC/2) +#define EAT_TIME (BSP_TICKS_PER_SEC/5) + // helper macro to provide the ID of Philo "me_" #define PHILO_ID(me_) ((uint8_t)((me_) - l_philo)) @@ -108,7 +109,6 @@ return Q_HANDLED(); } case TIMEOUT_SIG: { - BSP_busyDelay(); return Q_TRAN(&Philo::hungry); } case EAT_SIG: // intentionally fall-through @@ -126,12 +126,11 @@ case Q_ENTRY_SIG: { TableEvt *pe = Q_NEW(TableEvt, HUNGRY_SIG); pe->philoNum = PHILO_ID(me); - AO_Table->postFIFO(pe); + AO_Table->POST(pe, me); return Q_HANDLED(); } case EAT_SIG: { if (((TableEvt *)e)->philoNum == PHILO_ID(me)) { - BSP_busyDelay(); return Q_TRAN(&Philo::eating); } break; @@ -154,11 +153,10 @@ case Q_EXIT_SIG: { TableEvt *pe = Q_NEW(TableEvt, DONE_SIG); pe->philoNum = PHILO_ID(me); - QF::publish(pe); + QF::PUBLISH(pe, me); return Q_HANDLED(); } case TIMEOUT_SIG: { - BSP_busyDelay(); return Q_TRAN(&Philo::thinking); } case EAT_SIG: // intentionally fall-through @@ -170,4 +168,3 @@ } return Q_SUPER(&QHsm::top); } -
--- a/qp.lib Wed Feb 16 17:12:38 2011 +0000 +++ b/qp.lib Mon Sep 26 02:21:01 2011 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/QL/code/qp/#5c8be45330ab +http://mbed.org/users/QL/code/qp/#bf92d3a6625e
--- a/qp_config.h Wed Feb 16 17:12:38 2011 +0000 +++ b/qp_config.h Mon Sep 26 02:21:01 2011 +0000 @@ -1,7 +1,7 @@ ////////////////////////////////////////////////////////////////////////////// // Product: QP-mbed configuration file -// Last Updated for Version: 4.1.06 -// Date of the Last Update: Feb 10, 2011 +// 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 // ---------------------------
--- a/table.cpp Wed Feb 16 17:12:38 2011 +0000 +++ b/table.cpp Mon Sep 26 02:21:01 2011 +0000 @@ -1,13 +1,13 @@ ////////////////////////////////////////////////////////////////////////////// // Product: DPP example -// Last Updated for Version: 4.0.00 -// Date of the Last Update: Apr 06, 2008 +// Last Updated for Version: 4.2.00 +// Date of the Last Update: Jul 15, 2011 // // Q u a n t u m L e a P s // --------------------------- // innovating embedded systems // -// Copyright (C) 2002-2008 Quantum Leaps, LLC. All rights reserved. +// 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 @@ -89,7 +89,6 @@ switch (e->sig) { case HUNGRY_SIG: { - BSP_busyDelay(); n = ((TableEvt const *)e)->philoNum; // phil ID must be in range and he must be not hungry Q_ASSERT((n < N_PHILO) && (!me->m_isHungry[n])); @@ -100,7 +99,7 @@ me->m_fork[m] = me->m_fork[n] = USED; pe = Q_NEW(TableEvt, EAT_SIG); pe->philoNum = n; - QF::publish(pe); + QF::PUBLISH(pe, me); BSP_displyPhilStat(n, "eating "); } else { @@ -109,7 +108,6 @@ return Q_HANDLED(); } case DONE_SIG: { - BSP_busyDelay(); n = ((TableEvt const *)e)->philoNum; // phil ID must be in range and he must be not hungry Q_ASSERT((n < N_PHILO) && (!me->m_isHungry[n])); @@ -126,7 +124,7 @@ me->m_isHungry[m] = 0; pe = Q_NEW(TableEvt, EAT_SIG); pe->philoNum = m; - QF::publish(pe); + QF::PUBLISH(pe, me); BSP_displyPhilStat(m, "eating "); } m = LEFT(n); // check the left neighbor @@ -136,7 +134,7 @@ me->m_isHungry[m] = 0; pe = Q_NEW(TableEvt, EAT_SIG); pe->philoNum = m; - QF::publish(pe); + QF::PUBLISH(pe, me); BSP_displyPhilStat(m, "eating "); } return Q_HANDLED();