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