Added in more demo apps to the Win32 demo.

pull/1/head
Richard Barry 14 years ago
parent c30b4242bb
commit 0de50e377c

@ -64,19 +64,28 @@
* THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE
* FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE.
*----------------------------------------------------------*/ *----------------------------------------------------------*/
#define configUSE_PREEMPTION 1
#define configUSE_PREEMPTION 0
#define configUSE_IDLE_HOOK 1 #define configUSE_IDLE_HOOK 1
#define configUSE_TICK_HOOK 0 #define configUSE_TICK_HOOK 0
#define configCPU_CLOCK_HZ ( ( unsigned portLONG ) 47923200 ) #define configTICK_RATE_HZ ( ( portTickType ) 50 )
#define configTICK_RATE_HZ ( ( portTickType ) 100 )
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 5 )
#define configMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 50 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */ #define configMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 50 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */
#define configTOTAL_HEAP_SIZE ( ( size_t ) 0 ) /* This parameter has no effect when heap_3.c is included in the project. */ #define configTOTAL_HEAP_SIZE ( ( size_t ) 0 ) /* This parameter has no effect when heap_3.c is included in the project. */
#define configMAX_TASK_NAME_LEN ( 16 ) #define configMAX_TASK_NAME_LEN ( 12 )
#define configUSE_TRACE_FACILITY 0 #define configUSE_TRACE_FACILITY 1
#define configUSE_16_BIT_TICKS 0 #define configUSE_16_BIT_TICKS 0
#define configIDLE_SHOULD_YIELD 1 #define configIDLE_SHOULD_YIELD 1
#define configUSE_CO_ROUTINES 0
#define configUSE_MUTEXES 1
#define configGENERATE_RUN_TIME_STATS 0
#define configCHECK_FOR_STACK_OVERFLOW 0
#define configUSE_RECURSIVE_MUTEXES 1
#define configQUEUE_REGISTRY_SIZE 0
#define configUSE_MALLOC_FAILED_HOOK 1
#define configUSE_APPLICATION_TASK_TAG 0
#define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 7 )
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
/* Co-routine definitions. */ /* Co-routine definitions. */
#define configUSE_CO_ROUTINES 0 #define configUSE_CO_ROUTINES 0
@ -87,11 +96,13 @@ to exclude the API function. */
#define INCLUDE_vTaskPrioritySet 1 #define INCLUDE_vTaskPrioritySet 1
#define INCLUDE_uxTaskPriorityGet 1 #define INCLUDE_uxTaskPriorityGet 1
#define INCLUDE_vTaskDelete 0 #define INCLUDE_vTaskDelete 1
#define INCLUDE_vTaskCleanUpResources 0 #define INCLUDE_vTaskCleanUpResources 0
#define INCLUDE_vTaskSuspend 1 #define INCLUDE_vTaskSuspend 1
#define INCLUDE_vTaskDelayUntil 1 #define INCLUDE_vTaskDelayUntil 1
#define INCLUDE_vTaskDelay 1 #define INCLUDE_vTaskDelay 1
#define INCLUDE_uxTaskGetStackHighWaterMark 1
#define INCLUDE_xTaskGetSchedulerState 1
#endif /* FREERTOS_CONFIG_H */ #endif /* FREERTOS_CONFIG_H */

Binary file not shown.

@ -55,7 +55,7 @@
<ClCompile> <ClCompile>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>..\..\Source\include;..\..\Source\portable\MSVC-MingW;..\Common\Include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>..\..\Source\include;..\..\Source\portable\MSVC-MingW;..\Common\Include;.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0400;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0500;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild> <MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
@ -66,6 +66,7 @@
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner> <SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<DisableLanguageExtensions>false</DisableLanguageExtensions>
</ClCompile> </ClCompile>
<ResourceCompile> <ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
@ -78,6 +79,7 @@
<ProgramDatabaseFile>.\Debug/WIN32.pdb</ProgramDatabaseFile> <ProgramDatabaseFile>.\Debug/WIN32.pdb</ProgramDatabaseFile>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link> </Link>
<Bscmake> <Bscmake>
<SuppressStartupBanner>true</SuppressStartupBanner> <SuppressStartupBanner>true</SuppressStartupBanner>
@ -122,6 +124,15 @@
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\Source\portable\MemMang\heap_3.c" /> <ClCompile Include="..\..\Source\portable\MemMang\heap_3.c" />
<ClCompile Include="..\Common\Minimal\BlockQ.c" />
<ClCompile Include="..\Common\Minimal\blocktim.c" />
<ClCompile Include="..\Common\Minimal\flop.c" />
<ClCompile Include="..\Common\Minimal\GenQTest.c" />
<ClCompile Include="..\Common\Minimal\integer.c" />
<ClCompile Include="..\Common\Minimal\PollQ.c" />
<ClCompile Include="..\Common\Minimal\QPeek.c" />
<ClCompile Include="..\Common\Minimal\recmutex.c" />
<ClCompile Include="..\Common\Minimal\semtest.c" />
<ClCompile Include="main.c"> <ClCompile Include="main.c">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>

