static void prvCheckOtherTasksAreStillRunning( void ) { if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { ulErrorFlags |= 0x01; } if( xArePollingQueuesStillRunning() != pdTRUE ) { ulErrorFlags |= 0x02; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { ulErrorFlags |= 0x04; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { ulErrorFlags |= 0x08; } if( xAreComTestTasksStillRunning() != pdTRUE ) { ulErrorFlags |= 0x10; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { ulErrorFlags |= 0x20; } if( xAreMathsTaskStillRunning() != pdTRUE ) { ulErrorFlags |= 0x40; } if( xAreGenericQueueTasksStillRunning() != pdTRUE ) { ulErrorFlags |= 0x80; } if( xAreQueuePeekTasksStillRunning() != pdTRUE ) { ulErrorFlags |= 0x100; } }
/* * Check each set of tasks in turn to see if they have experienced any * error conditions. */ static long prvCheckOtherTasksAreStillRunning( unsigned long ulMemCheckTaskCount ) { long lNoErrorsDiscovered = ( long ) pdTRUE; if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { lNoErrorsDiscovered = pdFALSE; } if( xAreComTestTasksStillRunning() != pdTRUE ) { lNoErrorsDiscovered = pdFALSE; } if( xArePollingQueuesStillRunning() != pdTRUE ) { lNoErrorsDiscovered = pdFALSE; } if( xAreMathsTaskStillRunning() != pdTRUE ) { lNoErrorsDiscovered = pdFALSE; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { lNoErrorsDiscovered = pdFALSE; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { lNoErrorsDiscovered = pdFALSE; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { lNoErrorsDiscovered = pdFALSE; } if( ulMemCheckTaskCount == mainCOUNT_INITIAL_VALUE ) { /* The vMemCheckTask task did not increment the counter - it must have failed. */ lNoErrorsDiscovered = pdFALSE; } return lNoErrorsDiscovered; }
static void prvCheckTask( void *pvParameters ) { ( void ) pvParameters; /* Check all the demo tasks to ensure that they are all still running, and that none of them have detected an error. */ for( ;; ) { /* Block until it is time to check again. */ vTaskDelay( mainCHECK_DELAY ); if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { usCheckStatus |= 0x01; } if( xArePollingQueuesStillRunning() != pdTRUE ) { usCheckStatus |= 0x02; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { usCheckStatus |= 0x04; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { usCheckStatus |= 0x08; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { usCheckStatus |= 0x10; } if( xIsCreateTaskStillRunning() != pdTRUE ) { usCheckStatus |= 0x20; } if( xAreComTestTasksStillRunning() != pdTRUE ) { usCheckStatus |= 0x40; } } }
static portLONG prvCheckOtherTasksAreStillRunning( void ) { portLONG lReturn = pdPASS; /* Check all the demo tasks (other than the flash tasks) to ensure that they are all still running, and that none of them have detected an error. */ if( xAreIntegerMathsTaskStillRunning() != pdPASS ) { lReturn = pdFAIL; } if( xAreComTestTasksStillRunning() != pdPASS ) { lReturn = pdFAIL; } #ifdef KEIL_THUMB_INTERWORK /* When using THUMB mode we can start more tasks without the executable exceeding the size limit imposed by the evaluation version of uVision3. */ if( xArePollingQueuesStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } #endif return lReturn; }
/*! * \brief Checks that all the demo application tasks are still executing without error. */ static portBASE_TYPE prvCheckOtherTasksAreStillRunning( void ) { static portBASE_TYPE xErrorHasOccurred = pdFALSE; if( xAreComTestTasksStillRunning() != pdTRUE ) { xErrorHasOccurred = pdTRUE; } if( xArePollingQueuesStillRunning() != pdTRUE ) { xErrorHasOccurred = pdTRUE; } if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { xErrorHasOccurred = pdTRUE; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { xErrorHasOccurred = pdTRUE; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { xErrorHasOccurred = pdTRUE; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { xErrorHasOccurred = pdTRUE; } if( xAreMathsTaskStillRunning() != pdTRUE ) { xErrorHasOccurred = pdTRUE; } if( xIsCreateTaskStillRunning() != pdTRUE ) { xErrorHasOccurred = pdTRUE; } return ( xErrorHasOccurred ); }
static long prvCheckOtherTasksAreStillRunning( void ) { long lReturn = pdPASS; /* Check all the demo tasks (other than the flash tasks) to ensure that they are all still running, and that none of them have detected an error. */ if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreComTestTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xArePollingQueuesStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreRegTestTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } return lReturn; }
static short prvCheckOtherTasksAreStillRunning( void ) { static short sNoErrorFound = pdTRUE; static unsigned long ulLastIdleLoopCount = 0UL; /* The demo tasks maintain a count that increments every cycle of the task provided that the task has never encountered an error. This function checks the counts maintained by the tasks to ensure they are still being incremented. A count remaining at the same value between calls therefore indicates that an error has been detected. Only tasks that do not flash an LED are checked. */ if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } if( xAreComTestTasksStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } if( xArePollingQueuesStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } if( xLocalError == pdTRUE ) { sNoErrorFound = pdFALSE; } if( ulIdleLoops == ulLastIdleLoopCount ) { sNoErrorFound = pdFALSE; } else { ulLastIdleLoopCount = ulIdleLoops; } return sNoErrorFound; }
void vApplicationTickHook( void ) { static unsigned long ulCounter = 0; static const unsigned long ulCheckFrequency = 5000UL / portTICK_RATE_MS; long lHigherPriorityTaskWoken = pdFALSE; /* Define the status message that is sent to the LCD task. By default the status is PASS. */ static xQueueMessage xStatusMessage = { mainMESSAGE_STATUS, pdPASS }; /* This is called from within the tick interrupt and performs the 'check' functionality as described in the comments at the top of this file. Is it time to perform the 'check' functionality again? */ ulCounter++; if( ulCounter >= ulCheckFrequency ) { /* See if the standard demo tasks are executing as expected, changing the message that is sent to the LCD task from PASS to an error code if any tasks set reports an error. */ if( xAreDynamicPriorityTasksStillRunning() != pdPASS ) { xStatusMessage.lMessageValue = mainERROR_DYNAMIC_TASKS; } if( xAreComTestTasksStillRunning() != pdPASS ) { xStatusMessage.lMessageValue = mainERROR_COM_TEST; } if( xAreGenericQueueTasksStillRunning() != pdPASS ) { xStatusMessage.lMessageValue = mainERROR_GEN_QUEUE_TEST; } /* As this is the tick hook the lHigherPriorityTaskWoken parameter is not needed (a context switch is going to be performed anyway), but it must still be provided. */ xQueueSendFromISR( xLCDQueue, &xStatusMessage, &lHigherPriorityTaskWoken ); ulCounter = 0; } }
static long prvCheckOtherTasksAreStillRunning( void ) { portBASE_TYPE xAllTasksPassed = pdPASS; if( xArePollingQueuesStillRunning() != pdTRUE ) { xAllTasksPassed = pdFAIL; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { xAllTasksPassed = pdFAIL; } if( xAreComTestTasksStillRunning() != pdTRUE ) { xAllTasksPassed = pdFALSE; } if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { xAllTasksPassed = pdFALSE; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { xAllTasksPassed = pdFALSE; } if( xIsCreateTaskStillRunning() != pdTRUE ) { xAllTasksPassed = pdFALSE; } /* Also check the status flag for the tasks defined within this function. */ if( xLocalError != pdFALSE ) { xAllTasksPassed = pdFAIL; } return xAllTasksPassed; }
static void vErrorChecks( void *pvParameters ) { portTickType xDelayTime = mainNO_ERROR_CHECK_PERIOD; volatile unsigned long ulDummy = 3UL; /* Toggle the LED so we can see when a reset occurs. */ vParTestSetLED( mainRESET_LED, pdTRUE ); vTaskDelay( mainRESET_LED_PERIOD ); vParTestSetLED( mainRESET_LED, pdFALSE ); /* Cycle for ever, delaying then checking all the other tasks are still operating without error. */ for( ;; ) { /* Wait until it is time to check the other tasks. */ vTaskDelay( xDelayTime ); /* Perform an integer calculation - just to ensure the registers get used. The result is not important. */ ulDummy *= 3UL; /* Check all the other tasks are running, and running without ever having an error. The delay period is lowered if an error is reported, causing the LED to flash at a higher rate. */ if( xAreIntegerMathsTaskStillRunning() == pdFALSE ) { xDelayTime = mainERROR_CHECK_PERIOD; } if( xAreComTestTasksStillRunning() == pdFALSE ) { xDelayTime = mainERROR_CHECK_PERIOD; } /* Flash the LED for visual feedback. The rate of the flash will indicate the health of the system. */ vParTestToggleLED( mainCHECK_TASK_LED ); } }
static void prvCheckTimerCallback( xTimerHandle xTimer ) { static long lChangeToRedLEDsAlready = pdFALSE; static unsigned long ulLastRegTest1Counter = 0, ulLastRegTest2Counter = 0; unsigned long ulErrorFound = pdFALSE; /* LEDs are defaulted to use the Green LEDs. The Red LEDs are used if an error is found. */ static unsigned long ulLED1 = 8, ulLED2 = 11; const unsigned long ulRedLED1 = 6, ulRedLED2 = 9; /* 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( 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; } if( xAreMathsTaskStillRunning() != pdTRUE ) { ulErrorFound = pdTRUE; } if( xAreComTestTasksStillRunning() != pdTRUE ) { ulErrorFound = pdTRUE; } /* Check the reg test tasks are still cycling. They will stop incrementing their loop counters if they encounter an error. */ if( ulRegTest1Counter == ulLastRegTest1Counter ) { ulErrorFound = pdTRUE; } if( ulRegTest2Counter == ulLastRegTest2Counter ) { ulErrorFound = pdTRUE; } ulLastRegTest1Counter = ulRegTest1Counter; ulLastRegTest2Counter = ulRegTest2Counter; /* Toggle the check LEDs to give an indication of the system status. If the green LEDs are toggling, then no errors have been detected. If the red LEDs are toggling, then an error has been reported in at least one task. */ vParTestToggleLED( ulLED1 ); vParTestToggleLED( ulLED2 ); /* Have any errors been latch in ulErrorFound? If so, ensure the gree LEDs are off, then switch to using the red LEDs. */ if( ulErrorFound != pdFALSE ) { if( lChangeToRedLEDsAlready == pdFALSE ) { lChangeToRedLEDsAlready = pdTRUE; /* An error has been found. Switch to use the red LEDs. */ vParTestSetLED( ulLED1, pdFALSE ); vParTestSetLED( ulLED2, pdFALSE ); ulLED1 = ulRedLED1; ulLED2 = ulRedLED2; } } }
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( 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 ); } }
void vApplicationTickHook( void ) { static unsigned short usLastRegTest1Counter = 0, usLastRegTest2Counter = 0; static unsigned long ulCounter = 0; static const unsigned long ulCheckFrequency = 5000UL / portTICK_RATE_MS; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* Define the status message that is sent to the LCD task. By default the status is PASS. */ static xQueueMessage xStatusMessage = { mainMESSAGE_STATUS, pdPASS }; /* This is called from within the tick interrupt and performs the 'check' functionality as described in the comments at the top of this file. Is it time to perform the 'check' functionality again? */ ulCounter++; if( ulCounter >= ulCheckFrequency ) { /* See if the standard demo tasks are executing as expected, changing the message that is sent to the LCD task from PASS to an error code if any tasks set reports an error. */ if( xAreComTestTasksStillRunning() != pdPASS ) { xStatusMessage.ulMessageValue = mainERROR_COM_TEST; } if( xAreDynamicPriorityTasksStillRunning() != pdPASS ) { xStatusMessage.ulMessageValue = mainERROR_DYNAMIC_TASKS; } if( xAreGenericQueueTasksStillRunning() != pdPASS ) { xStatusMessage.ulMessageValue = mainERROR_GEN_QUEUE_TEST; } /* Check the reg test tasks are still cycling. They will stop incrementing their loop counters if they encounter an error. */ if( usRegTest1Counter == usLastRegTest1Counter ) { xStatusMessage.ulMessageValue = mainERROR_REG_TEST; } if( usRegTest2Counter == usLastRegTest2Counter ) { xStatusMessage.ulMessageValue = mainERROR_REG_TEST; } usLastRegTest1Counter = usRegTest1Counter; usLastRegTest2Counter = usRegTest2Counter; /* As this is the tick hook the lHigherPriorityTaskWoken parameter is not needed (a context switch is going to be performed anyway), but it must still be provided. */ xQueueSendFromISR( xLCDQueue, &xStatusMessage, &xHigherPriorityTaskWoken ); ulCounter = 0; } /* Just periodically toggle an LED to show that the tick interrupt is running. Note that this access LED_PORT_OUT in a non-atomic way, so tasks that access the same port must do so from a critical section. */ if( ( ulCounter & 0xff ) == 0 ) { if( ( LED_PORT_OUT & LED_1 ) == 0 ) { LED_PORT_OUT |= LED_1; } else { LED_PORT_OUT &= ~LED_1; } } }
static void prvCheckTimerCallback( xTimerHandle 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( 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; } if( xAreComTestTasksStillRunning() != pdTRUE ) { ulErrorFound = pdTRUE; } if( xAreQueueSetTasksStillRunning() != pdPASS ) { ulErrorFound = pdTRUE; } /* 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 ); } } }
void vCheckTask( void *pvParameters ) { unsigned long ulRow = 0; portTickType xDelay = 0; unsigned short usErrorCode = 0; unsigned long ulIteration = 0; extern unsigned portSHORT usMaxJitter; /* Intialise the sleeper. */ xDelay = xTaskGetTickCount(); for( ;; ) { /* Perform this check every mainCHECK_DELAY milliseconds. */ vTaskDelayUntil( &xDelay, mainCHECK_DELAY ); /* Check that all of the Demo tasks are still running. */ if( pdTRUE != xAreBlockingQueuesStillRunning() ) { usErrorCode |= 0x1; } if( pdTRUE != xAreBlockTimeTestTasksStillRunning() ) { usErrorCode |= 0x2; } if( pdTRUE != xAreCountingSemaphoreTasksStillRunning() ) { usErrorCode |= 0x4; } if( pdTRUE != xIsCreateTaskStillRunning() ) { usErrorCode |= 0x8; } if( pdTRUE != xAreDynamicPriorityTasksStillRunning() ) { usErrorCode |= 0x10; } if( pdTRUE != xAreMathsTaskStillRunning() ) { usErrorCode |= 0x20; } if( pdTRUE != xAreGenericQueueTasksStillRunning() ) { usErrorCode |= 0x40; } if( pdTRUE != xAreIntegerMathsTaskStillRunning() ) { usErrorCode |= 0x80; } if( pdTRUE != xArePollingQueuesStillRunning() ) { usErrorCode |= 0x100; } if( pdTRUE != xAreQueuePeekTasksStillRunning() ) { usErrorCode |= 0x200; } if( pdTRUE != xAreSemaphoreTasksStillRunning() ) { usErrorCode |= 0x400; } if( pdTRUE != xAreComTestTasksStillRunning() ) { usErrorCode |= 0x800; } if( pdTRUE != xAreIntQueueTasksStillRunning() ) { usErrorCode |= 0x1000; } /* Clear the display. */ LCD_Character_Display_ClearDisplay(); if( 0 == usErrorCode ) { LCD_Character_Display_Position( ( ulRow ) & 0x1, 0); LCD_Character_Display_PrintString( "Pass: "******"Jitter(ns):" ); LCD_Character_Display_PrintNumber( ( usMaxJitter * mainNS_PER_CLOCK ) ); } else { /* Do something to indicate the failure. */ LCD_Character_Display_Position( ( ulRow ) & 0x1, 0 ); LCD_Character_Display_PrintString( "Fail at: " ); LCD_Character_Display_PrintNumber( ulIteration ); LCD_Character_Display_Position( ( ++ulRow ) & 0x1, 0 ); LCD_Character_Display_PrintString( "Error: 0x" ); LCD_Character_Display_PrintHexUint16( usErrorCode ); } } }
static void prvCheckOtherTasksAreStillRunning( void ) { static short sErrorHasOccurred = pdFALSE; static unsigned long long uxLastHookCallCount = 0, uxLastQueueSendCount = 0; if( prvCheckMathTasksAreStillRunning() != pdTRUE ) { vDisplayMessage( "Maths task count unchanged!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreComTestTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Com test count unchanged!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { vDisplayMessage( "Blocking queues count unchanged!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreAltBlockingQueuesStillRunning() != pdTRUE ) { vDisplayMessage( "Alt blocking queues count unchanged!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xArePollingQueuesStillRunning() != pdTRUE ) { vDisplayMessage( "Polling queue count unchanged!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreAltPollingQueuesStillRunning() != pdTRUE ) { vDisplayMessage( "Alt polling queue count unchanged!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xIsCreateTaskStillRunning() != pdTRUE ) { vDisplayMessage( "Incorrect number of tasks running!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Semaphore take count unchanged!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Dynamic priority count unchanged!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreMultiEventTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Error in multi events tasks!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreFlashCoRoutinesStillRunning() != pdTRUE ) { vDisplayMessage( "Error in co-routine flash tasks!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreHookCoRoutinesStillRunning() != pdTRUE ) { vDisplayMessage( "Error in tick hook to co-routine communications!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Error in block time test tasks!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreAltBlockTimeTestTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Error in fast block time test tasks!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreGenericQueueTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Error in generic queue test task!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreAltGenericQueueTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Error in fast generic queue test task!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreQueuePeekTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Error in queue peek test task!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Error in counting semaphore demo task!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Error in recursive mutex tasks!\r\n" ); sErrorHasOccurred = pdTRUE; } /* The hook function associated with this task is called each time the task is switched in. We therefore expect the number of times the callback function has been executed to have increrment since the last time this function executed. */ if( uxCheckTaskHookCallCount <= uxLastHookCallCount ) { vDisplayMessage( "Error in task hook call count!\r\n" ); sErrorHasOccurred = pdTRUE; } else { uxLastHookCallCount = uxCheckTaskHookCallCount; } /* We would expect some queue sending to occur between calls of this function. */ if( uxQueueSendPassedCount <= uxLastQueueSendCount ) { vDisplayMessage( "Error in queue send hook call count!\r\n" ); sErrorHasOccurred = pdTRUE; } else { uxLastQueueSendCount = uxQueueSendPassedCount; } if( sErrorHasOccurred == pdFALSE ) { vDisplayMessage( "OK " ); } }
static void prvCheckTask( void *pvParameters ) { unsigned portLONG ulLastRegTest1Value = 0, ulLastRegTest2Value = 0, ulTicksToWait = mainNO_ERROR_PERIOD; portTickType xLastExecutionTime; /* Buffer into which the high frequency timer count is written as a string. */ static portCHAR cStringBuffer[ mainMAX_STRING_LENGTH ]; /* The count of the high frequency timer interrupts. */ extern unsigned portLONG ulHighFrequencyTimerInterrupts; xLCDMessage xMessage = { ( 200 / portTICK_RATE_MS ), cStringBuffer }; /* Setup the high frequency, high priority, timer test. It is setup here to ensure it does not fire before the scheduler is started. */ vSetupTimerTest( mainTEST_INTERRUPT_FREQUENCY ); /* Initialise the variable used to control our iteration rate prior to its first use. */ xLastExecutionTime = xTaskGetTickCount(); for( ;; ) { /* Wait until it is time to run the tests again. */ vTaskDelayUntil( &xLastExecutionTime, ulTicksToWait ); /* Has either register check 1 or 2 task discovered an error? */ if( ulStatus1 != pdPASS ) { ulTicksToWait = mainERROR_PERIOD; xMessage.pcMessage = "Error: Reg test1"; } /* Check that the register test 1 task is still running. */ if( ulLastRegTest1Value == ulRegTest1Cycles ) { ulTicksToWait = mainERROR_PERIOD; xMessage.pcMessage = "Error: Reg test2"; } ulLastRegTest1Value = ulRegTest1Cycles; /* Check that the register test 2 task is still running. */ if( ulLastRegTest2Value == ulRegTest2Cycles ) { ulTicksToWait = mainERROR_PERIOD; xMessage.pcMessage = "Error: Reg test3"; } ulLastRegTest2Value = ulRegTest2Cycles; /* Have any of the standard demo tasks detected an error in their operation? */ if( xAreGenericQueueTasksStillRunning() != pdTRUE ) { ulTicksToWait = mainERROR_PERIOD; xMessage.pcMessage = "Error: Gen Q"; } else if( xAreQueuePeekTasksStillRunning() != pdTRUE ) { ulTicksToWait = mainERROR_PERIOD; xMessage.pcMessage = "Error: Q Peek"; } else if( xAreComTestTasksStillRunning() != pdTRUE ) { ulTicksToWait = mainERROR_PERIOD; xMessage.pcMessage = "Error: COM test"; } else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { ulTicksToWait = mainERROR_PERIOD; xMessage.pcMessage = "Error: Blck time"; } else if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { ulTicksToWait = mainERROR_PERIOD; xMessage.pcMessage = "Error: Sem test"; } else if( xAreIntQueueTasksStillRunning() != pdTRUE ) { ulTicksToWait = mainERROR_PERIOD; xMessage.pcMessage = "Error: Int queue"; } /* Write the ulHighFrequencyTimerInterrupts value to the string buffer. It will only be displayed if no errors have been detected. */ sprintf( cStringBuffer, "Pass %u", ( unsigned int ) ulHighFrequencyTimerInterrupts ); xQueueSend( xLCDQueue, &xMessage, mainDONT_WAIT ); vParTestToggleLED( mainCHECK_LED ); } }
static short prvCheckOtherTasksAreStillRunning( void ) { portBASE_TYPE lReturn = pdPASS; /* The demo tasks maintain a count that increments every cycle of the task provided that the task has never encountered an error. This function checks the counts maintained by the tasks to ensure they are still being incremented. A count remaining at the same value between calls therefore indicates that an error has been detected. */ if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreComTestTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreMathsTaskStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xIsCreateTaskStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if ( xAreGenericQueueTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if ( xAreQueuePeekTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } /* Have the register test tasks found any errors? */ if( ulRegTestError != pdFALSE ) { lReturn = pdFAIL; } return lReturn; }
static void prvCheckTask( void *pvParameters ) { TickType_t xDelayPeriod = mainNO_ERROR_DELAY, xLastWakeTime; unsigned portBASE_TYPE uxLEDToUse = 0; /* Ensure parameter is passed in correctly. */ if( pvParameters != mainCHECK_PARAMETER ) { xDelayPeriod = mainERROR_DELAY; } /* Initialise xLastWakeTime before it is used. After this point it is not written to directly. */ xLastWakeTime = xTaskGetTickCount(); /* Cycle for ever, delaying then checking all the other tasks are still operating without error. */ for( ;; ) { /* Wait until it is time to check all the other tasks again. */ vTaskDelayUntil( &xLastWakeTime, xDelayPeriod ); if( lRegTestStatus != pdPASS ) { xDelayPeriod = mainERROR_DELAY; } if( xAreGenericQueueTasksStillRunning() != pdTRUE ) { xDelayPeriod = mainERROR_DELAY; } if( xAreQueuePeekTasksStillRunning() != pdTRUE ) { xDelayPeriod = mainERROR_DELAY; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { xDelayPeriod = mainERROR_DELAY; } if( xIsCreateTaskStillRunning() != pdTRUE ) { xDelayPeriod = mainERROR_DELAY; } /* The Fx3 runs more tasks, so more checks are performed. */ #ifdef __IAR_V850ES_Fx3__ { if( xAreComTestTasksStillRunning() != pdTRUE ) { xDelayPeriod = mainERROR_DELAY; } if( xArePollingQueuesStillRunning() != pdTRUE ) { xDelayPeriod = mainERROR_DELAY; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { xDelayPeriod = mainERROR_DELAY; } if( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) { xDelayPeriod = mainERROR_DELAY; } /* The application board has more LEDs and uses the flash tasks so the check task instead uses LED3 as LED3 is still spare. */ uxLEDToUse = 3; } #endif /* Toggle the LED. The toggle rate will depend on whether or not an error has been found in any tasks. */ vParTestToggleLED( uxLEDToUse ); } }
/* * See the documentation at the top of this file. */ static void vErrorChecks( void *pvParameters ) { portBASE_TYPE xErrorHasOccurred = pdFALSE; /* Just to prevent compiler warnings. */ ( void ) pvParameters; /* Cycle for ever, delaying then checking all the other tasks are still operating without error. The delay period depends on whether an error has ever been detected. */ for( ;; ) { if( xLatchedError == pdFALSE ) { /* No errors have been detected so delay for a longer period. The on board LED will get toggled every mainNO_ERROR_FLASH_PERIOD ms. */ vTaskDelay( mainNO_ERROR_FLASH_PERIOD ); } else { /* We have at some time recognised an error in one of the demo application tasks, delay for a shorter period. The on board LED will get toggled every mainERROR_FLASH_PERIOD ms. */ vTaskDelay( mainERROR_FLASH_PERIOD ); } /* Check the demo application tasks for errors. */ if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { xErrorHasOccurred = pdTRUE; } if( xArePollingQueuesStillRunning() != pdTRUE ) { xErrorHasOccurred = pdTRUE; } if( xAreComTestTasksStillRunning() != pdTRUE ) { xErrorHasOccurred = pdTRUE; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { xErrorHasOccurred = pdTRUE; } /* If an error has occurred, latch it to cause the LED flash rate to increase. */ if( xErrorHasOccurred == pdTRUE ) { xLatchedError = pdTRUE; } /* Toggle the LED to indicate the completion of a check cycle. The frequency of check cycles is dependent on whether or not we have latched an error. */ prvToggleOnBoardLED(); } }
static long prvCheckOtherTasksAreStillRunning( void ) { long lReturn = pdPASS; unsigned long ulHighFrequencyTimerTaskIterations, ulExpectedIncFrequency_ms; /* 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( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreComTestTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if ( xAreGenericQueueTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( prvAreRegTestTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xIsCreateTaskStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreTimerDemoTasksStillRunning( mainNO_ERROR_FLASH_PERIOD_MS ) != pdTRUE ) { lReturn = pdFAIL; } if( xArePollingQueuesStillRunning() != pdTRUE ) { lReturn = pdFAIL; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { lReturn = pdFAIL; } /* Obtain the number of times the task associated with the high frequency (interrupt nesting) timer test has increment since the check task last executed, and the frequency at which it is expected to execute in ms. */ ulHighFrequencyTimerTaskIterations = ulInterruptNestingTestGetIterationCount( &ulExpectedIncFrequency_ms ); if( ( ulHighFrequencyTimerTaskIterations < ( ( mainNO_ERROR_FLASH_PERIOD_MS / ulExpectedIncFrequency_ms ) - 1 ) ) || ( ulHighFrequencyTimerTaskIterations > ( ( mainNO_ERROR_FLASH_PERIOD_MS / ulExpectedIncFrequency_ms ) +5 ) ) ) { /* Would have expected the high frequency timer task to have incremented its execution count more times that reported. */ lReturn = pdFAIL; } return lReturn; }
static short prvCheckOtherTasksAreStillRunning( void ) { static short sNoErrorFound = pdTRUE; /* The demo tasks maintain a count that increments every cycle of the task provided that the task has never encountered an error. This function checks the counts maintained by the tasks to ensure they are still being incremented. A count remaining at the same value between calls therefore indicates that an error has been detected. Only tasks that do not flash an LED are checked. */ if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } if( xArePollingQueuesStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } if( xAreFlashCoRoutinesStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } if( xAreGenericQueueTasksStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } if( xIsCreateTaskStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } #if INCLUDE_TraceListTasks == 0 { if( xAreComTestTasksStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } } #endif return sNoErrorFound; }
static void vCheckTask( void *pvParameters ) { /* Used to wake the task at the correct frequency. */ TickType_t xLastExecutionTime; /* The maximum jitter time measured by the fast interrupt test. */ extern unsigned short usMaxJitter ; /* Buffer into which the maximum jitter time is written as a string. */ static char cStringBuffer[ mainMAX_STRING_LENGTH ]; /* The message that is sent on the queue to the LCD task. The first parameter is the minimum time (in ticks) that the message should be left on the LCD without being overwritten. The second parameter is a pointer to the message to display itself. */ xLCDMessage xMessage = { 0, cStringBuffer }; /* Set to pdTRUE should an error be detected in any of the standard demo tasks. */ unsigned short usErrorDetected = pdFALSE; /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil() works correctly. */ xLastExecutionTime = xTaskGetTickCount(); for( ;; ) { /* Wait until it is time for the next cycle. */ vTaskDelayUntil( &xLastExecutionTime, mainCHECK_TASK_PERIOD ); /* Has an error been found in any of the standard demo tasks? */ if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { usErrorDetected = pdTRUE; sprintf( cStringBuffer, "FAIL #1" ); } if( xAreComTestTasksStillRunning() != pdTRUE ) { usErrorDetected = pdTRUE; sprintf( cStringBuffer, "FAIL #2" ); } if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { usErrorDetected = pdTRUE; sprintf( cStringBuffer, "FAIL #3" ); } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { usErrorDetected = pdTRUE; sprintf( cStringBuffer, "FAIL #4" ); } if( usErrorDetected == pdFALSE ) { /* No errors have been discovered, so display the maximum jitter timer discovered by the "fast interrupt test". */ sprintf( cStringBuffer, "%dns max jitter", ( short ) ( usMaxJitter - mainEXPECTED_CLOCKS_BETWEEN_INTERRUPTS ) * mainNS_PER_CLOCK ); } /* Send the message to the LCD gatekeeper for display. */ xQueueSend( xLCDQueue, &xMessage, portMAX_DELAY ); } }
static void vCheckTask( void *pvParameters ) { static unsigned long ulErrorDetected = pdFALSE; portTickType xLastExecutionTime; unsigned char *ucErrorMessage = ( unsigned char * )" FAIL"; unsigned char *ucSuccessMessage = ( unsigned char * )" PASS"; unsigned portBASE_TYPE uxColumn = mainMAX_WRITE_COLUMN; LCDMessage xMessage; /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil() works correctly. */ xLastExecutionTime = xTaskGetTickCount(); for( ;; ) { /* Wait until it is time for the next cycle. */ vTaskDelayUntil( &xLastExecutionTime, mainCHECK_TASK_CYCLE_TIME ); /* Has an error been found in any of the standard demo tasks? */ if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { ulErrorDetected = pdTRUE; } if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { ulErrorDetected = pdTRUE; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { ulErrorDetected = pdTRUE; } if( xAreComTestTasksStillRunning() != pdTRUE ) { ulErrorDetected = pdTRUE; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { ulErrorDetected = pdTRUE; } /* Calculate the LCD line on which we would like the message to be displayed. The column variable is used for convenience as it is incremented each cycle anyway. */ xMessage.ucLine = ( unsigned char ) ( uxColumn & 0x01 ); /* The message displayed depends on whether an error was found or not. Any discovered error is latched. Here the column variable is used as an index into the text string as a simple way of moving the text from column to column. */ if( ulErrorDetected == pdFALSE ) { xMessage.pucString = ucSuccessMessage + uxColumn; } else { xMessage.pucString = ucErrorMessage + uxColumn; } /* Send the message to the print task for display. */ xQueueSend( xLCDQueue, ( void * ) &xMessage, mainNO_DELAY ); /* Make sure the message is printed in a different column the next time around. */ uxColumn--; if( uxColumn == 0 ) { uxColumn = mainMAX_WRITE_COLUMN; } } }
static void prvCheckTask( void * pvParameters ) { portTickType xNextWakeTime, xPeriod = mainNO_ERROR_PERIOD; static volatile unsigned long ulErrorCode = 0UL; /* Just to remove the compiler warning. */ ( void ) pvParameters; /* Initialise xNextWakeTime prior to its first use. From this point on the value of the variable is handled automatically by the kernel. */ xNextWakeTime = xTaskGetTickCount(); for( ;; ) { /* Delay until it is time for this task to execute again. */ vTaskDelayUntil( &xNextWakeTime, xPeriod ); /* Check all the other tasks in the system - latch any reported errors into the ulErrorCode variable. */ if( xAreBlockingQueuesStillRunning() != pdTRUE ) { ulErrorCode |= 0x01UL; } if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { ulErrorCode |= 0x02UL; } if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE ) { ulErrorCode |= 0x04UL; } if( xIsCreateTaskStillRunning() != pdTRUE ) { ulErrorCode |= 0x08UL; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { ulErrorCode |= 0x10UL; } if( xAreGenericQueueTasksStillRunning() != pdTRUE ) { ulErrorCode |= 0x20UL; } if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { ulErrorCode |= 0x40UL; } if( xArePollingQueuesStillRunning() != pdTRUE ) { ulErrorCode |= 0x80UL; } if( xAreQueuePeekTasksStillRunning() != pdTRUE ) { ulErrorCode |= 0x100UL; } if( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) { ulErrorCode |= 0x200UL; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { ulErrorCode |= 0x400UL; } if( xAreComTestTasksStillRunning() != pdTRUE ) { ulErrorCode |= 0x800UL; } /* Reduce the block period and in so doing increase the frequency at which this task executes if any errors have been latched. The increased frequency causes the LED toggle rate to increase and so gives some visual feedback that an error has occurred. */ if( ulErrorCode != 0x00 ) { xPeriod = mainERROR_PERIOD; } /* Finally toggle the LED. */ vParTestToggleLED( LED_POWER ); } }
static void prvCheckOtherTasksAreStillRunning( void ) { static portSHORT sErrorHasOccurred = pdFALSE; if( prvCheckMathTasksAreStillRunning() != pdTRUE ) { vDisplayMessage( "Maths task count unchanged!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreComTestTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Com test count unchanged!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { vDisplayMessage( "Blocking queues count unchanged!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreAltBlockingQueuesStillRunning() != pdTRUE ) { vDisplayMessage( "Alt blocking queues count unchanged!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xArePollingQueuesStillRunning() != pdTRUE ) { vDisplayMessage( "Polling queue count unchanged!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreAltPollingQueuesStillRunning() != pdTRUE ) { vDisplayMessage( "Alt polling queue count unchanged!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xIsCreateTaskStillRunning() != pdTRUE ) { vDisplayMessage( "Incorrect number of tasks running!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Semaphore take count unchanged!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Dynamic priority count unchanged!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreMultiEventTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Error in multi events tasks!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreFlashCoRoutinesStillRunning() != pdTRUE ) { vDisplayMessage( "Error in co-routine flash tasks!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreHookCoRoutinesStillRunning() != pdTRUE ) { vDisplayMessage( "Error in tick hook to co-routine communications!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Error in block time test tasks!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreAltBlockTimeTestTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Error in fast block time test tasks!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreGenericQueueTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Error in generic queue test task!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreAltGenericQueueTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Error in fast generic queue test task!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreQueuePeekTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Error in queue peek test task!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Error in counting semaphore demo task!\r\n" ); sErrorHasOccurred = pdTRUE; } if( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) { vDisplayMessage( "Error in recursive mutex tasks!\r\n" ); sErrorHasOccurred = pdTRUE; } if( sErrorHasOccurred == pdFALSE ) { vDisplayMessage( "OK " ); } }
static void prvCheckTask( void *pvParameters ) { portTickType xDelayPeriod = mainNO_ERROR_CHECK_TASK_PERIOD; portTickType xLastExecutionTime; static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0; unsigned long ulErrorFound = pdFALSE; /* Just to stop compiler warnings. */ ( void ) pvParameters; /* Initialise xLastExecutionTime so the first call to vTaskDelayUntil() works correctly. */ xLastExecutionTime = xTaskGetTickCount(); /* Cycle for ever, delaying then checking all the other tasks are still operating without error. The onboard LED is toggled on each iteration. If an error is detected then the delay period is decreased from mainNO_ERROR_CHECK_TASK_PERIOD to mainERROR_CHECK_TASK_PERIOD. This has the effect of increasing the rate at which the onboard LED toggles, and in so doing gives visual feedback of the system status. */ for( ;; ) { /* Delay until it is time to execute again. */ vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod ); /* 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( 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( xAreSemaphoreTasksStillRunning() != pdTRUE ) { ulErrorFound = pdTRUE; } if( xAreTimerDemoTasksStillRunning( ( portTickType ) mainNO_ERROR_CHECK_TASK_PERIOD ) != pdPASS ) { ulErrorFound = pdTRUE; } if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE ) { ulErrorFound = pdTRUE; } if( xIsQueueOverwriteTaskStillRunning() != pdPASS ) { ulErrorFound = pdTRUE; } #if mainINCLUDE_FAT_SL_DEMO == 0 { if( xAreComTestTasksStillRunning() != pdTRUE ) { ulErrorFound = pdTRUE; } } #endif /* 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 mainNO_ERROR_CHECK_TASK_PERIOD milliseconds then everything is ok. A faster toggle indicates an error. */ vParTestToggleLED( mainCHECK_LED ); if( ulErrorFound != pdFALSE ) { /* An error has been detected in one of the tasks - flash the LED at a higher frequency to give visible feedback that something has gone wrong (it might just be that the loop back connector required by the comtest tasks has not been fitted). */ xDelayPeriod = mainERROR_CHECK_TASK_PERIOD; } } }
static void prvCheckTimerCallback( TimerHandle_t xTimer ) { static long lChangedTimerPeriodAlready = pdFALSE; static unsigned long ulLastRegTest1Value = 0, ulLastRegTest2Value = 0; /* Buffer into which the high frequency timer count is written as a string. */ static char cStringBuffer[ mainMAX_STRING_LENGTH ]; /* The count of the high frequency timer interrupts. */ extern unsigned long ulHighFrequencyTimerInterrupts; static xLCDMessage xMessage = { ( 200 / portTICK_PERIOD_MS ), cStringBuffer }; /* Check that the register test 1 task is still running. */ if( ulLastRegTest1Value == ulRegTest1Cycles ) { xMessage.pcMessage = "Error: Reg test2"; } ulLastRegTest1Value = ulRegTest1Cycles; /* Check that the register test 2 task is still running. */ if( ulLastRegTest2Value == ulRegTest2Cycles ) { xMessage.pcMessage = "Error: Reg test3"; } ulLastRegTest2Value = ulRegTest2Cycles; /* Have any of the standard demo tasks detected an error in their operation? */ if( xAreGenericQueueTasksStillRunning() != pdTRUE ) { xMessage.pcMessage = "Error: Gen Q"; } else if( xAreQueuePeekTasksStillRunning() != pdTRUE ) { xMessage.pcMessage = "Error: Q Peek"; } else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { xMessage.pcMessage = "Error: Blck time"; } else if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { xMessage.pcMessage = "Error: Sem test"; } else if( xAreIntQueueTasksStillRunning() != pdTRUE ) { xMessage.pcMessage = "Error: Int queue"; } #if !defined(__32MX795F512L__) else if( xAreComTestTasksStillRunning() != pdTRUE ) { xMessage.pcMessage = "Error: COM test"; } #endif if( xMessage.pcMessage != cStringBuffer ) { /* An error string has been logged. If the timer period has not yet been changed it should be changed now. Increasing the frequency of the LED gives visual feedback of the error status (although it is written to the LCD too!). */ 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 ); } } else { /* Write the ulHighFrequencyTimerInterrupts value to the string buffer. It will only be displayed if no errors have been detected. */ sprintf( cStringBuffer, "Pass %u", ( unsigned int ) ulHighFrequencyTimerInterrupts ); } /* Send the status message to the LCD task for display on the LCD. This is a timer callback function, so the queue send function *must not* block. */ xQueueSend( xLCDQueue, &xMessage, mainDONT_BLOCK ); vParTestToggleLED( mainCHECK_LED ); }
/*-----------------------------------------------------------*/ static portSHORT prvCheckOtherTasksAreStillRunning( void ) { static portSHORT sNoErrorFound = pdTRUE; /* The demo tasks maintain a count that increments every cycle of the task provided that the task has never encountered an error. This function checks the counts maintained by the tasks to ensure they are still being incremented. A count remaining at the same value between calls therefore indicates that an error has been detected. Only tasks that do not flash an LED are checked. */ #if ( INCLUDE_StartIntegerMathTasks == 1 ) if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } #endif #if ( INCLUDE_AltStartComTestTasks == 1 ) if( xAreComTestTasksStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } #endif #if ( INCLUDE_StartPolledQueueTasks == 1 ) if( xArePollingQueuesStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } #endif #if ( INCLUDE_StartSemaphoreTasks == 1 ) if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } #endif #if ( INCLUDE_StartBlockingQueueTasks == 1 ) if( xAreBlockingQueuesStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } #endif #if ( INCLUDE_StartDynamicPriorityTasks == 1 ) if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } #endif #if ( INCLUDE_StartMathTasks == 1 ) if( xAreMathsTaskStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } #endif #if ( INCLUDE_StartFlashCoRoutines == 1 ) if( xAreFlashCoRoutinesStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } #endif #if ( INCLUDE_StartHookCoRoutines == 1 ) if( xAreHookCoRoutinesStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } #endif #if ( INCLUDE_StartGenericQueueTasks == 1 ) if( xAreGenericQueueTasksStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } #endif #if ( INCLUDE_StartQueuePeekTasks == 1 ) if( xAreQueuePeekTasksStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } #endif #if ( INCLUDE_CreateBlockTimeTasks == 1 ) if( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } #endif #if ( INCLUDE_CreateSuicidalTasks == 1 ) if( xIsCreateTaskStillRunning() != pdTRUE ) { sNoErrorFound = pdFALSE; } #endif return sNoErrorFound; }