From: rtel Date: Mon, 17 Dec 2018 22:06:58 +0000 (+0000) Subject: Update the the MPU simulator project to exercise the timer API. X-Git-Tag: V10.2.0~35 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=6af352806b3b53c40e5ffa2655885a41d42792ea;p=freertos Update the the MPU simulator project to exercise the timer API. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2607 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/FreeRTOSConfig.h index e8b04346a..852109962 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/FreeRTOSConfig.h @@ -105,7 +105,7 @@ to exclude the API function. */ #define INCLUDE_vTaskDelayUntil 1 #define INCLUDE_vTaskDelay 1 #define INCLUDE_eTaskGetState 1 -#define INCLUDE_xTimerPendFunctionCall 0 +#define INCLUDE_xTimerPendFunctionCall 1 #define INCLUDE_xSemaphoreGetMutexHolder 1 #define INCLUDE_xTaskGetHandle 1 #define INCLUDE_xTaskGetCurrentTaskHandle 1 diff --git a/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/GCC_Specific/RTOSDemo.uvoptx b/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/GCC_Specific/RTOSDemo.uvoptx index 365eb69ca..85705cfdb 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/GCC_Specific/RTOSDemo.uvoptx +++ b/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/GCC_Specific/RTOSDemo.uvoptx @@ -118,7 +118,7 @@ 0 DLGDARM - (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=1215,201,1680,501,0) + (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(1012=1071,201,1536,501,0) 0 @@ -146,7 +146,24 @@ -UV1115SAE -O2983 -S0 -C0 -P00 -N00("ARM CoreSight JTAG-DP") -D00(4BA00477) -L00(4) -TO18 -TC10000000 -TP21 -TDS8007 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO11 -FN1 -FC1000 -FD20000000 -FF0NEW_DEVICE -FL080000 -FS00 -FP0($$Device:ARMCM4_FP$Device\ARM\Flash\NEW_DEVICE.FLM) - + + + 0 + 0 + 614 + 1 +
23132
+ 0 + 0 + 0 + 0 + 0 + 1 + C:\Users\ribarry\Dev\FreeRTOS\WorkingCopy\FreeRTOS\Source\stream_buffer.c + + \\RTOSDemo\../../../Source/stream_buffer.c\614 +
+
0 @@ -173,7 +190,7 @@ 0 1 - 1 + 0 0 0 0 @@ -190,7 +207,7 @@ 0 0 0 - 0 + 1 0 0 0 diff --git a/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/main.c b/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/main.c index 1ccddbbe7..82b51a1b5 100644 --- a/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/main.c +++ b/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/main.c @@ -158,6 +158,7 @@ static void prvExerciseEventGroupAPI( void ); static void prvExerciseSemaphoreAPI( void ); static void prvExerciseTaskNotificationAPI( void ); static void prvExerciseStreamBufferAPI( void ); +static void prvExerciseTimerAPI( void ); /* * Just configures any clocks and IO necessary. @@ -196,6 +197,13 @@ static void prvTestMemoryRegions( void ); */ static void prvTimerCallback( TimerHandle_t xExpiredTimer ); +/* + * The callback function and a function that is pended used when exercising the + * timer API. + */ +static void prvPendedFunctionCall( void *pvParameter1, uint32_t ulParameter2 ); +static void prvTestTimerCallback( TimerHandle_t xTimer ); + /*-----------------------------------------------------------*/ /* The handle of the queue used to communicate between tasks and between tasks @@ -763,6 +771,7 @@ static void prvTaskToDelete( void *pvParameters ) prvExerciseSemaphoreAPI(); prvExerciseTaskNotificationAPI(); prvExerciseStreamBufferAPI(); + prvExerciseTimerAPI(); /* For code coverage test purposes it is deleted by the Idle task. */ configASSERT( uxTaskGetStackHighWaterMark( NULL ) > 0 ); @@ -771,6 +780,72 @@ static void prvTaskToDelete( void *pvParameters ) } /*-----------------------------------------------------------*/ +static void prvPendedFunctionCall( void *pvParameter1, uint32_t ulParameter2 ) +{ +uint32_t *pulCounter = ( uint32_t * ) pvParameter1; + + /* Increment the paramater to show the pended function has executed. */ + ( *pulCounter )++; +} +/*-----------------------------------------------------------*/ + +static void prvTestTimerCallback( TimerHandle_t xTimer ) +{ +uint32_t ulTimerID; + + /* Increment the timer's ID to show the callback has executed. */ + ulTimerID = ( uint32_t ) pvTimerGetTimerID( xTimer ); + ulTimerID++; + vTimerSetTimerID( xTimer, ( void * ) ulTimerID ); +} +/*-----------------------------------------------------------*/ + +static void prvExerciseTimerAPI( void ) +{ +TimerHandle_t xTimer; +const char * const pcTimerName = "TestTimer"; +const TickType_t x10ms = pdMS_TO_TICKS( 3 ); +uint32_t ulValueForTesting = 0; + + xTimer = xTimerCreate( pcTimerName, + x10ms, + pdFALSE, /* Created as a one shot timer. */ + 0, + prvTestTimerCallback ); + configASSERT( xTimer ); + configASSERT( xTimerIsTimerActive( xTimer ) == pdFALSE ); + configASSERT( xTimerGetTimerDaemonTaskHandle() != NULL ); + configASSERT( strcmp( pcTimerName, pcTimerGetName( xTimer ) ) == 0 ); + configASSERT( xTimerGetPeriod( xTimer ) == x10ms ); + configASSERT( xTimerGetExpiryTime( xTimer ) == 0 ); /* The timer has been created only. */ + + /* Pend a function then wait for it to execute. All it does is increment + its parameter. */ + xTimerPendFunctionCall( prvPendedFunctionCall, &ulValueForTesting, 0, 0 ); + vTaskDelay( x10ms ); + configASSERT( ulValueForTesting == 1 ); + + /* 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, 0 ); + vTaskDelay( 3UL * x10ms ); + configASSERT( ( ( uint32_t ) ( pvTimerGetTimerID( xTimer ) ) ) == 1UL ); + + /* Now change the timer to be an autoreload timer and check it executes + the expected number of times. */ + vTimerSetReloadMode( xTimer, pdTRUE ); + xTimerStart( xTimer, 0 ); + vTaskDelay( 3UL * x10ms ); + configASSERT( ( uint32_t ) ( pvTimerGetTimerID( xTimer ) ) > 3UL ); + configASSERT( xTimerStop( xTimer, 0 ) != pdFAIL ); + + /* Clean up at the end. */ + xTimerDelete( xTimer, portMAX_DELAY ); +} +/*-----------------------------------------------------------*/ + static void prvExerciseStreamBufferAPI( void ) { uint8_t ucBuffer[ 10 ]; @@ -799,19 +874,6 @@ StreamBufferHandle_t xStreamBuffer; 0 ); configASSERT( xReturned == sizeof( xRead ) ); configASSERT( xRead == x ); - - xStreamBufferSendFromISR( xStreamBuffer, - ( void * ) &x, - sizeof( x ), - NULL ); - configASSERT( xReturned == sizeof( x ) ); - - xReturned = xStreamBufferReceiveFromISR( xStreamBuffer, - ( void * ) &xRead, - sizeof( xRead ), - NULL ); - configASSERT( xReturned == sizeof( xRead ) ); - configASSERT( xRead == x ); configASSERT( xStreamBufferIsFull( xStreamBuffer ) == pdFALSE ); configASSERT( xStreamBufferIsEmpty( xStreamBuffer ) == pdTRUE ); configASSERT( xStreamBufferSpacesAvailable( xStreamBuffer ) == sizeof( ucBuffer ) ); @@ -865,8 +927,12 @@ volatile uint32_t ulReadData; test purposes. */ if( xTaskToDelete != NULL ) { - vTaskDelete( xTaskToDelete ); - xTaskToDelete = NULL; + if( eTaskGetState( xTaskToDelete ) == eSuspended ) + { + /* The task has finished its tests and can be deleted. */ + vTaskDelete( xTaskToDelete ); + xTaskToDelete = NULL; + } } ( void ) ulReadData;