2 * FreeRTOS+UDP V1.0.0 (C) 2013 Real Time Engineers ltd.
\r
4 * FreeRTOS+UDP is an add-on component to FreeRTOS. It is not, in itself, part
\r
5 * of the FreeRTOS kernel. FreeRTOS+UDP is licensed separately from FreeRTOS,
\r
6 * and uses a different license to FreeRTOS. FreeRTOS+UDP uses a dual license
\r
7 * model, information on which is provided below:
\r
9 * - Open source licensing -
\r
10 * FreeRTOS+UDP is a free download and may be used, modified and distributed
\r
11 * without charge provided the user adheres to version two of the GNU General
\r
12 * Public license (GPL) and does not remove the copyright notice or this text.
\r
13 * The GPL V2 text is available on the gnu.org web site, and on the following
\r
14 * URL: http://www.FreeRTOS.org/gpl-2.0.txt
\r
16 * - Commercial licensing -
\r
17 * Businesses and individuals who wish to incorporate FreeRTOS+UDP into
\r
18 * proprietary software for redistribution in any form must first obtain a
\r
19 * (very) low cost commercial license - and in-so-doing support the maintenance,
\r
20 * support and further development of the FreeRTOS+UDP product. Commercial
\r
21 * licenses can be obtained from http://shop.freertos.org and do not require any
\r
22 * source files to be changed.
\r
24 * FreeRTOS+UDP is distributed in the hope that it will be useful. You cannot
\r
25 * use FreeRTOS+UDP unless you agree that you use the software 'as is'.
\r
26 * FreeRTOS+UDP is provided WITHOUT ANY WARRANTY; without even the implied
\r
27 * warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR
\r
28 * PURPOSE. Real Time Engineers Ltd. disclaims all conditions and terms, be they
\r
29 * implied, expressed, or statutory.
\r
31 * 1 tab == 4 spaces!
\r
33 * http://www.FreeRTOS.org
\r
34 * http://www.FreeRTOS.org/udp
\r
38 /* Standard includes. */
\r
41 /* FreeRTOS includes. */
\r
42 #include "FreeRTOS.h"
\r
47 /* FreeRTOS+UDP includes. */
\r
48 #include "FreeRTOS_UDP_IP.h"
\r
49 #include "FreeRTOS_Sockets.h"
\r
50 #include "NetworkBufferManagement.h"
\r
52 /* Hardware includes. */
\r
53 #include "hwEthernet.h"
\r
55 /* Demo includes. */
\r
56 #include "NetworkInterface.h"
\r
58 #if ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES != 1
\r
59 #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eProcessBuffer
\r
61 #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eConsiderFrameForProcessing( ( pucEthernetBuffer ) )
\r
64 /* When a packet is ready to be sent, if it cannot be sent immediately then the
\r
65 task performing the transmit will block for niTX_BUFFER_FREE_WAIT
\r
66 milliseconds. It will do this a maximum of niMAX_TX_ATTEMPTS before giving
\r
68 #define niTX_BUFFER_FREE_WAIT ( ( portTickType ) 2UL / portTICK_RATE_MS )
\r
69 #define niMAX_TX_ATTEMPTS ( 5 )
\r
71 /* The length of the queue used to send interrupt status words from the
\r
72 interrupt handler to the deferred handler task. */
\r
73 #define niINTERRUPT_QUEUE_LENGTH ( 10 )
\r
75 /*-----------------------------------------------------------*/
\r
78 * A deferred interrupt handler task that processes
\r
80 extern void vEMACHandlerTask( void *pvParameters );
\r
82 /*-----------------------------------------------------------*/
\r
84 /* The queue used to communicate Ethernet events with the IP task. */
\r
85 extern xQueueHandle xNetworkEventQueue;
\r
87 /* The semaphore used to wake the deferred interrupt handler task when an Rx
\r
88 interrupt is received. */
\r
89 xSemaphoreHandle xEMACRxEventSemaphore = NULL;
\r
90 /*-----------------------------------------------------------*/
\r
92 portBASE_TYPE xNetworkInterfaceInitialise( void )
\r
94 portBASE_TYPE xStatus, xReturn;
\r
95 extern uint8_t ucMACAddress[ 6 ];
\r
97 /* Initialise the MAC. */
\r
100 while( lEMACWaitForLink() != pdPASS )
\r
105 vSemaphoreCreateBinary( xEMACRxEventSemaphore );
\r
106 configASSERT( xEMACRxEventSemaphore );
\r
108 /* The handler task is created at the highest possible priority to
\r
109 ensure the interrupt handler can return directly to it. */
\r
110 xTaskCreate( vEMACHandlerTask, ( const signed char * const ) "EMAC", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL );
\r
115 /*-----------------------------------------------------------*/
\r
117 portBASE_TYPE xNetworkInterfaceOutput( xNetworkBufferDescriptor_t * const pxNetworkBuffer )
\r
119 extern void vEMACCopyWrite( uint8_t * pucBuffer, uint16_t usLength );
\r
121 vEMACCopyWrite( pxNetworkBuffer->pucBuffer, pxNetworkBuffer->xDataLength );
\r
123 /* Finished with the network buffer. */
\r
124 vNetworkBufferRelease( pxNetworkBuffer );
\r
128 /*-----------------------------------------------------------*/
\r