static void prvCheckTimerCallback( xTimerHandle xTimer ) { static long lChangedTimerPeriodAlready = pdFALSE; static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0; unsigned long ulErrorFound = pdFALSE; /* Check all the demo tasks (other than the flash tasks) to ensure that they are all still running, and that none have detected an error. */ if( xAreMathsTaskStillRunning() != pdTRUE ) { ulErrorFound = pdTRUE; } if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { ulErrorFound = pdTRUE; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { ulErrorFound = pdTRUE; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { ulErrorFound = pdTRUE; } if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { ulErrorFound = pdTRUE; } if ( xAreGenericQueueTasksStillRunning() != pdTRUE ) { ulErrorFound = pdTRUE; } if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) { ulErrorFound = pdTRUE; } if( xIsCreateTaskStillRunning() != pdTRUE ) { ulErrorFound = pdTRUE; } if( xArePollingQueuesStillRunning() != pdTRUE ) { ulErrorFound = pdTRUE; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { ulErrorFound = pdTRUE; } /* Check that the register test 1 task is still running. */ if( ulLastRegTest1Value == ulRegTest1LoopCounter ) { ulErrorFound = pdTRUE; } ulLastRegTest1Value = ulRegTest1LoopCounter; /* Check that the register test 2 task is still running. */ if( ulLastRegTest2Value == ulRegTest2LoopCounter ) { ulErrorFound = pdTRUE; } ulLastRegTest2Value = ulRegTest2LoopCounter; /* Toggle the check LED to give an indication of the system status. If the LED toggles every mainCHECK_TIMER_PERIOD_MS milliseconds then everything is ok. A faster toggle indicates an error. */ mainTOGGLE_LED(); /* Have any errors been latch in ulErrorFound? If so, shorten the period of the check timer to mainERROR_CHECK_TIMER_PERIOD_MS milliseconds. This will result in an increase in the rate at which mainCHECK_LED toggles. */ if( ulErrorFound != pdFALSE ) { if( lChangedTimerPeriodAlready == pdFALSE ) { lChangedTimerPeriodAlready = pdTRUE; /* This call to xTimerChangePeriod() uses a zero block time. Functions called from inside of a timer callback function must *never* attempt to block. */ xTimerChangePeriod( xTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK ); } } }
static void prvCheckTimerCallback( xTimerHandle xTimer ) { /* Check the standard demo tasks are running without error. Latch the latest reported error in the pcStatusMessage character pointer. */ if( xAreGenericQueueTasksStillRunning() != pdTRUE ) { pcStatusMessage = "Error: GenQueue"; } if( xAreQueuePeekTasksStillRunning() != pdTRUE ) { pcStatusMessage = "Error: QueuePeek\r\n"; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { pcStatusMessage = "Error: BlockQueue\r\n"; } if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { pcStatusMessage = "Error: BlockTime\r\n"; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { pcStatusMessage = "Error: SemTest\r\n"; } if( xIsCreateTaskStillRunning() != pdTRUE ) { pcStatusMessage = "Error: Death\r\n"; } if( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) { pcStatusMessage = "Error: RecMutex\r\n"; } if( xAreTimerDemoTasksStillRunning( ( mainCHECK_TIMER_PERIOD_MS ) ) != pdTRUE ) { pcStatusMessage = "Error: TimerDemo"; } /* Toggle the check LED to give an indication of the system status. If the LED toggles every mainCHECK_TIMER_PERIOD_MS milliseconds then everything is ok. A faster toggle indicates an error. */ vParTestToggleLED( mainCHECK_LED ); /* Have any errors been latch in pcStatusMessage? If so, shorten the period of the check timer to mainERROR_CHECK_TIMER_PERIOD_MS milliseconds. This will result in an increase in the rate at which mainCHECK_LED toggles. */ if( pcStatusMessage != NULL ) { /* This call to xTimerChangePeriod() uses a zero block time. Functions called from inside of a timer callback function must *never* attempt to block. */ xTimerChangePeriod( xCheckTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK ); } }
static void prvCheckTimerCallback( TimerHandle_t xTimer ) { /* Check the standard demo tasks are running without error. Latch the latest reported error in the pcStatusMessage character pointer. */ if( xAreGenericQueueTasksStillRunning() != pdTRUE ) { pcStatusMessage = "Error: GenQueue"; } if( xAreQueuePeekTasksStillRunning() != pdTRUE ) { pcStatusMessage = "Error: QueuePeek\r\n"; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { pcStatusMessage = "Error: BlockQueue\r\n"; } if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { pcStatusMessage = "Error: BlockTime\r\n"; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { pcStatusMessage = "Error: SemTest\r\n"; } if( xIsCreateTaskStillRunning() != pdTRUE ) { pcStatusMessage = "Error: Death\r\n"; } if( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) { pcStatusMessage = "Error: RecMutex\r\n"; } if( xAreComTestTasksStillRunning() != pdPASS ) { pcStatusMessage = "Error: ComTest\r\n"; } if( xAreTimerDemoTasksStillRunning( ( mainCHECK_TIMER_PERIOD_MS ) ) != pdTRUE ) { pcStatusMessage = "Error: TimerDemo"; } if( xArePollingQueuesStillRunning() != pdTRUE ) { pcStatusMessage = "Error: PollQueue"; } if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE ) { pcStatusMessage = "Error: CountSem"; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { pcStatusMessage = "Error: DynamicPriority"; } /* Toggle the check LED to give an indication of the system status. If the LED toggles every mainCHECK_TIMER_PERIOD_MS milliseconds then everything is ok. A faster toggle indicates an error. vParTestToggleLED() is not used to toggle this particular LED as it is on a different IP port to to the LEDs controlled by ParTest.c. A critical section is not required as the only other place this port is accessed is from another timer - and only one timer can be running at any one time. */ if( ( FM3_GPIO->PDOR3 & mainCHECK_LED ) != 0 ) { FM3_GPIO->PDOR3 &= ~mainCHECK_LED; } else { FM3_GPIO->PDOR3 |= mainCHECK_LED; } /* Have any errors been latch in pcStatusMessage? If so, shorten the period of the check timer to mainERROR_CHECK_TIMER_PERIOD_MS milliseconds. This will result in an increase in the rate at which mainCHECK_LED toggles. */ if( pcStatusMessage != NULL ) { /* This call to xTimerChangePeriod() uses a zero block time. Functions called from inside of a timer callback function must *never* attempt to block. */ xTimerChangePeriod( xCheckTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK ); } }
static void prvCheckTimerCallback( TimerHandle_t xTimer ) { static long lChangedTimerPeriodAlready = pdFALSE; unsigned long ulErrorFound = pdFALSE; /* Check all the demo tasks (other than the flash tasks) to ensure they are all still running, and that none have detected an error. */ if( xAreIntQueueTasksStillRunning() != pdTRUE ) { ulErrorFound |= 1UL << 0UL; } if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { ulErrorFound |= 1UL << 1UL; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { ulErrorFound |= 1UL << 2UL; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { ulErrorFound |= 1UL << 3UL; } if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { ulErrorFound |= 1UL << 4UL; } if ( xAreGenericQueueTasksStillRunning() != pdTRUE ) { ulErrorFound |= 1UL << 5UL; } if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) { ulErrorFound |= 1UL << 6UL; } if( xIsCreateTaskStillRunning() != pdTRUE ) { ulErrorFound |= 1UL << 7UL; } if( xArePollingQueuesStillRunning() != pdTRUE ) { ulErrorFound |= 1UL << 8UL; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { ulErrorFound |= 1UL << 9UL; } if( xAreComTestTasksStillRunning() != pdTRUE ) { ulErrorFound |= 1UL << 10UL; } if( xAreQueueSetTasksStillRunning() != pdTRUE ) { ulErrorFound |= 1UL << 11UL; } if( xAreTaskNotificationTasksStillRunning() != pdTRUE ) { ulErrorFound |= 1UL << 12UL; } if( xAreTimerDemoTasksStillRunning( mainCHECK_TIMER_PERIOD_MS ) != pdTRUE ) { ulErrorFound |= 1UL << 13UL; } if( xAreEventGroupTasksStillRunning() != pdTRUE ) { ulErrorFound |= 1UL << 14UL; } if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE ) { ulErrorFound |= 1UL << 15UL; } /* Toggle the check LED to give an indication of the system status. If the LED toggles every mainCHECK_TIMER_PERIOD_MS milliseconds then everything is ok. A faster toggle indicates an error. */ vParTestToggleLED( mainCHECK_LED ); /* Have any errors been latch in ulErrorFound? If so, shorten the period of the check timer to mainERROR_CHECK_TIMER_PERIOD_MS milliseconds. This will result in an increase in the rate at which mainCHECK_LED toggles. */ if( ulErrorFound != pdFALSE ) { if( lChangedTimerPeriodAlready == pdFALSE ) { lChangedTimerPeriodAlready = pdTRUE; /* This call to xTimerChangePeriod() uses a zero block time. Functions called from inside of a timer callback function must *never* attempt to block. */ xTimerChangePeriod( xTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK ); } } }
static void prvCheckTimerCallback( TimerHandle_t xTimer ) { static long lChangedTimerPeriodAlready = pdFALSE, lErrorStatus = pdPASS; static volatile unsigned long ulLastRegTest1CycleCount = 0UL, ulLastRegTest2CycleCount = 0UL; /* Remove compiler warnings about unused parameters. */ ( void ) xTimer; /* Check the standard demo tasks are running without error. */ if( xAreGenericQueueTasksStillRunning() != pdTRUE ) { lErrorStatus = pdFAIL; } else if( xIsCreateTaskStillRunning() != pdTRUE ) { lErrorStatus = pdFAIL; } else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { lErrorStatus = pdFAIL; } else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) { lErrorStatus = pdFAIL; } /* Check the reg test tasks are still cycling. They will stop incrementing their loop counters if they encounter an error. */ if( ulRegTest1CycleCount == ulLastRegTest1CycleCount ) { lErrorStatus = pdFAIL; } if( ulRegTest2CycleCount == ulLastRegTest2CycleCount ) { lErrorStatus = pdFAIL; } /* Remember the loop counter values this time around so they can be checked again the next time this callback function executes. */ ulLastRegTest1CycleCount = ulRegTest1CycleCount; ulLastRegTest2CycleCount = ulRegTest2CycleCount; /* Toggle the check LED to give an indication of the system status. If the LED toggles every three seconds then everything is ok. A faster toggle indicates an error. */ vParTestToggleLED( mainCHECK_LED ); /* Was an error detected this time through the callback execution? */ if( lErrorStatus != pdPASS ) { if( lChangedTimerPeriodAlready == pdFALSE ) { lChangedTimerPeriodAlready = pdTRUE; /* This call to xTimerChangePeriod() uses a zero block time. Functions called from inside of a timer callback function must *never* attempt to block. */ xTimerChangePeriod( xCheckTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK ); } } }
/** * @brief Start or restart a timer. * @param timer_id timer ID obtained by \ref osTimerCreate. * @param millisec time delay value of the timer. * @retval status code that indicates the execution status of the function * @note MUST REMAIN UNCHANGED: \b osTimerStart shall be consistent in every CMSIS-RTOS. */ osStatus osTimerStart (osTimerId timer_id, uint32_t millisec) { osStatus result = osOK; #if (configUSE_TIMERS == 1) portBASE_TYPE taskWoken = pdFALSE; TickType_t ticks = millisec / portTICK_PERIOD_MS; if (xTimerIsTimerActive(timer_id) != pdFALSE) { if (inHandlerMode()) { if(xTimerResetFromISR(timer_id, &taskWoken) != pdPASS) { result = osErrorOS; } else { portEND_SWITCHING_ISR(taskWoken); result = osOK; } } else { if (xTimerReset(timer_id, 0) != pdPASS) result = osErrorOS; else result = osOK; } } else { if (ticks == 0) ticks = 1; if (inHandlerMode()) { if (xTimerChangePeriodFromISR(timer_id, ticks, &taskWoken) != pdPASS) result = osErrorOS; else { xTimerStartFromISR(timer_id, &taskWoken); portEND_SWITCHING_ISR(taskWoken); result = osOK; } } else { if (xTimerChangePeriod(timer_id, ticks, 0) != pdPASS) result = osErrorOS; else { if (xTimerStart(timer_id, 0) != pdPASS) result = osErrorOS; } } } #else result = osErrorOS; #endif return result; }
static void umac_impl_request_future_tick(umtick delta_tick) { xTimerChangePeriod(um_tim_hdl, delta_tick, 0); xTimerReset(um_tim_hdl, 0); }
static void prvCheckTimerCallback( TimerHandle_t xTimer ) { static long lChangedTimerPeriodAlready = pdFALSE; static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0, ulLastHighFrequencyTimerInterrupts = 0; static const unsigned long ulExpectedHighFrequencyInterrupts = ( ( mainTEST_INTERRUPT_FREQUENCY / 1000UL ) * mainCHECK_TIMER_PERIOD_MS ) - 10; /* 10 allows for a margin of error. */ unsigned long ulErrorOccurred = pdFALSE; /* The count of the high frequency timer interrupts. */ extern unsigned long ulHighFrequencyTimerInterrupts; /* Avoid compiler warnings. */ ( void ) xTimer; /* Check that the register test 1 task is still running. */ if( ulLastRegTest1Value == ulRegTest1Cycles ) { ulErrorOccurred |= ( 0x01UL << 1UL ); } ulLastRegTest1Value = ulRegTest1Cycles; /* Check that the register test 2 task is still running. */ if( ulLastRegTest2Value == ulRegTest2Cycles ) { ulErrorOccurred |= ( 0x01UL << 2UL ); } ulLastRegTest2Value = ulRegTest2Cycles; /* Have any of the standard demo tasks detected an error in their operation? */ if( xAreGenericQueueTasksStillRunning() != pdTRUE ) { ulErrorOccurred |= ( 0x01UL << 3UL ); } else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { ulErrorOccurred |= ( 0x01UL << 4UL ); } else if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { ulErrorOccurred |= ( 0x01UL << 5UL ); } else if( xAreIntQueueTasksStillRunning() != pdTRUE ) { ulErrorOccurred |= ( 0x01UL << 6UL ); } else if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE ) { ulErrorOccurred |= ( 0x01UL << 7UL ); } /* Ensure the expected number of high frequency interrupts have occurred. */ if( ulLastHighFrequencyTimerInterrupts != 0 ) { if( ( ulHighFrequencyTimerInterrupts - ulLastHighFrequencyTimerInterrupts ) < ulExpectedHighFrequencyInterrupts ) { ulErrorOccurred |= ( 0x01UL << 8UL ); } } ulLastHighFrequencyTimerInterrupts = ulHighFrequencyTimerInterrupts; if( ulErrorOccurred != pdFALSE ) { /* An error occurred. Increase the frequency at which the check timer toggles its LED to give visual feedback of the potential error condition. */ if( lChangedTimerPeriodAlready == pdFALSE ) { lChangedTimerPeriodAlready = pdTRUE; /* This call to xTimerChangePeriod() uses a zero block time. Functions called from inside of a timer callback function must *never* attempt to block as to do so could impact other software timers. */ xTimerChangePeriod( xTimer, ( mainERROR_CHECK_TIMER_PERIOD_MS ), mainDONT_BLOCK ); } } vToggleLED( mainCHECK_LED ); }
void FreeRTOSTimer::changePeriod(TIME_MS t) { xTimerChangePeriod(mTimerHandle, t, 0); }