]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M4F_ATSAM4E_Atmel_Studio/src/config/FreeRTOSIPConfig.h
Update copyright date ready for tagging V10.1.0.
[freertos] / FreeRTOS / Demo / CORTEX_M4F_ATSAM4E_Atmel_Studio / src / config / FreeRTOSIPConfig.h
1 /*\r
2  * FreeRTOS+UDP V1.0.4\r
3  * Copyright (C) 2018 Amazon.com, Inc. or its affiliates.  All Rights Reserved.\r
4  *\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
11  *\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
14  *\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
21  *\r
22  * http://www.FreeRTOS.org\r
23  * http://aws.amazon.com/freertos\r
24  *\r
25  * 1 tab == 4 spaces!\r
26  */\r
27 \r
28 /*****************************************************************************\r
29  *\r
30  * See the following URL for configuration information.\r
31  * http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/UDP_IP_Configuration.shtml\r
32  *\r
33  *****************************************************************************/\r
34 \r
35 #ifndef FREERTOS_IP_CONFIG_H\r
36 #define FREERTOS_IP_CONFIG_H\r
37 \r
38 /* The IP stack executes it its own task (although any application task can make\r
39 use of its services through the published sockets API). ipconfigUDP_TASK_PRIORITY\r
40 sets the priority of the task that executes the IP stack.  The priority is a\r
41 standard FreeRTOS task priority so can take any value from 0 (the lowest\r
42 priority) to (configMAX_PRIORITIES - 1) (the highest priority).\r
43 configMAX_PRIORITIES is a standard FreeRTOS configuration parameter defined in\r
44 FreeRTOSConfig.h, not FreeRTOSIPConfig.h. Consideration needs to be given as to\r
45 the priority assigned to the task executing the IP stack relative to the\r
46 priority assigned to tasks that use the IP stack.\r
47 \r
48 Note:  If the application is started without the network cable plugged in then\r
49 this should be set to the lowest priority - otherwise the Atmel ASF GMAC driver\r
50 will poll the GMAC interface waiting for a connection to be established.  The\r
51 driver uses a very long timeout and no lower priority tasks will be able to\r
52 execute during this time.  This demo starts with the IP task running at the idle\r
53 priority - then raises the priority of the IP task in the network event hook\r
54 when a connection has been established. */\r
55 #define ipconfigUDP_TASK_PRIORITY                       ( tskIDLE_PRIORITY )\r
56 \r
57 /* The size, in words (not bytes), of the stack allocated to the FreeRTOS+UDP\r
58 task.  This setting is less important when the FreeRTOS Win32 simulator is used\r
59 as the Win32 simulator only stores a fixed amount of information on the task\r
60 stack.  FreeRTOS includes optional stack overflow detection, see:\r
61 http://www.freertos.org/Stacks-and-stack-overflow-checking.html */\r
62 #define ipconfigUDP_TASK_STACK_SIZE_WORDS       ( configMINIMAL_STACK_SIZE * 2 )\r
63 \r
64 /* ipconfigRAND32() is called by the IP stack to generate a random number that\r
65 is then used as a DHCP transaction number.  Random number generation is performed\r
66 via this macro to allow applications to use their own random number generation\r
67 method.  For example, it might be possible to generate a random number by\r
68 sampling noise on an analogue input. */\r
69 #define ipconfigRAND32()        1\r
70 \r
71 /* If ipconfigUSE_NETWORK_EVENT_HOOK is set to 1 then FreeRTOS+UDP will call the\r
72 network event hook at the appropriate times.  If ipconfigUSE_NETWORK_EVENT_HOOK\r
73 is not set to 1 then the network event hook will never be called.  See\r
74 http://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_UDP/API/vApplicationIPNetworkEventHook.shtml\r
75 */\r
76 #define ipconfigUSE_NETWORK_EVENT_HOOK 1\r
77 \r
78 /* Sockets have a send block time attribute.  If FreeRTOS_sendto() is called but\r
79 a network buffer cannot be obtained then the calling task is held in the Blocked\r
80 state (so other tasks can continue to executed) until either a network buffer\r
81 becomes available or the send block time expires.  If the send block time expires\r
82 then the send operation is aborted.  The maximum allowable send block time is\r
83 capped to the value set by ipconfigMAX_SEND_BLOCK_TIME_TICKS.  Capping the\r
84 maximum allowable send block time prevents prevents a deadlock occurring when\r
85 all the network buffers are in use and the tasks that process (and subsequently\r
86 free) the network buffers are themselves blocked waiting for a network buffer.\r
87 ipconfigMAX_SEND_BLOCK_TIME_TICKS is specified in RTOS ticks.  A time in\r
88 milliseconds can be converted to a time in ticks by dividing the time in\r
89 milliseconds by portTICK_PERIOD_MS. */\r
90 #define ipconfigMAX_SEND_BLOCK_TIME_TICKS ( 20 / portTICK_PERIOD_MS )\r
91 \r
92 /* If ipconfigUSE_DHCP is 1 then FreeRTOS+UDP will attempt to retrieve an IP\r
93 address, netmask, DNS server address and gateway address from a DHCP server.  If\r
94 ipconfigUSE_DHCP is 0 then FreeRTOS+UDP will use a static IP address.  The\r
95 stack will revert to using the static IP address even when ipconfigUSE_DHCP is\r
96 set to 1 if a valid configuration cannot be obtained from a DHCP server for any\r
97 reason.  The static configuration used is that passed into the stack by the\r
98 FreeRTOS_IPInit() function call. */\r
99 #define ipconfigUSE_DHCP        1\r
100 \r
101 /* When ipconfigUSE_DHCP is set to 1, DHCP requests will be sent out at\r
102 increasing time intervals until either a reply is received from a DHCP server\r
103 and accepted, or the interval between transmissions reaches\r
104 ipconfigMAXIMUM_DISCOVER_TX_PERIOD.  The IP stack will revert to using the\r
105 static IP address passed as a parameter to FreeRTOS_IPInit() if the\r
106 re-transmission time interval reaches ipconfigMAXIMUM_DISCOVER_TX_PERIOD without\r
107 a DHCP reply being received. */\r
108 #define ipconfigMAXIMUM_DISCOVER_TX_PERIOD              ( 999 / portTICK_PERIOD_MS )\r
109 \r
110 /* The ARP cache is a table that maps IP addresses to MAC addresses.  The IP\r
111 stack can only send a UDP message to a remove IP address if it knowns the MAC\r
112 address associated with the IP address, or the MAC address of the router used to\r
113 contact the remote IP address.  When a UDP message is received from a remote IP\r
114 address the MAC address and IP address are added to the ARP cache.  When a UDP\r
115 message is sent to a remote IP address that does not already appear in the ARP\r
116 cache then the UDP message is replaced by a ARP message that solicits the\r
117 required MAC address information.  ipconfigARP_CACHE_ENTRIES defines the maximum\r
118 number of entries that can exist in the ARP table at any one time. */\r
119 #define ipconfigARP_CACHE_ENTRIES               6\r
120 \r
121 /* ARP requests that do not result in an ARP response will be re-transmitted a\r
122 maximum of ipconfigMAX_ARP_RETRANSMISSIONS times before the ARP request is\r
123 aborted. */\r
124 #define ipconfigMAX_ARP_RETRANSMISSIONS ( 5 )\r
125 \r
126 /* ipconfigMAX_ARP_AGE defines the maximum time between an entry in the ARP\r
127 table being created or refreshed and the entry being removed because it is stale.\r
128 New ARP requests are sent for ARP cache entries that are nearing their maximum\r
129 age.  ipconfigMAX_ARP_AGE is specified in tens of seconds, so a value of 150 is\r
130 equal to 1500 seconds (or 25 minutes). */\r
131 #define ipconfigMAX_ARP_AGE                     150\r
132 \r
133 /* Implementing FreeRTOS_inet_addr() necessitates the use of string handling\r
134 routines, which are relatively large.  To save code space the full\r
135 FreeRTOS_inet_addr() implementation is made optional, and a smaller and faster\r
136 alternative called FreeRTOS_inet_addr_quick() is provided.  FreeRTOS_inet_addr()\r
137 takes an IP in decimal dot format (for example, "192.168.0.1") as its parameter.\r
138 FreeRTOS_inet_addr_quick() takes an IP address as four separate numerical octets\r
139 (for example, 192, 168, 0, 1) as its parameters.  If\r
140 ipconfigINCLUDE_FULL_INET_ADDR is set to 1 then both FreeRTOS_inet_addr() and\r
141 FreeRTOS_indet_addr_quick() are available.  If ipconfigINCLUDE_FULL_INET_ADDR is\r
142 not set to 1 then only FreeRTOS_indet_addr_quick() is available. */\r
143 #define ipconfigINCLUDE_FULL_INET_ADDR  1\r
144 \r
145 /* ipconfigNUM_NETWORK_BUFFERS defines the total number of network buffer that\r
146 are available to the IP stack.  The total number of network buffers is limited\r
147 to ensure the total amount of RAM that can be consumed by the IP stack is capped\r
148 to a pre-determinable value. */\r
149 #define ipconfigNUM_NETWORK_BUFFERS             10\r
150 \r
151 /* A FreeRTOS queue is used to send events from application tasks to the IP\r
152 stack.  ipconfigEVENT_QUEUE_LENGTH sets the maximum number of events that can\r
153 be queued for processing at any one time.  The event queue must be a minimum of\r
154 5 greater than the total number of network buffers. */\r
155 #define ipconfigEVENT_QUEUE_LENGTH              ( ipconfigNUM_NETWORK_BUFFERS + 5 )\r
156 \r
157 /* The address of a socket is the combination of its IP address and its port\r
158 number.  FreeRTOS_bind() is used to manually allocate a port number to a socket\r
159 (to 'bind' the socket to a port), but manual binding is not normally necessary\r
160 for client sockets (those sockets that initiate outgoing connections rather than\r
161 wait for incoming connections on a known port number).  If\r
162 ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 1 then calling\r
163 FreeRTOS_sendto() on a socket that has not yet been bound will result in the IP\r
164 stack automatically binding the socket to a port number from the range\r
165 socketAUTO_PORT_ALLOCATION_START_NUMBER to 0xffff.  If\r
166 ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND is set to 0 then calling FreeRTOS_sendto()\r
167 on a socket that has not yet been bound will result in the send operation being\r
168 aborted. */\r
169 #define ipconfigALLOW_SOCKET_SEND_WITHOUT_BIND 1\r
170 \r
171 /* Defines the Time To Live (TTL) values used in outgoing UDP packets. */\r
172 #define updconfigIP_TIME_TO_LIVE                128\r
173 \r
174 /* If ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is set to 1 then UDP packets that\r
175 contain more data than will fit in a single network frame will be fragmented\r
176 across multiple IP packets.  Also see the ipconfigNETWORK_MTU setting.  If\r
177 ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must\r
178 be divisible by 8.  Setting ipconfigCAN_FRAGMENT_OUTGOING_PACKETS to 1 will\r
179 increase both the code size and execution time. */\r
180 #define ipconfigCAN_FRAGMENT_OUTGOING_PACKETS 0\r
181 \r
182 /* The MTU is the maximum number of bytes the payload of a network frame can\r
183 contain.  For normal Ethernet V2 frames the maximum MTU is 1500.  Setting a\r
184 lower value can save RAM, depending on the buffer management scheme used.  If\r
185 ipconfigCAN_FRAGMENT_OUTGOING_PACKETS is 1 then (ipconfigNETWORK_MTU - 28) must\r
186 be divisible by 8. */\r
187 #define ipconfigNETWORK_MTU 1500 /* Leave at 1500 for SAM4E. */\r
188 \r
189 /* Set ipconfigUSE_DNS to 1 to include a basic DNS client/resolver.  DNS is used\r
190 through the FreeRTOS_gethostbyname() API function. */\r
191 #define ipconfigUSE_DNS         1\r
192 \r
193 /* If ipconfigREPLY_TO_INCOMING_PINGS is set to 1 then the IP stack will\r
194 generate replies to incoming ICMP echo (ping) requests. */\r
195 #define ipconfigREPLY_TO_INCOMING_PINGS                         1\r
196 \r
197 /* If ipconfigSUPPORT_OUTGOING_PINGS is set to 1 then the\r
198 FreeRTOS_SendPingRequest() API function is available. */\r
199 #define ipconfigSUPPORT_OUTGOING_PINGS                          1\r
200 \r
201 /* If ipconfigSUPPORT_SELECT_FUNCTION is set to 1 then the FreeRTOS_select()\r
202 (and associated) API function is available. */\r
203 #define ipconfigSUPPORT_SELECT_FUNCTION                         1\r
204 \r
205 /* Used for stack testing only, and must be implemented in the network\r
206 interface. */\r
207 #define updconfigLOOPBACK_ETHERNET_PACKETS      0\r
208 \r
209 /* If ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES is set to 1 then Ethernet frames\r
210 that are not in Ethernet II format will be dropped.  This option is included for\r
211 potential future IP stack developments. */\r
212 #define ipconfigFILTER_OUT_NON_ETHERNET_II_FRAMES 1\r
213 \r
214 /* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1 then it is the\r
215 responsibility of the Ethernet interface to filter out packets that are of no\r
216 interest.  If the Ethernet interface does not implement this functionality, then\r
217 set ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES to 0 to have the IP stack\r
218 perform the filtering instead (it is much less efficient for the stack to do it\r
219 because the packet will already have been passed into the stack).  If the\r
220 Ethernet driver does all the necessary filtering in hardware then software\r
221 filtering can be removed by using a value other than 1 or 0. */\r
222 #define ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES     0\r
223 \r
224 /* If ipconfigETHERNET_DRIVER_ADDS_UDP_CHECKSUM is set to 1 then a UDP checksum\r
225 will not be calculated and added to a packet before the packet is sent to the\r
226 hardware for transmission. */\r
227 #define ipconfigETHERNET_DRIVER_ADDS_UDP_CHECKSUM       0\r
228 \r
229 /* If ipconfigETHERNET_DRIVER_ADDS_IP_CHECKSUM is set to 1 then an IP checksum\r
230 will not be calculated and added to a packet before the packet is sent to the\r
231 hardware for transmission. */\r
232 #define ipconfigETHERNET_DRIVER_ADDS_IP_CHECKSUM        0\r
233 \r
234 /* If ipconfigETHERNET_DRIVER_CHECKS_IP_CHECKSUM is set to 1 then the IP\r
235 checksum will be ignored on incoming packets on the assumption IP packets with\r
236 an invalid checksum are not passed to the stack. */\r
237 #define ipconfigETHERNET_DRIVER_CHECKS_IP_CHECKSUM      0\r
238 \r
239 /* If ipconfigETHERNET_DRIVER_CHECKS_UDP_CHECKSUM is set to 1 then the UDP\r
240 checksum will be ignored on incoming packets on the assumption the UDP packets\r
241 with an invalid checksum are not passed to the stack. */\r
242 #define ipconfigETHERNET_DRIVER_CHECKS_UDP_CHECKSUM 0\r
243 \r
244 /* Set ipconfigFREERTOS_PLUS_NABTO to 1 to support the Nabto protocol, or 0 to\r
245 exclude support for the Nabto protocol.  If ipconfigFREERTOS_PLUS_NABTO is set\r
246 to one then the project must build the Nabto source code (or reference a\r
247 pre-build Nabto library. */\r
248 #define ipconfigFREERTOS_PLUS_NABTO                                     0\r
249 \r
250 /* Sets the size of the stack used by the Nabto service task.  The Nabto event\r
251 handler executes in the context of the Nabto service task.  If the event handler\r
252 uses a lot of stack then it is possible the value set here will need to be\r
253 increased.  It is recommended to have FreeRTOS stack overflow checking turned\r
254 on during development (see the configCHECK_FOR_STACK_OVERFLOW in\r
255 FreeRTOSConfig.h and in the documentation. */\r
256 #define ipconfigNABTO_TASK_STACK_SIZE ( configMINIMAL_STACK_SIZE * 2 )\r
257 \r
258 /* Sets the priority of the Nabto service task.  This is a standard FreeRTOS\r
259 task priority so can take values between 0 (the lowest priority) and\r
260 configMAX_PRIORITIES - 1 (the highest priority).  Also see the definition of\r
261 ipconfigUDP_TASK_PRIORITY.  This would normally be set to be either one higher\r
262 or one lower than ipconfigUDP_TASK_PRIORITY, depending on the application. */\r
263 #define ipconfigNABTO_TASK_PRIORITY      ( ipconfigUDP_TASK_PRIORITY + 1 )\r
264 \r
265 /* The windows simulator cannot really simulate MAC interrupts, and needs to\r
266 block occasionally to allow other tasks to run. */\r
267 #ifdef _WINDOWS_\r
268         #define configWINDOWS_MAC_INTERRUPT_SIMULATOR_DELAY ( 3 / portTICK_PERIOD_MS )\r
269 #endif\r
270 \r
271 /* The example IP trace macros are included here so the definitions are\r
272 available in all the FreeRTOS+UDP source files. */\r
273 #include "DemoIPTrace.h"\r
274 \r
275 #endif /* FREERTOS_IP_CONFIG_H */\r