@ -23,6 +23,12 @@
<UniqueIdentifier>{34567deb-d5ab-4a56-8640-0aaec609521a}</UniqueIdentifier> <UniqueIdentifier>{34567deb-d5ab-4a56-8640-0aaec609521a}</UniqueIdentifier>
<Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions> <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions>
</Filter> </Filter>
<Filter Include="Demo App Source\Common Demo Tasks">
<UniqueIdentifier>{2d4a700c-06e3-4dd2-afbe-ab1be71ebe2a}</UniqueIdentifier>
</Filter>
<Filter Include="FreeRTOS Source\Source\Portable">
<UniqueIdentifier>{88f409e6-d396-4ac5-94bd-7a99c914be46}</UniqueIdentifier>
</Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="main.c"> <ClCompile Include="main.c">
@ -31,9 +37,6 @@
<ClCompile Include="..\..\Source\list.c"> <ClCompile Include="..\..\Source\list.c">
<Filter>FreeRTOS Source\Source</Filter> <Filter>FreeRTOS Source\Source</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\Source\portable\WIN32\port.c">
<Filter>FreeRTOS Source\Source</Filter>
</ClCompile>
<ClCompile Include="..\..\Source\queue.c"> <ClCompile Include="..\..\Source\queue.c">
<Filter>FreeRTOS Source\Source</Filter> <Filter>FreeRTOS Source\Source</Filter>
</ClCompile> </ClCompile>
@ -43,6 +46,36 @@
<ClCompile Include="..\..\Source\portable\MemMang\heap_3.c"> <ClCompile Include="..\..\Source\portable\MemMang\heap_3.c">
<Filter>FreeRTOS Source\Source</Filter> <Filter>FreeRTOS Source\Source</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\Source\portable\MSVC-MingW\port.c">
<Filter>FreeRTOS Source\Source\Portable</Filter>
</ClCompile>
<ClCompile Include="..\Common\Minimal\flop.c">
<Filter>Demo App Source\Common Demo Tasks</Filter>
</ClCompile>
<ClCompile Include="..\Common\Minimal\GenQTest.c">
<Filter>Demo App Source\Common Demo Tasks</Filter>
</ClCompile>
<ClCompile Include="..\Common\Minimal\integer.c">
<Filter>Demo App Source\Common Demo Tasks</Filter>
</ClCompile>
<ClCompile Include="..\Common\Minimal\PollQ.c">
<Filter>Demo App Source\Common Demo Tasks</Filter>
</ClCompile>
<ClCompile Include="..\Common\Minimal\QPeek.c">
<Filter>Demo App Source\Common Demo Tasks</Filter>
</ClCompile>
<ClCompile Include="..\Common\Minimal\recmutex.c">
<Filter>Demo App Source\Common Demo Tasks</Filter>
</ClCompile>
<ClCompile Include="..\Common\Minimal\semtest.c">
<Filter>Demo App Source\Common Demo Tasks</Filter>
</ClCompile>
<ClCompile Include="..\Common\Minimal\BlockQ.c">
<Filter>Demo App Source\Common Demo Tasks</Filter>
</ClCompile>
<ClCompile Include="..\Common\Minimal\blocktim.c">
<Filter>Demo App Source\Common Demo Tasks</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Board.h"> <ClInclude Include="Board.h">

