2 FreeRTOS V8.0.0 - Copyright (C) 2014 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 ***************************************************************************
\r
9 * FreeRTOS provides completely free yet professionally developed, *
\r
10 * robust, strictly quality controlled, supported, and cross *
\r
11 * platform software that has become a de facto standard. *
\r
13 * Help yourself get started quickly and support the FreeRTOS *
\r
14 * project by purchasing a FreeRTOS tutorial book, reference *
\r
15 * manual, or both from: http://www.FreeRTOS.org/Documentation *
\r
19 ***************************************************************************
\r
21 This file is part of the FreeRTOS distribution.
\r
23 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
24 the terms of the GNU General Public License (version 2) as published by the
\r
25 Free Software Foundation >>!AND MODIFIED BY!<< the FreeRTOS exception.
\r
27 >>! NOTE: The modification to the GPL is included to allow you to distribute
\r
28 >>! a combined work that includes FreeRTOS without being obliged to provide
\r
29 >>! the source code for proprietary components outside of the FreeRTOS
\r
32 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
33 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
34 FOR A PARTICULAR PURPOSE. Full license text is available from the following
\r
35 link: http://www.freertos.org/a00114.html
\r
39 ***************************************************************************
\r
41 * Having a problem? Start by reading the FAQ "My application does *
\r
42 * not run, what could be wrong?" *
\r
44 * http://www.FreeRTOS.org/FAQHelp.html *
\r
46 ***************************************************************************
\r
48 http://www.FreeRTOS.org - Documentation, books, training, latest versions,
\r
49 license and Real Time Engineers Ltd. contact details.
\r
51 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
52 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
\r
53 compatible FAT file system, and our tiny thread aware UDP/IP stack.
\r
55 http://www.OpenRTOS.com - Real Time Engineers ltd license FreeRTOS to High
\r
56 Integrity Systems to sell under the OpenRTOS brand. Low cost OpenRTOS
\r
57 licenses offer ticketed support, indemnification and middleware.
\r
59 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
60 engineered and independently SIL3 certified version for use in safety and
\r
61 mission critical applications that require provable dependability.
\r
66 /******************************************************************************
\r
68 * This demo is described on the following web page:
\r
69 * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT_SL/Demos/File_System_Win32_Simulator_demo.shtml
\r
71 ******************************************************************************/
\r
73 /* Standard includes. */
\r
77 /* FreeRTOS includes. */
\r
78 #include <FreeRTOS.h>
\r
83 /* File system includes. */
\r
84 #include "config_fat_sl.h"
\r
86 /* Priorities at which the tasks are created. */
\r
87 #define mainUDP_CLI_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
89 /*-----------------------------------------------------------*/
\r
92 * Register the generic commands that can be used with FreeRTOS+CLI.
\r
94 extern void vRegisterSampleCLICommands( void );
\r
97 * Register the file system commands that can be used with FreeRTOS+CLI.
\r
99 extern void vRegisterFileSystemCLICommands( void );
\r
102 * The task that implements the UDP command interpreter using FreeRTOS+CLI.
\r
104 extern void vUDPCommandInterpreterTask( void *pvParameters );
\r
107 * Creates and verifies different files on the volume, demonstrating the use of
\r
108 * various different API functions.
\r
110 extern void vCreateAndVerifySampleFiles( void );
\r
112 /*-----------------------------------------------------------*/
\r
114 /******************************************************************************
\r
116 * This demo is described on the following web page:
\r
117 * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT_SL/Demos/File_System_Win32_Simulator_demo.shtml
\r
119 ******************************************************************************/
\r
123 const uint32_t ulLongTime_ms = 250UL;
\r
125 /* If the file system is only going to be accessed from one task then
\r
126 F_FS_THREAD_AWARE can be set to 0 and the set of example files are created
\r
127 before the RTOS scheduler is started. If the file system is going to be
\r
128 access from more than one task then F_FS_THREAD_AWARE must be set to 1 and
\r
129 the set of sample files are created from the idle task hook function
\r
130 vApplicationIdleHook() - which is defined in this file. */
\r
131 #if F_FS_THREAD_AWARE == 0
\r
133 /* Initialise the drive and file system, then create a few example
\r
134 files. The output from this function just goes to the stdout window,
\r
135 allowing the output to be viewed when the UDP command console is not
\r
137 vCreateAndVerifySampleFiles();
\r
141 /* Register generic commands with the FreeRTOS+CLI command interpreter. */
\r
142 vRegisterSampleCLICommands();
\r
144 /* Register file system related commands with the FreeRTOS+CLI command
\r
146 vRegisterFileSystemCLICommands();
\r
148 /* Create the task that handles the CLI on a UDP port. The port number
\r
149 is set using the configUDP_CLI_PORT_NUMBER setting in FreeRTOSConfig.h. */
\r
150 xTaskCreate( vUDPCommandInterpreterTask, /* The function that implements the command interpreter IO handling. */
\r
151 "CLI", /* The name of the task - just to assist debugging. */
\r
152 configMINIMAL_STACK_SIZE, NULL, /* The size of the stack allocated to the task. */
\r
153 mainUDP_CLI_TASK_PRIORITY, /* The priority at which the task will run. */
\r
154 NULL ); /* A handle to the task is not required, so NULL is passed. */
\r
156 /* Start the RTOS scheduler. */
\r
157 vTaskStartScheduler();
\r
159 /* If all is well, the scheduler will now be running, and the following
\r
160 line will never be reached. If the following line does execute, then
\r
161 there was insufficient FreeRTOS heap memory available for the idle and/or
\r
162 timer tasks to be created. See the memory management section on the
\r
163 FreeRTOS web site for more details (this is standard text that is not not
\r
164 really applicable to the Win32 simulator port). */
\r
167 Sleep( ulLongTime_ms );
\r
170 /*-----------------------------------------------------------*/
\r
172 void vApplicationIdleHook( void )
\r
174 const unsigned long ulMSToSleep = 5;
\r
176 /* If the file system is only going to be accessed from one task then
\r
177 F_FS_THREAD_AWARE can be set to 0 and the set of example files is created
\r
178 before the RTOS scheduler is started. If the file system is going to be
\r
179 access from more than one task then F_FS_THREAD_AWARE must be set to 1 and
\r
180 the set of sample files are created from the idle task hook function. */
\r
181 #if F_FS_THREAD_AWARE == 1
\r
183 static portBASE_TYPE xCreatedSampleFiles = pdFALSE;
\r
185 /* Initialise the drive and file system, then create a few example
\r
186 files. The output from this function just goes to the stdout window,
\r
187 allowing the output to be viewed when the UDP command console is not
\r
189 if( xCreatedSampleFiles == pdFALSE )
\r
191 vCreateAndVerifySampleFiles();
\r
192 xCreatedSampleFiles = pdTRUE;
\r
197 /* This function is called on each cycle of the idle task if
\r
198 configUSE_IDLE_HOOK is set to 1 in FreeRTOSConfig.h. Sleep to reduce CPU
\r
200 Sleep( ulMSToSleep );
\r
202 /*-----------------------------------------------------------*/
\r
204 void vAssertCalled( const char *pcFile, unsigned long ulLine )
\r
206 printf( "ASSERT FAILED: File %s, line %u\r\n", pcFile, ulLine );
\r
208 /*-----------------------------------------------------------*/
\r
210 void vApplicationMallocFailedHook( void )
\r
212 /* vApplicationMallocFailedHook() will only be called if
\r
213 configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
\r
214 function that will get called if a call to pvPortMalloc() fails.
\r
215 pvPortMalloc() is called internally by the kernel whenever a task, queue,
\r
216 timer or semaphore is created. It is also called by various parts of the
\r
217 demo application. If heap_1.c, heap_2.c or heap_4.c are used, then the
\r
218 size of the heap available to pvPortMalloc() is defined by
\r
219 configTOTAL_HEAP_SIZE in FreeRTOSConfig.h, and the xPortGetFreeHeapSize()
\r
220 API function can be used to query the size of free heap space that remains
\r
221 (although it does not provide information on how the remaining heap might
\r
223 taskDISABLE_INTERRUPTS();
\r