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
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* FreeRTOS V202212.00
|
* FreeRTOS V202212.00
|
||||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* FreeRTOS V202212.00
|
* FreeRTOS V202212.00
|
||||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
@ -219,6 +219,7 @@ int main_full( void )
|
||||||
xTaskCreate( prvDemoQueueSpaceFunctions, "QSpace", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
xTaskCreate( prvDemoQueueSpaceFunctions, "QSpace", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
||||||
xTaskCreate( prvPermanentlyBlockingSemaphoreTask, "BlockSem", 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( prvPermanentlyBlockingNotificationTask, "BlockNoti", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY, NULL );
|
||||||
|
xTaskCreate( prvDemonstrateChangingTimerReloadMode, "TimerMode", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL );
|
||||||
|
|
||||||
vStartMessageBufferTasks( configMINIMAL_STACK_SIZE );
|
vStartMessageBufferTasks( configMINIMAL_STACK_SIZE );
|
||||||
vStartStreamBufferTasks();
|
vStartStreamBufferTasks();
|
||||||
|
@ -916,13 +917,15 @@ static void prvDemonstrateChangingTimerReloadMode( void * pvParameters )
|
||||||
{
|
{
|
||||||
TimerHandle_t xTimer;
|
TimerHandle_t xTimer;
|
||||||
const char * const pcTimerName = "TestTimer";
|
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. */
|
/* Avoid compiler warnings about unused parameter. */
|
||||||
( void ) pvParameters;
|
( 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,
|
xTimer = xTimerCreate( pcTimerName,
|
||||||
x100ms,
|
x50ms,
|
||||||
pdFALSE, /* Created as a one-shot timer. */
|
pdFALSE, /* Created as a one-shot timer. */
|
||||||
0,
|
0,
|
||||||
prvReloadModeTestTimerCallback );
|
prvReloadModeTestTimerCallback );
|
||||||
|
@ -930,14 +933,14 @@ static void prvDemonstrateChangingTimerReloadMode( void * pvParameters )
|
||||||
configASSERT( xTimerIsTimerActive( xTimer ) == pdFALSE );
|
configASSERT( xTimerIsTimerActive( xTimer ) == pdFALSE );
|
||||||
configASSERT( xTimerGetTimerDaemonTaskHandle() != NULL );
|
configASSERT( xTimerGetTimerDaemonTaskHandle() != NULL );
|
||||||
configASSERT( strcmp( pcTimerName, pcTimerGetName( xTimer ) ) == 0 );
|
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 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
|
* 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. */
|
* periods, then check the timer has only executed once. */
|
||||||
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
||||||
xTimerStart( xTimer, portMAX_DELAY );
|
xTimerStart( xTimer, portMAX_DELAY );
|
||||||
vTaskDelay( 3UL * x100ms );
|
vTaskDelay( 3UL * x50ms );
|
||||||
configASSERT( ( ( uintptr_t ) ( pvTimerGetTimerID( xTimer ) ) ) == 1UL );
|
configASSERT( ( ( uintptr_t ) ( pvTimerGetTimerID( xTimer ) ) ) == 1UL );
|
||||||
|
|
||||||
/* Now change the timer to be an auto-reload timer and check it executes
|
/* 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 );
|
vTimerSetReloadMode( xTimer, pdTRUE );
|
||||||
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
||||||
xTimerStart( xTimer, 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( ( uintptr_t ) ( pvTimerGetTimerID( xTimer ) ) == 3UL );
|
||||||
configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL );
|
configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL );
|
||||||
|
|
||||||
|
@ -954,7 +957,7 @@ static void prvDemonstrateChangingTimerReloadMode( void * pvParameters )
|
||||||
vTimerSetReloadMode( xTimer, pdFALSE );
|
vTimerSetReloadMode( xTimer, pdFALSE );
|
||||||
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
||||||
xTimerStart( xTimer, 0 );
|
xTimerStart( xTimer, 0 );
|
||||||
vTaskDelay( 3UL * x100ms );
|
vTaskDelay( 3UL * x50ms );
|
||||||
configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL );
|
configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL );
|
||||||
configASSERT( ( uintptr_t ) ( pvTimerGetTimerID( xTimer ) ) == 1UL );
|
configASSERT( ( uintptr_t ) ( pvTimerGetTimerID( xTimer ) ) == 1UL );
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
* FreeRTOS V202212.00
|
* FreeRTOS V202212.00
|
||||||
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
* Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
* this software and associated documentation files (the "Software"), to deal in
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
|
@ -857,49 +857,49 @@ uint32_t ulTimerID;
|
||||||
|
|
||||||
static void prvDemonstrateChangingTimerReloadMode( void *pvParameters )
|
static void prvDemonstrateChangingTimerReloadMode( void *pvParameters )
|
||||||
{
|
{
|
||||||
TimerHandle_t xTimer;
|
TimerHandle_t xTimer;
|
||||||
const char * const pcTimerName = "TestTimer";
|
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. */
|
/* Avoid compiler warnings about unused parameter. */
|
||||||
( void ) pvParameters;
|
( void ) pvParameters;
|
||||||
|
|
||||||
xTimer = xTimerCreate(
|
/* The duration of 1 period is kept at 50ms to allow IDLE task to
|
||||||
pcTimerName,
|
* free up this task's resources before suicidal tests can run. */
|
||||||
x100ms,
|
xTimer = xTimerCreate( pcTimerName,
|
||||||
pdFALSE, /* Created as a one-shot timer. */
|
x50ms,
|
||||||
0,
|
pdFALSE, /* Created as a one-shot timer. */
|
||||||
prvReloadModeTestTimerCallback );
|
0,
|
||||||
|
prvReloadModeTestTimerCallback );
|
||||||
configASSERT( xTimer );
|
configASSERT( xTimer );
|
||||||
configASSERT( xTimerIsTimerActive( xTimer ) == pdFALSE );
|
configASSERT( xTimerIsTimerActive( xTimer ) == pdFALSE );
|
||||||
configASSERT( xTimerGetTimerDaemonTaskHandle() != NULL );
|
configASSERT( xTimerGetTimerDaemonTaskHandle() != NULL );
|
||||||
configASSERT( strcmp( pcTimerName, pcTimerGetName( xTimer ) ) == 0 );
|
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 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
|
* 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. */
|
* periods, then check the timer has only executed once. */
|
||||||
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
||||||
xTimerStart( xTimer, portMAX_DELAY );
|
xTimerStart( xTimer, portMAX_DELAY );
|
||||||
vTaskDelay( 3UL * x100ms );
|
vTaskDelay( 3UL * x50ms );
|
||||||
configASSERT( ( ( uint32_t ) ( pvTimerGetTimerID( xTimer ) ) ) == 1UL );
|
configASSERT( ( ( uint32_t ) ( pvTimerGetTimerID( xTimer ) ) ) == 1UL );
|
||||||
|
|
||||||
/* Now change the timer to be an auto-reload timer and check it executes
|
/* 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 );
|
vTimerSetReloadMode( xTimer, pdTRUE );
|
||||||
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
||||||
xTimerStart( xTimer, 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( ( uint32_t ) ( pvTimerGetTimerID( xTimer ) ) == 3UL );
|
||||||
configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL );
|
configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL );
|
||||||
|
|
||||||
/* Now change the timer back to be a one-shot timer and check it only
|
/* Now change the timer back to be a one-shot timer and check it only
|
||||||
executes once. */
|
* executes once. */
|
||||||
vTimerSetReloadMode( xTimer, pdFALSE );
|
vTimerSetReloadMode( xTimer, pdFALSE );
|
||||||
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
vTimerSetTimerID( xTimer, ( void * ) 0 );
|
||||||
xTimerStart( xTimer, 0 );
|
xTimerStart( xTimer, 0 );
|
||||||
vTaskDelay( 3UL * x100ms );
|
vTaskDelay( 3UL * x50ms );
|
||||||
configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL );
|
configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL );
|
||||||
configASSERT( ( uint32_t ) ( pvTimerGetTimerID( xTimer ) ) == 1UL );
|
configASSERT( ( uint32_t ) ( pvTimerGetTimerID( xTimer ) ) == 1UL );
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue