2 * FreeRTOS Kernel V10.2.1
\r
3 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
\r
6 * this software and associated documentation files (the "Software"), to deal in
\r
7 * the Software without restriction, including without limitation the rights to
\r
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
\r
9 * the Software, and to permit persons to whom the Software is furnished to do so,
\r
10 * subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in all
\r
13 * copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
\r
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
\r
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
\r
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
\r
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
22 * http://www.FreeRTOS.org
\r
23 * http://aws.amazon.com/freertos
\r
25 * 1 tab == 4 spaces!
\r
29 * This project is a cut down version of the project described on the following
\r
30 * link. Only the simple UDP client and server and the TCP echo clients are
\r
31 * included in the build:
\r
32 * http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/examples_FreeRTOS_simulator.html
\r
35 /* Standard includes. */
\r
39 /* Visual studio intrinsics used so the __debugbreak() function is available
\r
40 should an assert get hit. */
\r
43 /* FreeRTOS includes. */
\r
44 #include <FreeRTOS.h>
\r
47 /* TCP/IP stack includes. */
\r
48 #include "FreeRTOS_IP.h"
\r
51 * Prototypes for the demos that can be started from this project.
\r
53 extern void vStartSimpleTaskPoolDemo( void );
\r
55 /* This example is the first in a sequence that adds IoT functionality into
\r
56 an existing TCP/IP project. In this first project the TCP/IP stack is not
\r
57 actually used, but it is still built, which requires this array to be
\r
59 const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };
\r
61 /*-----------------------------------------------------------*/
\r
66 * Instructions for using this project are provided on:
\r
70 /* Create the example that demonstrates task pool functionality. Examples
\r
71 that demonstrate networking connectivity will be added in future projects
\r
72 and get started after the network has connected (from within the
\r
73 vApplicationIPNetworkEventHook() function).*/
\r
74 vStartSimpleTaskPoolDemo();
\r
76 /* Start the scheduler - if all is well from this point on only FreeRTOS
\r
77 tasks will execute. */
\r
78 vTaskStartScheduler();
\r
80 /* If all is well, the scheduler will now be running, and the following
\r
81 line will never be reached. If the following line does execute, then
\r
82 there was insufficient FreeRTOS heap memory available for the idle and/or
\r
83 timer tasks to be created. See the memory management section on the
\r
84 FreeRTOS web site for more details (this is standard text that is not not
\r
85 really applicable to the Win32 simulator port). */
\r
91 /*-----------------------------------------------------------*/
\r
93 void vAssertCalled( const char *pcFile, uint32_t ulLine )
\r
95 volatile uint32_t ulBlockVariable = 0UL;
\r
96 volatile char *pcFileName = ( volatile char * ) pcFile;
\r
97 volatile uint32_t ulLineNumber = ulLine;
\r
99 ( void ) pcFileName;
\r
100 ( void ) ulLineNumber;
\r
102 printf( "vAssertCalled( %s, %u\n", pcFile, ulLine );
\r
104 /* Setting ulBlockVariable to a non-zero value in the debugger will allow
\r
105 this function to be exited. */
\r
106 taskDISABLE_INTERRUPTS();
\r
108 while( ulBlockVariable == 0UL )
\r
113 taskENABLE_INTERRUPTS();
\r
115 /*-----------------------------------------------------------*/
\r
117 /* Called by FreeRTOS+TCP when the network connects or disconnects. Disconnect
\r
118 events are only received if implemented in the MAC driver. */
\r
119 void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
\r
121 /* This example is the first in a sequence that adds IoT functionality into
\r
122 an existing TCP/IP project. In this first project the TCP/IP stack is not
\r
123 actually used, but it is still built, which requires this function to be
\r
124 present. For now this function does not need to do anything, so just ensure
\r
125 the unused parameters don't cause compiler warnings and that calls to this
\r
126 function are trapped by the debugger. */
\r
128 ( void ) eNetworkEvent;
\r
130 /*-----------------------------------------------------------*/
\r
132 extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
\r
133 uint16_t usSourcePort,
\r
134 uint32_t ulDestinationAddress,
\r
135 uint16_t usDestinationPort )
\r
137 /* This example is the first in a sequence that adds IoT functionality into
\r
138 an existing TCP/IP project. In this first project the TCP/IP stack is not
\r
139 actually used, but it is still built, which requires this function to be
\r
140 present. For now this function does not need to do anything, so just ensure
\r
141 the unused parameters don't cause compiler warnings and that calls to this
\r
142 function are trapped by the debugger. */
\r
143 ( void ) ulSourceAddress;
\r
144 ( void ) usSourcePort;
\r
145 ( void ) ulDestinationAddress;
\r
146 ( void ) usDestinationPort;
\r
150 /*-----------------------------------------------------------*/
\r
152 UBaseType_t uxRand( void )
\r
154 /* This example is the first in a sequence that adds IoT functionality into
\r
155 an existing TCP/IP project. In this first project the TCP/IP stack is not
\r
156 actually used, but it is still built, which requires this function to be
\r
157 present. For now this function does not need to do anything, so just ensure
\r
158 the calls to the function are trapped by the debugger. */
\r
162 /*-----------------------------------------------------------*/
\r
164 /* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
\r
165 implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
\r
166 used by the Idle task. */
\r
167 void vApplicationGetIdleTaskMemory( StaticTask_t** ppxIdleTaskTCBBuffer, StackType_t** ppxIdleTaskStackBuffer, uint32_t* pulIdleTaskStackSize )
\r
169 /* If the buffers to be provided to the Idle task are declared inside this
\r
170 function then they must be declared static - otherwise they will be allocated on
\r
171 the stack and so not exists after this function exits. */
\r
172 static StaticTask_t xIdleTaskTCB;
\r
173 static StackType_t uxIdleTaskStack[configMINIMAL_STACK_SIZE];
\r
175 /* Pass out a pointer to the StaticTask_t structure in which the Idle task's
\r
176 state will be stored. */
\r
177 *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
\r
179 /* Pass out the array that will be used as the Idle task's stack. */
\r
180 *ppxIdleTaskStackBuffer = uxIdleTaskStack;
\r
182 /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
\r
183 Note that, as the array is necessarily of type StackType_t,
\r
184 configMINIMAL_STACK_SIZE is specified in words, not bytes. */
\r
185 *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
\r
187 /*-----------------------------------------------------------*/
\r
189 /* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
\r
190 application must provide an implementation of vApplicationGetTimerTaskMemory()
\r
191 to provide the memory that is used by the Timer service task. */
\r
192 void vApplicationGetTimerTaskMemory( StaticTask_t** ppxTimerTaskTCBBuffer, StackType_t** ppxTimerTaskStackBuffer, uint32_t* pulTimerTaskStackSize )
\r
194 /* If the buffers to be provided to the Timer task are declared inside this
\r
195 function then they must be declared static - otherwise they will be allocated on
\r
196 the stack and so not exists after this function exits. */
\r
197 static StaticTask_t xTimerTaskTCB;
\r
198 static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH];
\r
200 /* Pass out a pointer to the StaticTask_t structure in which the Timer
\r
201 task's state will be stored. */
\r
202 *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
\r
204 /* Pass out the array that will be used as the Timer task's stack. */
\r
205 *ppxTimerTaskStackBuffer = uxTimerTaskStack;
\r
207 /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
\r
208 Note that, as the array is necessarily of type StackType_t,
\r
209 configMINIMAL_STACK_SIZE is specified in words, not bytes. */
\r
210 *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
\r