2 FreeRTOS V9.0.0rc1 - Copyright (C) 2016 Real Time Engineers Ltd.
\r
5 VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.
\r
7 This file is part of the FreeRTOS distribution.
\r
9 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
10 the terms of the GNU General Public License (version 2) as published by the
\r
11 Free Software Foundation >>>> AND MODIFIED BY <<<< the FreeRTOS exception.
\r
13 ***************************************************************************
\r
14 >>! NOTE: The modification to the GPL is included to allow you to !<<
\r
15 >>! distribute a combined work that includes FreeRTOS without being !<<
\r
16 >>! obliged to provide the source code for proprietary components !<<
\r
17 >>! outside of the FreeRTOS kernel. !<<
\r
18 ***************************************************************************
\r
20 FreeRTOS is distributed in the hope that it will be useful, but WITHOUT ANY
\r
21 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
\r
22 FOR A PARTICULAR PURPOSE. Full license text is available on the following
\r
23 link: http://www.freertos.org/a00114.html
\r
25 ***************************************************************************
\r
27 * FreeRTOS provides completely free yet professionally developed, *
\r
28 * robust, strictly quality controlled, supported, and cross *
\r
29 * platform software that is more than just the market leader, it *
\r
30 * is the industry's de facto standard. *
\r
32 * Help yourself get started quickly while simultaneously helping *
\r
33 * to support the FreeRTOS project by purchasing a FreeRTOS *
\r
34 * tutorial book, reference manual, or both: *
\r
35 * http://www.FreeRTOS.org/Documentation *
\r
37 ***************************************************************************
\r
39 http://www.FreeRTOS.org/FAQHelp.html - Having a problem? Start by reading
\r
40 the FAQ page "My application does not run, what could be wrong?". Have you
\r
41 defined configASSERT()?
\r
43 http://www.FreeRTOS.org/support - In return for receiving this top quality
\r
44 embedded software for free we request you assist our global community by
\r
45 participating in the support forum.
\r
47 http://www.FreeRTOS.org/training - Investing in training allows your team to
\r
48 be as productive as possible as early as possible. Now you can receive
\r
49 FreeRTOS training directly from Richard Barry, CEO of Real Time Engineers
\r
50 Ltd, and the world's leading authority on the world's leading RTOS.
\r
52 http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,
\r
53 including FreeRTOS+Trace - an indispensable productivity tool, a DOS
\r
54 compatible FAT file system, and our tiny thread aware UDP/IP stack.
\r
56 http://www.FreeRTOS.org/labs - Where new FreeRTOS products go to incubate.
\r
57 Come and try FreeRTOS+TCP, our new open source TCP/IP stack for FreeRTOS.
\r
59 http://www.OpenRTOS.com - Real Time Engineers ltd. license FreeRTOS to High
\r
60 Integrity Systems ltd. to sell under the OpenRTOS brand. Low cost OpenRTOS
\r
61 licenses offer ticketed support, indemnification and commercial middleware.
\r
63 http://www.SafeRTOS.com - High Integrity Systems also provide a safety
\r
64 engineered and independently SIL3 certified version for use in safety and
\r
65 mission critical applications that require provable dependability.
\r
70 /******************************************************************************
\r
72 * This demo is described on the following web page:
\r
73 * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT_SL/Demos/File_System_Win32_Simulator_demo.shtml
\r
75 ******************************************************************************/
\r
77 /* Standard includes. */
\r
81 /* FreeRTOS includes. */
\r
82 #include <FreeRTOS.h>
\r
87 /* File system includes. */
\r
88 #include "config_fat_sl.h"
\r
90 /* Priorities at which the tasks are created. */
\r
91 #define mainUDP_CLI_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
93 /*-----------------------------------------------------------*/
\r
96 * Register the generic commands that can be used with FreeRTOS+CLI.
\r
98 extern void vRegisterSampleCLICommands( void );
\r
101 * Register the file system commands that can be used with FreeRTOS+CLI.
\r
103 extern void vRegisterFileSystemCLICommands( void );
\r
106 * The task that implements the UDP command interpreter using FreeRTOS+CLI.
\r
108 extern void vUDPCommandInterpreterTask( void *pvParameters );
\r
111 * Creates and verifies different files on the volume, demonstrating the use of
\r
112 * various different API functions.
\r
114 extern void vCreateAndVerifySampleFiles( void );
\r
116 /*-----------------------------------------------------------*/
\r
118 /******************************************************************************
\r
120 * This demo is described on the following web page:
\r
121 * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT_SL/Demos/File_System_Win32_Simulator_demo.shtml
\r
123 ******************************************************************************/
\r
127 const uint32_t ulLongTime_ms = 250UL;
\r
129 /* If the file system is only going to be accessed from one task then
\r
130 F_FS_THREAD_AWARE can be set to 0 and the set of example files are created
\r
131 before the RTOS scheduler is started. If the file system is going to be
\r
132 access from more than one task then F_FS_THREAD_AWARE must be set to 1 and
\r
133 the set of sample files are created from the idle task hook function
\r
134 vApplicationIdleHook() - which is defined in this file. */
\r
135 #if F_FS_THREAD_AWARE == 0
\r
137 /* Initialise the drive and file system, then create a few example
\r
138 files. The output from this function just goes to the stdout window,
\r
139 allowing the output to be viewed when the UDP command console is not
\r
141 vCreateAndVerifySampleFiles();
\r
145 /* Register generic commands with the FreeRTOS+CLI command interpreter. */
\r
146 vRegisterSampleCLICommands();
\r
148 /* Register file system related commands with the FreeRTOS+CLI command
\r
150 vRegisterFileSystemCLICommands();
\r
152 /* Create the task that handles the CLI on a UDP port. The port number
\r
153 is set using the configUDP_CLI_PORT_NUMBER setting in FreeRTOSConfig.h. */
\r
154 xTaskCreate( vUDPCommandInterpreterTask, /* The function that implements the command interpreter IO handling. */
\r
155 "CLI", /* The name of the task - just to assist debugging. */
\r
156 configMINIMAL_STACK_SIZE, NULL, /* The size of the stack allocated to the task. */
\r
157 mainUDP_CLI_TASK_PRIORITY, /* The priority at which the task will run. */
\r
158 NULL ); /* A handle to the task is not required, so NULL is passed. */
\r
160 /* Start the RTOS scheduler. */
\r
161 vTaskStartScheduler();
\r
163 /* If all is well, the scheduler will now be running, and the following
\r
164 line will never be reached. If the following line does execute, then
\r
165 there was insufficient FreeRTOS heap memory available for the idle and/or
\r
166 timer tasks to be created. See the memory management section on the
\r
167 FreeRTOS web site for more details (this is standard text that is not not
\r
168 really applicable to the Win32 simulator port). */
\r
171 Sleep( ulLongTime_ms );
\r
174 /*-----------------------------------------------------------*/
\r
176 void vApplicationIdleHook( void )
\r
178 const unsigned long ulMSToSleep = 5;
\r
180 /* If the file system is only going to be accessed from one task then
\r
181 F_FS_THREAD_AWARE can be set to 0 and the set of example files is created
\r
182 before the RTOS scheduler is started. If the file system is going to be
\r
183 access from more than one task then F_FS_THREAD_AWARE must be set to 1 and
\r
184 the set of sample files are created from the idle task hook function. */
\r
185 #if F_FS_THREAD_AWARE == 1
\r
187 static BaseType_t xCreatedSampleFiles = pdFALSE;
\r
189 /* Initialise the drive and file system, then create a few example
\r
190 files. The output from this function just goes to the stdout window,
\r
191 allowing the output to be viewed when the UDP command console is not
\r
193 if( xCreatedSampleFiles == pdFALSE )
\r
195 vCreateAndVerifySampleFiles();
\r
196 xCreatedSampleFiles = pdTRUE;
\r
201 /* This function is called on each cycle of the idle task if
\r
202 configUSE_IDLE_HOOK is set to 1 in FreeRTOSConfig.h. Sleep to reduce CPU
\r
204 Sleep( ulMSToSleep );
\r
206 /*-----------------------------------------------------------*/
\r
208 void vAssertCalled( const char *pcFile, unsigned long ulLine )
\r
210 printf( "ASSERT FAILED: File %s, line %u\r\n", pcFile, ulLine );
\r
212 /*-----------------------------------------------------------*/
\r
214 void vApplicationMallocFailedHook( void )
\r
216 /* vApplicationMallocFailedHook() will only be called if
\r
217 configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
\r
218 function that will get called if a call to pvPortMalloc() fails.
\r
219 pvPortMalloc() is called internally by the kernel whenever a task, queue,
\r
220 timer or semaphore is created. It is also called by various parts of the
\r
221 demo application. If heap_1.c, heap_2.c or heap_4.c are used, then the
\r
222 size of the heap available to pvPortMalloc() is defined by
\r
223 configTOTAL_HEAP_SIZE in FreeRTOSConfig.h, and the xPortGetFreeHeapSize()
\r
224 API function can be used to query the size of free heap space that remains
\r
225 (although it does not provide information on how the remaining heap might
\r
227 taskDISABLE_INTERRUPTS();
\r