mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-14 08:47:45 -04:00
Fix duration of TimerMode Task in WIN32-MingW Demo (#1084)
* Reduce duration of prvDemonstrateChangingTimerReloadMode Task * Apply same change in WIN32-MingW Demo * Add changes to Posix_GCC Demo
This commit is contained in:
parent
8104777681
commit
58765d6b4c
3 changed files with 30 additions and 27 deletions
|
@ -219,6 +219,7 @@ int main_full( void )
|
|||
xTaskCreate( prvDemoQueueSpaceFunctions, "QSpace", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
||||
xTaskCreate( prvPermanentlyBlockingSemaphoreTask, "BlockSem", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
||||
xTaskCreate( prvPermanentlyBlockingNotificationTask, "BlockNoti", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
||||
xTaskCreate( prvDemonstrateChangingTimerReloadMode, "TimerMode", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL );
|
||||
|
||||
vStartMessageBufferTasks( configMINIMAL_STACK_SIZE );
|
||||
vStartStreamBufferTasks();
|
||||
|
@ -916,13 +917,15 @@ static void prvDemonstrateChangingTimerReloadMode( void * pvParameters )
|
|||
{
|
||||
TimerHandle_t xTimer;
|
||||
const char * const pcTimerName = "TestTimer";
|
||||
const TickType_t x100ms = pdMS_TO_TICKS( 100UL );
|
||||
const TickType_t x50ms = pdMS_TO_TICKS( 50UL );
|
||||
|
||||
/* Avoid compiler warnings about unused parameter. */
|
||||
( void ) pvParameters;
|
||||
|
||||
/* The duration of 1 period is kept at 50ms to allow IDLE task to
|
||||
* free up this task's resources before suicidal tests can run. */
|
||||
xTimer = xTimerCreate( pcTimerName,
|
||||
x100ms,
|
||||
x50ms,
|
||||
pdFALSE, /* Created as a one-shot timer. */
|
||||
0,
|
||||
prvReloadModeTestTimerCallback );
|
||||
|
@ -930,14 +933,14 @@ static void prvDemonstrateChangingTimerReloadMode( void * pvParameters )
|
|||
configASSERT( xTimerIsTimerActive( xTimer ) == pdFALSE );
|
||||
configASSERT( xTimerGetTimerDaemonTaskHandle() != NULL );
|
||||
configASSERT( strcmp( pcTimerName, pcTimerGetName( xTimer ) ) == 0 );
|
||||
configASSERT( xTimerGetPeriod( xTimer ) == x100ms );
|
||||
configASSERT( xTimerGetPeriod( xTimer ) == x50ms );
|
||||
|
||||
/* Timer was created as a one-shot timer. Its callback just increments the
|
||||
* timer's ID - so set the ID to 0, let the timer run for a number of timeout
|
||||
* periods, then check the timer has only executed once. */
|
||||
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
||||
xTimerStart( xTimer, portMAX_DELAY );
|
||||
vTaskDelay( 3UL * x100ms );
|
||||
vTaskDelay( 3UL * x50ms );
|
||||
configASSERT( ( ( uintptr_t ) ( pvTimerGetTimerID( xTimer ) ) ) == 1UL );
|
||||
|
||||
/* Now change the timer to be an auto-reload timer and check it executes
|
||||
|
@ -945,7 +948,7 @@ static void prvDemonstrateChangingTimerReloadMode( void * pvParameters )
|
|||
vTimerSetReloadMode( xTimer, pdTRUE );
|
||||
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
||||
xTimerStart( xTimer, 0 );
|
||||
vTaskDelay( ( 3UL * x100ms ) + ( x100ms / 2UL ) ); /* Three full periods. */
|
||||
vTaskDelay( ( 3UL * x50ms ) + ( x50ms / 2UL ) ); /* Three full periods. */
|
||||
configASSERT( ( uintptr_t ) ( pvTimerGetTimerID( xTimer ) ) == 3UL );
|
||||
configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL );
|
||||
|
||||
|
@ -954,7 +957,7 @@ static void prvDemonstrateChangingTimerReloadMode( void * pvParameters )
|
|||
vTimerSetReloadMode( xTimer, pdFALSE );
|
||||
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
||||
xTimerStart( xTimer, 0 );
|
||||
vTaskDelay( 3UL * x100ms );
|
||||
vTaskDelay( 3UL * x50ms );
|
||||
configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL );
|
||||
configASSERT( ( uintptr_t ) ( pvTimerGetTimerID( xTimer ) ) == 1UL );
|
||||
|
||||
|
|
|
@ -859,47 +859,47 @@ static void prvDemonstrateChangingTimerReloadMode( void *pvParameters )
|
|||
{
|
||||
TimerHandle_t xTimer;
|
||||
const char * const pcTimerName = "TestTimer";
|
||||
const TickType_t x100ms = pdMS_TO_TICKS( 100UL );
|
||||
const TickType_t x50ms = pdMS_TO_TICKS( 50UL );
|
||||
|
||||
/* Avoid compiler warnings about unused parameter. */
|
||||
( void ) pvParameters;
|
||||
|
||||
xTimer = xTimerCreate(
|
||||
pcTimerName,
|
||||
x100ms,
|
||||
/* The duration of 1 period is kept at 50ms to allow IDLE task to
|
||||
* free up this task's resources before suicidal tests can run. */
|
||||
xTimer = xTimerCreate( pcTimerName,
|
||||
x50ms,
|
||||
pdFALSE, /* Created as a one-shot timer. */
|
||||
0,
|
||||
prvReloadModeTestTimerCallback );
|
||||
|
||||
configASSERT( xTimer );
|
||||
configASSERT( xTimerIsTimerActive( xTimer ) == pdFALSE );
|
||||
configASSERT( xTimerGetTimerDaemonTaskHandle() != NULL );
|
||||
configASSERT( strcmp( pcTimerName, pcTimerGetName( xTimer ) ) == 0 );
|
||||
configASSERT( xTimerGetPeriod( xTimer ) == x100ms );
|
||||
configASSERT( xTimerGetPeriod( xTimer ) == x50ms );
|
||||
|
||||
/* Timer was created as a one-shot timer. Its callback just increments the
|
||||
timer's ID - so set the ID to 0, let the timer run for a number of timeout
|
||||
periods, then check the timer has only executed once. */
|
||||
* timer's ID - so set the ID to 0, let the timer run for a number of timeout
|
||||
* periods, then check the timer has only executed once. */
|
||||
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
||||
xTimerStart( xTimer, portMAX_DELAY );
|
||||
vTaskDelay( 3UL * x100ms );
|
||||
vTaskDelay( 3UL * x50ms );
|
||||
configASSERT( ( ( uint32_t ) ( pvTimerGetTimerID( xTimer ) ) ) == 1UL );
|
||||
|
||||
/* Now change the timer to be an auto-reload timer and check it executes
|
||||
the expected number of times. */
|
||||
* the expected number of times. */
|
||||
vTimerSetReloadMode( xTimer, pdTRUE );
|
||||
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
||||
xTimerStart( xTimer, 0 );
|
||||
vTaskDelay( ( 3UL * x100ms ) + ( x100ms / 2UL ) ); /* Three full periods. */
|
||||
vTaskDelay( ( 3UL * x50ms ) + ( x50ms / 2UL ) ); /* Three full periods. */
|
||||
configASSERT( ( uint32_t ) ( pvTimerGetTimerID( xTimer ) ) == 3UL );
|
||||
configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL );
|
||||
|
||||
/* Now change the timer back to be a one-shot timer and check it only
|
||||
executes once. */
|
||||
* executes once. */
|
||||
vTimerSetReloadMode( xTimer, pdFALSE );
|
||||
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
||||
xTimerStart( xTimer, 0 );
|
||||
vTaskDelay( 3UL * x100ms );
|
||||
vTaskDelay( 3UL * x50ms );
|
||||
configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL );
|
||||
configASSERT( ( uint32_t ) ( pvTimerGetTimerID( xTimer ) ) == 1UL );
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue