@@ -364,7 +364,7 @@ static void prvTest2_CheckTaskAndTimersInitialState( void )
364
364
{
365
365
uint8_t ucTimer ;
366
366
367
- /* Ensure all the timers are in their expected initial state. This depends
367
+ /* Ensure all the timers are in their expected initial state. This depends
368
368
* on the timer service task having a higher priority than this task.
369
369
*
370
370
* auto-reload timers 0 to ( configTIMER_QUEUE_LENGTH - 1 ) should now be active,
@@ -691,6 +691,8 @@ static void prvTest6_CheckAutoReloadResetBehaviour( void )
691
691
692
692
static void prvTest7_CheckBacklogBehaviour ( void )
693
693
{
694
+ UBaseType_t uxOriginalPriority ;
695
+
694
696
/* Use the first auto-reload timer to test stopping a timer from a
695
697
* backlogged callback. */
696
698
@@ -739,6 +741,55 @@ static void prvTest7_CheckBacklogBehaviour( void )
739
741
/* Clear the reload count for the timer used in this test. */
740
742
ucAutoReloadTimerCounters [ 0 ] = ( uint8_t ) 0 ;
741
743
744
+
745
+ /* Verify a one-shot timer is marked as inactive if the timer task processes
746
+ * the start or reset request after the expiration time has passed. */
747
+
748
+ /* The timer has not been started yet! */
749
+ if ( xTimerIsTimerActive ( xOneShotTimer ) != pdFALSE )
750
+ {
751
+ xTestStatus = pdFAIL ;
752
+ configASSERT ( xTestStatus );
753
+ }
754
+
755
+ /* Use the timer period specific to backlogged timers because it reduces
756
+ * the impact on other tests that might be running when xTaskCatchUpTicks()
757
+ * creates the backlog, below. */
758
+ xTimerChangePeriod ( xOneShotTimer , tmrdemoBACKLOG_TIMER_PERIOD , tmrdemoDONT_BLOCK );
759
+
760
+ /* Temporarily give this task maximum priority so it can cause the timer
761
+ * task to delay its processing of the reset request below. */
762
+ uxOriginalPriority = uxTaskPriorityGet ( NULL );
763
+ vTaskPrioritySet ( NULL , ( configMAX_PRIORITIES - 1 ) );
764
+
765
+ /* Reset the timer. The timer service won't process this request right
766
+ * away as noted above. */
767
+ xTimerReset ( xOneShotTimer , tmrdemoDONT_BLOCK );
768
+
769
+ /* Cause the timer period to elapse without giving an opportunity for the
770
+ * timer service task to process the reset request. */
771
+ xTaskCatchUpTicks ( tmrdemoBACKLOG_TIMER_PERIOD );
772
+
773
+ /* Return this task to its original priority. The timer service task will
774
+ * process the reset request immediately. The timer task must handle the reset
775
+ * request as if it were processed at the time of the request even though in
776
+ * this test the processing occurs after the intended expiration time. */
777
+ vTaskPrioritySet ( NULL , uxOriginalPriority );
778
+
779
+ /* The timer should now be inactive. */
780
+ if ( xTimerIsTimerActive ( xOneShotTimer ) != pdFALSE )
781
+ {
782
+ xTestStatus = pdFAIL ;
783
+ configASSERT ( xTestStatus );
784
+ }
785
+
786
+ /* Restore the standard timer period, and leave the timer inactive. */
787
+ xTimerChangePeriod ( xOneShotTimer , tmrdemoONE_SHOT_TIMER_PERIOD , tmrdemoDONT_BLOCK );
788
+ xTimerStop ( xOneShotTimer , tmrdemoDONT_BLOCK );
789
+
790
+ /* Clear the counter for the timer used in this test. */
791
+ ucOneShotTimerCounter = ( uint8_t ) 0 ;
792
+
742
793
if ( xTestStatus == pdPASS )
743
794
{
744
795
/* No errors have been reported so increment the loop counter so the check
@@ -931,7 +982,7 @@ void vTimerPeriodicISRTests( void )
931
982
else if ( uxTick == ( ( 3 * xBasePeriod ) + xMargin ) )
932
983
{
933
984
/* The auto-reload timer and one-shot timer will be active. At
934
- * this time the auto-reload timer should have expired again, but the one
985
+ * this time the auto-reload timer should have expired again, but the one
935
986
* shot timer count should not have changed yet. */
936
987
if ( ucISRAutoReloadTimerCounter != 3 )
937
988
{
@@ -1063,8 +1114,8 @@ void vTimerPeriodicISRTests( void )
1063
1114
else if ( uxTick == ( ( 12 * xBasePeriod ) - ( 2 * xMargin ) ) )
1064
1115
{
1065
1116
/* Only the one-shot timer should have been running and this time it
1066
- * should have expired. Check its callback count has been incremented.
1067
- * The auto-reload timer is still not running so should still have the same
1117
+ * should have expired. Check its callback count has been incremented.
1118
+ * The auto-reload timer is still not running so should still have the same
1068
1119
* count value. This time the one-shot timer is not reset so should not
1069
1120
* restart from its expiry period again. */
1070
1121
if ( ucISRAutoReloadTimerCounter != 3 )
0 commit comments