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

Committer:
nyatla
Date:
Wed Oct 01 13:58:53 2014 +0000
Revision:
92:4f77028cce64
?????????????????; K64F??????????????; LPC?????????????????

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nyatla 92:4f77028cce64 1 #include "NyLPC_config.h"
nyatla 92:4f77028cce64 2 #if NyLPC_MCU==NyLPC_MCU_K64F
nyatla 92:4f77028cce64 3 #include "NyLPC_stdlib.h"
nyatla 92:4f77028cce64 4 #include "NyLPC_os.h"
nyatla 92:4f77028cce64 5 #include "copy_of_ethernet_api.h"
nyatla 92:4f77028cce64 6 #include "NyLPC_IEthernetDevice.h"
nyatla 92:4f77028cce64 7 #include "NyLPC_cEthernetMM.h"
nyatla 92:4f77028cce64 8 //////////
nyatla 92:4f77028cce64 9 #include "fsl_enet_driver.h"
nyatla 92:4f77028cce64 10 #include "fsl_enet_hal.h"
nyatla 92:4f77028cce64 11 #include "fsl_device_registers.h"
nyatla 92:4f77028cce64 12 #include "fsl_phy_driver.h"
nyatla 92:4f77028cce64 13 #include "fsl_interrupt_manager.h"
nyatla 92:4f77028cce64 14 #include "k64f_emac_config.h"
nyatla 92:4f77028cce64 15 #include <string.h>
nyatla 92:4f77028cce64 16 #include <stdlib.h>
nyatla 92:4f77028cce64 17
nyatla 92:4f77028cce64 18 /**
nyatla 92:4f77028cce64 19 */
nyatla 92:4f77028cce64 20 static NyLPC_TBool start(const struct NyLPC_TEthAddr* i_eth_addr,NyLPC_TiEthernetDevice_onEvent i_handler,void* i_param);
nyatla 92:4f77028cce64 21 static void stop(void);
nyatla 92:4f77028cce64 22 static void* getRxEthFrame(unsigned short* o_len_of_data);
nyatla 92:4f77028cce64 23 static void nextRxEthFrame(void);
nyatla 92:4f77028cce64 24 static void* allocTxBuf(NyLPC_TUInt16 i_hint,NyLPC_TUInt16* o_size);
nyatla 92:4f77028cce64 25 static void releaseTxBuf(void* i_buf);
nyatla 92:4f77028cce64 26 static void sendTxEthFrame(void* i_buf,unsigned short i_size);
nyatla 92:4f77028cce64 27
nyatla 92:4f77028cce64 28 const static struct TiEthernetDevice _interface_KSZ8081RNACA=
nyatla 92:4f77028cce64 29 {
nyatla 92:4f77028cce64 30 "KSZ8081RNACA",
nyatla 92:4f77028cce64 31 start,
nyatla 92:4f77028cce64 32 stop,
nyatla 92:4f77028cce64 33 getRxEthFrame,
nyatla 92:4f77028cce64 34 nextRxEthFrame,
nyatla 92:4f77028cce64 35 allocTxBuf,
nyatla 92:4f77028cce64 36 releaseTxBuf,
nyatla 92:4f77028cce64 37 sendTxEthFrame,
nyatla 92:4f77028cce64 38 NULL //deleted API
nyatla 92:4f77028cce64 39 };
nyatla 92:4f77028cce64 40
nyatla 92:4f77028cce64 41
nyatla 92:4f77028cce64 42
nyatla 92:4f77028cce64 43 struct TEtherDriver{
nyatla 92:4f77028cce64 44 int rx_idx;
nyatla 92:4f77028cce64 45 int tx_idx;
nyatla 92:4f77028cce64 46 uint8_t *tx_desc_start_addr; /**< TX descriptor start address */
nyatla 92:4f77028cce64 47 uint8_t *rx_desc_start_addr; /**< RX descriptor start address */
nyatla 92:4f77028cce64 48 };
nyatla 92:4f77028cce64 49
nyatla 92:4f77028cce64 50 static struct TEtherDriver _driver;
nyatla 92:4f77028cce64 51 static void* _event_param;
nyatla 92:4f77028cce64 52 static NyLPC_TiEthernetDevice_onEvent _event_handler;
nyatla 92:4f77028cce64 53
nyatla 92:4f77028cce64 54 ////////////////////////////////////////////////////////////////////////////////
nyatla 92:4f77028cce64 55 // LANパケットバッファ
nyatla 92:4f77028cce64 56 ////////////////////////////////////////////////////////////////////////////////
nyatla 92:4f77028cce64 57 #define NUM_OF_RX_BUF 4
nyatla 92:4f77028cce64 58 #define SIZE_OF_ETH_PACKET (1536) //16バイト単位であること
nyatla 92:4f77028cce64 59 static void* RX_BUF_BASE; //[NUM_OF_RX_BUF][SIZE_OF_ETH_PACKET]
nyatla 92:4f77028cce64 60 static unsigned char* RX_BUF; //[NUM_OF_RX_BUF][SIZE_OF_ETH_PACKET]
nyatla 92:4f77028cce64 61 static void* TX_BUF_BASE; //
nyatla 92:4f77028cce64 62 static unsigned char* TX_BUF; //sizeof(struct NyLPC_TcEthernetMM_TxMemoryBlock)
nyatla 92:4f77028cce64 63
nyatla 92:4f77028cce64 64 #define NUM_OF_RX_RING NUM_OF_RX_BUF
nyatla 92:4f77028cce64 65 #define NUM_OF_TX_RING 4
nyatla 92:4f77028cce64 66
nyatla 92:4f77028cce64 67 ////////////////////////////////////////////////////////////////////////////////
nyatla 92:4f77028cce64 68 //private function
nyatla 92:4f77028cce64 69 ////////////////////////////////////////////////////////////////////////////////
nyatla 92:4f77028cce64 70
nyatla 92:4f77028cce64 71
nyatla 92:4f77028cce64 72 static NyLPC_TBool low_level_init(const unsigned char* i_ethaddr,int i_addr_len);
nyatla 92:4f77028cce64 73 static void setRxDesc(void* rx_buf, int idx);
nyatla 92:4f77028cce64 74 static void updateRxDesc(int idx);
nyatla 92:4f77028cce64 75 static void setTxDesc(int idx);
nyatla 92:4f77028cce64 76 static void updateTxDesc(int idx, uint8_t *buffer, uint16_t length, bool isLast);
nyatla 92:4f77028cce64 77 static void eth_arch_enable_interrupts(void);
nyatla 92:4f77028cce64 78 static void eth_arch_disable_interrupts(void);
nyatla 92:4f77028cce64 79 static NyLPC_TUInt32 waitForTxEthFrameEmpty(void);
nyatla 92:4f77028cce64 80
nyatla 92:4f77028cce64 81 ////////////////////////////////////////////////////////////////////////////////
nyatla 92:4f77028cce64 82 //LAN API
nyatla 92:4f77028cce64 83 ////////////////////////////////////////////////////////////////////////////////
nyatla 92:4f77028cce64 84 NyLPC_TBool EthDev_K64F_getInterface(
nyatla 92:4f77028cce64 85 const struct TiEthernetDevice** o_dev)
nyatla 92:4f77028cce64 86 {
nyatla 92:4f77028cce64 87 *o_dev=&_interface_KSZ8081RNACA;
nyatla 92:4f77028cce64 88 RX_BUF_BASE=(unsigned char*)malloc(SIZE_OF_ETH_PACKET*NUM_OF_RX_BUF+RX_BUF_ALIGNMENT);
nyatla 92:4f77028cce64 89 RX_BUF=(unsigned char*)ENET_ALIGN((NyLPC_TUInt32)RX_BUF_BASE,RX_BUF_ALIGNMENT);
nyatla 92:4f77028cce64 90 TX_BUF_BASE=malloc(sizeof(struct NyLPC_TcEthernetMM_TxMemoryBlock)+TX_BUF_ALIGNMENT);
nyatla 92:4f77028cce64 91 TX_BUF=(unsigned char*)ENET_ALIGN((NyLPC_TUInt32)TX_BUF_BASE,TX_BUF_ALIGNMENT);
nyatla 92:4f77028cce64 92
nyatla 92:4f77028cce64 93 return NyLPC_TBool_TRUE;
nyatla 92:4f77028cce64 94 }
nyatla 92:4f77028cce64 95
nyatla 92:4f77028cce64 96 static NyLPC_TBool start(const struct NyLPC_TEthAddr* i_eth_addr,NyLPC_TiEthernetDevice_onEvent i_handler,void* i_param)
nyatla 92:4f77028cce64 97 {
nyatla 92:4f77028cce64 98 _driver.rx_idx=0;
nyatla 92:4f77028cce64 99 _driver.tx_idx=0;
nyatla 92:4f77028cce64 100 //ISRw割り込み設定
nyatla 92:4f77028cce64 101 _event_handler=i_handler;
nyatla 92:4f77028cce64 102 _event_param=i_param;
nyatla 92:4f77028cce64 103
nyatla 92:4f77028cce64 104 if(!low_level_init((const NyLPC_TUInt8*)(i_eth_addr->addr),6)){
nyatla 92:4f77028cce64 105 return NyLPC_TBool_FALSE;
nyatla 92:4f77028cce64 106 }
nyatla 92:4f77028cce64 107 //TXメモリマネージャの準備(バッファのアライメントは16,パディングも16にしてね。謎バイトが2個いるから。)
nyatla 92:4f77028cce64 108 NyLPC_cEthernetMM_initialize(TX_BUF);
nyatla 92:4f77028cce64 109
nyatla 92:4f77028cce64 110 //Ethernetの割込み開始設定
nyatla 92:4f77028cce64 111 NyLPC_cIsr_enterCritical();
nyatla 92:4f77028cce64 112 //Ethernetの初期化シーケンス。割込みONとか
nyatla 92:4f77028cce64 113 {
nyatla 92:4f77028cce64 114 eth_arch_enable_interrupts();
nyatla 92:4f77028cce64 115 }
nyatla 92:4f77028cce64 116 NyLPC_cIsr_exitCritical();
nyatla 92:4f77028cce64 117
nyatla 92:4f77028cce64 118 return NyLPC_TBool_TRUE;
nyatla 92:4f77028cce64 119 }
nyatla 92:4f77028cce64 120
nyatla 92:4f77028cce64 121 static void stop(void)
nyatla 92:4f77028cce64 122 {
nyatla 92:4f77028cce64 123 NyLPC_cIsr_enterCritical();
nyatla 92:4f77028cce64 124 {
nyatla 92:4f77028cce64 125 eth_arch_disable_interrupts();
nyatla 92:4f77028cce64 126 }
nyatla 92:4f77028cce64 127 NyLPC_cIsr_exitCritical();
nyatla 92:4f77028cce64 128 return;
nyatla 92:4f77028cce64 129 }
nyatla 92:4f77028cce64 130
nyatla 92:4f77028cce64 131
nyatla 92:4f77028cce64 132 #define err_mask (kEnetRxBdTrunc | kEnetRxBdCrc | kEnetRxBdNoOctet | kEnetRxBdLengthViolation)
nyatla 92:4f77028cce64 133
nyatla 92:4f77028cce64 134 static void* getRxEthFrame(unsigned short* o_len_of_data)
nyatla 92:4f77028cce64 135 {
nyatla 92:4f77028cce64 136 int idx=_driver.rx_idx;
nyatla 92:4f77028cce64 137 enet_bd_struct_t * bdPtr = (enet_bd_struct_t*)_driver.rx_desc_start_addr;
nyatla 92:4f77028cce64 138 if((bdPtr[idx].control & kEnetRxBdEmpty)!=0){
nyatla 92:4f77028cce64 139 //パケット未着
nyatla 92:4f77028cce64 140 return NULL;
nyatla 92:4f77028cce64 141 }
nyatla 92:4f77028cce64 142 if((bdPtr[idx].control & err_mask) != 0){
nyatla 92:4f77028cce64 143 //エラー:パケットバッファを再設定して返却
nyatla 92:4f77028cce64 144 setRxDesc(RX_BUF+(idx*SIZE_OF_ETH_PACKET),idx);
nyatla 92:4f77028cce64 145 _driver.rx_idx=(idx+1)%NUM_OF_RX_BUF;
nyatla 92:4f77028cce64 146 return NULL;
nyatla 92:4f77028cce64 147 }
nyatla 92:4f77028cce64 148 *o_len_of_data =(unsigned short)enet_hal_get_bd_length(&(bdPtr[idx]))-2;
nyatla 92:4f77028cce64 149 return &RX_BUF[idx*SIZE_OF_ETH_PACKET+2];
nyatla 92:4f77028cce64 150 }
nyatla 92:4f77028cce64 151
nyatla 92:4f77028cce64 152 static void nextRxEthFrame(void)
nyatla 92:4f77028cce64 153 {
nyatla 92:4f77028cce64 154 int idx=_driver.rx_idx;
nyatla 92:4f77028cce64 155 enet_bd_struct_t * bdPtr = (enet_bd_struct_t*)_driver.rx_desc_start_addr;
nyatla 92:4f77028cce64 156 //現在のRXメモリが有効かを確認
nyatla 92:4f77028cce64 157 if((bdPtr[idx].control & kEnetRxBdEmpty)==0){
nyatla 92:4f77028cce64 158 //パケットバッファを復活させる
nyatla 92:4f77028cce64 159 updateRxDesc(idx);
nyatla 92:4f77028cce64 160 //キューのエントリを進行
nyatla 92:4f77028cce64 161 _driver.rx_idx=(idx+1)%NUM_OF_RX_BUF;
nyatla 92:4f77028cce64 162 return;
nyatla 92:4f77028cce64 163 }
nyatla 92:4f77028cce64 164 }
nyatla 92:4f77028cce64 165
nyatla 92:4f77028cce64 166 static void* allocTxBuf(NyLPC_TUInt16 i_hint,NyLPC_TUInt16* o_size)
nyatla 92:4f77028cce64 167 {
nyatla 92:4f77028cce64 168 return ((NyLPC_TUInt8*)NyLPC_cEthernetMM_alloc(i_hint,o_size))+2;
nyatla 92:4f77028cce64 169 }
nyatla 92:4f77028cce64 170 static void releaseTxBuf(void* i_buf)
nyatla 92:4f77028cce64 171 {
nyatla 92:4f77028cce64 172 NyLPC_cEthernetMM_release((NyLPC_TUInt8*)i_buf-2);
nyatla 92:4f77028cce64 173 }
nyatla 92:4f77028cce64 174
nyatla 92:4f77028cce64 175
nyatla 92:4f77028cce64 176 static void sendTxEthFrame(void* i_buf,unsigned short i_size)
nyatla 92:4f77028cce64 177 {
nyatla 92:4f77028cce64 178 int Index;
nyatla 92:4f77028cce64 179 struct NyLPC_TTxBufferHeader* bh=NyLPC_TTxBufferHeader_getBufferHeaderAddr(i_buf-2);
nyatla 92:4f77028cce64 180 //サイズ0なら送信の必要なし
nyatla 92:4f77028cce64 181 if(i_size == 0)
nyatla 92:4f77028cce64 182 {
nyatla 92:4f77028cce64 183 return;
nyatla 92:4f77028cce64 184 }
nyatla 92:4f77028cce64 185 //送信デスクリプタが使えるようになるのを待つよ!
nyatla 92:4f77028cce64 186 waitForTxEthFrameEmpty();
nyatla 92:4f77028cce64 187
nyatla 92:4f77028cce64 188 //送信対象のメモリブロックを送信中に設定。
nyatla 92:4f77028cce64 189 if(bh->is_lock){
nyatla 92:4f77028cce64 190 //送信中のメモリブロックなら無視
nyatla 92:4f77028cce64 191 return;
nyatla 92:4f77028cce64 192 }
nyatla 92:4f77028cce64 193
nyatla 92:4f77028cce64 194 //送信中にセット
nyatla 92:4f77028cce64 195 bh->is_lock=NyLPC_TUInt8_TRUE;
nyatla 92:4f77028cce64 196
nyatla 92:4f77028cce64 197 //最大送信サイズの制限
nyatla 92:4f77028cce64 198 if (i_size > ETH_FRAG_SIZE){
nyatla 92:4f77028cce64 199 i_size = ETH_FRAG_SIZE;
nyatla 92:4f77028cce64 200 }
nyatla 92:4f77028cce64 201 Index=_driver.tx_idx;
nyatla 92:4f77028cce64 202
nyatla 92:4f77028cce64 203 updateTxDesc(Index,(uint8_t*)((unsigned char*)i_buf-2),i_size+2,Index==(NUM_OF_TX_RING-1));
nyatla 92:4f77028cce64 204 _driver.tx_idx=(_driver.tx_idx+1)%NUM_OF_TX_RING;
nyatla 92:4f77028cce64 205 return;
nyatla 92:4f77028cce64 206 }
nyatla 92:4f77028cce64 207
nyatla 92:4f77028cce64 208 /**
nyatla 92:4f77028cce64 209 * 送信キューが空くまで待ちます。
nyatla 92:4f77028cce64 210 * @return
nyatla 92:4f77028cce64 211 * 次に書き込むことが出来る送信キューのIDだけど使わないで
nyatla 92:4f77028cce64 212 */
nyatla 92:4f77028cce64 213 static NyLPC_TUInt32 waitForTxEthFrameEmpty(void)
nyatla 92:4f77028cce64 214 {
nyatla 92:4f77028cce64 215 int idx;
nyatla 92:4f77028cce64 216 int i;
nyatla 92:4f77028cce64 217 struct NyLPC_TTxBufferHeader *b;
nyatla 92:4f77028cce64 218 volatile void* p;
nyatla 92:4f77028cce64 219 volatile enet_bd_struct_t * bdPtr = (enet_bd_struct_t*)_driver.tx_desc_start_addr;
nyatla 92:4f77028cce64 220
nyatla 92:4f77028cce64 221
nyatla 92:4f77028cce64 222 //送信キューフルが解除されるまで待ち.現在のTQDescがReady状態の間ループ
nyatla 92:4f77028cce64 223
nyatla 92:4f77028cce64 224 while((bdPtr[_driver.tx_idx].control & kEnetTxBdReady)!=0)
nyatla 92:4f77028cce64 225 {
nyatla 92:4f77028cce64 226 NyLPC_cThread_sleep(10);
nyatla 92:4f77028cce64 227 }
nyatla 92:4f77028cce64 228 //インデクスを起点にReady状態が0のデスクリプタを全て解放(無駄があるけど無視)
nyatla 92:4f77028cce64 229 for(i=0;i<NUM_OF_TX_RING;i++){
nyatla 92:4f77028cce64 230 idx=(_driver.tx_idx+i)%NUM_OF_TX_RING;
nyatla 92:4f77028cce64 231 if((bdPtr[idx].control & kEnetTxBdReady)!=0){
nyatla 92:4f77028cce64 232 //if Ready state then break!
nyatla 92:4f77028cce64 233 break;
nyatla 92:4f77028cce64 234 }
nyatla 92:4f77028cce64 235 bdPtr[idx].control=(bdPtr[idx].control)&(~kEnetTxBdReady);
nyatla 92:4f77028cce64 236 //バッファを参照してたらそいつのロックビットも解放
nyatla 92:4f77028cce64 237 p=(void*)NTOHL(bdPtr[idx].buffer);
nyatla 92:4f77028cce64 238 if(p!=NULL){
nyatla 92:4f77028cce64 239 b=((struct NyLPC_TTxBufferHeader*)p)-1;
nyatla 92:4f77028cce64 240 b->is_lock=NyLPC_TUInt8_FALSE;
nyatla 92:4f77028cce64 241 bdPtr[idx].buffer=0;
nyatla 92:4f77028cce64 242 }
nyatla 92:4f77028cce64 243 }
nyatla 92:4f77028cce64 244 return _driver.tx_idx;
nyatla 92:4f77028cce64 245 }
nyatla 92:4f77028cce64 246
nyatla 92:4f77028cce64 247 ////////////////////////////////////////////////////////////////////////////////
nyatla 92:4f77028cce64 248 // Ethernet interdface functions
nyatla 92:4f77028cce64 249 ////////////////////////////////////////////////////////////////////////////////
nyatla 92:4f77028cce64 250
nyatla 92:4f77028cce64 251
nyatla 92:4f77028cce64 252 // K64F-specific macros
nyatla 92:4f77028cce64 253 #define RX_PBUF_AUTO_INDEX (-1)
nyatla 92:4f77028cce64 254 extern void k64f_init_eth_hardware(void);
nyatla 92:4f77028cce64 255
nyatla 92:4f77028cce64 256
nyatla 92:4f77028cce64 257 //static struct k64f_enetdata k64f_enetdata;
nyatla 92:4f77028cce64 258
nyatla 92:4f77028cce64 259 static enet_dev_if_t enetDevIf[HW_ENET_INSTANCE_COUNT];
nyatla 92:4f77028cce64 260 static enet_mac_config_t g_enetMacCfg[HW_ENET_INSTANCE_COUNT] =
nyatla 92:4f77028cce64 261 {
nyatla 92:4f77028cce64 262 {
nyatla 92:4f77028cce64 263 ENET_ETH_MAX_FLEN , /*!< enet receive buffer size*/
nyatla 92:4f77028cce64 264 ENET_RX_LARGE_BUFFER_NUM, /*!< enet large receive buffer number*/
nyatla 92:4f77028cce64 265 NUM_OF_RX_RING, /*!< enet receive bd number*/
nyatla 92:4f77028cce64 266 NUM_OF_TX_RING, /*!< enet transmit bd number*/
nyatla 92:4f77028cce64 267 {0}, /*!< enet mac address*/
nyatla 92:4f77028cce64 268 kEnetCfgRmii, /*!< enet rmii interface*/
nyatla 92:4f77028cce64 269 kEnetCfgSpeed100M, /*!< enet rmii 100M*/
nyatla 92:4f77028cce64 270 kEnetCfgFullDuplex, /*!< enet rmii Full- duplex*/
nyatla 92:4f77028cce64 271 /*!< enet mac control flag recommended to use enet_mac_control_flag_t
nyatla 92:4f77028cce64 272 we send frame with crc so receive crc forward for data length check test*/
nyatla 92:4f77028cce64 273 kEnetRxCrcFwdEnable | kEnetRxFlowControlEnable,
nyatla 92:4f77028cce64 274 true, /*!< enet txaccelerator enabled*/
nyatla 92:4f77028cce64 275 true, /*!< enet rxaccelerator enabled*/
nyatla 92:4f77028cce64 276 false, /*!< enet store and forward*/
nyatla 92:4f77028cce64 277 {false, false, true, false, true}, /*!< enet rxaccelerator config*/
nyatla 92:4f77028cce64 278 {false, false, true}, /*!< enet txaccelerator config*/
nyatla 92:4f77028cce64 279 true, /*!< vlan frame support*/
nyatla 92:4f77028cce64 280 true, /*!< phy auto discover*/
nyatla 92:4f77028cce64 281 ENET_MII_CLOCK, /*!< enet MDC clock*/
nyatla 92:4f77028cce64 282 },
nyatla 92:4f77028cce64 283 };
nyatla 92:4f77028cce64 284 static enet_phy_config_t g_enetPhyCfg[HW_ENET_INSTANCE_COUNT] =
nyatla 92:4f77028cce64 285 {
nyatla 92:4f77028cce64 286 {0, false}
nyatla 92:4f77028cce64 287 };
nyatla 92:4f77028cce64 288
nyatla 92:4f77028cce64 289 static NyLPC_TBool k64f_rx_setup(enet_rxbd_config_t *rxbdCfg);
nyatla 92:4f77028cce64 290 static NyLPC_TBool k64f_tx_setup(enet_txbd_config_t *txbdCfg);
nyatla 92:4f77028cce64 291
nyatla 92:4f77028cce64 292
nyatla 92:4f77028cce64 293 /**
nyatla 92:4f77028cce64 294 * i_idx番目のデスクリプタにバッファをセット
nyatla 92:4f77028cce64 295 */
nyatla 92:4f77028cce64 296 static void setRxDesc(void* rx_buf, int idx)
nyatla 92:4f77028cce64 297 {
nyatla 92:4f77028cce64 298 enet_bd_struct_t *start = (enet_bd_struct_t *)_driver.rx_desc_start_addr;
nyatla 92:4f77028cce64 299 /* Setup descriptor and clear statuses */
nyatla 92:4f77028cce64 300 enet_hal_init_rxbds(start + idx, (uint8_t*)rx_buf,idx ==(NUM_OF_RX_RING - 1));
nyatla 92:4f77028cce64 301 enet_hal_active_rxbd(BOARD_DEBUG_ENET_INSTANCE);
nyatla 92:4f77028cce64 302 }
nyatla 92:4f77028cce64 303 static void updateRxDesc(int idx)
nyatla 92:4f77028cce64 304 {
nyatla 92:4f77028cce64 305 enet_bd_struct_t *start = (enet_bd_struct_t *)_driver.rx_desc_start_addr;
nyatla 92:4f77028cce64 306 /* Setup descriptor and clear statuses */
nyatla 92:4f77028cce64 307 enet_hal_update_rxbds(start + idx,NULL,false);
nyatla 92:4f77028cce64 308 enet_hal_active_rxbd(BOARD_DEBUG_ENET_INSTANCE);
nyatla 92:4f77028cce64 309 }
nyatla 92:4f77028cce64 310 static void setTxDesc(int idx)
nyatla 92:4f77028cce64 311 {
nyatla 92:4f77028cce64 312 enet_bd_struct_t *start = (enet_bd_struct_t *)_driver.tx_desc_start_addr;
nyatla 92:4f77028cce64 313 /* Setup descriptor and clear statuses */
nyatla 92:4f77028cce64 314 enet_hal_init_txbds(start + idx,idx ==(NUM_OF_RX_RING - 1));
nyatla 92:4f77028cce64 315 enet_hal_active_txbd(BOARD_DEBUG_ENET_INSTANCE);
nyatla 92:4f77028cce64 316 }
nyatla 92:4f77028cce64 317
nyatla 92:4f77028cce64 318 static void updateTxDesc(int idx, uint8_t *buffer, uint16_t length, bool isLast)
nyatla 92:4f77028cce64 319 {
nyatla 92:4f77028cce64 320 volatile enet_bd_struct_t * bdPtr = (enet_bd_struct_t *)(_driver.tx_desc_start_addr + idx * enet_hal_get_bd_size());
nyatla 92:4f77028cce64 321
nyatla 92:4f77028cce64 322 bdPtr->length = HTONS(length); /* Set data length*/
nyatla 92:4f77028cce64 323 bdPtr->buffer = (uint8_t *)HTONL((uint32_t)buffer); /* Set data buffer*/
nyatla 92:4f77028cce64 324 bdPtr->control |= kEnetTxBdLast;//最終フラグメントのフラグね
nyatla 92:4f77028cce64 325 bdPtr->controlExtend1 |= kEnetTxBdTxInterrupt;
nyatla 92:4f77028cce64 326 bdPtr->controlExtend2 &= ~TX_DESC_UPDATED_MASK; // descriptor not updated by DMA
nyatla 92:4f77028cce64 327 bdPtr->control |= kEnetTxBdTransmitCrc | kEnetTxBdReady;
nyatla 92:4f77028cce64 328 if(isLast){
nyatla 92:4f77028cce64 329 //これはデスクリプタの終了位置のフラグ
nyatla 92:4f77028cce64 330 bdPtr->control |=kEnetTxBdWrap;
nyatla 92:4f77028cce64 331 }
nyatla 92:4f77028cce64 332 enet_hal_active_txbd(BOARD_DEBUG_ENET_INSTANCE);
nyatla 92:4f77028cce64 333 }
nyatla 92:4f77028cce64 334
nyatla 92:4f77028cce64 335 static void* ENET_MAC_CONTEXT_BUF=NULL;
nyatla 92:4f77028cce64 336
nyatla 92:4f77028cce64 337 /** \brief Low level init of the MAC and PHY.
nyatla 92:4f77028cce64 338 *
nyatla 92:4f77028cce64 339 * \param[in] netif Pointer to LWIP netif structure
nyatla 92:4f77028cce64 340 */
nyatla 92:4f77028cce64 341 NyLPC_TBool low_level_init(const unsigned char* i_ethaddr,int i_addr_len)
nyatla 92:4f77028cce64 342 {
nyatla 92:4f77028cce64 343 enet_dev_if_t * enetIfPtr;
nyatla 92:4f77028cce64 344 uint32_t device = BOARD_DEBUG_ENET_INSTANCE;
nyatla 92:4f77028cce64 345 enet_rxbd_config_t rxbdCfg;
nyatla 92:4f77028cce64 346 enet_txbd_config_t txbdCfg;
nyatla 92:4f77028cce64 347 enet_phy_speed_t phy_speed;
nyatla 92:4f77028cce64 348 enet_phy_duplex_t phy_duplex;
nyatla 92:4f77028cce64 349
nyatla 92:4f77028cce64 350 //RX/TXメモリはデバイス選択時に確保
nyatla 92:4f77028cce64 351 k64f_init_eth_hardware();
nyatla 92:4f77028cce64 352
nyatla 92:4f77028cce64 353 /* Initialize device*/
nyatla 92:4f77028cce64 354 enetIfPtr = (enet_dev_if_t *)&enetDevIf[device];
nyatla 92:4f77028cce64 355 enetIfPtr->deviceNumber = device;
nyatla 92:4f77028cce64 356 enetIfPtr->macCfgPtr = &g_enetMacCfg[device];
nyatla 92:4f77028cce64 357 enetIfPtr->phyCfgPtr = &g_enetPhyCfg[device];
nyatla 92:4f77028cce64 358 enetIfPtr->macApiPtr = &g_enetMacApi;
nyatla 92:4f77028cce64 359 enetIfPtr->phyApiPtr = (void *)&g_enetPhyApi;
nyatla 92:4f77028cce64 360 //macアドレスのコピー
nyatla 92:4f77028cce64 361 memcpy(enetIfPtr->macCfgPtr->macAddr,(char*)i_ethaddr,i_addr_len);
nyatla 92:4f77028cce64 362 //enetIfPtr->macContextPtrはgetInterface
nyatla 92:4f77028cce64 363 if(ENET_MAC_CONTEXT_BUF!=NULL){
nyatla 92:4f77028cce64 364 free(ENET_MAC_CONTEXT_BUF);
nyatla 92:4f77028cce64 365 ENET_MAC_CONTEXT_BUF=NULL;
nyatla 92:4f77028cce64 366 }
nyatla 92:4f77028cce64 367 ENET_MAC_CONTEXT_BUF=calloc(1, sizeof(enet_mac_context_t));
nyatla 92:4f77028cce64 368 if(ENET_MAC_CONTEXT_BUF==NULL){
nyatla 92:4f77028cce64 369 return NyLPC_TBool_FALSE;//ERR_BUF;
nyatla 92:4f77028cce64 370 }
nyatla 92:4f77028cce64 371 enetIfPtr->macContextPtr = (enet_mac_context_t *)ENET_MAC_CONTEXT_BUF;
nyatla 92:4f77028cce64 372
nyatla 92:4f77028cce64 373 /* Initialize enet buffers*/
nyatla 92:4f77028cce64 374 if(!k64f_rx_setup(&rxbdCfg)) {
nyatla 92:4f77028cce64 375 return NyLPC_TBool_FALSE;//ERR_BUF;
nyatla 92:4f77028cce64 376 }
nyatla 92:4f77028cce64 377 /* Initialize enet buffers*/
nyatla 92:4f77028cce64 378 if(!k64f_tx_setup(&txbdCfg)) {
nyatla 92:4f77028cce64 379 return NyLPC_TBool_FALSE;//ERR_BUF;
nyatla 92:4f77028cce64 380 }
nyatla 92:4f77028cce64 381 /* Initialize enet module*/
nyatla 92:4f77028cce64 382 if (enet_mac_init(enetIfPtr, &rxbdCfg, &txbdCfg) == kStatus_ENET_Success)
nyatla 92:4f77028cce64 383 {
nyatla 92:4f77028cce64 384 /* Initialize PHY*/
nyatla 92:4f77028cce64 385 if (enetIfPtr->macCfgPtr->isPhyAutoDiscover) {
nyatla 92:4f77028cce64 386 if (((enet_phy_api_t *)(enetIfPtr->phyApiPtr))->phy_auto_discover(enetIfPtr) != kStatus_PHY_Success)
nyatla 92:4f77028cce64 387 return NyLPC_TBool_FALSE;//ERR_IF;
nyatla 92:4f77028cce64 388 }
nyatla 92:4f77028cce64 389 if (((enet_phy_api_t *)(enetIfPtr->phyApiPtr))->phy_init(enetIfPtr) != kStatus_PHY_Success)
nyatla 92:4f77028cce64 390 return NyLPC_TBool_FALSE;//ERR_IF;
nyatla 92:4f77028cce64 391 enetIfPtr->isInitialized = true;
nyatla 92:4f77028cce64 392 }else{
nyatla 92:4f77028cce64 393 // TODOETH: cleanup memory
nyatla 92:4f77028cce64 394 return NyLPC_TBool_FALSE;//ERR_IF;
nyatla 92:4f77028cce64 395 }
nyatla 92:4f77028cce64 396
nyatla 92:4f77028cce64 397 /* Get link information from PHY */
nyatla 92:4f77028cce64 398 phy_get_link_speed(enetIfPtr, &phy_speed);
nyatla 92:4f77028cce64 399 phy_get_link_duplex(enetIfPtr, &phy_duplex);
nyatla 92:4f77028cce64 400 BW_ENET_RCR_RMII_10T(enetIfPtr->deviceNumber, phy_speed == kEnetSpeed10M ? kEnetCfgSpeed10M : kEnetCfgSpeed100M);
nyatla 92:4f77028cce64 401 BW_ENET_TCR_FDEN(enetIfPtr->deviceNumber, phy_duplex == kEnetFullDuplex ? kEnetCfgFullDuplex : kEnetCfgHalfDuplex);
nyatla 92:4f77028cce64 402
nyatla 92:4f77028cce64 403 /* Enable Ethernet module*/
nyatla 92:4f77028cce64 404 enet_hal_config_ethernet(device, true, true);
nyatla 92:4f77028cce64 405
nyatla 92:4f77028cce64 406 /* Active Receive buffer descriptor must be done after module enable*/
nyatla 92:4f77028cce64 407 enet_hal_active_rxbd(enetIfPtr->deviceNumber);
nyatla 92:4f77028cce64 408 enet_hal_active_txbd(enetIfPtr->deviceNumber);
nyatla 92:4f77028cce64 409
nyatla 92:4f77028cce64 410 return NyLPC_TBool_TRUE;//ERR_OK;
nyatla 92:4f77028cce64 411 }
nyatla 92:4f77028cce64 412
nyatla 92:4f77028cce64 413
nyatla 92:4f77028cce64 414 static void* RX_DESC_BUF_BASE=NULL;
nyatla 92:4f77028cce64 415
nyatla 92:4f77028cce64 416
nyatla 92:4f77028cce64 417 /** \brief Sets up the RX descriptor ring buffers.
nyatla 92:4f77028cce64 418 *
nyatla 92:4f77028cce64 419 * This function sets up the descriptor list used for receive packets.
nyatla 92:4f77028cce64 420 *
nyatla 92:4f77028cce64 421 * \param[in] netif Pointer to driver data structure
nyatla 92:4f77028cce64 422 * \returns true/false
nyatla 92:4f77028cce64 423 */
nyatla 92:4f77028cce64 424 static NyLPC_TBool k64f_rx_setup(enet_rxbd_config_t *rxbdCfg)
nyatla 92:4f77028cce64 425 {
nyatla 92:4f77028cce64 426 // struct k64f_enetdata *k64f_enet = &(netif->state);
nyatla 92:4f77028cce64 427 enet_dev_if_t *enetIfPtr = (enet_dev_if_t *)&enetDevIf[BOARD_DEBUG_ENET_INSTANCE];
nyatla 92:4f77028cce64 428 uint32_t rxBufferSizeAligned;
nyatla 92:4f77028cce64 429 int i;
nyatla 92:4f77028cce64 430
nyatla 92:4f77028cce64 431 // Allocate RX descriptors
nyatla 92:4f77028cce64 432 if(RX_DESC_BUF_BASE!=NULL){
nyatla 92:4f77028cce64 433 free(RX_DESC_BUF_BASE);
nyatla 92:4f77028cce64 434 RX_DESC_BUF_BASE=NULL;
nyatla 92:4f77028cce64 435 }
nyatla 92:4f77028cce64 436 RX_DESC_BUF_BASE = (void*)calloc(1, enet_hal_get_bd_size() * enetIfPtr->macCfgPtr->rxBdNumber + ENET_BD_ALIGNMENT);
nyatla 92:4f77028cce64 437 if(RX_DESC_BUF_BASE==NULL){
nyatla 92:4f77028cce64 438 return NyLPC_TBool_FALSE;
nyatla 92:4f77028cce64 439 }
nyatla 92:4f77028cce64 440 //16byteアライメントに修正
nyatla 92:4f77028cce64 441 _driver.rx_desc_start_addr = (uint8_t *)ENET_ALIGN((NyLPC_TUInt32)RX_DESC_BUF_BASE, ENET_BD_ALIGNMENT);
nyatla 92:4f77028cce64 442 rxBufferSizeAligned = ENET_ALIGN(enetIfPtr->macCfgPtr->rxBufferSize, ENET_RX_BUFFER_ALIGNMENT);
nyatla 92:4f77028cce64 443 enetIfPtr->macContextPtr->rxBufferSizeAligned = rxBufferSizeAligned;
nyatla 92:4f77028cce64 444 rxbdCfg->rxBdPtrAlign = _driver.rx_desc_start_addr;
nyatla 92:4f77028cce64 445 rxbdCfg->rxBdNum = enetIfPtr->macCfgPtr->rxBdNumber;
nyatla 92:4f77028cce64 446 rxbdCfg->rxBufferNum = enetIfPtr->macCfgPtr->rxBdNumber;
nyatla 92:4f77028cce64 447
nyatla 92:4f77028cce64 448 //初期化
nyatla 92:4f77028cce64 449 enet_hal_active_rxbd(BOARD_DEBUG_ENET_INSTANCE);
nyatla 92:4f77028cce64 450 for(i=0;i<NUM_OF_RX_RING;i++){
nyatla 92:4f77028cce64 451 setRxDesc(RX_BUF+(i*SIZE_OF_ETH_PACKET),i);
nyatla 92:4f77028cce64 452 }
nyatla 92:4f77028cce64 453 // k64f_rx_queue(netif, RX_PBUF_AUTO_INDEX);
nyatla 92:4f77028cce64 454 return NyLPC_TBool_TRUE;
nyatla 92:4f77028cce64 455 }
nyatla 92:4f77028cce64 456
nyatla 92:4f77028cce64 457
nyatla 92:4f77028cce64 458
nyatla 92:4f77028cce64 459
nyatla 92:4f77028cce64 460 static void* TX_DESC_BUF_BASE=NULL;
nyatla 92:4f77028cce64 461 /** \brief Sets up the TX descriptor ring buffers.
nyatla 92:4f77028cce64 462 *
nyatla 92:4f77028cce64 463 * This function sets up the descriptor list used for transmit packets.
nyatla 92:4f77028cce64 464 *
nyatla 92:4f77028cce64 465 * \param[in] netif Pointer to driver data structure
nyatla 92:4f77028cce64 466 * \returns true/false
nyatla 92:4f77028cce64 467 */
nyatla 92:4f77028cce64 468 static NyLPC_TBool k64f_tx_setup(enet_txbd_config_t *txbdCfg)
nyatla 92:4f77028cce64 469 {
nyatla 92:4f77028cce64 470 int i;
nyatla 92:4f77028cce64 471
nyatla 92:4f77028cce64 472 enet_dev_if_t *enetIfPtr = (enet_dev_if_t *)&enetDevIf[BOARD_DEBUG_ENET_INSTANCE];
nyatla 92:4f77028cce64 473
nyatla 92:4f77028cce64 474 // Allocate TX descriptors
nyatla 92:4f77028cce64 475 if(TX_DESC_BUF_BASE!=NULL){
nyatla 92:4f77028cce64 476 free(TX_DESC_BUF_BASE);
nyatla 92:4f77028cce64 477 TX_DESC_BUF_BASE=NULL;
nyatla 92:4f77028cce64 478 }
nyatla 92:4f77028cce64 479 TX_DESC_BUF_BASE = (void*)calloc(1, enet_hal_get_bd_size() * enetIfPtr->macCfgPtr->txBdNumber + ENET_BD_ALIGNMENT);
nyatla 92:4f77028cce64 480 if(TX_DESC_BUF_BASE==NULL){
nyatla 92:4f77028cce64 481 return NyLPC_TBool_FALSE;
nyatla 92:4f77028cce64 482 }
nyatla 92:4f77028cce64 483
nyatla 92:4f77028cce64 484 _driver.tx_desc_start_addr = (uint8_t *)ENET_ALIGN((uint32_t)TX_DESC_BUF_BASE, ENET_BD_ALIGNMENT);
nyatla 92:4f77028cce64 485
nyatla 92:4f77028cce64 486 txbdCfg->txBdPtrAlign = _driver.tx_desc_start_addr;
nyatla 92:4f77028cce64 487 txbdCfg->txBufferNum = enetIfPtr->macCfgPtr->txBdNumber;
nyatla 92:4f77028cce64 488 txbdCfg->txBufferSizeAlign = ENET_ALIGN(enetIfPtr->maxFrameSize, ENET_TX_BUFFER_ALIGNMENT);
nyatla 92:4f77028cce64 489
nyatla 92:4f77028cce64 490 // Make the TX descriptor ring circular
nyatla 92:4f77028cce64 491 for(i=0;i<NUM_OF_TX_RING;i++){
nyatla 92:4f77028cce64 492 setTxDesc(i);
nyatla 92:4f77028cce64 493 }
nyatla 92:4f77028cce64 494 return NyLPC_TBool_TRUE;
nyatla 92:4f77028cce64 495 }
nyatla 92:4f77028cce64 496
nyatla 92:4f77028cce64 497
nyatla 92:4f77028cce64 498 //--------------------------------------------------------------------------------
nyatla 92:4f77028cce64 499 // ISR
nyatla 92:4f77028cce64 500 //--------------------------------------------------------------------------------
nyatla 92:4f77028cce64 501 extern IRQn_Type enet_irq_ids[HW_ENET_INSTANCE_COUNT][FSL_FEATURE_ENET_INTERRUPT_COUNT];
nyatla 92:4f77028cce64 502 extern uint8_t enetIntMap[kEnetIntNum];
nyatla 92:4f77028cce64 503 extern void *enetIfHandle;
nyatla 92:4f77028cce64 504
nyatla 92:4f77028cce64 505 static void eth_arch_enable_interrupts(void)
nyatla 92:4f77028cce64 506 {
nyatla 92:4f77028cce64 507 enet_hal_config_interrupt(BOARD_DEBUG_ENET_INSTANCE, (kEnetTxFrameInterrupt | kEnetRxFrameInterrupt), true);
nyatla 92:4f77028cce64 508 interrupt_enable(enet_irq_ids[BOARD_DEBUG_ENET_INSTANCE][enetIntMap[kEnetRxfInt]]);
nyatla 92:4f77028cce64 509 interrupt_enable(enet_irq_ids[BOARD_DEBUG_ENET_INSTANCE][enetIntMap[kEnetTxfInt]]);
nyatla 92:4f77028cce64 510 }
nyatla 92:4f77028cce64 511
nyatla 92:4f77028cce64 512 static void eth_arch_disable_interrupts(void)
nyatla 92:4f77028cce64 513 {
nyatla 92:4f77028cce64 514 interrupt_disable(enet_irq_ids[BOARD_DEBUG_ENET_INSTANCE][enetIntMap[kEnetRxfInt]]);
nyatla 92:4f77028cce64 515 interrupt_disable(enet_irq_ids[BOARD_DEBUG_ENET_INSTANCE][enetIntMap[kEnetTxfInt]]);
nyatla 92:4f77028cce64 516 }
nyatla 92:4f77028cce64 517 void ENET_Transmit_IRQHandler(void)
nyatla 92:4f77028cce64 518 {
nyatla 92:4f77028cce64 519 // led(0,-1);
nyatla 92:4f77028cce64 520 enet_hal_clear_interrupt(((enet_dev_if_t *)enetIfHandle)->deviceNumber, kEnetTxFrameInterrupt);
nyatla 92:4f77028cce64 521 _event_handler(_event_param,NyLPC_TiEthernetDevice_EVENT_ON_TX);
nyatla 92:4f77028cce64 522 }
nyatla 92:4f77028cce64 523
nyatla 92:4f77028cce64 524 void ENET_Receive_IRQHandler(void)
nyatla 92:4f77028cce64 525 {
nyatla 92:4f77028cce64 526 enet_hal_clear_interrupt(((enet_dev_if_t *)enetIfHandle)->deviceNumber, kEnetRxFrameInterrupt);
nyatla 92:4f77028cce64 527 _event_handler(_event_param,NyLPC_TiEthernetDevice_EVENT_ON_RX);
nyatla 92:4f77028cce64 528 }
nyatla 92:4f77028cce64 529
nyatla 92:4f77028cce64 530
nyatla 92:4f77028cce64 531 #endif
nyatla 92:4f77028cce64 532
nyatla 92:4f77028cce64 533
nyatla 92:4f77028cce64 534