From 702eb2128ca5a045bed89e68d7ff90bbccc74056 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Sun, 14 Nov 2010 21:00:36 +0000 Subject: [PATCH] Start of new Win32 emulator project. Currently working but not well tested, and does not include a method for shutting down the generated processes. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1139 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Demo/WIN32-MSVC/FreeRTOSConfig.h | 97 +++++++++++++ Demo/WIN32-MSVC/WIN32.sln | 20 +++ Demo/WIN32-MSVC/WIN32.suo | Bin 0 -> 36864 bytes Demo/WIN32-MSVC/WIN32.vcxproj | 166 ++++++++++++++++++++++ Demo/WIN32-MSVC/WIN32.vcxproj.filters | 79 +++++++++++ Demo/WIN32-MSVC/main.c | 196 ++++++++++++++++++++++++++ 6 files changed, 558 insertions(+) create mode 100644 Demo/WIN32-MSVC/FreeRTOSConfig.h create mode 100644 Demo/WIN32-MSVC/WIN32.sln create mode 100644 Demo/WIN32-MSVC/WIN32.suo create mode 100644 Demo/WIN32-MSVC/WIN32.vcxproj create mode 100644 Demo/WIN32-MSVC/WIN32.vcxproj.filters create mode 100644 Demo/WIN32-MSVC/main.c diff --git a/Demo/WIN32-MSVC/FreeRTOSConfig.h b/Demo/WIN32-MSVC/FreeRTOSConfig.h new file mode 100644 index 000000000..01a8bd564 --- /dev/null +++ b/Demo/WIN32-MSVC/FreeRTOSConfig.h @@ -0,0 +1,97 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + + +#ifndef FREERTOS_CONFIG_H +#define FREERTOS_CONFIG_H + +/*----------------------------------------------------------- + * Application specific definitions. + * + * These definitions should be adjusted for your particular hardware and + * application requirements. + * + * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE + * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. + *----------------------------------------------------------*/ + +#define configUSE_PREEMPTION 0 +#define configUSE_IDLE_HOOK 1 +#define configUSE_TICK_HOOK 0 +#define configCPU_CLOCK_HZ ( ( unsigned portLONG ) 47923200 ) +#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 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 configUSE_TRACE_FACILITY 0 +#define configUSE_16_BIT_TICKS 0 +#define configIDLE_SHOULD_YIELD 1 + +/* Co-routine definitions. */ +#define configUSE_CO_ROUTINES 0 +#define configMAX_CO_ROUTINE_PRIORITIES ( 2 ) + +/* Set the following definitions to 1 to include the API function, or zero +to exclude the API function. */ + +#define INCLUDE_vTaskPrioritySet 1 +#define INCLUDE_uxTaskPriorityGet 1 +#define INCLUDE_vTaskDelete 0 +#define INCLUDE_vTaskCleanUpResources 0 +#define INCLUDE_vTaskSuspend 1 +#define INCLUDE_vTaskDelayUntil 1 +#define INCLUDE_vTaskDelay 1 + + +#endif /* FREERTOS_CONFIG_H */ diff --git a/Demo/WIN32-MSVC/WIN32.sln b/Demo/WIN32-MSVC/WIN32.sln new file mode 100644 index 000000000..3f819af17 --- /dev/null +++ b/Demo/WIN32-MSVC/WIN32.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WIN32", "WIN32.vcxproj", "{C686325E-3261-42F7-AEB1-DDE5280E1CEB}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C686325E-3261-42F7-AEB1-DDE5280E1CEB}.Debug|Win32.ActiveCfg = Debug|Win32 + {C686325E-3261-42F7-AEB1-DDE5280E1CEB}.Debug|Win32.Build.0 = Debug|Win32 + {C686325E-3261-42F7-AEB1-DDE5280E1CEB}.Release|Win32.ActiveCfg = Release|Win32 + {C686325E-3261-42F7-AEB1-DDE5280E1CEB}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Demo/WIN32-MSVC/WIN32.suo b/Demo/WIN32-MSVC/WIN32.suo new file mode 100644 index 0000000000000000000000000000000000000000..39aba2fe49eb4b534e6e23b94ccd30ef088b9c2d GIT binary patch literal 36864 zcmeHQ33wdEm2MduZ17?nF5>_eMu2TRV`*f`H$)mqU~Jg}37aGn#As$DjWwDX&mmjJ zb_^th5FoIzfen`raM%UIIzZS30{*-qgw1X+$9~KAZE(U7j%FRa_3FJ>RjmUrP5$MMy;I**GQtJQQOe;X6O^M3_e+o_sNn=f z8H2=8fWt?Q91%Aa1Nl2b=+z1~?N?1}Fub1(*dm8*o109KgAN^8hmd zGXa$V7hpEP4Oj?h08{|TdmhAd0n-6hfNH=zzMdl`8j45lBrNG{fRK2p^rWEtz zQy_&Te#Yjf`LD>=3@wUZNh)2+awUv7rCg5R5NMM3lOkK*-?9SmQ-*SUG06IdlmM{T z0e2FVbf7gzg?%Vh#*}c}a_l*+KY3f0EXM|8%7I)mK#qUr*@irfIsVy(lmQ(7yhj

