2 * FreeRTOS+TCP Labs Build 150406 (C) 2015 Real Time Engineers ltd.
\r
3 * Authors include Hein Tibosch and Richard Barry
\r
5 *******************************************************************************
\r
6 ***** NOTE ******* NOTE ******* NOTE ******* NOTE ******* NOTE ******* NOTE ***
\r
9 *** FREERTOS+TCP IS STILL IN THE LAB: ***
\r
11 *** This product is functional and is already being used in commercial ***
\r
12 *** products. Be aware however that we are still refining its design, ***
\r
13 *** the source code does not yet fully conform to the strict coding and ***
\r
14 *** style standards mandated by Real Time Engineers ltd., and the ***
\r
15 *** documentation and testing is not necessarily complete. ***
\r
17 *** PLEASE REPORT EXPERIENCES USING THE SUPPORT RESOURCES FOUND ON THE ***
\r
18 *** URL: http://www.FreeRTOS.org/contact Active early adopters may, at ***
\r
19 *** the sole discretion of Real Time Engineers Ltd., be offered versions ***
\r
20 *** under a license other than that described below. ***
\r
23 ***** NOTE ******* NOTE ******* NOTE ******* NOTE ******* NOTE ******* NOTE ***
\r
24 *******************************************************************************
\r
26 * - Open source licensing -
\r
27 * While FreeRTOS+TCP is in the lab it is provided only under version two of the
\r
28 * GNU General Public License (GPL) (which is different to the standard FreeRTOS
\r
29 * license). FreeRTOS+TCP is free to download, use and distribute under the
\r
30 * terms of that license provided the copyright notice and this text are not
\r
31 * altered or removed from the source files. The GPL V2 text is available on
\r
32 * the gnu.org web site, and on the following
\r
33 * URL: http://www.FreeRTOS.org/gpl-2.0.txt. Active early adopters may, and
\r
34 * solely at the discretion of Real Time Engineers Ltd., be offered versions
\r
35 * under a license other then the GPL.
\r
37 * FreeRTOS+TCP is distributed in the hope that it will be useful. You cannot
\r
38 * use FreeRTOS+TCP unless you agree that you use the software 'as is'.
\r
39 * FreeRTOS+TCP is provided WITHOUT ANY WARRANTY; without even the implied
\r
40 * warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR
\r
41 * PURPOSE. Real Time Engineers Ltd. disclaims all conditions and terms, be they
\r
42 * implied, expressed, or statutory.
\r
44 * 1 tab == 4 spaces!
\r
46 * http://www.FreeRTOS.org
\r
47 * http://www.FreeRTOS.org/plus
\r
48 * http://www.FreeRTOS.org/labs
\r
52 /* Standard includes. */
\r
55 /* FreeRTOS includes. */
\r
56 #include "FreeRTOS.h"
\r
61 /* FreeRTOS+TCP includes. */
\r
62 #include "FreeRTOS_UDP_IP.h"
\r
63 #include "FreeRTOS_Sockets.h"
\r
64 #include "NetworkBufferManagement.h"
\r
66 /* Hardware includes. */
\r
67 #include "hwEthernet.h"
\r
69 /* Demo includes. */
\r
70 #include "NetworkInterface.h"
\r
72 #if ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES != 1
\r
73 #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eProcessBuffer
\r
75 #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eConsiderFrameForProcessing( ( pucEthernetBuffer ) )
\r
78 /* When a packet is ready to be sent, if it cannot be sent immediately then the
\r
79 task performing the transmit will block for niTX_BUFFER_FREE_WAIT
\r
80 milliseconds. It will do this a maximum of niMAX_TX_ATTEMPTS before giving
\r
82 #define niTX_BUFFER_FREE_WAIT ( ( TickType_t ) 2UL / portTICK_PERIOD_MS )
\r
83 #define niMAX_TX_ATTEMPTS ( 5 )
\r
85 /* The length of the queue used to send interrupt status words from the
\r
86 interrupt handler to the deferred handler task. */
\r
87 #define niINTERRUPT_QUEUE_LENGTH ( 10 )
\r
89 /*-----------------------------------------------------------*/
\r
92 * A deferred interrupt handler task that processes
\r
94 extern void vEMACHandlerTask( void *pvParameters );
\r
96 /*-----------------------------------------------------------*/
\r
98 /* The queue used to communicate Ethernet events with the IP task. */
\r
99 extern QueueHandle_t xNetworkEventQueue;
\r
101 /* The semaphore used to wake the deferred interrupt handler task when an Rx
\r
102 interrupt is received. */
\r
103 SemaphoreHandle_t xEMACRxEventSemaphore = NULL;
\r
104 /*-----------------------------------------------------------*/
\r
106 BaseType_t xNetworkInterfaceInitialise( void )
\r
108 BaseType_t xStatus, xReturn;
\r
109 extern uint8_t ucMACAddress[ 6 ];
\r
111 /* Initialise the MAC. */
\r
114 while( lEMACWaitForLink() != pdPASS )
\r
119 vSemaphoreCreateBinary( xEMACRxEventSemaphore );
\r
120 configASSERT( xEMACRxEventSemaphore );
\r
122 /* The handler task is created at the highest possible priority to
\r
123 ensure the interrupt handler can return directly to it. */
\r
124 xTaskCreate( vEMACHandlerTask, "EMAC", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL );
\r
129 /*-----------------------------------------------------------*/
\r
131 BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer )
\r
133 extern void vEMACCopyWrite( uint8_t * pucBuffer, uint16_t usLength );
\r
135 vEMACCopyWrite( pxNetworkBuffer->pucBuffer, pxNetworkBuffer->xDataLength );
\r
137 /* Finished with the network buffer. */
\r
138 vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer );
\r
142 /*-----------------------------------------------------------*/
\r