This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088

Dependents:   MbedFileServer_1768MiniDK2 RedWireBridge IssueDebug_gcc MiMicRemoteMCU-for-Mbed ... more

libMiMic(MiMic library for mbed)は、WebService機能を提供するSDKです。 mbedでWebAPIに対応したネットワークデバイスを簡単に作ることが出来ます。

libMiMicはMiMic projectで開発しています。MiMic projectについてはこちらをご覧ください。 http://nyatla.jp/mimic/wp/

構成

libMiMicはmbedRTOS上で動作し、ユーザアプリケーションにAPIを提供します。コアAPIはC言語で記述されていますが、使用頻度の高いものについてはmbed向けのC++APIが準備されています。

/media/uploads/nyatla/libmimic-sdk.png

※libMiMicはmbedの標準イーサネットドライバをしようしていません。

標準イーサネットドライバと同時に使用することはできません。

  • MiMicIP - IPv4スタックです。レテンシとメモリ消費量を抑えたuipベースのライブラリです。
  • ARP/ICMP/UDP/TCP - 基礎的なソケットAPIを提供します。APIは独自です。
  • HTTP/1.1 Server - HTTP/1.1に対応したサーバです。マルチセッション・Chunked・持続性接続に対応しています。
  • HTTP Modules - HTTP/1.1の機能モジュールです。以下のモジュールがあります。
    • ROM file provider - ROMに格納したファイルイメージを公開します。
    • File system provider - mbedファイルシステムを公開します。
    • Onchip configuration - プログラムフラッシュを利用して設定を保存します。
    • MiMicVM processor - RPCリクエスト(MiMicVM)を処理します。
    • FileUpload - ファイルアップロードを受け取ります。
    • URL decoder - HTTPリクエストを解析します。
    • UPnP handler -UPnPメッセージを処理します。
    • WebSocket - Websocketサーバです。
  • mDNS - マルチキャストDNSサービスです。
  • UPnP - UPnP/1.0の機能を提供します。UPnP handlerと協調して動作します。(現在はデバイス探索(SSDP)・デスクリプション(Description)のみ実装してあります。)
  • DHCP/APIPA - ゼロコンフィギュレーション用のモジュールです。
  • HTTP/1.1 Client
  • mbed C++ class library - mbed向けのC++CPIです。C言語のものより簡単です。

対応機種

  • mbed(mbed LPC1768)
  • LPCXpresso1769

プログラム

Import programMiMicRemoteMCU-for-Mbed

MiMic RemoteMCU for mbed. This program provides MCU control API over REST API. It can control MCU from Javascript,PHP or any HTTP rest client directly. And, The application has self development environment.

Import programMbedFileServer

The program publishes files at local directory and SD filesystem. It is a full-fledged webServer somewhat.

サンプル

Import programMiMicSimpleHttpd

This is a simplest HTTP server made ​​of libMiMic. It will echo back a request path.

Import programUPnPBasicDevice

Simplest UPnP basic device example. This program to run UPnP basic device on the mbed.

Import programWebSocketSample

MiMicSDK Websocket module sample program.

Import programHttpClientSamlpe

A http client sample program.

Import programTcpSocketClientSamlpe

MiMicSDK Tcp client socket sample program.

Import programUdpSocketSamlpe

Udp socket sample program. This program will send back the received packet.

チュートリアル

English

libMiMic(MiMic library for mbed) is SDK which provides Webservice functions. It can be created networking device easily using mbed.

See more MiMic information, See MiMic project website. http://nyatla.jp/mimic/wp/

Structure

libMiMic run on mbed RTOS and provides networking API to user application. This library has C++ class API for the mbed, and low-level C language API.

/media/uploads/nyatla/libmimic-sdk.png

For WebService general, it can be written in a simple C + + API.

