mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2026-02-20 09:05:30 -05:00
Added +TCP code to main repo.
This commit is contained in:
parent
037abdddf2
commit
77e95538dc
114 changed files with 46629 additions and 446 deletions
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* FreeRTOS+TCP Labs Build 150406 (C) 2015 Real Time Engineers ltd.
|
||||
* Authors include Hein Tibosch and Richard Barry
|
||||
*
|
||||
*******************************************************************************
|
||||
***** NOTE ******* NOTE ******* NOTE ******* NOTE ******* NOTE ******* NOTE ***
|
||||
*** ***
|
||||
*** ***
|
||||
*** FREERTOS+TCP IS STILL IN THE LAB: ***
|
||||
*** ***
|
||||
*** This product is functional and is already being used in commercial ***
|
||||
*** products. Be aware however that we are still refining its design, ***
|
||||
*** the source code does not yet fully conform to the strict coding and ***
|
||||
*** style standards mandated by Real Time Engineers ltd., and the ***
|
||||
*** documentation and testing is not necessarily complete. ***
|
||||
*** ***
|
||||
*** PLEASE REPORT EXPERIENCES USING THE SUPPORT RESOURCES FOUND ON THE ***
|
||||
*** URL: http://www.FreeRTOS.org/contact Active early adopters may, at ***
|
||||
*** the sole discretion of Real Time Engineers Ltd., be offered versions ***
|
||||
*** under a license other than that described below. ***
|
||||
*** ***
|
||||
*** ***
|
||||
***** NOTE ******* NOTE ******* NOTE ******* NOTE ******* NOTE ******* NOTE ***
|
||||
*******************************************************************************
|
||||
*
|
||||
* - Open source licensing -
|
||||
* While FreeRTOS+TCP is in the lab it is provided only under version two of the
|
||||
* GNU General Public License (GPL) (which is different to the standard FreeRTOS
|
||||
* license). FreeRTOS+TCP is free to download, use and distribute under the
|
||||
* terms of that license provided the copyright notice and this text are not
|
||||
* altered or removed from the source files. The GPL V2 text is available on
|
||||
* the gnu.org web site, and on the following
|
||||
* URL: http://www.FreeRTOS.org/gpl-2.0.txt. Active early adopters may, and
|
||||
* solely at the discretion of Real Time Engineers Ltd., be offered versions
|
||||
* under a license other then the GPL.
|
||||
*
|
||||
* FreeRTOS+TCP is distributed in the hope that it will be useful. You cannot
|
||||
* use FreeRTOS+TCP unless you agree that you use the software 'as is'.
|
||||
* FreeRTOS+TCP is provided WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranties of NON-INFRINGEMENT, MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. Real Time Engineers Ltd. disclaims all conditions and terms, be they
|
||||
* implied, expressed, or statutory.
|
||||
*
|
||||
* 1 tab == 4 spaces!
|
||||
*
|
||||
* http://www.FreeRTOS.org
|
||||
* http://www.FreeRTOS.org/plus
|
||||
* http://www.FreeRTOS.org/labs
|
||||
*
|
||||
*/
|
||||
|
||||
/* Standard includes. */
|
||||
#include <stdint.h>
|
||||
|
||||
/* FreeRTOS includes. */
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
#include "semphr.h"
|
||||
|
||||
/* FreeRTOS+TCP includes. */
|
||||
#include "FreeRTOS_UDP_IP.h"
|
||||
#include "FreeRTOS_Sockets.h"
|
||||
#include "NetworkBufferManagement.h"
|
||||
|
||||
/* Hardware includes. */
|
||||
#include "hwEthernet.h"
|
||||
|
||||
/* Demo includes. */
|
||||
#include "NetworkInterface.h"
|
||||
|
||||
#if ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES != 1
|
||||
#define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eProcessBuffer
|
||||
#else
|
||||
#define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eConsiderFrameForProcessing( ( pucEthernetBuffer ) )
|
||||
#endif
|
||||
|
||||
/* When a packet is ready to be sent, if it cannot be sent immediately then the
|
||||
task performing the transmit will block for niTX_BUFFER_FREE_WAIT
|
||||
milliseconds. It will do this a maximum of niMAX_TX_ATTEMPTS before giving
|
||||
up. */
|
||||
#define niTX_BUFFER_FREE_WAIT ( ( TickType_t ) 2UL / portTICK_PERIOD_MS )
|
||||
#define niMAX_TX_ATTEMPTS ( 5 )
|
||||
|
||||
/* The length of the queue used to send interrupt status words from the
|
||||
interrupt handler to the deferred handler task. */
|
||||
#define niINTERRUPT_QUEUE_LENGTH ( 10 )
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/*
|
||||
* A deferred interrupt handler task that processes
|
||||
*/
|
||||
extern void vEMACHandlerTask( void *pvParameters );
|
||||
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* The queue used to communicate Ethernet events with the IP task. */
|
||||
extern QueueHandle_t xNetworkEventQueue;
|
||||
|
||||
/* The semaphore used to wake the deferred interrupt handler task when an Rx
|
||||
interrupt is received. */
|
||||
SemaphoreHandle_t xEMACRxEventSemaphore = NULL;
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
BaseType_t xNetworkInterfaceInitialise( void )
|
||||
{
|
||||
BaseType_t xStatus, xReturn;
|
||||
extern uint8_t ucMACAddress[ 6 ];
|
||||
|
||||
/* Initialise the MAC. */
|
||||
vInitEmac();
|
||||
|
||||
while( lEMACWaitForLink() != pdPASS )
|
||||
{
|
||||
vTaskDelay( 20 );
|
||||
}
|
||||
|
||||
vSemaphoreCreateBinary( xEMACRxEventSemaphore );
|
||||
configASSERT( xEMACRxEventSemaphore );
|
||||
|
||||
/* The handler task is created at the highest possible priority to
|
||||
ensure the interrupt handler can return directly to it. */
|
||||
xTaskCreate( vEMACHandlerTask, "EMAC", configMINIMAL_STACK_SIZE, NULL, configMAX_PRIORITIES - 1, NULL );
|
||||
xReturn = pdPASS;
|
||||
|
||||
return xReturn;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer )
|
||||
{
|
||||
extern void vEMACCopyWrite( uint8_t * pucBuffer, uint16_t usLength );
|
||||
|
||||
vEMACCopyWrite( pxNetworkBuffer->pucBuffer, pxNetworkBuffer->xDataLength );
|
||||
|
||||
/* Finished with the network buffer. */
|
||||
vReleaseNetworkBufferAndDescriptor( pxNetworkBuffer );
|
||||
|
||||
return pdTRUE;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue