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 * TODO: This link describes the FAT version of this demo.
\r
74 * http://www.freertos.org/FreeRTOS-Plus/Fail_Safe_File_System/Fail_Safe_Embedded_File_System_demo.shtml
\r
76 ******************************************************************************/
\r
78 /* Standard includes. */
\r
82 /* FreeRTOS includes. */
\r
83 #include <FreeRTOS.h>
\r
88 /* Priorities at which the tasks are created. */
\r
89 #define mainUDP_CLI_TASK_PRIORITY ( tskIDLE_PRIORITY )
\r
91 /*-----------------------------------------------------------*/
\r
94 * Register the generic commands that can be used with FreeRTOS+CLI.
\r
96 extern void vRegisterSampleCLICommands( void );
\r
99 * Register the file system commands that can be used with FreeRTOS+CLI.
\r
101 extern void vRegisterFileSystemCLICommands( void );
\r
104 * The task that implements the UDP command interpreter using FreeRTOS+CLI.
\r
106 extern void vUDPCommandInterpreterTask( void *pvParameters );
\r
109 * Creates and verifies different files on the volume, demonstrating the use of
\r
110 * various different API functions.
\r
112 extern void vCreateAndVerifySampleFiles( void );
\r
114 /*-----------------------------------------------------------*/
\r
116 /* See http://www.freertos.org/FreeRTOS-Plus/Fail_Safe_File_System/Fail_Safe_Embedded_File_System_demo.shtml
\r
117 for instructions. */
\r
121 const uint32_t ulLongTime_ms = 250UL;
\r
123 /* Initialise the drive and file system, then create a few example
\r
124 files. The output from this function just goes to the stdout window,
\r
125 allowing the output to be viewed when the UDP command console is not
\r
127 vCreateAndVerifySampleFiles();
\r
129 /* Register generic commands with the FreeRTOS+CLI command interpreter. */
\r
130 vRegisterSampleCLICommands();
\r
132 /* Register file system related commands with the FreeRTOS+CLI command
\r
134 vRegisterFileSystemCLICommands();
\r
136 /* Create the task that handles the CLI on a UDP port. The port number
\r
137 is set using the configUDP_CLI_PORT_NUMBER setting in FreeRTOSConfig.h. */
\r
138 xTaskCreate( vUDPCommandInterpreterTask, /* The function that implements the command interpreter IO handling. */
\r
139 "CLI", /* The name of the task - just to assist debugging. */
\r
140 configMINIMAL_STACK_SIZE, NULL, /* The size of the stack allocated to the task. */
\r
141 mainUDP_CLI_TASK_PRIORITY, /* The priority at which the task will run. */
\r
142 NULL ); /* A handle to the task is not required, so NULL is passed. */
\r
144 /* Start the RTOS scheduler. */
\r
145 vTaskStartScheduler();
\r
147 /* If all is well, the scheduler will now be running, and the following
\r
148 line will never be reached. If the following line does execute, then
\r
149 there was insufficient FreeRTOS heap memory available for the idle and/or
\r
150 timer tasks to be created. See the memory management section on the
\r
151 FreeRTOS web site for more details (this is standard text that is not not
\r
152 really applicable to the Win32 simulator port). */
\r
155 Sleep( ulLongTime_ms );
\r
158 /*-----------------------------------------------------------*/
\r
160 void vApplicationIdleHook( void )
\r
162 const unsigned long ulMSToSleep = 5;
\r
164 /* This function is called on each cycle of the idle task if
\r
165 configUSE_IDLE_HOOK is set to 1 in FreeRTOSConfig.h. Sleep to reduce CPU
\r
167 Sleep( ulMSToSleep );
\r
169 /*-----------------------------------------------------------*/
\r
171 void vAssertCalled( const char *pcFile, unsigned long ulLine )
\r
173 volatile uint32_t ulSetToNonZeroToExitLoop = 0;
\r
175 printf( "ASSERT FAILED: File %s, line %u\r\n", pcFile, ulLine );
\r
177 taskENTER_CRITICAL();
\r
179 while( ulSetToNonZeroToExitLoop == 0 )
\r
181 /* Do not leave the assert function unless the debugger is used to
\r
182 set ulSetToNonZeroToExitLoop to a non-zero value. */
\r
185 taskEXIT_CRITICAL();
\r
187 /*-----------------------------------------------------------*/
\r
189 void vApplicationMallocFailedHook( void )
\r
191 /* vApplicationMallocFailedHook() will only be called if
\r
192 configUSE_MALLOC_FAILED_HOOK is set to 1 in FreeRTOSConfig.h. It is a hook
\r
193 function that will get called if a call to pvPortMalloc() fails.
\r
194 pvPortMalloc() is called internally by the kernel whenever a task, queue,
\r
195 timer or semaphore is created. It is also called by various parts of the
\r
196 demo application. If heap_1.c, heap_2.c or heap_4.c are used, then the
\r
197 size of the heap available to pvPortMalloc() is defined by
\r
198 configTOTAL_HEAP_SIZE in FreeRTOSConfig.h, and the xPortGetFreeHeapSize()
\r
199 API function can be used to query the size of free heap space that remains
\r
200 (although it does not provide information on how the remaining heap might
\r
202 taskDISABLE_INTERRUPTS();
\r