1010* @cond
1111******************************************************************************
1212* Last updated for version 6.8.0
13- * Last updated on 2020-01-21
13+ * Last updated on 2020-03-25
1414*
1515* Q u a n t u m L e a P s
1616* ------------------------
@@ -447,7 +447,7 @@ void QTicker_ctor(QTicker * const me, uint8_t tickRate) {
447447 QActive_ctor (me , Q_STATE_CAST (0 )); /* superclass' ctor */
448448 me -> super .vptr = & vtable .super ; /* hook the vptr */
449449
450- /* reuse eQueue.head for tick-rate */
450+ /* reuse eQueue.head for tick-rate */
451451 me -> eQueue .head = (QEQueueCtr )tickRate ;
452452}
453453/*..........................................................................*/
@@ -458,17 +458,17 @@ static void QTicker_init_(QHsm * const me, void const *par) {
458458}
459459/*..........................................................................*/
460460static void QTicker_dispatch_ (QHsm * const me , QEvt const * const e ) {
461- QEQueueCtr n ;
461+ QEQueueCtr nTicks ; /* # ticks since the last call */
462462 QF_CRIT_STAT_
463463
464464 (void )e ; /* unused parameter */
465465
466466 QF_CRIT_ENTRY_ ();
467+ nTicks = QTICKER_CAST_ (me )-> eQueue .tail ; /* save the # of ticks */
467468 QTICKER_CAST_ (me )-> eQueue .tail = 0U ; /* clear the # ticks */
468469 QF_CRIT_EXIT_ ();
469470
470- /* # ticks since last call */
471- for (n = QTICKER_CAST_ (me )-> eQueue .tail ; n > 0U ; -- n ) {
471+ for (; nTicks > 0U ; -- nTicks ) {
472472 QF_TICK_X ((uint_fast8_t )QTICKER_CAST_ (me )-> eQueue .head , me );
473473 }
474474}
0 commit comments