libMiMic does not have the standard Ethernet driver of mbed. It is not possible that will be used with the standard Ethernet driver.

  • MiMicIP - IPv4 protocol stack. This is based uip which is reduced memory and latency.
  • ARP / ICMP / UDP / TCP - Those are provide basic IP protocols.
  • HTTP/1.1 Server - The Http server compatible HTTP/1.1. It supports multi-session, chunked transport, persistent connection.
  • HTTP Modules - There are addon-module for HTTP server. The following modules.
    • ROM file module - Publish the file images in ROM.
    • File system module - Publish thefiles in mbed file system.
    • Onchip configuration module - To save the network settings to the program flash via REST.
    • MiMicVM module - To handle the (MiMicVM) RPC request.
    • FileUpload module - Accept a file via HTTP POST.
    • URL dedoce module - A versatility URL decoder.
    • UPnP handle module - To handle UPnP messages.
    • UPnP - This provides UPnP/1.0 device functions. It works together with UPnP handler.
    • Websocket - websocket (version13) server
  • mDNS Service - DNS-SD protocol server.
  • UPnP - This provides UPnP/1.0 device functions which works with UPnP handler. (You have been implemented (SSDP) ? description only (Description) device search now.) It is a module zero configuration for - DHCP / APIPA. mbed C + + class library - C of mbed for + + is the CPI. It is simple than that of the C language.
  • DHCP/APIPA - It support zero-cpnfigulation.
  • mbed C++ class library. Almost APIs for Web applications are available.
  • HTTP/1.1 Client

Supported target

  • mbed(mbed LPC1768)
  • LPCXpresso1769

Application

Import programMiMicRemoteMCU-for-Mbed

MiMic RemoteMCU for mbed. This program provides MCU control API over REST API. It can control MCU from Javascript,PHP or any HTTP rest client directly. And, The application has self development environment.

Import programMbedFileServer

The program publishes files at local directory and SD filesystem. It is a full-fledged webServer somewhat.

Sample

Import programMiMicSimpleHttpd

This is a simplest HTTP server made ​​of libMiMic. It will echo back a request path.

Import programUPnPBasicDevice

Simplest UPnP basic device example. This program to run UPnP basic device on the mbed.

Import programWebSocketSample

MiMicSDK Websocket module sample program.

Import programHttpClientSamlpe

A http client sample program.

Import programTcpSocketClientSamlpe

MiMicSDK Tcp client socket sample program.

Import programUdpSocketSamlpe

Udp socket sample program. This program will send back the received packet.

Tutorial

