int main( void ) { #ifdef DEBUG debug(); #endif prvSetupHardware(); /* Create the queue used by the LCD task. Messages for display on the LCD are received via this queue. */ xLCDQueue = xQueueCreate( mainLCD_QUEUE_SIZE, sizeof( xLCDMessage ) ); /* Start the standard demo tasks. */ vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); vCreateBlockTimeTasks(); vStartGenericQueueTasks( mainGEN_Q_PRIORITY ); vStartQueuePeekTasks(); vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY ); /* Start the tasks defined within this file/specific to this demo. */ xTaskCreate( prvCheckTask, ( signed portCHAR * ) "Check", mainCHECK_TASK_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL ); xTaskCreate( prvLCDTask, ( signed portCHAR * ) "LCD", configLCD_TASK_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ); xTaskCreate( prvFlashTask, ( signed portCHAR * ) "Flash", configMINIMAL_STACK_SIZE, NULL, mainFLASH_TASK_PRIORITY, NULL ); /* Configure the timers used by the fast interrupt timer test. */ vSetupTimerTest(); /* Start the scheduler. */ vTaskStartScheduler(); /* Will only get here if there was not enough heap space to create the idle task. */ return 0; }
/* * Create the demo tasks then start the scheduler. */ int main( void ) { /* Configure any hardware required for this demo. */ prvSetupHardware(); /* Create the standard demo tasks. */ vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); vStartIntegerMathTasks( tskIDLE_PRIORITY ); vStartFlashCoRoutines( mainNUM_FLASH_COROUTINES ); vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED ); vCreateBlockTimeTasks(); /* Create the test tasks defined within this file. */ xTaskCreate( vCheckTask, "Check", mainCHECK_TAKS_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL ); /* Start the task that will control the LCD. This returns the handle to the queue used to write text out to the task. */ xLCDQueue = xStartLCDTask(); /* Start the high frequency interrupt test. */ vSetupTimerTest( mainTEST_INTERRUPT_FREQUENCY ); /* Finally start the scheduler. */ vTaskStartScheduler(); /* Will only reach here if there is insufficient heap available to start the scheduler. */ return 0; }
static void prvSetupHighFrequencyTimerTest( TimerHandle_t xTimer ) { /* Setup the high frequency, high priority, timer test. It is setup in this software timer callback to ensure it does not start before the kernel does. This is a one shot timer - so the setup routine will only be executed once. */ vSetupTimerTest( mainTEST_INTERRUPT_FREQUENCY ); }
static void prvSetupHighFrequencyTimerTest( xTimerHandle xTimer ) { void vSetupTimerTest( unsigned short usFrequencyHz ); /* Avoid compiler warnings. */ ( void ) xTimer; /* Setup the high frequency, high priority, timer test. It is setup in this software timer callback to ensure it does not start before the kernel does. This is a one shot timer - so the setup routine will only be executed once. */ vSetupTimerTest( mainTEST_INTERRUPT_FREQUENCY ); }
void main( void ) { /* Place your initialization/startup code here (e.g. MyInst_Start()) */ prvHardwareSetup(); /* Start the standard demo tasks. These are just here to exercise the kernel port and provide examples of how the FreeRTOS API can be used. */ vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); vCreateBlockTimeTasks(); vStartCountingSemaphoreTasks(); vStartDynamicPriorityTasks(); vStartMathTasks( mainINTEGER_TASK_PRIORITY ); vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY ); vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY ); vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY ); vStartQueuePeekTasks(); vStartSemaphoreTasks( mainSEM_TEST_PRIORITY ); vStartLEDFlashTasks( mainFLASH_TEST_TASK_PRIORITY ); vAltStartComTestTasks( mainCOM_TEST_TASK_PRIORITY, 57600, mainCOM_LED ); vStartInterruptQueueTasks(); /* Start the error checking task. */ ( void ) xTaskCreate( vCheckTask, ( signed portCHAR * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL ); /* Configure the timers used by the fast interrupt timer test. */ vSetupTimerTest(); /* The suicide tasks must be created last as they need to know how many tasks were running prior to their creation in order to ascertain whether or not the correct/expected number of tasks are running at any given time. */ vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY ); /* Will only get here if there was insufficient memory to create the idle task. The idle task is created within vTaskStartScheduler(). */ vTaskStartScheduler(); /* Should never reach here as the kernel will now be running. If vTaskStartScheduler() does return then it is very likely that there was insufficient (FreeRTOS) heap space available to create all the tasks, including the idle task that is created within vTaskStartScheduler() itself. */ for( ;; ); }
int main( void ) { #ifdef DEBUG debug(); #endif prvSetupHardware(); /* Create the queue used by the LCD task. Messages for display on the LCD are received via this queue. */ xLCDQueue = xQueueCreate( mainLCD_QUEUE_SIZE, sizeof( xLCDMessage ) ); /* Start the standard demo tasks. */ vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); vCreateBlockTimeTasks(); vStartSemaphoreTasks( mainSEM_TEST_PRIORITY ); vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY ); vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY ); vStartLEDFlashTasks( mainFLASH_TASK_PRIORITY ); vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED ); /* Start the tasks defined within this file/specific to this demo. */ xTaskCreate( vCheckTask, ( signed portCHAR * ) "Check", mainCHECK_TASK_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL ); xTaskCreate( vLCDTask, ( signed portCHAR * ) "LCD", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL ); /* The suicide tasks must be created last as they need to know how many tasks were running prior to their creation in order to ascertain whether or not the correct/expected number of tasks are running at any given time. */ vCreateSuicidalTasks( mainCREATOR_TASK_PRIORITY ); /* Configure the timers used by the fast interrupt timer test. */ vSetupTimerTest(); /* Start the scheduler. */ vTaskStartScheduler(); /* Will only get here if there was not enough heap space to create the idle task. */ return 0; }
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 ); } }