2 FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd.
\r
5 FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME. PLEASE VISIT
\r
6 http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
8 ***************************************************************************
\r
10 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
11 * Complete, revised, and edited pdf reference manuals are also *
\r
14 * Purchasing FreeRTOS documentation will not only help you, by *
\r
15 * ensuring you get running as quickly as possible and with an *
\r
16 * in-depth knowledge of how to use FreeRTOS, it will also help *
\r
17 * the FreeRTOS project to continue with its mission of providing *
\r
18 * professional grade, cross platform, de facto standard solutions *
\r
19 * for microcontrollers - completely free of charge! *
\r
21 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
23 * Thank you for using FreeRTOS, and thank you for your support! *
\r
25 ***************************************************************************
\r
28 This file is part of the FreeRTOS distribution.
\r
30 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
31 the terms of the GNU General Public License (version 2) as published by the
\r
32 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
34 >>>>>>NOTE<<<<<< The modification to the GPL is included to allow you to
\r
35 distribute a combined work that includes FreeRTOS without being obliged to
\r
36 provide the source code for proprietary components outside of the FreeRTOS
\r
39 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
40 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
41 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
\r
42 details. You should have received a copy of the GNU General Public License
\r
43 and the FreeRTOS license exception along with FreeRTOS; if not itcan be
\r
44 viewed here: http://www.freertos.org/a00114.html and also obtained by
\r
45 writing to Real Time Engineers Ltd., contact details for whom are available
\r
46 on the FreeRTOS WEB site.
\r
50 ***************************************************************************
\r
52 * Having a problem? Start by reading the FAQ "My application does *
\r
53 * not run, what could be wrong?" *
\r
55 * http://www.FreeRTOS.org/FAQHelp.html *
\r
57 ***************************************************************************
\r
60 http://www.FreeRTOS.org - Documentation, books, training, latest versions,
\r
61 license and Real Time Engineers Ltd. contact details.
\r
63 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
64 including FreeRTOS+Trace - an indispensable productivity tool, and our new
\r
65 fully thread aware and reentrant UDP/IP stack.
\r
67 http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
\r
68 Integrity Systems, who sell the code with commercial support,
\r
69 indemnification and middleware, under the OpenRTOS brand.
\r
71 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
72 engineered and independently SIL3 certified version for use in safety and
\r
73 mission critical applications that require provable dependability.
\r
76 /******************************************************************************
\r
78 * This demo is described on the following web page:
\r
79 * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT_SL/Demos/File_System_Win32_Simulator_demo.shtml
\r
81 ******************************************************************************/
\r
83 /* Standard includes. */
\r
87 /* FreeRTOS includes. */
\r
88 #include <FreeRTOS.h>
\r
93 /* File system includes. */
\r
94 #include "config_fat_sl.h"
\r
96 /* Priorities at which the tasks are created. */
\r
97 #define mainUDP_CLI_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
99 /*-----------------------------------------------------------*/
\r
102 * Register the generic commands that can be used with FreeRTOS+CLI.
\r
104 extern void vRegisterSampleCLICommands( void );
\r
107 * Register the file system commands that can be used with FreeRTOS+CLI.
\r
109 extern void vRegisterFileSystemCLICommands( void );
\r
112 * The task that implements the UDP command interpreter using FreeRTOS+CLI.
\r
114 extern void vUDPCommandInterpreterTask( void *pvParameters );
\r
117 * Creates and verifies different files on the volume, demonstrating the use of
\r
118 * various different API functions.
\r
120 extern void vCreateAndVerifySampleFiles( void );
\r
122 /*-----------------------------------------------------------*/
\r
124 /******************************************************************************
\r
126 * This demo is described on the following web page:
\r
127 * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT_SL/Demos/File_System_Win32_Simulator_demo.shtml
\r
129 ******************************************************************************/
\r
133 const uint32_t ulLongTime_ms = 250UL;
\r
135 /* If the file system is only going to be accessed from one task then
\r
136 F_FS_THREAD_AWARE can be set to 0 and the set of example files are created
\r
137 before the RTOS scheduler is started. If the file system is going to be
\r
138 access from more than one task then F_FS_THREAD_AWARE must be set to 1 and
\r
139 the set of sample files are created from the idle task hook function
\r
140 vApplicationIdleHook() - which is defined in this file. */
\r
141 #if F_FS_THREAD_AWARE == 0
\r
143 /* Initialise the drive and file system, then create a few example
\r
144 files. The output from this function just goes to the stdout window,
\r
145 allowing the output to be viewed when the UDP command console is not
\r
147 vCreateAndVerifySampleFiles();
\r
151 /* Register generic commands with the FreeRTOS+CLI command interpreter. */
\r
152 vRegisterSampleCLICommands();
\r
154 /* Register file system related commands with the FreeRTOS+CLI command
\r
156 vRegisterFileSystemCLICommands();
\r
158 /* Create the task that handles the CLI on a UDP port. The port number
\r
159 is set using the configUDP_CLI_PORT_NUMBER setting in FreeRTOSConfig.h. */
\r
160 xTaskCreate( vUDPCommandInterpreterTask, /* The function that implements the command interpreter IO handling. */
\r
161 ( signed char * ) "CLI", /* The name of the task - just to assist debugging. */
\r
162 configMINIMAL_STACK_SIZE, NULL, /* The size of the stack allocated to the task. */
\r
163 mainUDP_CLI_TASK_PRIORITY, /* The priority at which the task will run. */
\r
164 NULL ); /* A handle to the task is not required, so NULL is passed. */
\r
166 /* Start the RTOS scheduler. */
\r
167 vTaskStartScheduler();
\r
169 /* If all is well, the scheduler will now be running, and the following
\r
170 line will never be reached. If the following line does execute, then
\r
171 there was insufficient FreeRTOS heap memory available for the idle and/or
\r
172 timer tasks to be created. See the memory management section on the
\r
173 FreeRTOS web site for more details (this is standard text that is not not
\r
174 really applicable to the Win32 simulator port). */
\r
177 Sleep( ulLongTime_ms );
\r
180 /*-----------------------------------------------------------*/
\r
182 void vApplicationIdleHook( void )
\r
184 const unsigned long ulMSToSleep = 5;
\r
186 /* If the file system is only going to be accessed from one task then
\r
187 F_FS_THREAD_AWARE can be set to 0 and the set of example files is created
\r
188 before the RTOS scheduler is started. If the file system is going to be
\r
189 access from more than one task then F_FS_THREAD_AWARE must be set to 1 and
\r
190 the set of sample files are created from the idle task hook function. */
\r
191 #if F_FS_THREAD_AWARE == 1
\r
193 static portBASE_TYPE xCreatedSampleFiles = pdFALSE;
\r
195 /* Initialise the drive and file system, then create a few example
\r
196 files. The output from this function just goes to the stdout window,
\r
197 allowing the output to be viewed when the UDP command console is not
\r
199 if( xCreatedSampleFiles == pdFALSE )
\r
201 vCreateAndVerifySampleFiles();
\r
202 xCreatedSampleFiles = pdTRUE;
\r
207 /* This function is called on each cycle of the idle task if
\r
208 configUSE_IDLE_HOOK is set to 1 in FreeRTOSConfig.h. Sleep to reduce CPU
\r
210 Sleep( ulMSToSleep );
\r
212 /*-----------------------------------------------------------*/
\r
214 void vAssertCalled( const char *pcFile, unsigned long ulLine )
\r
216 printf( "ASSERT FAILED: File %s, line %u\r\n", pcFile, ulLine );
\r
218 /*-----------------------------------------------------------*/
\r
220 void vApplicationMallocFailedHook( void )
\r
222 /* vApplicationMallocFailedHook() will only be called if
\r
223 configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
\r
224 function that will get called if a call to pvPortMalloc() fails.
\r
225 pvPortMalloc() is called internally by the kernel whenever a task, queue,
\r
226 timer or semaphore is created. It is also called by various parts of the
\r
227 demo application. If heap_1.c, heap_2.c or heap_4.c are used, then the
\r
228 size of the heap available to pvPortMalloc() is defined by
\r
229 configTOTAL_HEAP_SIZE in FreeRTOSConfig.h, and the xPortGetFreeHeapSize()
\r
230 API function can be used to query the size of free heap space that remains
\r
231 (although it does not provide information on how the remaining heap might
\r
233 taskDISABLE_INTERRUPTS();
\r