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
28 /* Standard includes. */
\r
32 /* Visual studio intrinsics used so the __debugbreak() function is available
\r
33 should an assert get hit. */
\r
36 /* FreeRTOS includes. */
\r
37 #include <FreeRTOS.h>
\r
40 /* TCP/IP stack includes. */
\r
41 #include "FreeRTOS_IP.h"
\r
44 * Prototypes for the demos that can be started from this project.
\r
46 extern void vStartSimpleTaskPoolDemo( void );
\r
48 /* This example is the first in a sequence that adds IoT functionality into
\r
49 an existing TCP/IP project. In this first project the TCP/IP stack is not
\r
50 actually used, but it is still built, which requires this array to be
\r
52 const uint8_t ucMACAddress[ 6 ] = { configMAC_ADDR0, configMAC_ADDR1, configMAC_ADDR2, configMAC_ADDR3, configMAC_ADDR4, configMAC_ADDR5 };
\r
54 /*-----------------------------------------------------------*/
\r
59 * Instructions for using this project are provided on:
\r
63 /* Create the example that demonstrates task pool functionality. Examples
\r
64 that demonstrate networking connectivity will be added in future projects
\r
65 and get started after the network has connected (from within the
\r
66 vApplicationIPNetworkEventHook() function).*/
\r
67 vStartSimpleTaskPoolDemo();
\r
69 /* Start the scheduler - if all is well from this point on only FreeRTOS
\r
70 tasks will execute. */
\r
71 vTaskStartScheduler();
\r
73 /* If all is well, the scheduler will now be running, and the following
\r
74 line will never be reached. If the following line does execute, then
\r
75 there was insufficient FreeRTOS heap memory available for the idle and/or
\r
76 timer tasks to be created. See the memory management section on the
\r
77 FreeRTOS web site for more details (this is standard text that is not not
\r
78 really applicable to the Win32 simulator port). */
\r
84 /*-----------------------------------------------------------*/
\r
86 void vAssertCalled( const char *pcFile, uint32_t ulLine )
\r
88 volatile uint32_t ulBlockVariable = 0UL;
\r
89 volatile char *pcFileName = ( volatile char * ) pcFile;
\r
90 volatile uint32_t ulLineNumber = ulLine;
\r
92 ( void ) pcFileName;
\r
93 ( void ) ulLineNumber;
\r
95 printf( "vAssertCalled( %s, %u\n", pcFile, ulLine );
\r
97 /* Setting ulBlockVariable to a non-zero value in the debugger will allow
\r
98 this function to be exited. */
\r
99 taskDISABLE_INTERRUPTS();
\r
101 while( ulBlockVariable == 0UL )
\r
106 taskENABLE_INTERRUPTS();
\r
108 /*-----------------------------------------------------------*/
\r
110 /* Called by FreeRTOS+TCP when the network connects or disconnects. Disconnect
\r
111 events are only received if implemented in the MAC driver. */
\r
112 void vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
\r
114 /* This example is the first in a sequence that adds IoT functionality into
\r
115 an existing TCP/IP project. In this first project the TCP/IP stack is not
\r
116 actually used, but it is still built, which requires this function to be
\r
117 present. For now this function does not need to do anything, so just ensure
\r
118 the unused parameters don't cause compiler warnings and that calls to this
\r
119 function are trapped by the debugger. */
\r
121 ( void ) eNetworkEvent;
\r
123 /*-----------------------------------------------------------*/
\r
125 extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
\r
126 uint16_t usSourcePort,
\r
127 uint32_t ulDestinationAddress,
\r
128 uint16_t usDestinationPort )
\r
130 /* This example is the first in a sequence that adds IoT functionality into
\r
131 an existing TCP/IP project. In this first project the TCP/IP stack is not
\r
132 actually used, but it is still built, which requires this function to be
\r
133 present. For now this function does not need to do anything, so just ensure
\r
134 the unused parameters don't cause compiler warnings and that calls to this
\r
135 function are trapped by the debugger. */
\r
136 ( void ) ulSourceAddress;
\r
137 ( void ) usSourcePort;
\r
138 ( void ) ulDestinationAddress;
\r
139 ( void ) usDestinationPort;
\r
143 /*-----------------------------------------------------------*/
\r
145 UBaseType_t uxRand( void )
\r
147 /* This example is the first in a sequence that adds IoT functionality into
\r
148 an existing TCP/IP project. In this first project the TCP/IP stack is not
\r
149 actually used, but it is still built, which requires this function to be
\r
150 present. For now this function does not need to do anything, so just ensure
\r
151 the calls to the function are trapped by the debugger. */
\r
155 /*-----------------------------------------------------------*/
\r
157 /* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an
\r
158 implementation of vApplicationGetIdleTaskMemory() to provide the memory that is
\r
159 used by the Idle task. */
\r
160 void vApplicationGetIdleTaskMemory( StaticTask_t** ppxIdleTaskTCBBuffer, StackType_t** ppxIdleTaskStackBuffer, uint32_t* pulIdleTaskStackSize )
\r
162 /* If the buffers to be provided to the Idle task are declared inside this
\r
163 function then they must be declared static - otherwise they will be allocated on
\r
164 the stack and so not exists after this function exits. */
\r
165 static StaticTask_t xIdleTaskTCB;
\r
166 static StackType_t uxIdleTaskStack[configMINIMAL_STACK_SIZE];
\r
168 /* Pass out a pointer to the StaticTask_t structure in which the Idle task's
\r
169 state will be stored. */
\r
170 *ppxIdleTaskTCBBuffer = &xIdleTaskTCB;
\r
172 /* Pass out the array that will be used as the Idle task's stack. */
\r
173 *ppxIdleTaskStackBuffer = uxIdleTaskStack;
\r
175 /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer.
\r
176 Note that, as the array is necessarily of type StackType_t,
\r
177 configMINIMAL_STACK_SIZE is specified in words, not bytes. */
\r
178 *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
\r
180 /*-----------------------------------------------------------*/
\r
182 /* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
\r
183 application must provide an implementation of vApplicationGetTimerTaskMemory()
\r
184 to provide the memory that is used by the Timer service task. */
\r
185 void vApplicationGetTimerTaskMemory( StaticTask_t** ppxTimerTaskTCBBuffer, StackType_t** ppxTimerTaskStackBuffer, uint32_t* pulTimerTaskStackSize )
\r
187 /* If the buffers to be provided to the Timer task are declared inside this
\r
188 function then they must be declared static - otherwise they will be allocated on
\r
189 the stack and so not exists after this function exits. */
\r
190 static StaticTask_t xTimerTaskTCB;
\r
191 static StackType_t uxTimerTaskStack[configTIMER_TASK_STACK_DEPTH];
\r
193 /* Pass out a pointer to the StaticTask_t structure in which the Timer
\r
194 task's state will be stored. */
\r
195 *ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
\r
197 /* Pass out the array that will be used as the Timer task's stack. */
\r
198 *ppxTimerTaskStackBuffer = uxTimerTaskStack;
\r
200 /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
\r
201 Note that, as the array is necessarily of type StackType_t,
\r
202 configMINIMAL_STACK_SIZE is specified in words, not bytes. */
\r
203 *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
\r