|bLWx*W)DF-M6IQ}UIN&y`I9Jd_*^4-kw&-;`Oj420XKE{**9REyH25|f{Eyq98 zgArB&Pm_i#U-?(y`4_c3UqK_=@8;}E!~MYtfjjUM*!X0bqsMF zuvWV!pQf~Q58`zIjwIH91LCUz8@21rh`$Qh0(fqP^7^Bf|Dpa{cl+mD*0yOiZuKjC zgS z#5gwH7!D+2$yj^Jy(*kc`yhYf*QY|!WVkIH38#A9O{6r5JAu&o%hg0E!S|X|u|$aVJWkceimCo8$eR{* z4u~jih}SF4s^sYb=LL|m3)3NgC<90XgI#_;C*_ni3@yMD$4H{IqvWFu4ng`k!Oi#2 z1pXaxE(4Dt1%y>fV~q}cCw%EL;m*F-6?+RQKcI9Wa6(y zJA^<(7g{BT_TZdsMaK-(e?H2iJa&rz5b~}8Fu2S6&;H{`dvxHK-oWOP<+TCfjYT4% z07oxTj^z+hJ8lBI@C5!aP&X|!uw3f9)HTzPu;j$35>#8hL)A*ij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mV?d00001 diff --git a/Demo/WIN32-MSVC/WIN32.vcxproj b/Demo/WIN32-MSVC/WIN32.vcxproj new file mode 100644 index 000000000..789455967 --- /dev/null +++ b/Demo/WIN32-MSVC/WIN32.vcxproj @@ -0,0 +1,166 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + {C686325E-3261-42F7-AEB1-DDE5280E1CEB} + RTOSDemo + + + + Application + false + MultiByte + + + Application + false + MultiByte + + + + + + + + + + + + + + + <_ProjectFileVersion>10.0.30319.1 + .\Debug\ + .\Debug\ + true + .\Release\ + .\Release\ + false + + + + .\Debug/WIN32.tlb + + + + + Disabled + ..\..\Source\include;..\..\Source\portable\MSVC-MingW;..\Common\Include;.;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_CONSOLE;_WIN32_WINNT=0x0400;WINVER=0x400;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebug + .\Debug/WIN32.pch + .\Debug/ + .\Debug/ + .\Debug/ + Level4 + true + EditAndContinue + + + _DEBUG;%(PreprocessorDefinitions) + 0x0c09 + + + .\Debug/RTOSDemo.exe + true + true + .\Debug/WIN32.pdb + Console + MachineX86 + + + true + .\Debug/WIN32.bsc + + + + + .\Release/WIN32.tlb + + + + + MaxSpeed + OnlyExplicitInline + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + MultiThreaded + true + .\Release/WIN32.pch + .\Release/ + .\Release/ + .\Release/ + Level3 + true + + + NDEBUG;%(PreprocessorDefinitions) + 0x0c09 + + + .\Release/WIN32.exe + true + .\Release/WIN32.pdb + Console + MachineX86 + + + true + .\Release/WIN32.bsc + + + + + + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + %(AdditionalIncludeDirectories) + %(PreprocessorDefinitions) + %(PreprocessorDefinitions) + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Demo/WIN32-MSVC/WIN32.vcxproj.filters b/Demo/WIN32-MSVC/WIN32.vcxproj.filters new file mode 100644 index 000000000..99f5959de --- /dev/null +++ b/Demo/WIN32-MSVC/WIN32.vcxproj.filters @@ -0,0 +1,79 @@ + + + + + {19ff1a34-36de-4c48-9d10-3fb1fa0d1fa4} + h;hpp;hxx;hm;inl + + + {38712199-cebf-4124-bf15-398f7c3419ea} + ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe + + + {af3445a1-4908-4170-89ed-39345d90d30c} + + + {f32be356-4763-4cae-9020-974a2638cb08} + *.c + + + {a60060e3-3949-4f60-b025-cb84164ae9ed} + + + {34567deb-d5ab-4a56-8640-0aaec609521a} + cpp;c;cxx;rc;def;r;odl;idl;hpj;bat + + + + + Demo App Source + + + FreeRTOS Source\Source + + + FreeRTOS Source\Source + + + FreeRTOS Source\Source + + + FreeRTOS Source\Source + + + FreeRTOS Source\Source + + + + + Header Files + + + Header Files + + + FreeRTOS Source\Include + + + FreeRTOS Source\Include + + + FreeRTOS Source\Include + + + FreeRTOS Source\Include + + + FreeRTOS Source\Include + + + FreeRTOS Source\Include + + + FreeRTOS Source\Include + + + FreeRTOS Source\Include + + + \ No newline at end of file diff --git a/Demo/WIN32-MSVC/main.c b/Demo/WIN32-MSVC/main.c new file mode 100644 index 000000000..b5b7d497b --- /dev/null +++ b/Demo/WIN32-MSVC/main.c @@ -0,0 +1,196 @@ +/* + FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd. + + *************************************************************************** + * * + * If you are: * + * * + * + New to FreeRTOS, * + * + Wanting to learn FreeRTOS or multitasking in general quickly * + * + Looking for basic training, * + * + Wanting to improve your FreeRTOS skills and productivity * + * * + * then take a look at the FreeRTOS books - available as PDF or paperback * + * * + * "Using the FreeRTOS Real Time Kernel - a Practical Guide" * + * http://www.FreeRTOS.org/Documentation * + * * + * A pdf reference manual is also available. Both are usually delivered * + * to your inbox within 20 minutes to two hours when purchased between 8am * + * and 8pm GMT (although please allow up to 24 hours in case of * + * exceptional circumstances). Thank you for your support! * + * * + *************************************************************************** + + This file is part of the FreeRTOS distribution. + + FreeRTOS is free software; you can redistribute it and/or modify it under + the terms of the GNU General Public License (version 2) as published by the + Free Software Foundation AND MODIFIED BY the FreeRTOS exception. + ***NOTE*** The exception to the GPL is included to allow you to distribute + a combined work that includes FreeRTOS without being obliged to provide the + source code for proprietary components outside of the FreeRTOS kernel. + FreeRTOS is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + more details. You should have received a copy of the GNU General Public + License and the FreeRTOS license exception along with FreeRTOS; if not it + can be viewed here: http://www.freertos.org/a00114.html and also obtained + by writing to Richard Barry, contact details for whom are available on the + FreeRTOS WEB site. + + 1 tab == 4 spaces! + + http://www.FreeRTOS.org - Documentation, latest information, license and + contact details. + + http://www.SafeRTOS.com - A version that is certified for use in safety + critical systems. + + http://www.OpenRTOS.com - Commercial support, development, porting, + licensing and training services. +*/ + +#include +#include +#include "task.h" +#include "queue.h" + +/* Task priorities. */ +#define mainSTDOUT_TASK_PRIORITY tskIDLE_PRIORITY + +/* Stack sizes. */ +#define mainSTDOUT_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 4 ) + +/* File scope variables. */ +static volatile unsigned long ul1 = 0, ul2 = 0; +static xQueueHandle xStdoutQueue = NULL; + +/* Task function prototypes. */ +static void prvTask1( 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 +task that processes the queue - printf()'ing each string that is received. */ +static void prvStartStdoutTask( void ); + +/* Post a message for output by the stdout task. Basically queues the message +pointed to by pcTextToPrint for output to stdout in a thread safe manner. */ +void vMainConsolePrint( const char *pcTextToPrint, portTickType xTicksToWait ); + +volatile unsigned long ulIdleCount = 0UL, ulT1Count = 0UL, ulT2Count = 0UL, ulTicks = 0UL; +/*-----------------------------------------------------------*/ + +int main( void ) +{ + prvStartStdoutTask(); + xTaskCreate( prvTask1, "t1", 100, NULL, 0, NULL ); + xTaskCreate( prvTask2, "t2", 100, NULL, 0, NULL ); + vTaskStartScheduler(); + + /* Should never get here unless there was not enough heap space to create + the idle and other system tasks. */ + return 0; +} +/*-----------------------------------------------------------*/ + +void vMainConsolePrint( const char *pcTextToPrint, portTickType xTicksToWait ) +{ + if( xStdoutQueue != NULL ) + { + xQueueSend( xStdoutQueue, &pcTextToPrint, xTicksToWait ); + } +} +/*-----------------------------------------------------------*/ + +static void prvStartStdoutTask( void ) +{ +const unsigned long ulQueueLength = 20; + + /* Create the queue on which starings for output will be stored. */ + xStdoutQueue = xQueueCreate( ulQueueLength, ( unsigned portBASE_TYPE ) sizeof( char * ) ); + + if( xStdoutQueue != NULL ) + { + /* Create the task that processes the stdout messages. */ + xTaskCreate( prvStdoutTask, "stdout task", mainSTDOUT_TASK_STACK_SIZE, NULL, mainSTDOUT_TASK_PRIORITY, NULL ); + } +} +/*-----------------------------------------------------------*/ + +static void prvStdoutTask( void *pvParameters ) +{ +char *pcString; + + /* Just to remove compiler warnings. */ + ( void ) pvParameters; + + for( ;; ) + { + /* This task would not have been created if the queue had not been created + 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 ); + } +} +/*-----------------------------------------------------------*/ + +static void prvTask1( void *pvParameters ) +{ +const char *pcTask1Message = "Task 1 running\r\n"; +const portTickType xTicksToDelay = 1000 / portTICK_RATE_MS; + + /* Just to remove compiler warnings. */ + ( void ) pvParameters; + + for( ;; ) + { +// ul1++; + vMainConsolePrint( pcTask1Message, 0 ); + vTaskDelay( xTicksToDelay ); + ulT1Count++; + } +} +/*-----------------------------------------------------------*/ + +static void prvTask2( void *pvParameters ) +{ +const char *pcTask2Message = "Task 2 running\r\n"; +const portTickType xTicksToDelay = 500 / portTICK_RATE_MS; + + /* Just to remove compiler warnings. */ + ( void ) pvParameters; + + for( ;; ) + { +// ul2++; + vMainConsolePrint( pcTask2Message, 0 ); + vTaskDelay( xTicksToDelay ); + ulT2Count++; +// taskYIELD(); + } +} +/*-----------------------------------------------------------*/ + +void vApplicationIdleHook() +{ +const unsigned long ulMSToSleep = 5; + + /* Sleep to reduce CPU load, but don't sleep indefinitely if not using + preemption as as nothing will cause a task switch. */ + #if configUSE_PREEMPTION != 0 + { + SleepEx( INFINITE, TRUE ); + } + #else + { + SleepEx( ulMSToSleep, TRUE ); + } + #endif + + ulIdleCount++; +} -- 2.39.5