@ -51,13 +51,38 @@
licensing and training services. licensing and training services.
*/ */
/* Standard includes. */
#include <stdio.h> #include <stdio.h>
/* Kernel includes. */
#include <FreeRTOS.h> #include <FreeRTOS.h>
#include "task.h" #include "task.h"
#include "queue.h" #include "queue.h"
/* Task priorities. */ /* Standard demo includes. */
#define mainSTDOUT_TASK_PRIORITY tskIDLE_PRIORITY #include "partest.h"
#include "BlockQ.h"
#include "death.h"
#include "integer.h"
//#include "blocktim.h"
#include "semtest.h"
#include "PollQ.h"
#include "GenQTest.h"
#include "QPeek.h"
#include "recmutex.h"
#include "flop.h"
/* Priorities at which the tasks are created. */
#define mainCHECK_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
#define mainQUEUE_POLL_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define mainBLOCK_Q_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainCREATOR_TASK_PRIORITY ( tskIDLE_PRIORITY + 3 )
#define mainFLASH_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define mainuIP_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 )
#define mainINTEGER_TASK_PRIORITY ( tskIDLE_PRIORITY )
#define mainGEN_QUEUE_TASK_PRIORITY ( tskIDLE_PRIORITY )
#define mainFLOP_TASK_PRIORITY ( tskIDLE_PRIORITY )
/* Stack sizes. */ /* Stack sizes. */
#define mainSTDOUT_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 4 ) #define mainSTDOUT_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 4 )
@ -67,9 +92,7 @@ static volatile unsigned long ul1 = 0, ul2 = 0;
static xQueueHandle xStdoutQueue = NULL; static xQueueHandle xStdoutQueue = NULL;
/* Task function prototypes. */ /* Task function prototypes. */
static void prvTask1( void *pvParameters ); static void prvCheckTask( void *pvParameters );
static void prvTask2( void *pvParameters );
static void prvStdoutTask( void *pvParameters );
/* Create a queue on which console output strings can be posted, then start the /* Create a queue on which console output strings can be posted, then start the
task that processes the queue - printf()'ing each string that is received. */ task that processes the queue - printf()'ing each string that is received. */
@ -79,14 +102,25 @@ static void prvStartStdoutTask( void );
pointed to by pcTextToPrint for output to stdout in a thread safe manner. */ pointed to by pcTextToPrint for output to stdout in a thread safe manner. */
void vMainConsolePrint( const char *pcTextToPrint, portTickType xTicksToWait ); void vMainConsolePrint( const char *pcTextToPrint, portTickType xTicksToWait );
volatile unsigned long ulIdleCount = 0UL, ulT1Count = 0UL, ulT2Count = 0UL, ulTicks = 0UL;
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
int main( void ) int main( void )
{ {
prvStartStdoutTask(); /* Start the check task as described at the top of this file. */
xTaskCreate( prvTask1, "t1", 100, NULL, 0, NULL ); xTaskCreate( prvCheckTask, ( signed char * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL );
xTaskCreate( prvTask2, "t2", 100, NULL, 0, NULL );
/* Create the standard demo tasks. */
vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY );
// vCreateBlockTimeTasks();
vStartSemaphoreTasks( mainSEM_TEST_PRIORITY );
vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY );
vStartIntegerMathTasks( mainINTEGER_TASK_PRIORITY );
vStartGenericQueueTasks( mainGEN_QUEUE_TASK_PRIORITY );
vStartQueuePeekTasks();
vStartRecursiveMutexTasks();
vStartMathTasks( mainFLOP_TASK_PRIORITY );
/* Start the scheduler itself. */
vTaskStartScheduler(); vTaskStartScheduler();
/* Should never get here unless there was not enough heap space to create /* Should never get here unless there was not enough heap space to create
@ -95,102 +129,97 @@ int main( void )
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void vMainConsolePrint( const char *pcTextToPrint, portTickType xTicksToWait ) static void prvCheckTask( void *pvParameters )
{
if( xStdoutQueue != NULL )
{ {
xQueueSend( xStdoutQueue, &pcTextToPrint, xTicksToWait ); portTickType xNextWakeTime;
} const portTickType xCycleFrequency = 5000 / portTICK_RATE_MS;
} char *pcStatusMessage = "OK";
/*-----------------------------------------------------------*/ long lCycleCount = 0;
static void prvStartStdoutTask( void ) /* Just to remove compiler warning. */
{ ( void ) pvParameters;
const unsigned long ulQueueLength = 20;
/* Create the queue on which starings for output will be stored. */ /* Initialise xNextWakeTime - this only needs to be done once. */
xStdoutQueue = xQueueCreate( ulQueueLength, ( unsigned portBASE_TYPE ) sizeof( char * ) ); xNextWakeTime = xTaskGetTickCount();
if( xStdoutQueue != NULL ) for( ;; )
{ {
/* Create the task that processes the stdout messages. */ /* Place this task in the blocked state until it is time to run again. */
xTaskCreate( prvStdoutTask, "stdout task", mainSTDOUT_TASK_STACK_SIZE, NULL, mainSTDOUT_TASK_PRIORITY, NULL ); vTaskDelayUntil( &xNextWakeTime, xCycleFrequency );
}
}
/*-----------------------------------------------------------*/
static void prvStdoutTask( void *pvParameters ) /* Check the standard demo tasks are running without error. */
if( xAreIntegerMathsTaskStillRunning() != pdTRUE )
{ {
char *pcString; pcStatusMessage = "Error: IntMath";
}
/* Just to remove compiler warnings. */ else if( xAreGenericQueueTasksStillRunning() != pdTRUE )
( void ) pvParameters;
for( ;; )
{ {
/* This task would not have been created if the queue had not been created pcStatusMessage = "Error: GenQueue";
successfully too. Also, because of the FreeRTOSConfig.h settings using
portMAX_DELAY in this case means wait forever, so when this function returns
we know there is a string to print. */
xQueueReceive( xStdoutQueue, &pcString, portMAX_DELAY );
printf( "%s", pcString );
//fflush( stdout );
} }
else if( xAreQueuePeekTasksStillRunning() != pdTRUE )
{
pcStatusMessage = "Error: QueuePeek";
} }
/*-----------------------------------------------------------*/ else if( xAreBlockingQueuesStillRunning() != pdTRUE )
static void prvTask1( void *pvParameters )
{ {
const char *pcTask1Message = "Task 1 running\r\n"; pcStatusMessage = "Error: BlockQueue";
const portTickType xTicksToDelay = 1000 / portTICK_RATE_MS; }
// else if( xAreBlockTimeTestTasksStillRunning() != pdTRUE )
/* Just to remove compiler warnings. */ // {
( void ) pvParameters; // pcStatusMessage = "Error: BlockTime";
// }
for( ;; ) else if( xAreSemaphoreTasksStillRunning() != pdTRUE )
{ {
// ul1++; pcStatusMessage = "Error: SemTest";
vMainConsolePrint( pcTask1Message, 0 );
vTaskDelay( xTicksToDelay );
ulT1Count++;
} }
else if( xArePollingQueuesStillRunning() != pdTRUE )
{
pcStatusMessage = "Error: PollQueue";
} }
/*-----------------------------------------------------------*/ else if( xAreRecursiveMutexTasksStillRunning() != pdTRUE )
static void prvTask2( void *pvParameters )
{ {
const char *pcTask2Message = "Task 2 running\r\n"; pcStatusMessage = "Error: RecMutex";
const portTickType xTicksToDelay = 500 / portTICK_RATE_MS; }
else if( xAreMathsTaskStillRunning() != pdPASS )
/* Just to remove compiler warnings. */
( void ) pvParameters;
for( ;; )
{ {
// ul2++; pcStatusMessage = "Error: Flop";
vMainConsolePrint( pcTask2Message, 0 ); }
vTaskDelay( xTicksToDelay );
ulT2Count++; /* This is the only task that uses stdout so its ok to call printf()
// taskYIELD(); directly. */
printf( "%s - %d\r\n", pcStatusMessage, xTaskGetTickCount() );
} }
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void vApplicationIdleHook() void vApplicationIdleHook( void )
{ {
const unsigned long ulMSToSleep = 5;
/* Sleep to reduce CPU load, but don't sleep indefinitely if not using /* Sleep to reduce CPU load, but don't sleep indefinitely if not using
preemption as as nothing will cause a task switch. */ preemption as as nothing will cause a task switch. */
#if configUSE_PREEMPTION != 0 #if( configUSE_PREEMPTION != 0 )
{ {
SleepEx( INFINITE, TRUE ); SleepEx( INFINITE, TRUE );
} }
#else #else
{ {
const unsigned long ulMSToSleep = 5;
SleepEx( ulMSToSleep, TRUE ); SleepEx( ulMSToSleep, TRUE );
} }
#endif #endif
}
/*-----------------------------------------------------------*/
ulIdleCount++; void vApplicationMallocFailedHook( void )
{
/* Can be implemented if required, but probably not required in this
environment and running this demo. */
} }
/*-----------------------------------------------------------*/
void vApplicationStackOverflowHook( void )
{
/* Can be implemented if required, but not required in this
environment and running this demo. */
}

Loading…
Cancel
Save