]> git.sur5r.net Git - freertos/blob - FreeRTOS-Plus/Demo/FreeRTOS_Plus_Reliance_Edge_and_CLI_Windows_Simulator/main.c
Update FreeRTOS+ version number ready for version 9 release candidate 1.
[freertos] / FreeRTOS-Plus / Demo / FreeRTOS_Plus_Reliance_Edge_and_CLI_Windows_Simulator / main.c
1 /*\r
2     FreeRTOS V9.0.0rc1 - Copyright (C) 2016 Real Time Engineers Ltd.\r
3     All rights reserved\r
4 \r
5     VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
6 \r
7     This file is part of the FreeRTOS distribution.\r
8 \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
12 \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
19 \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
24 \r
25     ***************************************************************************\r
26      *                                                                       *\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
31      *                                                                       *\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
36      *                                                                       *\r
37     ***************************************************************************\r
38 \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
42 \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
46 \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
51 \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
55 \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
58 \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
62 \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
66 \r
67     1 tab == 4 spaces!\r
68 */\r
69 \r
70 /******************************************************************************\r
71  *\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
75  *\r
76  ******************************************************************************/\r
77 \r
78 /* Standard includes. */\r
79 #include <stdio.h>\r
80 #include <stdint.h>\r
81 \r
82 /* FreeRTOS includes. */\r
83 #include <FreeRTOS.h>\r
84 #include "task.h"\r
85 #include "queue.h"\r
86 #include "semphr.h"\r
87 \r
88 /* Priorities at which the tasks are created. */\r
89 #define mainUDP_CLI_TASK_PRIORITY                       ( tskIDLE_PRIORITY )\r
90 \r
91 /*-----------------------------------------------------------*/\r
92 \r
93 /*\r
94  * Register the generic commands that can be used with FreeRTOS+CLI.\r
95  */\r
96 extern void vRegisterSampleCLICommands( void );\r
97 \r
98 /*\r
99  * Register the file system commands that can be used with FreeRTOS+CLI.\r
100  */\r
101 extern void vRegisterFileSystemCLICommands( void );\r
102 \r
103 /*\r
104  * The task that implements the UDP command interpreter using FreeRTOS+CLI.\r
105  */\r
106 extern void vUDPCommandInterpreterTask( void *pvParameters );\r
107 \r
108 /*\r
109  * Creates and verifies different files on the volume, demonstrating the use of\r
110  * various different API functions.\r
111  */\r
112 extern void vCreateAndVerifySampleFiles( void );\r
113 \r
114 /*-----------------------------------------------------------*/\r
115 \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
118 \r
119 int main( void )\r
120 {\r
121 const uint32_t ulLongTime_ms = 250UL;\r
122 \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
126         connected. */\r
127         vCreateAndVerifySampleFiles();\r
128 \r
129         /* Register generic commands with the FreeRTOS+CLI command interpreter. */\r
130         vRegisterSampleCLICommands();\r
131 \r
132         /* Register file system related commands with the FreeRTOS+CLI command\r
133         interpreter. */\r
134         vRegisterFileSystemCLICommands();\r
135 \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
143 \r
144         /* Start the RTOS scheduler. */\r
145         vTaskStartScheduler();\r
146 \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
153         for( ;; )\r
154         {\r
155                 Sleep( ulLongTime_ms );\r
156         }\r
157 }\r
158 /*-----------------------------------------------------------*/\r
159 \r
160 void vApplicationIdleHook( void )\r
161 {\r
162 const unsigned long ulMSToSleep = 5;\r
163 \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
166         load. */\r
167         Sleep( ulMSToSleep );\r
168 }\r
169 /*-----------------------------------------------------------*/\r
170 \r
171 void vAssertCalled( const char *pcFile, unsigned long ulLine )\r
172 {\r
173 volatile uint32_t ulSetToNonZeroToExitLoop = 0;\r
174 \r
175         printf( "ASSERT FAILED: File %s, line %u\r\n", pcFile, ulLine );\r
176 \r
177         taskENTER_CRITICAL();\r
178         {\r
179                 while( ulSetToNonZeroToExitLoop == 0 )\r
180                 {\r
181                         /* Do not leave the assert function unless the debugger is used to\r
182                         set ulSetToNonZeroToExitLoop to a non-zero value. */\r
183                 }\r
184         }\r
185         taskEXIT_CRITICAL();\r
186 }\r
187 /*-----------------------------------------------------------*/\r
188 \r
189 void vApplicationMallocFailedHook( void )\r
190 {\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
201         be fragmented). */\r
202         taskDISABLE_INTERRUPTS();\r
203         for( ;; );\r
204 }\r
205 \r
206 \r
207 \r