From d42623c440f0c169c03009d9b66339f09c6972de Mon Sep 17 00:00:00 2001 From: richardbarry Date: Wed, 27 Jul 2011 14:16:24 +0000 Subject: [PATCH] Add test/demonstration calls to xTaskGetIdleTaskHandle(), xTimerGetTimerTaskHandle, pcTaskGetTaskName() and vQueueDelete() functions to the Win32 demo project. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1514 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Demo/WIN32-MSVC/FreeRTOSConfig.h | 2 ++ Demo/WIN32-MSVC/WIN32.suo | Bin 55296 -> 55296 bytes Demo/WIN32-MSVC/main.c | 45 ++++++++++++++++++++++++++++++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Demo/WIN32-MSVC/FreeRTOSConfig.h b/Demo/WIN32-MSVC/FreeRTOSConfig.h index d946a0766..a8e04ae6e 100644 --- a/Demo/WIN32-MSVC/FreeRTOSConfig.h +++ b/Demo/WIN32-MSVC/FreeRTOSConfig.h @@ -111,6 +111,8 @@ to exclude the API function. */ #define INCLUDE_vTaskDelay 1 #define INCLUDE_uxTaskGetStackHighWaterMark 1 #define INCLUDE_xTaskGetSchedulerState 1 +#define INCLUDE_xTimerGetTimerTaskHandle 1 +#define INCLUDE_xTaskGetIdleTaskHandle 1 extern void vAssertCalled( void ); #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled() diff --git a/Demo/WIN32-MSVC/WIN32.suo b/Demo/WIN32-MSVC/WIN32.suo index 6f3cdfbcd0073334213a887a676be73334bef3e6..481e87bf0306909b2b9db3c3afab29f181709f19 100644 GIT binary patch delta 1685 zcmcIke^69a6n=Mqu?noa>#8dntO!VGx+Wr+EsM}50=g0!2}8RWzfqUvi9lcu8IcmW z`-zI;R^T+npzZ9dnV1q+%bIZn(P6sHaI1atUHO!HY%wW_?srp((hC+8A3HH9Q4XxI${?Qjuj( z7R<9gl}K8daCi1fIlhz`1^!7{C>upx!fOv7eJ>%=FhtpBNrp+zk(?(PAAvXqolcSVP9k)h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lyfD^iJC>0w-~34lH9jeg&i@7rhqji%5x7S~1E_ z4CrxSDFkV@75B*5Kpy3IQ2~Smp^Ym+49~{k?dVBGdtU0^wXZ8A#KQXX)SbaI=Z1Pp zPr%KVIdH_94NXN!wDrksxIX}{eGx1pBoOGvTDlHb;@ze=r9UNPDjKAiLLtTz-rLs1ygPyjz)CX*v8u|aCGZG!b(UC#~5a9u_3_Vr^S1fT* zLdJz@M-TAjgLNWqksgtnBsA+JKI~*Za`7)ecGRCpY6bE%o=Cbw#4PO&#og7C| zqEvJS(Jrv{Er;y>5V#%|4lAv(z}f0)Iiz$Q+idvj zKo$ERsIm27X|Fk#nzncKz#zj;$&-l|mgpdm8ht=ltQUqxOGOOalr zGtCk3OPUYxwv4BF@O{DqDTRS|w^IwUR0=tJ{OD)Uy>}mM$w%<10Z58B6ux(u)*u=) znD+;G6B3UHs6i~XFxqt-mUI`uwX|U7v$u)TN=#z}<7}Va23|G=Uz^Ddn)Na6N+)RF z4~Oh}0nVr7Vtxgv_qMRzjb)SzCqS!o=vx2-A(;@}oFH=%16=!X7Wf^=V$MpQ0uO`G z8}Skb`2zjm7PU%$#M_7mOUHxR@nEILh7WMkkt-njU??nUt%uS@ULPq1w4hrD-B0AKy6zg ztIdUfo$GElz}cu6ZXShg?YZ(daD7}X?c?e(PB?_ay^`L-X6P_u7`nxR7-7a7u>=d* zg(HjT3y8HG_zw5~D6ka5>w}+HZ||CMVn9FlW!Shz!J>bUbs>@H*HuiXlaear?=4+pD9aVR#ir?7A+5_Da1 K_VdNrs(%2fY@{Xt diff --git a/Demo/WIN32-MSVC/main.c b/Demo/WIN32-MSVC/main.c index 3ff9e4d76..6aa0e3270 100644 --- a/Demo/WIN32-MSVC/main.c +++ b/Demo/WIN32-MSVC/main.c @@ -86,6 +86,8 @@ #include #include "task.h" #include "queue.h" +#include "timers.h" +#include "semphr.h" /* Standard demo includes. */ #include "BlockQ.h" @@ -116,6 +118,13 @@ /* Task function prototypes. */ static void prvCheckTask( void *pvParameters ); +/* The variable into which error messages are latched. */ +static char *pcStatusMessage = "OK"; + +/* This semaphore is created purely to test using the vSemaphoreDelete() API +function. It has no other purpose. */ +static xSemaphoreHandle xSemaphoreToDelete = NULL; + /*-----------------------------------------------------------*/ int main( void ) @@ -135,6 +144,10 @@ int main( void ) vStartTimerDemoTask( mainTIMER_TEST_PERIOD ); vStartCountingSemaphoreTasks(); + /* Create the semaphore that will be deleted in the idle task hook. This + is done purely to test the use of vSemaphoreDelete(). */ + xSemaphoreToDelete = xSemaphoreCreateMutex(); + /* Start the scheduler itself. */ vTaskStartScheduler(); @@ -148,7 +161,6 @@ static void prvCheckTask( void *pvParameters ) { portTickType xNextWakeTime; const portTickType xCycleFrequency = 1000 / portTICK_RATE_MS; -char *pcStatusMessage = "OK"; /* Just to remove compiler warning. */ ( void ) pvParameters; @@ -213,10 +225,41 @@ char *pcStatusMessage = "OK"; void vApplicationIdleHook( void ) { const unsigned long ulMSToSleep = 5; +xTaskHandle xIdleTaskHandle, xTimerTaskHandle; +signed char *pcTaskName; /* Sleep to reduce CPU load, but don't sleep indefinitely in case there are tasks waiting to be terminated by the idle task. */ Sleep( ulMSToSleep ); + + /* Demonstrate the use of the xTimerGetTimerTaskHandle() and + xTaskGetIdleTaskHandle() functions. */ + xIdleTaskHandle = xTaskGetIdleTaskHandle(); + xTimerTaskHandle = xTimerGetTimerTaskHandle(); + + /* This is the idle hook, so the current task handle should equal the + returned idle task handle. */ + if( xTaskGetCurrentTaskHandle() != xIdleTaskHandle ) + { + pcStatusMessage = "Error: Returned idle task handle was incorrect"; + } + + /* Check the timer task handle was returned correctly. */ + pcTaskName = pcTaskGetTaskName( xTimerTaskHandle ); + if( strcmp( pcTaskName, "Tmr Svc" ) != 0 ) + { + pcStatusMessage = "Error: Returned timer task handle was incorrect"; + } + + /* If xSemaphoreToDelete has not already been deleted, then delete it now. + This is done purely to demonstrate the use of, and test, the + vSemaphoreDelete() macro. Care must be taken not to delete a semaphore + that has tasks blocked on it. */ + if( xSemaphoreToDelete != NULL ) + { + vSemaphoreDelete( xSemaphoreToDelete ); + xSemaphoreToDelete = NULL; + } } /*-----------------------------------------------------------*/ -- 2.39.5