这篇教程C++ vPrintDisplayMessage函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中vPrintDisplayMessage函数的典型用法代码示例。如果您正苦于以下问题:C++ vPrintDisplayMessage函数的具体用法?C++ vPrintDisplayMessage怎么用?C++ vPrintDisplayMessage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了vPrintDisplayMessage函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: portTASK_FUNCTIONstatic portTASK_FUNCTION( vPolledQueueProducer, pvParameters ){ unsigned portSHORT usValue = ( unsigned portSHORT ) 0; signed portBASE_TYPE xError = pdFALSE, xLoop;#ifdef USE_STDIO void vPrintDisplayMessage( const portCHAR * const * ppcMessageToSend ); const portCHAR * const pcTaskStartMsg = "Alt polling queue producer task started./r/n"; /* Queue a message for printing to say the task has started. */ vPrintDisplayMessage( &pcTaskStartMsg );#endif for( ;; ) { for( xLoop = 0; xLoop < pollqVALUES_TO_PRODUCE; xLoop++ ) { /* Send an incrementing number on the queue without blocking. */ if( xQueueAltSendToBack( *( ( xQueueHandle * ) pvParameters ), ( void * ) &usValue, pollqNO_DELAY ) != pdPASS ) { /* We should never find the queue full so if we get here there has been an error. */ xError = pdTRUE; } else { if( xError == pdFALSE ) { /* If an error has ever been recorded we stop incrementing the check variable. */ portENTER_CRITICAL(); xPollingProducerCount++; portEXIT_CRITICAL(); } /* Update the value we are going to post next time around. */ usValue++; } } /* Wait before we start posting again to ensure the consumer runs and empties the queue. */ vTaskDelay( pollqPRODUCER_DELAY ); }} /*lint !e818 Function prototype must conform to API. */
开发者ID:ya-mouse,项目名称:freertos-np51x0,代码行数:46,
示例2: portTASK_FUNCTIONstatic portTASK_FUNCTION( vBlockingQueueConsumer, pvParameters ){unsigned portSHORT usData, usExpectedValue = 0;xBlockingQueueParameters *pxQueueParameters;portSHORT sErrorEverOccurred = pdFALSE; #ifdef USE_STDIO void vPrintDisplayMessage( const portCHAR * const * ppcMessageToSend ); const portCHAR * const pcTaskStartMsg = "Alt blocking queue consumer task started./r/n"; /* Queue a message for printing to say the task has started. */ vPrintDisplayMessage( &pcTaskStartMsg ); #endif pxQueueParameters = ( xBlockingQueueParameters * ) pvParameters; for( ;; ) { if( xQueueAltReceive( pxQueueParameters->xQueue, &usData, pxQueueParameters->xBlockTime ) == pdPASS ) { if( usData != usExpectedValue ) { /* Catch-up. */ usExpectedValue = usData; sErrorEverOccurred = pdTRUE; } else { /* We have successfully received a message, so increment the variable used to check we are still running. */ if( sErrorEverOccurred == pdFALSE ) { ( *pxQueueParameters->psCheckVariable )++; } /* Increment the value we expect to remove from the queue next time round. */ ++usExpectedValue; } } }}
开发者ID:InSoonPark,项目名称:FreeRTOS,代码行数:44,
示例3: prvLowPriorityMutexTaskstatic void prvLowPriorityMutexTask( void *pvParameters ){SemaphoreHandle_t xMutex = ( SemaphoreHandle_t ) pvParameters, xLocalMutex; #ifdef USE_STDIO void vPrintDisplayMessage( const char * const * ppcMessageToSend ); const char * const pcTaskStartMsg = "Mutex with priority inheritance test started./r/n"; /* Queue a message for printing to say the task has started. */ vPrintDisplayMessage( &pcTaskStartMsg ); #endif /* The local mutex is used to check the 'mutexs held' count. */ xLocalMutex = xSemaphoreCreateMutex(); configASSERT( xLocalMutex ); for( ;; ) { /* The first tests exercise the priority inheritance when two mutexes are taken then returned in a different order to which they were taken. */ prvTakeTwoMutexesReturnInDifferentOrder( xMutex, xLocalMutex ); /* Just to show this task is still running. */ ulLoopCounter2++; #if configUSE_PREEMPTION == 0 taskYIELD(); #endif /* The second tests exercise the priority inheritance when two mutexes are taken then returned in the same order in which they were taken. */ prvTakeTwoMutexesReturnInSameOrder( xMutex, xLocalMutex ); /* Just to show this task is still running. */ ulLoopCounter2++; #if configUSE_PREEMPTION == 0 taskYIELD(); #endif }}
开发者ID:LukasWoodtli,项目名称:QFreeRTOS,代码行数:43,
示例4: vLEDFlashTaskstatic void vLEDFlashTask( void *pvParameters ){xLEDParameters *pxParameters; /* Queue a message for printing to say the task has started. */ vPrintDisplayMessage( &pcTaskStartMsg ); pxParameters = ( xLEDParameters * ) pvParameters; for(;;) { /* Delay for half the flash period then turn the LED on. */ vTaskDelay( pxParameters->xFlashRate / ( TickType_t ) 2 ); vParTestToggleLED( pxParameters->uxLED ); /* Delay for half the flash period then turn the LED off. */ vTaskDelay( pxParameters->xFlashRate / ( TickType_t ) 2 ); vParTestToggleLED( pxParameters->uxLED ); }}
开发者ID:Eclo,项目名称:FreeRTOS,代码行数:20,
示例5: prvMultiEventTaskstatic void prvMultiEventTask( void *pvParameters ){portBASE_TYPE *pxCounter;unsigned portBASE_TYPE uxDummy;const portCHAR * const pcTaskStartMsg = "Multi event task started./r/n"; /* The variable this task will increment is passed in as a parameter. */ pxCounter = ( portBASE_TYPE * ) pvParameters; vPrintDisplayMessage( &pcTaskStartMsg ); for( ;; ) { /* Block on the queue. */ if( xQueueReceive( xQueue, &uxDummy, portMAX_DELAY ) ) { /* We unblocked by reading the queue - so simply increment the counter specific to this task instance. */ ( *pxCounter )++; } }}
开发者ID:Paolo-Maffei,项目名称:ninostack,代码行数:22,
示例6: prvCountingSemaphoreTaskstatic void prvCountingSemaphoreTask( void *pvParameters ){xCountSemStruct *pxParameter; #ifdef USE_STDIO void vPrintDisplayMessage( const char * const * ppcMessageToSend ); const char * const pcTaskStartMsg = "Counting semaphore demo started./r/n"; /* Queue a message for printing to say the task has started. */ vPrintDisplayMessage( &pcTaskStartMsg ); #endif /* The semaphore to be used was passed as the parameter. */ pxParameter = ( xCountSemStruct * ) pvParameters; /* Did we expect to find the semaphore already at its max count value, or at zero? */ if( pxParameter->uxExpectedStartCount == countSTART_AT_MAX_COUNT ) { prvDecrementSemaphoreCount( pxParameter->xSemaphore, &( pxParameter->uxLoopCounter ) ); } /* Now we expect the semaphore count to be 0, so this time there is an error if we can take the semaphore. */ if( xSemaphoreTake( pxParameter->xSemaphore, 0 ) == pdPASS ) { xErrorDetected = pdTRUE; } for( ;; ) { prvIncrementSemaphoreCount( pxParameter->xSemaphore, &( pxParameter->uxLoopCounter ) ); prvDecrementSemaphoreCount( pxParameter->xSemaphore, &( pxParameter->uxLoopCounter ) ); }}
开发者ID:bryanclark90,项目名称:Autonomous-Car,代码行数:36,
示例7: prvEventControllerTaskstatic void prvEventControllerTask( void *pvParameters ){const char * const pcTaskStartMsg = "Multi event controller task started./r/n";portBASE_TYPE xDummy = 0; /* Just to stop warnings. */ ( void ) pvParameters; vPrintDisplayMessage( &pcTaskStartMsg ); for( ;; ) { /* All tasks are blocked on the queue. When a message is posted one of the two tasks that share the highest priority should unblock to read the queue. The next message written should unblock the other task with the same high priority, and so on in order. No other task should unblock to read data as they have lower priorities. */ prvCheckTaskCounters( evtHIGHEST_PRIORITY_INDEX_1, 1 ); prvCheckTaskCounters( evtHIGHEST_PRIORITY_INDEX_2, 1 ); prvCheckTaskCounters( evtHIGHEST_PRIORITY_INDEX_1, 1 ); prvCheckTaskCounters( evtHIGHEST_PRIORITY_INDEX_2, 1 ); prvCheckTaskCounters( evtHIGHEST_PRIORITY_INDEX_1, 1 ); /* For the rest of these tests we don't need the second 'highest' priority task - so it is suspended. */ vTaskSuspend( xCreatedTasks[ evtHIGHEST_PRIORITY_INDEX_2 ] ); /* Now suspend the other highest priority task. The medium priority task will then be the task with the highest priority that remains blocked on the queue. */ vTaskSuspend( xCreatedTasks[ evtHIGHEST_PRIORITY_INDEX_1 ] ); /* This time, when we post onto the queue we will expect the medium priority task to unblock and preempt us. */ prvCheckTaskCounters( evtMEDIUM_PRIORITY_INDEX, 1 ); /* Now try resuming the highest priority task while the scheduler is suspended. The task should start executing as soon as the scheduler is resumed - therefore when we post to the queue again, the highest priority task should again preempt us. */ vTaskSuspendAll(); vTaskResume( xCreatedTasks[ evtHIGHEST_PRIORITY_INDEX_1 ] ); xTaskResumeAll(); prvCheckTaskCounters( evtHIGHEST_PRIORITY_INDEX_1, 1 ); /* Now we are going to suspend the high and medium priority tasks. The low priority task should then preempt us. Again the task suspension is done with the whole scheduler suspended just for test purposes. */ vTaskSuspendAll(); vTaskSuspend( xCreatedTasks[ evtHIGHEST_PRIORITY_INDEX_1 ] ); vTaskSuspend( xCreatedTasks[ evtMEDIUM_PRIORITY_INDEX ] ); xTaskResumeAll(); prvCheckTaskCounters( evtLOWEST_PRIORITY_INDEX, 1 ); /* Do the same basic test another few times - selectively suspending and resuming tasks and each time calling prvCheckTaskCounters() passing to the function the number of the task we expected to be unblocked by the post. */ vTaskResume( xCreatedTasks[ evtHIGHEST_PRIORITY_INDEX_1 ] ); prvCheckTaskCounters( evtHIGHEST_PRIORITY_INDEX_1, 1 ); vTaskSuspendAll(); /* Just for test. */ vTaskSuspendAll(); /* Just for test. */ vTaskSuspendAll(); /* Just for even more test. */ vTaskSuspend( xCreatedTasks[ evtHIGHEST_PRIORITY_INDEX_1 ] ); xTaskResumeAll(); xTaskResumeAll(); xTaskResumeAll(); prvCheckTaskCounters( evtLOWEST_PRIORITY_INDEX, 1 ); vTaskResume( xCreatedTasks[ evtMEDIUM_PRIORITY_INDEX ] ); prvCheckTaskCounters( evtMEDIUM_PRIORITY_INDEX, 1 ); vTaskResume( xCreatedTasks[ evtHIGHEST_PRIORITY_INDEX_1 ] ); prvCheckTaskCounters( evtHIGHEST_PRIORITY_INDEX_1, 1 ); /* Now a slight change, first suspend all tasks. */ vTaskSuspend( xCreatedTasks[ evtHIGHEST_PRIORITY_INDEX_1 ] ); vTaskSuspend( xCreatedTasks[ evtMEDIUM_PRIORITY_INDEX ] ); vTaskSuspend( xCreatedTasks[ evtLOWEST_PRIORITY_INDEX ] ); /* Now when we resume the low priority task and write to the queue 3 times. We expect the low priority task to service the queue three times. */ vTaskResume( xCreatedTasks[ evtLOWEST_PRIORITY_INDEX ] ); prvCheckTaskCounters( evtLOWEST_PRIORITY_INDEX, evtQUEUE_LENGTH ); /* Again suspend all tasks (only the low priority task is not suspended already). */ vTaskSuspend( xCreatedTasks[ evtLOWEST_PRIORITY_INDEX ] ); /* This time we are going to suspend the scheduler, resume the low priority task, then resume the high priority task. In this state we will write to the queue three times. When the scheduler is resumed we expect the high priority task to service all three messages. */ vTaskSuspendAll();//.........这里部分代码省略.........
开发者ID:SongHerz,项目名称:FreeRTOS_Simulator,代码行数:101,
示例8: vCounterControlTask/* * Controller task as described above. */static void vCounterControlTask( void * pvParameters ){unsigned long ulLastCounter;short sLoops;short sError = pdFALSE;const char * const pcTaskStartMsg = "Priority manipulation tasks started./r/n";const char * const pcTaskFailMsg = "Priority manipulation Task Failed/r/n"; /* Just to stop warning messages. */ ( void ) pvParameters; /* Queue a message for printing to say the task has started. */ vPrintDisplayMessage( &pcTaskStartMsg ); for( ;; ) { /* Start with the counter at zero. */ ulCounter = ( unsigned long ) 0; /* First section : */ /* Check the continuous count task is running. */ for( sLoops = 0; sLoops < priLOOPS; sLoops++ ) { /* Suspend the continuous count task so we can take a mirror of the shared variable without risk of corruption. */ vTaskSuspend( xContinuousIncrementHandle ); ulLastCounter = ulCounter; vTaskResume( xContinuousIncrementHandle ); /* Now delay to ensure the other task has processor time. */ vTaskDelay( priSLEEP_TIME ); /* Check the shared variable again. This time to ensure mutual exclusion the whole scheduler will be locked. This is just for demo purposes! */ vTaskSuspendAll(); { if( ulLastCounter == ulCounter ) { /* The shared variable has not changed. There is a problem with the continuous count task so flag an error. */ sError = pdTRUE; xTaskResumeAll(); vPrintDisplayMessage( &pcTaskFailMsg ); vTaskSuspendAll(); } } xTaskResumeAll(); } /* Second section: */ /* Suspend the continuous counter task so it stops accessing the shared variable. */ vTaskSuspend( xContinuousIncrementHandle ); /* Reset the variable. */ ulCounter = ( unsigned long ) 0; /* Resume the limited count task which has a higher priority than us. We should therefore not return from this call until the limited count task has suspended itself with a known value in the counter variable. The scheduler suspension is not necessary but is included for test purposes. */ vTaskSuspendAll(); vTaskResume( xLimitedIncrementHandle ); xTaskResumeAll(); /* Does the counter variable have the expected value? */ if( ulCounter != priMAX_COUNT ) { sError = pdTRUE; vPrintDisplayMessage( &pcTaskFailMsg ); } if( sError == pdFALSE ) { /* If no errors have occurred then increment the check variable. */ portENTER_CRITICAL(); usCheckVariable++; portEXIT_CRITICAL(); } #if configUSE_PREEMPTION == 0 taskYIELD(); #endif /* Resume the continuous count task and do it all again. */ vTaskResume( xContinuousIncrementHandle ); }}
开发者ID:Cuixiaoxia198106,项目名称:freertos-sparc,代码行数:95,
示例9: prvHighestPriorityPeekTaskstatic void prvHighestPriorityPeekTask( void *pvParameters ){xQueueHandle xQueue = ( xQueueHandle ) pvParameters;unsigned portLONG ulValue; #ifdef USE_STDIO { void vPrintDisplayMessage( const portCHAR * const * ppcMessageToSend ); const portCHAR * const pcTaskStartMsg = "Queue peek test started./r/n"; /* Queue a message for printing to say the task has started. */ vPrintDisplayMessage( &pcTaskStartMsg ); } #endif for( ;; ) { /* Try peeking from the queue. The queue should be empty so we will block, allowing the high priority task to execute. */ if( xQueuePeek( xQueue, &ulValue, portMAX_DELAY ) != pdPASS ) { /* We expected to have received something by the time we unblock. */ xErrorDetected = pdTRUE; } /* When we reach here the high and medium priority tasks should still be blocked on the queue. We unblocked because the low priority task wrote a value to the queue, which we should have peeked. Peeking the data (rather than receiving it) will leave the data on the queue, so the high priority task should then have also been unblocked, but not yet executed. */ if( ulValue != 0x11223344 ) { /* We did not receive the expected value. */ xErrorDetected = pdTRUE; } if( uxQueueMessagesWaiting( xQueue ) != 1 ) { /* The message should have been left on the queue. */ xErrorDetected = pdTRUE; } /* Now we are going to actually receive the data, so when the high priority task runs it will find the queue empty and return to the blocked state. */ ulValue = 0; if( xQueueReceive( xQueue, &ulValue, qpeekNO_BLOCK ) != pdPASS ) { /* We expected to receive the value. */ xErrorDetected = pdTRUE; } if( ulValue != 0x11223344 ) { /* We did not receive the expected value - which should have been the same value as was peeked. */ xErrorDetected = pdTRUE; } /* Now we will block again as the queue is once more empty. The low priority task can then execute again. */ if( xQueuePeek( xQueue, &ulValue, portMAX_DELAY ) != pdPASS ) { /* We expected to have received something by the time we unblock. */ xErrorDetected = pdTRUE; } /* When we get here the low priority task should have again written to the queue. */ if( ulValue != 0x01234567 ) { /* We did not receive the expected value. */ xErrorDetected = pdTRUE; } if( uxQueueMessagesWaiting( xQueue ) != 1 ) { /* The message should have been left on the queue. */ xErrorDetected = pdTRUE; } /* We only peeked the data, so suspending ourselves now should enable the high priority task to also peek the data. The high priority task will have been unblocked when we peeked the data as we left the data in the queue. */ vTaskSuspend( NULL ); /* This time we are going to do the same as the above test, but the high priority task is going to receive the data, rather than peek it. This means that the medium priority task should never peek the value. */ if( xQueuePeek( xQueue, &ulValue, portMAX_DELAY ) != pdPASS ) { xErrorDetected = pdTRUE; } if( ulValue != 0xaabbaabb )//.........这里部分代码省略.........
开发者ID:darknesmonk,项目名称:freertos-5.1.2-lpc23xx,代码行数:101,
示例10: prvSemaphoreTeststatic void prvSemaphoreTest( void *pvParameters ){xSemaphoreParameters *pxParameters;volatile unsigned long *pulSharedVariable, ulExpectedValue;unsigned long ulCounter;short sError = pdFALSE, sCheckVariableToUse; /* See which check variable to use. sNextCheckVariable is not semaphore protected! */ portENTER_CRITICAL(); sCheckVariableToUse = sNextCheckVariable; sNextCheckVariable++; portEXIT_CRITICAL(); /* Queue a message for printing to say the task has started. */ vPrintDisplayMessage( &pcSemaphoreTaskStart ); /* A structure is passed in as the parameter. This contains the shared variable being guarded. */ pxParameters = ( xSemaphoreParameters * ) pvParameters; pulSharedVariable = pxParameters->pulSharedVariable; /* If we are blocking we use a much higher count to ensure loads of context switches occur during the count. */ if( pxParameters->xBlockTime > ( portTickType ) 0 ) { ulExpectedValue = semtstBLOCKING_EXPECTED_VALUE; } else { ulExpectedValue = semtstNON_BLOCKING_EXPECTED_VALUE; } for( ;; ) { /* Try to obtain the semaphore. */ if( xSemaphoreTake( pxParameters->xSemaphore, pxParameters->xBlockTime ) == pdPASS ) { /* We have the semaphore and so expect any other tasks using the shared variable to have left it in the state we expect to find it. */ if( *pulSharedVariable != ulExpectedValue ) { vPrintDisplayMessage( &pcPollingSemaphoreTaskError ); sError = pdTRUE; } /* Clear the variable, then count it back up to the expected value before releasing the semaphore. Would expect a context switch or two during this time. */ for( ulCounter = ( unsigned long ) 0; ulCounter <= ulExpectedValue; ulCounter++ ) { *pulSharedVariable = ulCounter; if( *pulSharedVariable != ulCounter ) { if( sError == pdFALSE ) { vPrintDisplayMessage( &pcPollingSemaphoreTaskError ); } sError = pdTRUE; } } /* Release the semaphore, and if no errors have occurred increment the check variable. */ if( xSemaphoreGive( pxParameters->xSemaphore ) == pdFALSE ) { vPrintDisplayMessage( &pcPollingSemaphoreTaskError ); sError = pdTRUE; } if( sError == pdFALSE ) { if( sCheckVariableToUse < semtstNUM_TASKS ) { ( sCheckVariables[ sCheckVariableToUse ] )++; } } /* If we have a block time then we are running at a priority higher than the idle priority. This task takes a long time to complete a cycle (deliberately so to test the guarding) so will be starving out lower priority tasks. Block for some time to allow give lower priority tasks some processor time. */ vTaskDelay( pxParameters->xBlockTime * semtstDELAY_FACTOR ); } else { if( pxParameters->xBlockTime == ( portTickType ) 0 ) { /* We have not got the semaphore yet, so no point using the processor. We are not blocking when attempting to obtain the semaphore. */ taskYIELD(); } } }}
开发者ID:ECEEmbedded,项目名称:ARMCodeRichardMS3,代码行数:98,
示例11: vComRxTaskstatic void vComRxTask( void *pvParameters ){const char * const pcTaskStartMsg = "COM Rx task started./r/n";const char * const pcTaskErrorMsg = "COM read error/r/n";const char * const pcTaskRestartMsg = "COM resynced/r/n";const char * const pcTaskTimeoutMsg = "COM Rx timed out/r/n";const portTickType xBlockTime = ( portTickType ) 0xffff / portTICK_RATE_MS;const char *pcExpectedChar;portBASE_TYPE xGotChar;char cRxedChar;short sResyncRequired, sConsecutiveErrors, sLatchedError; /* Stop warnings. */ ( void ) pvParameters; /* Queue a message for printing to say the task has started. */ vPrintDisplayMessage( &pcTaskStartMsg ); /* The first expected character is the first character in the string. */ pcExpectedChar = pcMessageToExchange; sResyncRequired = pdFALSE; sConsecutiveErrors = 0; sLatchedError = pdFALSE; for( ;; ) { /* Receive a message from the com port interrupt routine. If a message is not yet available the call will block the task. */ xGotChar = xSerialGetChar( xPort, &cRxedChar, xBlockTime ); if( xGotChar == pdTRUE ) { if( sResyncRequired == pdTRUE ) { /* We got out of sequence and are waiting for the start of the next transmission of the string. */ if( cRxedChar == '/n' ) { /* This is the end of the message so we can start again - with the first character in the string being the next thing we expect to receive. */ pcExpectedChar = pcMessageToExchange; sResyncRequired = pdFALSE; /* Queue a message for printing to say that we are going to try again. */ vPrintDisplayMessage( &pcTaskRestartMsg ); /* Stop incrementing the check variable, if consecutive errors occur. */ sConsecutiveErrors++; if( sConsecutiveErrors >= comMAX_CONSECUTIVE_ERRORS ) { sLatchedError = pdTRUE; } } } else { /* We have received a character, but is it the expected character? */ if( cRxedChar != *pcExpectedChar ) { /* This was not the expected character so post a message for printing to say that an error has occurred. We will then wait to resynchronise. */ vPrintDisplayMessage( &pcTaskErrorMsg ); sResyncRequired = pdTRUE; } else { /* This was the expected character so next time we will expect the next character in the string. Wrap back to the beginning of the string when the null terminator has been reached. */ pcExpectedChar++; if( *pcExpectedChar == '/0' ) { pcExpectedChar = pcMessageToExchange; /* We have got through the entire string without error. */ sConsecutiveErrors = 0; } } } /* Increment the count that is used to check that this task is still running. This is only done if an error has never occurred. */ if( sLatchedError == pdFALSE ) { sRxCount++; } } else { vPrintDisplayMessage( &pcTaskTimeoutMsg ); } }} /*lint !e715 !e818 pvParameters is required for a task function even if it is not referenced. */
开发者ID:ECEEmbedded,项目名称:ARMCodeRichardMS3,代码行数:95,
示例12: vSecondaryBlockTimeTestTaskstatic void vSecondaryBlockTimeTestTask( void *pvParameters ){portTickType xTimeWhenBlocking, xBlockedTime;portBASE_TYPE xData; #ifdef USE_STDIO void vPrintDisplayMessage( const portCHAR * const * ppcMessageToSend ); const portCHAR * const pcTaskStartMsg = "Alt secondary block time test started./r/n"; /* Queue a message for printing to say the task has started. */ vPrintDisplayMessage( &pcTaskStartMsg ); #endif ( void ) pvParameters; for( ;; ) { /********************************************************************* Test 1 and 2 This task does does not participate in these tests. */ vTaskSuspend( NULL ); /********************************************************************* Test 3 The first thing we do is attempt to read from the queue. It should be full so we block. Note the time before we block so we can check the wake time is as per that expected. */ portENTER_CRITICAL(); { xTimeWhenBlocking = xTaskGetTickCount(); /* We should unblock after bktTIME_TO_BLOCK having not received anything on the queue. */ xData = 0; xRunIndicator = bktRUN_INDICATOR; if( xQueueAltSendToBack( xTestQueue, &xData, bktTIME_TO_BLOCK ) != errQUEUE_FULL ) { xErrorOccurred = pdTRUE; } /* How long were we inside the send function? */ xBlockedTime = xTaskGetTickCount() - xTimeWhenBlocking; } portEXIT_CRITICAL(); /* We should not have blocked for less time than bktTIME_TO_BLOCK. */ if( xBlockedTime < bktTIME_TO_BLOCK ) { xErrorOccurred = pdTRUE; } /* We should of not blocked for much longer than bktALLOWABLE_MARGIN either. A margin is permitted as we would not necessarily run as soon as we unblocked. */ if( xBlockedTime > ( bktTIME_TO_BLOCK + bktALLOWABLE_MARGIN ) ) { xErrorOccurred = pdTRUE; } /* Suspend ready for test 3. */ xRunIndicator = bktRUN_INDICATOR; vTaskSuspend( NULL ); /********************************************************************* Test 4 As per test three, but with the send and receive reversed. */ portENTER_CRITICAL(); { xTimeWhenBlocking = xTaskGetTickCount(); /* We should unblock after bktTIME_TO_BLOCK having not received anything on the queue. */ xRunIndicator = bktRUN_INDICATOR; if( xQueueAltReceive( xTestQueue, &xData, bktTIME_TO_BLOCK ) != errQUEUE_EMPTY ) { xErrorOccurred = pdTRUE; } xBlockedTime = xTaskGetTickCount() - xTimeWhenBlocking; } portEXIT_CRITICAL(); /* We should not have blocked for less time than bktTIME_TO_BLOCK. */ if( xBlockedTime < bktTIME_TO_BLOCK ) { xErrorOccurred = pdTRUE; } /* We should of not blocked for much longer than bktALLOWABLE_MARGIN either. A margin is permitted as we would not necessarily run as soon as we unblocked. */ if( xBlockedTime > ( bktTIME_TO_BLOCK + bktALLOWABLE_MARGIN ) ) { xErrorOccurred = pdTRUE; }//.........这里部分代码省略.........
开发者ID:DonjetaE,项目名称:FreeRTOS,代码行数:101,
示例13: vPrimaryBlockTimeTestTaskstatic void vPrimaryBlockTimeTestTask( void *pvParameters ){portBASE_TYPE xItem, xData;portTickType xTimeWhenBlocking;portTickType xTimeToBlock, xBlockedTime; #ifdef USE_STDIO void vPrintDisplayMessage( const portCHAR * const * ppcMessageToSend ); const portCHAR * const pcTaskStartMsg = "Alt primary block time test started./r/n"; /* Queue a message for printing to say the task has started. */ vPrintDisplayMessage( &pcTaskStartMsg ); #endif ( void ) pvParameters; for( ;; ) { /********************************************************************* Test 1 Simple block time wakeup test on queue receives. */ for( xItem = 0; xItem < bktQUEUE_LENGTH; xItem++ ) { /* The queue is empty. Attempt to read from the queue using a block time. When we wake, ensure the delta in time is as expected. */ xTimeToBlock = bktPRIMARY_BLOCK_TIME << xItem; /* A critical section is used to minimise the jitter in the time measurements. */ portENTER_CRITICAL(); { xTimeWhenBlocking = xTaskGetTickCount(); /* We should unblock after xTimeToBlock having not received anything on the queue. */ if( xQueueAltReceive( xTestQueue, &xData, xTimeToBlock ) != errQUEUE_EMPTY ) { xErrorOccurred = pdTRUE; } /* How long were we blocked for? */ xBlockedTime = xTaskGetTickCount() - xTimeWhenBlocking; } portEXIT_CRITICAL(); if( xBlockedTime < xTimeToBlock ) { /* Should not have blocked for less than we requested. */ xErrorOccurred = pdTRUE; } if( xBlockedTime > ( xTimeToBlock + bktALLOWABLE_MARGIN ) ) { /* Should not have blocked for longer than we requested, although we would not necessarily run as soon as we were unblocked so a margin is allowed. */ xErrorOccurred = pdTRUE; } } #if configUSE_PREEMPTION == 0 taskYIELD(); #endif /********************************************************************* Test 2 Simple block time wakeup test on queue sends. First fill the queue. It should be empty so all sends should pass. */ for( xItem = 0; xItem < bktQUEUE_LENGTH; xItem++ ) { if( xQueueAltSendToBack( xTestQueue, &xItem, bktDONT_BLOCK ) != pdPASS ) { xErrorOccurred = pdTRUE; } } for( xItem = 0; xItem < bktQUEUE_LENGTH; xItem++ ) { /* The queue is full. Attempt to write to the queue using a block time. When we wake, ensure the delta in time is as expected. */ xTimeToBlock = bktPRIMARY_BLOCK_TIME << xItem; portENTER_CRITICAL(); { xTimeWhenBlocking = xTaskGetTickCount(); /* We should unblock after xTimeToBlock having not received anything on the queue. */ if( xQueueAltSendToBack( xTestQueue, &xItem, xTimeToBlock ) != errQUEUE_FULL ) { xErrorOccurred = pdTRUE; } /* How long were we blocked for? *///.........这里部分代码省略.........
开发者ID:DonjetaE,项目名称:FreeRTOS,代码行数:101,
示例14: vErrorChecksstatic void vErrorChecks( void *pvParameters ){portTickType xExpectedWakeTime;const portTickType xPrintRate = ( portTickType ) 5000 / portTICK_RATE_MS;const long lMaxAllowableTimeDifference = ( long ) 0;portTickType xWakeTime;long lTimeDifference;const char *pcReceivedMessage;const char * const pcTaskBlockedTooLongMsg = "Print task blocked too long!/r/n"; /* Stop warnings. */ ( void ) pvParameters; /* Loop continuously, blocking, then checking all the other tasks are still running, before blocking once again. This task blocks on the queue of messages that require displaying so will wake either by its time out expiring, or a message becoming available. */ for( ;; ) { /* Calculate the time we will unblock if no messages are received on the queue. This is used to check that we have not blocked for too long. */ xExpectedWakeTime = xTaskGetTickCount(); xExpectedWakeTime += xPrintRate; /* Block waiting for either a time out or a message to be posted that required displaying. */ pcReceivedMessage = pcPrintGetNextMessage( xPrintRate ); /* Was a message received? */ if( pcReceivedMessage == NULL ) { /* A message was not received so we timed out, did we unblock at the expected time? */ xWakeTime = xTaskGetTickCount(); /* Calculate the difference between the time we unblocked and the time we should have unblocked. */ if( xWakeTime > xExpectedWakeTime ) { lTimeDifference = ( long ) ( xWakeTime - xExpectedWakeTime ); } else { lTimeDifference = ( long ) ( xExpectedWakeTime - xWakeTime ); } if( lTimeDifference > lMaxAllowableTimeDifference ) { /* We blocked too long - create a message that will get printed out the next time around. */ vPrintDisplayMessage( &pcTaskBlockedTooLongMsg ); } /* Check the other tasks are still running, just in case. */ prvCheckOtherTasksAreStillRunning(); } else { /* We unblocked due to a message becoming available. Send the message for printing. */ vDisplayMessage( pcReceivedMessage ); } /* Key presses are used to invoke the trace visualisation utility, or end the program. */ prvCheckForKeyPresses(); }} /*lint !e715 !e818 pvParameters is not used but all task functions must take this form. */
开发者ID:RitikaGupta1207,项目名称:freertos,代码行数:68,
示例15: prvSendFrontAndBackTeststatic void prvSendFrontAndBackTest( void *pvParameters ){unsigned portLONG ulData, ulData2;xQueueHandle xQueue; #ifdef USE_STDIO void vPrintDisplayMessage( const portCHAR * const * ppcMessageToSend ); const portCHAR * const pcTaskStartMsg = "Queue SendToFront/SendToBack/Peek test started./r/n"; /* Queue a message for printing to say the task has started. */ vPrintDisplayMessage( &pcTaskStartMsg ); #endif xQueue = ( xQueueHandle ) pvParameters; for( ;; ) { /* The queue is empty, so sending an item to the back of the queue should have the same efect as sending it to the front of the queue. First send to the front and check everything is as expected. */ xQueueSendToFront( xQueue, ( void * ) &ulLoopCounter, genqNO_BLOCK ); if( uxQueueMessagesWaiting( xQueue ) != 1 ) { xErrorDetected = pdTRUE; } if( xQueueReceive( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != pdPASS ) { xErrorDetected = pdTRUE; } /* The data we sent to the queue should equal the data we just received from the queue. */ if( ulLoopCounter != ulData ) { xErrorDetected = pdTRUE; } /* Then do the same, sending the data to the back, checking everything is as expected. */ if( uxQueueMessagesWaiting( xQueue ) != 0 ) { xErrorDetected = pdTRUE; } xQueueSendToBack( xQueue, ( void * ) &ulLoopCounter, genqNO_BLOCK ); if( uxQueueMessagesWaiting( xQueue ) != 1 ) { xErrorDetected = pdTRUE; } if( xQueueReceive( xQueue, ( void * ) &ulData, genqNO_BLOCK ) != pdPASS ) { xErrorDetected = pdTRUE; } if( uxQueueMessagesWaiting( xQueue ) != 0 ) { xErrorDetected = pdTRUE; } /* The data we sent to the queue should equal the data we just received from the queue. */ if( ulLoopCounter != ulData ) { xErrorDetected = pdTRUE; } #if configUSE_PREEMPTION == 0 taskYIELD(); #endif /* Place 2, 3, 4 into the queue, adding items to the back of the queue. */ for( ulData = 2; ulData < 5; ulData++ ) { xQueueSendToBack( xQueue, ( void * ) &ulData, genqNO_BLOCK ); } /* Now the order in the queue should be 2, 3, 4, with 2 being the first thing to be read out. Now add 1 then 0 to the front of the queue. */ if( uxQueueMessagesWaiting( xQueue ) != 3 ) { xErrorDetected = pdTRUE; } ulData = 1; xQueueSendToFront( xQueue, ( void * ) &ulData, genqNO_BLOCK ); ulData = 0; xQueueSendToFront( xQueue, ( void * ) &ulData, genqNO_BLOCK ); /* Now the queue should be full, and when we read the data out we should receive 0, 1, 2, 3, 4. */ if( uxQueueMessagesWaiting( xQueue ) != 5 ) { xErrorDetected = pdTRUE;//.........这里部分代码省略.........
开发者ID:jefchavesfer,项目名称:H3DGE,代码行数:101,
示例16: prvLowPriorityMutexTaskstatic void prvLowPriorityMutexTask( void *pvParameters ){xSemaphoreHandle xMutex = ( xSemaphoreHandle ) pvParameters; #ifdef USE_STDIO void vPrintDisplayMessage( const portCHAR * const * ppcMessageToSend ); const portCHAR * const pcTaskStartMsg = "Mutex with priority inheritance test started./r/n"; /* Queue a message for printing to say the task has started. */ vPrintDisplayMessage( &pcTaskStartMsg ); #endif for( ;; ) { /* Take the mutex. It should be available now. */ if( xSemaphoreTake( xMutex, genqNO_BLOCK ) != pdPASS ) { xErrorDetected = pdTRUE; } /* Set our guarded variable to a known start value. */ ulGuardedVariable = 0; /* Our priority should be as per that assigned when the task was created. */ if( uxTaskPriorityGet( NULL ) != genqMUTEX_LOW_PRIORITY ) { xErrorDetected = pdTRUE; } /* Now unsuspend the high priority task. This will attempt to take the mutex, and block when it finds it cannot obtain it. */ vTaskResume( xHighPriorityMutexTask ); /* We should now have inherited the prioritoy of the high priority task, as by now it will have attempted to get the mutex. */ if( uxTaskPriorityGet( NULL ) != genqMUTEX_HIGH_PRIORITY ) { xErrorDetected = pdTRUE; } /* We can attempt to set our priority to the test priority - between the idle priority and the medium/high test priorities, but our actual prioroity should remain at the high priority. */ vTaskPrioritySet( NULL, genqMUTEX_TEST_PRIORITY ); if( uxTaskPriorityGet( NULL ) != genqMUTEX_HIGH_PRIORITY ) { xErrorDetected = pdTRUE; } /* Now unsuspend the medium priority task. This should not run as our inherited priority is above that of the medium priority task. */ vTaskResume( xMediumPriorityMutexTask ); /* If the did run then it will have incremented our guarded variable. */ if( ulGuardedVariable != 0 ) { xErrorDetected = pdTRUE; } /* When we give back the semaphore our priority should be disinherited back to the priority to which we attempted to set ourselves. This means that when the high priority task next blocks, the medium priority task should execute and increment the guarded variable. When we next run both the high and medium priority tasks will have been suspended again. */ if( xSemaphoreGive( xMutex ) != pdPASS ) { xErrorDetected = pdTRUE; } /* Check that the guarded variable did indeed increment... */ if( ulGuardedVariable != 1 ) { xErrorDetected = pdTRUE; } /* ... and that our priority has been disinherited to genqMUTEX_TEST_PRIORITY. */ if( uxTaskPriorityGet( NULL ) != genqMUTEX_TEST_PRIORITY ) { xErrorDetected = pdTRUE; } /* Set our priority back to our original priority ready for the next loop around this test. */ vTaskPrioritySet( NULL, genqMUTEX_LOW_PRIORITY ); /* Just to show we are still running. */ ulLoopCounter2++; #if configUSE_PREEMPTION == 0 taskYIELD(); #endif }}
开发者ID:jefchavesfer,项目名称:H3DGE,代码行数:96,
示例17: prvChangePriorityWhenSuspendedTaskstatic void prvChangePriorityWhenSuspendedTask( void *pvParameters ){const char * const pcTaskStartMsg = "Priority change when suspended task started./r/n";const char * const pcTaskFailMsg = "Priority change when suspended task failed./r/n"; /* Just to stop warning messages. */ ( void ) pvParameters; /* Queue a message for printing to say the task has started. */ vPrintDisplayMessage( &pcTaskStartMsg ); for( ;; ) { /* Start with the counter at 0 so we know what the counter should be when we check it next. */ ulPrioritySetCounter = ( unsigned long ) 0; /* Resume the helper task. At this time it has a priority lower than ours so no context switch should occur. */ vTaskResume( xChangePriorityWhenSuspendedHandle ); /* Check to ensure the task just resumed has not executed. */ portENTER_CRITICAL(); { if( ulPrioritySetCounter != ( unsigned long ) 0 ) { xPriorityRaiseWhenSuspendedError = pdTRUE; vPrintDisplayMessage( &pcTaskFailMsg ); } } portEXIT_CRITICAL(); /* Now try raising the priority while the scheduler is suspended. */ vTaskSuspendAll(); { vTaskPrioritySet( xChangePriorityWhenSuspendedHandle, ( configMAX_PRIORITIES - 1 ) ); /* Again, even though the helper task has a priority greater than ours, it should not have executed yet because the scheduler is suspended. */ portENTER_CRITICAL(); { if( ulPrioritySetCounter != ( unsigned long ) 0 ) { xPriorityRaiseWhenSuspendedError = pdTRUE; vPrintDisplayMessage( &pcTaskFailMsg ); } } portEXIT_CRITICAL(); } xTaskResumeAll(); /* Now the scheduler has been resumed the helper task should immediately preempt us and execute. When it executes it will increment the ulPrioritySetCounter exactly once before suspending itself. We should now always find the counter set to 1. */ portENTER_CRITICAL(); { if( ulPrioritySetCounter != ( unsigned long ) 1 ) { xPriorityRaiseWhenSuspendedError = pdTRUE; vPrintDisplayMessage( &pcTaskFailMsg ); } } portEXIT_CRITICAL(); /* Delay until we try this again. */ vTaskDelay( priSLEEP_TIME * 2 ); /* Set the priority of the helper task back ready for the next execution of this task. */ vTaskSuspendAll(); vTaskPrioritySet( xChangePriorityWhenSuspendedHandle, tskIDLE_PRIORITY ); xTaskResumeAll(); }}
开发者ID:Cuixiaoxia198106,项目名称:freertos-sparc,代码行数:77,
示例18: vCompetingMathTask4static void vCompetingMathTask4( void *pvParameters ){portDOUBLE *pdArray, dTotal1, dTotal2, dDifference;volatile unsigned short *pusTaskCheckVariable;const unsigned short usArraySize = 250;unsigned short usPosition;const char * const pcTaskStartMsg = "Math task 4 started./r/n";const char * const pcTaskFailMsg = "Math task 4 failed./r/n";short sError = pdFALSE; /* Queue a message for printing to say the task has started. */ vPrintDisplayMessage( &pcTaskStartMsg ); freertos_print("Started math task 4/n"); freertos_print(pcTaskStartMsg); /* The variable this task increments to show it is still running is passed in as the parameter. */ pusTaskCheckVariable = ( unsigned short * ) pvParameters; pdArray = ( portDOUBLE * ) pvPortMalloc( ( size_t ) 250 * sizeof( portDOUBLE ) ); /* Keep filling an array, keeping a running total of the values placed in the array. Then run through the array adding up all the values. If the two totals do not match, stop the check variable from incrementing. */ for( ;; ) { dTotal1 = 0.0; dTotal2 = 0.0; for( usPosition = 0; usPosition < usArraySize; usPosition++ ) { pdArray[ usPosition ] = ( portDOUBLE ) usPosition * 12.123; dTotal1 += ( portDOUBLE ) usPosition * 12.123; } // freertos_print("yielding from task 4/n"); taskYIELD(); for( usPosition = 0; usPosition < usArraySize; usPosition++ ) { dTotal2 += pdArray[ usPosition ]; } dDifference = dTotal1 - dTotal2; if( fabs( dDifference ) > 0.001 ) { vPrintDisplayMessage( &pcTaskFailMsg ); sError = pdTRUE; } else { // freertos_print("Math task 4 successful/n"); } taskYIELD(); if( sError == pdFALSE ) { /* If the calculation has always been correct, increment the check variable so we know this task is still running okay. */ ( *pusTaskCheckVariable )++; } }}
开发者ID:nks5295,项目名称:Composite,代码行数:61,
注:本文中的vPrintDisplayMessage函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ vQueueAddToRegistry函数代码示例 C++ vPortSetupTimerInterrupt函数代码示例 |