/* FreeRTOS+TCP V2.0.11 Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. http://aws.amazon.com/freertos http://www.FreeRTOS.org */ /* FreeRTOS includes. */ #include "FreeRTOS.h" #include "os_list.h" /* FreeRTOS+TCP includes. */ #include "FreeRTOS_IP.h" /* TI Hercules Halcogen includes */ #include "HL_emac.h" /* If ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES is set to 1, then the Ethernet driver will filter incoming packets and only pass the stack those packets it considers need processing. */ #if( ipconfigETHERNET_DRIVER_FILTERS_FRAME_TYPES == 0 ) #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eProcessBuffer #else #define ipCONSIDER_FRAME_FOR_PROCESSING( pucEthernetBuffer ) eConsiderFrameForProcessing( ( pucEthernetBuffer ) ) #endif BaseType_t xNetworkInterfaceInitialise( void ) { /* TC - MOVED MAC and PHY address from HL_sys_main.c to here. I'm not sure where, if anywhere, * PHY address is used. * * MAC address is a HACK. Copied from an LwIP project for RM57L. * The LaunchXL2-RM57L board does not have an EUI ID ROM. */ /* _HT_ In stead of declaring a MAC-address here, you can use the macro 'ipLOCAL_MAC_ADDRESS'. See FreeRTOS_IP_Private.h It will be filled by FreeRTOS_IPInit() at start-up. */ uint8 emacAddress[6U] = {0x00U, 0x08U, 0xeeU, 0xFFU, 0x03U, 0x6CU}; // uint32 emacPhyAddress = 1U; BaseType_t xReturn; /* TC - Ethernet MAC initialization function EMACHWInit() provided by TI Hercules Halcogen */ /* _HT_ Mind you that xNetworkInterfaceInitialise() will be called repeatedly until it returns pdPASS (same as pdTRUE). Sp make sure that you call EMACHWInit() only once. It probably makes no sense to call it more often. When the EMAC is initialised successfully, this function returns pdPASS only when the Link Status is high, i.e. when the connection with the router or switch is OK. */ if ( EMACHWInit(emacAddress) == EMAC_ERR_OK ) { xReturn = pdTRUE; } else { xReturn = pdFALSE; } return xReturn; } BaseType_t xNetworkInterfaceOutput( NetworkBufferDescriptor_t * const pxNetworkBuffer, BaseType_t xReleaseAfterSend ) { /* _HT_ The function pxGetNetworkBufferWithDescriptor() is not needed here. Also I would check if the Link Status is hig before attempting to sen any Network Packet. */ /* TC - Just dumping stuff here that may be applicable... */ /* NetworkBufferDescriptor_t *pxGetNetworkBufferWithDescriptor( size_t xRequestedSizeBytes, TickType_t xBlockTimeTicks ) boolean EMACTransmit(hdkif_t *hdkif, pbuf_t *pbuf) iptraceNETWORK_INTERFACE_TRANSMIT(); if( xReleaseAfterSens != pdFALSE ) { vReleaseNetworkBufferAndDescriptor( pxDescriptor ); } return pdTRUE; */ /* FIX ME. */ return pdFALSE; } /* TC - Using BufferAllocation_2.c (dynamic allocation) so vNetworkInterfaceAllocateRAMToBuffers() is not needed. */ /* _HT_ That is correct. */ void vNetworkInterfaceAllocateRAMToBuffers( NetworkBufferDescriptor_t pxNetworkBuffers[ ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS ] ) { /* FIX ME. */ /* _HT_ You can look up any of the implementation in the other drivers like STM32Fxx or Zynq. */ } BaseType_t xGetPhyLinkStatus( void ) { /* FIX ME. */ /* _HT_ Please look at e.g. the STH32Fxx driver how it uses the generic common/phyHandler.c It needs a read and a write function to communicate with the PHY through the MMI or RMMI bus. Please check if you PHY type will also be recognised. It will only work for 100 Mbps networks. */ return pdFALSE; } /* _HT_ Please look at other driver how they start up a task caller something like DeferredInterruptHandler(). For each packet coming in, there will be an RX interrupt. This interrupt will wakeup the DI-handler. The handler will check for incoming packets and forward them to the IP-task. The task will also check regularly the Link Status. Again, see the drivers for STM32Fxx or Zynq. */