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