2 * FreeRTOS+UDP V1.0.4 (C) 2014 Real Time Engineers ltd.
\r
3 * All rights reserved
\r
5 * This file is part of the FreeRTOS+UDP distribution. The FreeRTOS+UDP license
\r
6 * terms are different to the FreeRTOS license terms.
\r
8 * FreeRTOS+UDP uses a dual license model that allows the software to be used
\r
9 * under a standard GPL open source license, or a commercial license. The
\r
10 * standard GPL license (unlike the modified GPL license under which FreeRTOS
\r
11 * itself is distributed) requires that all software statically linked with
\r
12 * FreeRTOS+UDP is also distributed under the same GPL V2 license terms.
\r
13 * Details of both license options follow:
\r
15 * - Open source licensing -
\r
16 * FreeRTOS+UDP is a free download and may be used, modified, evaluated and
\r
17 * distributed without charge provided the user adheres to version two of the
\r
18 * GNU General Public License (GPL) and does not remove the copyright notice or
\r
19 * this text. The GPL V2 text is available on the gnu.org web site, and on the
\r
20 * following URL: http://www.FreeRTOS.org/gpl-2.0.txt.
\r
22 * - Commercial licensing -
\r
23 * Businesses and individuals that for commercial or other reasons cannot comply
\r
24 * with the terms of the GPL V2 license must obtain a commercial license before
\r
25 * incorporating FreeRTOS+UDP into proprietary software for distribution in any
\r
26 * form. Commercial licenses can be purchased from http://shop.freertos.org/udp
\r
27 * and do not require any source files to be changed.
\r
29 * FreeRTOS+UDP is distributed in the hope that it will be useful. You cannot
\r
30 * use FreeRTOS+UDP unless you agree that you use the software 'as is'.
\r
31 * FreeRTOS+UDP is provided WITHOUT ANY WARRANTY; without even the implied
\r
32 * warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR
\r
33 * PURPOSE. Real Time Engineers Ltd. disclaims all conditions and terms, be they
\r
34 * implied, expressed, or statutory.
\r
36 * 1 tab == 4 spaces!
\r
38 * http://www.FreeRTOS.org
\r
39 * http://www.FreeRTOS.org/udp
\r
43 /* Standard includes. */
\r
46 /* FreeRTOS includes. */
\r
47 #include "FreeRTOS.h"
\r
52 /* FreeRTOS+UDP includes. */
\r
53 #include "FreeRTOS_UDP_IP.h"
\r
54 #include "FreeRTOS_IP_Private.h"
\r
55 #include "FreeRTOS_Sockets.h"
\r
56 #include "NetworkBufferManagement.h"
\r
58 /* Hardware includes. */
\r
59 #include "hwEthernet.h"
\r
61 /* Demo includes. */
\r
62 #include "NetworkInterface.h"
\r
64 #if ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES != 1
\r
65 #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eProcessBuffer
\r
67 #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eConsiderFrameForProcessing( ( pucEthernetBuffer ) )
\r
70 /* When a packet is ready to be sent, if it cannot be sent immediately then the
\r
71 task performing the transmit will block for niTX_BUFFER_FREE_WAIT
\r
72 milliseconds. It will do this a maximum of niMAX_TX_ATTEMPTS before giving
\r
74 #define niTX_BUFFER_FREE_WAIT ( ( TickType_t ) 2UL / portTICK_RATE_MS )
\r
75 #define niMAX_TX_ATTEMPTS ( 5 )
\r
77 /* The length of the queue used to send interrupt status words from the
\r
78 interrupt handler to the deferred handler task. */
\r
79 #define niINTERRUPT_QUEUE_LENGTH ( 10 )
\r
81 /*-----------------------------------------------------------*/
\r
84 * A deferred interrupt handler task that processes
\r
86 extern void vEMACHandlerTask( void *pvParameters );
\r
88 /*-----------------------------------------------------------*/
\r
90 /* The queue used to communicate Ethernet events with the IP task. */
\r
91 extern xQueueHandle xNetworkEventQueue;
\r
93 /* The semaphore used to wake the deferred interrupt handler task when an Rx
\r
94 interrupt is received. */
\r
95 xSemaphoreHandle xEMACRxEventSemaphore = NULL;
\r
96 /*-----------------------------------------------------------*/
\r
98 BaseType_t xNetworkInterfaceInitialise( void )
\r
100 BaseType_t xStatus, xReturn;
\r
101 extern uint8_t ucMACAddress[ 6 ];
\r
103 /* Initialise the MAC. */
\r
106 while( lEMACWaitForLink() != pdPASS )
\r
111 vSemaphoreCreateBinary( xEMACRxEventSemaphore );
\r
112 configASSERT( xEMACRxEventSemaphore );
\r
114 /* The handler task is created at the highest possible priority to
\r
115 ensure the interrupt handler can return directly to it. */
\r
116 xTaskCreate( vEMACHandlerTask, "EMAC", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL );
\r
121 /*-----------------------------------------------------------*/
\r
123 BaseType_t xNetworkInterfaceOutput( xNetworkBufferDescriptor_t * const pxNetworkBuffer )
\r
125 extern void vEMACCopyWrite( uint8_t * pucBuffer, uint16_t usLength );
\r
127 vEMACCopyWrite( pxNetworkBuffer->pucEthernetBuffer, pxNetworkBuffer->xDataLength );
\r
129 /* Finished with the network buffer. */
\r
130 vNetworkBufferRelease( pxNetworkBuffer );
\r
134 /*-----------------------------------------------------------*/
\r