Revision:
92:4f77028cce64
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/core/driver/ethernet/k64f/fsl/fsl_enet_driver.c	Wed Oct 01 13:58:53 2014 +0000
@@ -0,0 +1,475 @@
+/*
+* Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
+* All rights reserved.
+*
+* Redistribution and use in source and binary forms, with or without modification,
+* are permitted provided that the following conditions are met:
+*
+* o Redistributions of source code must retain the above copyright notice, this list
+*   of conditions and the following disclaimer.
+*
+* o Redistributions in binary form must reproduce the above copyright notice, this
+*   list of conditions and the following disclaimer in the documentation and/or
+*   other materials provided with the distribution.
+*
+* o Neither the name of Freescale Semiconductor, Inc. nor the names of its
+*   contributors may be used to endorse or promote products derived from this
+*   software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
+* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/* Modified by mbed for the lwIP port */
+#include "NyLPC_config.h"
+#if NyLPC_MCU==NyLPC_MCU_K64F
+#include "fsl_enet_driver.h"
+#include "fsl_enet_hal.h"
+#include "fsl_clock_manager.h"
+#include "fsl_interrupt_manager.h"
+#include <string.h>
+
+//#include "sys_arch.h"
+
+/*******************************************************************************
+ * Variables
+ ******************************************************************************/
+/*! @brief Define ENET's IRQ list */
+
+void *enetIfHandle;
+
+/*! @brief Define MAC driver API structure and for application of stack adaptor layer*/
+const enet_mac_api_t g_enetMacApi = 
+{
+    enet_mac_init,
+    NULL, // enet_mac_deinit,
+    NULL, // enet_mac_send,
+#if !ENET_RECEIVE_ALL_INTERRUPT
+    NULL, // enet_mac_receive,
+#endif
+    enet_mii_read,
+    enet_mii_write,
+    NULL, // enet_mac_add_multicast_group,
+    NULL, //enet_mac_leave_multicast_group,
+};
+/*******************************************************************************
+ * Code
+ ******************************************************************************/
+
+// NOTE: we need these functions to be non-blocking fpr the PHY task, hence the
+// osDelay() below
+
+/*FUNCTION****************************************************************
+ *
+ * Function Name: enet_mii_read
+ * Return Value: The execution status.
+ * Description: Read function.
+ * This interface read data over the (R)MII bus from the specified PHY register,
+ * This function is called by all PHY interfaces.
+ *END*********************************************************************/
+uint32_t enet_mii_read(uint32_t instance, uint32_t phyAddr, uint32_t phyReg, uint32_t *dataPtr)
+{
+    uint32_t  counter;
+	
+    /* Check the input parameters*/
+    if (!dataPtr)
+    {
+        return kStatus_ENET_InvalidInput;
+    }
+
+    /* Check if the mii is enabled*/
+    if (!enet_hal_is_mii_enabled(instance))
+    {
+        return kStatus_ENET_Miiuninitialized;
+    }
+
+    /* Clear the MII interrupt event*/
+    enet_hal_clear_interrupt(instance, kEnetMiiInterrupt);
+
+    /* Read command operation*/
+    enet_hal_set_mii_command(instance, phyAddr, phyReg, kEnetReadValidFrame, 0);
+
+    /* Poll for MII complete*/
+    for (counter = 0; counter < kEnetMaxTimeout; counter++)
+    {
+        if (enet_hal_get_interrupt_status(instance, kEnetMiiInterrupt))
+        {
+            break;
+        }	
+        osDelay(1);
+    }
+
+    /* Check for timeout*/
+    if (counter == kEnetMaxTimeout)
+    {
+        return kStatus_ENET_TimeOut;
+    }
+
+    /* Get data from mii register*/
+    *dataPtr = enet_hal_get_mii_data(instance);
+
+    /* Clear MII interrupt event*/
+    enet_hal_clear_interrupt(instance, kEnetMiiInterrupt);
+	
+    return kStatus_ENET_Success;
+}
+
+/*FUNCTION****************************************************************
+ *
+ * Function Name: enet_mii_write
+ * Return Value: The execution status.
+ * Description: Write function.
+ * This interface write data over the (R)MII bus to the specified PHY register.   
+ * This function is called by all PHY interfaces.
+ *END*********************************************************************/
+uint32_t enet_mii_write(uint32_t instance, uint32_t phyAddr, uint32_t phyReg, uint32_t data)
+{
+    uint32_t counter;
+
+    /* Check if the mii is enabled*/
+    if (!enet_hal_is_mii_enabled(instance))
+    {
+        return kStatus_ENET_Miiuninitialized;
+    }
+
+    /* Clear the MII interrupt event*/
+    enet_hal_clear_interrupt(instance, kEnetMiiInterrupt);
+
+    /* Read command operation*/
+    enet_hal_set_mii_command(instance, phyAddr, phyReg, kEnetWriteValidFrame, data);
+
+    /* Poll for MII complete*/
+    for (counter = 0; counter < kEnetMaxTimeout; counter++)
+    {
+        if (enet_hal_get_interrupt_status(instance, kEnetMiiInterrupt))
+        {
+            break;
+        }		
+        osDelay(1);
+    }
+
+    /* Check for timeout*/
+    if (counter == kEnetMaxTimeout)
+    {
+        return kStatus_ENET_TimeOut;
+    }
+
+    /* Clear MII intrrupt event*/
+    enet_hal_clear_interrupt(instance, kEnetMiiInterrupt);
+	
+    return kStatus_ENET_Success;
+}
+/*FUNCTION****************************************************************
+ *
+ * Function Name: enet_mac_mii_init
+ * Return Value: The execution status.
+ * Description:Initialize the ENET Mac mii(mdc/mdio)interface.
+ *END*********************************************************************/
+uint32_t enet_mac_mii_init(enet_dev_if_t * enetIfPtr)
+{
+    uint32_t frequency;
+	
+    /* Check the input parameters*/
+    if (enetIfPtr == NULL)
+    {
+        return kStatus_ENET_InvalidInput;
+    }   
+
+    /* Configure mii speed*/
+    clock_manager_get_frequency(kSystemClock, &frequency);
+    enet_hal_config_mii(enetIfPtr->deviceNumber, (frequency/(2 * enetIfPtr->macCfgPtr->miiClock) + 1), 
+                 kEnetMdioHoldOneClkCycle, false);
+
+    return kStatus_ENET_Success;
+}
+
+/*FUNCTION****************************************************************
+ *
+ * Function Name: enet_mac_rxbd_init
+ * Return Value: The execution status.
+ * Description:Initialize the ENET receive buffer descriptors.
+ * Note: If you do receive on receive interrupt handler the receive 
+ * data buffer number can be the same as the receive descriptor numbers. 
+ * But if you are polling receive frames please make sure the receive data 
+ * buffers are more than buffer descriptors to guarantee a good performance.
+ *END*********************************************************************/
+uint32_t enet_mac_rxbd_init(enet_dev_if_t * enetIfPtr, enet_rxbd_config_t *rxbdCfg)
+{
+    /* Check the input parameters*/
+    if ((!enetIfPtr) || (!rxbdCfg))
+    {
+        return kStatus_ENET_InvalidInput;
+    }
+
+    enetIfPtr->macContextPtr->bufferdescSize = enet_hal_get_bd_size();
+
+    /* Initialize the bd status*/
+    enetIfPtr->macContextPtr->isRxFull = false;
+		
+    /* Initialize receive bd base address and current address*/
+    enetIfPtr->macContextPtr->rxBdBasePtr = rxbdCfg->rxBdPtrAlign;
+    enetIfPtr->macContextPtr->rxBdCurPtr = enetIfPtr->macContextPtr->rxBdBasePtr;
+    enetIfPtr->macContextPtr->rxBdDirtyPtr = enetIfPtr->macContextPtr->rxBdBasePtr;	
+    enet_hal_set_rxbd_address(enetIfPtr->deviceNumber, (uint32_t)(enetIfPtr->macContextPtr->rxBdBasePtr));
+	
+    return kStatus_ENET_Success;
+}
+
+/*FUNCTION****************************************************************
+ *
+ * Function Name: enet_mac_txbd_init
+ * Return Value: The execution status.
+ * Description:Initialize the ENET transmit buffer descriptors.
+ * This function prepare all of the transmit buffer descriptors.
+ *END*********************************************************************/
+uint32_t enet_mac_txbd_init(enet_dev_if_t * enetIfPtr, enet_txbd_config_t *txbdCfg)
+{
+    /* Check the input parameters*/
+    if ((!enetIfPtr) || (!txbdCfg))
+    {
+        return kStatus_ENET_InvalidInput;
+    }
+
+    /* Initialize the bd status*/
+    enetIfPtr->macContextPtr->isTxFull = false;
+
+    /* Initialize transmit bd base address and current address*/
+    enetIfPtr->macContextPtr->txBdBasePtr = txbdCfg->txBdPtrAlign;
+    enetIfPtr->macContextPtr->txBdCurPtr = enetIfPtr->macContextPtr->txBdBasePtr;
+    enetIfPtr->macContextPtr->txBdDirtyPtr = enetIfPtr->macContextPtr->txBdBasePtr;
+    enet_hal_set_txbd_address(enetIfPtr->deviceNumber, (uint32_t)(enetIfPtr->macContextPtr->txBdBasePtr));
+    return kStatus_ENET_Success;
+}
+
+/*FUNCTION****************************************************************
+ *
+ * Function Name: enet_mac_configure_fifo_accel
+ * Return Value: The execution status.
+ * Description: Configure the ENET FIFO and Accelerator.
+ *END*********************************************************************/
+uint32_t enet_mac_configure_fifo_accel(enet_dev_if_t * enetIfPtr)
+{
+    enet_config_rx_fifo_t rxFifo;
+    enet_config_tx_fifo_t txFifo;
+	
+    /* Check the input parameters*/
+    if (!enetIfPtr)
+    {
+        return kStatus_ENET_InvalidInput;
+    }
+		
+		/* Initialize values that will not be initialized later on */
+    rxFifo.rxEmpty = 0;
+    rxFifo.rxFull = 0;
+    txFifo.isStoreForwardEnabled = 0;
+    txFifo.txFifoWrite = 0;
+    txFifo.txEmpty = 0;
+
+    /* Configure tx/rx accelerator*/
+    if (enetIfPtr->macCfgPtr->isRxAccelEnabled)
+    {
+        enet_hal_config_rx_accelerator(enetIfPtr->deviceNumber, 
+           (enet_config_rx_accelerator_t *)&(enetIfPtr->macCfgPtr->rxAcceler));
+        if ((enetIfPtr->macCfgPtr->rxAcceler.isIpcheckEnabled) || (enetIfPtr->macCfgPtr->rxAcceler.isProtocolCheckEnabled))
+        {
+            rxFifo.rxFull = 0;
+        }
+    }
+    if (enetIfPtr->macCfgPtr->isTxAccelEnabled)
+    {
+        enet_hal_config_tx_accelerator(enetIfPtr->deviceNumber, 
+            (enet_config_tx_accelerator_t *)&(enetIfPtr->macCfgPtr->txAcceler));
+        if ((enetIfPtr->macCfgPtr->txAcceler.isIpCheckEnabled) || (enetIfPtr->macCfgPtr->txAcceler.isProtocolCheckEnabled))
+        {
+            txFifo.isStoreForwardEnabled = 1;
+        }
+    }
+    if (enetIfPtr->macCfgPtr->isStoreAndFwEnabled)
+    {
+          rxFifo.rxFull = 0;
+          txFifo.isStoreForwardEnabled = 1;
+    }
+
+
+    /* Set TFWR value if STRFWD is not being used  */		
+    if (txFifo.isStoreForwardEnabled == 1)
+          txFifo.txFifoWrite = 0;
+    else
+          /* TFWR value is a trade-off between transmit latency and risk of transmit FIFO underrun due to contention for the system bus
+		      TFWR = 15 means transmission will begin once 960 bytes has been written to the Tx FIFO (for frames larger than 960 bytes)
+          See Section 45.4.18 - Transmit FIFO Watermark Register of the K64F Reference Manual for details		*/
+          txFifo.txFifoWrite = 15;
+		
+    /* Configure tx/rx FIFO with default value*/
+    rxFifo.rxAlmostEmpty = 4;
+    rxFifo.rxAlmostFull = 4;
+    txFifo.txAlmostEmpty = 4;
+    txFifo.txAlmostFull = 8;
+    enet_hal_config_rx_fifo(enetIfPtr->deviceNumber, &rxFifo);
+    enet_hal_config_tx_fifo(enetIfPtr->deviceNumber, &txFifo); 
+
+    return kStatus_ENET_Success;
+}
+
+/*FUNCTION****************************************************************
+ *
+ * Function Name: enet_mac_configure_controller
+ * Return Value: The execution status.
+ * Description: Configure the ENET controller with the basic configuration.
+ *END*********************************************************************/
+uint32_t enet_mac_configure_controller(enet_dev_if_t * enetIfPtr)
+{
+    uint32_t macCtlCfg;
+
+    /* Check the input parameters*/
+    if (enetIfPtr == NULL)
+    {
+        return kStatus_ENET_InvalidInput;
+    }   
+
+    macCtlCfg = enetIfPtr->macCfgPtr->macCtlConfigure;	
+    /* Configure rmii/mii interface*/
+    enet_hal_config_rmii(enetIfPtr->deviceNumber, enetIfPtr->macCfgPtr->rmiiCfgMode, 
+        enetIfPtr->macCfgPtr->speed, enetIfPtr->macCfgPtr->duplex, false, 
+        (macCtlCfg & kEnetRxMiiLoopback));
+     /* Configure receive buffer size*/
+    if (enetIfPtr->macCfgPtr->isVlanEnabled)
+    {
+        enetIfPtr->maxFrameSize = kEnetMaxFrameVlanSize;
+        enet_hal_set_rx_max_size(enetIfPtr->deviceNumber, 
+              enetIfPtr->macContextPtr->rxBufferSizeAligned, kEnetMaxFrameVlanSize);
+    }
+    else
+    {   
+        enetIfPtr->maxFrameSize = kEnetMaxFrameSize;
+        enet_hal_set_rx_max_size(enetIfPtr->deviceNumber, 
+              enetIfPtr->macContextPtr->rxBufferSizeAligned, kEnetMaxFrameSize); 
+    }
+
+	/* Set receive controller promiscuous */
+    enet_hal_config_promiscuous(enetIfPtr->deviceNumber, macCtlCfg & kEnetRxPromiscuousEnable);
+    /* Set receive flow control*/
+    enet_hal_enable_flowcontrol(enetIfPtr->deviceNumber, (macCtlCfg & kEnetRxFlowControlEnable));
+    /* Set received PAUSE frames are forwarded/terminated*/
+    enet_hal_enable_pauseforward(enetIfPtr->deviceNumber, (macCtlCfg & kEnetRxPauseFwdEnable));
+    /* Set receive broadcast frame reject*/
+    enet_hal_enable_broadcastreject(enetIfPtr->deviceNumber, (macCtlCfg & kEnetRxBcRejectEnable));
+    /* Set padding is removed from the received frame*/
+    enet_hal_enable_padremove(enetIfPtr->deviceNumber, (macCtlCfg & kEnetRxPadRemoveEnable));
+    /* Set the crc of the received frame is stripped from the frame*/
+    enet_hal_enable_rxcrcforward(enetIfPtr->deviceNumber, (macCtlCfg & kEnetRxCrcFwdEnable));
+    /* Set receive payload length check*/
+    enet_hal_enable_payloadcheck(enetIfPtr->deviceNumber, (macCtlCfg & kEnetPayloadlenCheckEnable));
+    /* Set control sleep mode*/
+    enet_hal_enable_sleep(enetIfPtr->deviceNumber, (macCtlCfg & kEnetSleepModeEnable));
+    return kStatus_ENET_Success;
+}
+
+/*FUNCTION****************************************************************
+ *
+ * Function Name: enet_mac_init
+ * Return Value: The execution status.
+ * Description:Initialize the ENET device with the basic configuration
+ * When ENET is used, this function need to be called by the NET initialize 
+ * interface.
+ *END*********************************************************************/
+uint32_t enet_mac_init(enet_dev_if_t * enetIfPtr, enet_rxbd_config_t *rxbdCfg,
+                            enet_txbd_config_t *txbdCfg)
+{   
+    uint32_t timeOut = 0;
+    uint32_t devNumber, result = 0; 
+	
+    /* Check the input parameters*/
+    if (enetIfPtr == NULL)
+    {
+        return kStatus_ENET_InvalidInput;
+    }
+
+    /* Get device number and check the parameter*/
+    devNumber = enetIfPtr->deviceNumber;
+
+    /* Store the global ENET structure for ISR input parameters for instance 0*/
+    if (!devNumber)
+    {
+        enetIfHandle = enetIfPtr;
+    }
+
+    /* Turn on ENET module clock gate */
+    clock_manager_set_gate(kClockModuleENET, 0U, true);
+
+    /* Reset ENET mac*/
+    enet_hal_reset_ethernet(devNumber);
+    while ((!enet_hal_is_reset_completed(devNumber)) && (timeOut < kEnetMaxTimeout))
+    {
+        time_delay(1);
+        timeOut++;
+    }
+
+    /* Check out if timeout*/
+    if (timeOut == kEnetMaxTimeout)
+    {
+        return kStatus_ENET_TimeOut;
+    }
+	
+    /* Disable all ENET mac interrupt and Clear all interrupt events*/
+    enet_hal_config_interrupt(devNumber, kEnetAllInterrupt, false);
+    enet_hal_clear_interrupt(devNumber, kEnetAllInterrupt);
+	
+    /* Program this station's physical address*/
+    enet_hal_set_mac_address(devNumber, enetIfPtr->macCfgPtr->macAddr);
+
+    /* Clear group and individual hash register*/
+    enet_hal_set_group_hashtable(devNumber, 0, kEnetSpecialAddressInit);
+    enet_hal_set_individual_hashtable(devNumber, 0, kEnetSpecialAddressInit);
+
+	  /* Configure mac controller*/
+    result = enet_mac_configure_controller(enetIfPtr);
+    if(result != kStatus_ENET_Success)
+    {
+        return result;
+    }
+    /* Clear mib zero counters*/
+    enet_hal_clear_mib(devNumber, true);
+
+    /* Initialize FIFO and accelerator*/
+    result = enet_mac_configure_fifo_accel(enetIfPtr);
+    if(result != kStatus_ENET_Success)
+    {
+        return result;
+    }
+    /* Initialize receive buffer descriptors*/
+    result = enet_mac_rxbd_init(enetIfPtr, rxbdCfg);
+    if(result != kStatus_ENET_Success)
+    {
+        return result;
+    }
+    /* Initialize transmit buffer descriptors*/
+	  result = enet_mac_txbd_init(enetIfPtr, txbdCfg);
+    if(result != kStatus_ENET_Success)
+    {
+        return result;
+    }	
+    /* Initialize rmii/mii interface*/
+    result = enet_mac_mii_init(enetIfPtr);
+    if (result != kStatus_ENET_Success)
+    {
+        return result;
+    }
+    
+    return kStatus_ENET_Success;
+}
+
+/*******************************************************************************
+ * EOF
+ ******************************************************************************/
+
+#endif
+