This is Webservice SDK for mbed. LPCXpresso1769/LPC1768/FRDM-K64F/LPC4088
Fork of libMiMic by
Revision 63:157ee3202edb, committed 2013-10-18
- Comitter:
- nyatla
- Date:
- Fri Oct 18 12:40:09 2013 +0000
- Parent:
- 62:8be8c5924c3e
- Child:
- 64:258e84040262
- Commit message:
- update core to t338; bugfix; 1.Ethernet driver setting, descripter setting; 2.TCP socket close sequence; 3.HTTP stream
Changed in this revision
--- a/core/NyLPC_cMiMicEnv.h Thu Oct 03 04:53:11 2013 +0000 +++ b/core/NyLPC_cMiMicEnv.h Fri Oct 18 12:40:09 2013 +0000 @@ -13,7 +13,7 @@ #endif /* __cplusplus */ -#define NyLPC_cMiMicEnv_VERSION "MiMic/1.4.71" +#define NyLPC_cMiMicEnv_VERSION "MiMic/1.4.73" #ifdef __cplusplus
--- a/core/driver/uip/EthDev.h Thu Oct 03 04:53:11 2013 +0000 +++ b/core/driver/uip/EthDev.h Fri Oct 18 12:40:09 2013 +0000 @@ -42,8 +42,6 @@ Ethernet Device Defines *----------------------------------------------------------------------------*/ #define EthDev_ADDR_SIZE 6 /*!< Ethernet Address size in bytes */ -#define EthDev_MTU_SIZE 1514 /*!< Maximum Transmission Unit */ - /*---------------------------------------------------------------------------- Ethernet Device Configuration and Control Command Defines
--- a/core/driver/uip/EthDev_LPC17xx.c Thu Oct 03 04:53:11 2013 +0000 +++ b/core/driver/uip/EthDev_LPC17xx.c Fri Oct 18 12:40:09 2013 +0000 @@ -20,36 +20,46 @@ * TXバッファ ***********************************************************************/ -//TXバッファの先頭アドレス +/** + * TXバッファの先頭アドレス + * Ethernetベースアドレス+RXメモリ領域 + */ #define ETH_TX_BUF_BASE (ETH_BUF_BASE+ETH_FRAG_SIZE*NUM_RX_FRAG) -#define NUM_OF_1536_BUF 3 +#define NUM_OF_MAX_BUF 3 #define NUM_OF_512_BUF 3 #define NUM_OF_256_BUF 4 #define NUM_OF_128_BUF 16 /** + * FULLサイズのEthernetFrame送信メモリのサイズ。 + * ここで最大送信サイズを制限する。 + * 通常は1460+20+20+14=1514バイト + */ +#define MAX_TX_ETHERNET_FRAME_SIZE 1514 + +/** * TXメモリブロックの配置 - * 12360バイト + * 9246バイト */ struct TTxMemoryBlock { struct{ struct NyLPC_TTxBufferHeader h; - NyLPC_TUInt8 b[1536]; - }buf1536[NUM_OF_1536_BUF];//(4+1536)*3=4620 + NyLPC_TUInt8 b[MAX_TX_ETHERNET_FRAME_SIZE]; + }buf_max[NUM_OF_MAX_BUF];//(4+MAX_TX_ETHERNET_FRAME_SIZE(1514))*3=? default=4554 struct{ struct NyLPC_TTxBufferHeader h; NyLPC_TUInt8 b[512]; - }buf512[NUM_OF_512_BUF];//(4+512)*3=1548 + }buf_512[NUM_OF_512_BUF];//(4+512)*3=1548 struct{ struct NyLPC_TTxBufferHeader h; NyLPC_TUInt8 b[256]; - }buf256[NUM_OF_256_BUF];//(4+256)*4=1560 + }buf_256[NUM_OF_256_BUF];//(4+256)*4=1560 struct{ struct NyLPC_TTxBufferHeader h; NyLPC_TUInt8 b[128]; - }buf128[NUM_OF_128_BUF];//(4+128)*16=1584 + }buf_128[NUM_OF_128_BUF];//(4+128)*16=1584 }; //メモリブロックの定義 @@ -63,26 +73,26 @@ int x; NyLPC_TUInt8 r1,r2,r3,r4; r1=r2=r3=r4=0; - for(x=0;x<NUM_OF_1536_BUF;x++){ - if(_txbuf->buf1536[x].h.is_lock || _txbuf->buf1536[x].h.ref>0){ + for(x=0;x<NUM_OF_MAX_BUF;x++){ + if(_txbuf->buf_max[x].h.is_lock || _txbuf->buf_max[x].h.ref>0){ r1++; continue; } } for(x=0;x<NUM_OF_512_BUF;x++){ - if(_txbuf->buf512[x].h.is_lock || _txbuf->buf512[x].h.ref>0){ + if(_txbuf->buf_512[x].h.is_lock || _txbuf->buf_512[x].h.ref>0){ r2++; continue; } } for(x=0;x<NUM_OF_256_BUF;x++){ - if(_txbuf->buf256[x].h.is_lock || _txbuf->buf256[x].h.ref>0){ + if(_txbuf->buf_256[x].h.is_lock || _txbuf->buf_256[x].h.ref>0){ r3++; continue; } } for(x=0;x<NUM_OF_128_BUF;x++){ - if(_txbuf->buf128[x].h.is_lock || _txbuf->buf128[x].h.ref>0){ + if(_txbuf->buf_128[x].h.is_lock || _txbuf->buf_128[x].h.ref>0){ r4++; continue; } @@ -104,21 +114,21 @@ TX_STAT_INFO( x ) = 0; } //TXバッファを初期化 - for(x=0;x<NUM_OF_1536_BUF;x++){ - _txbuf->buf1536[x].h.is_lock=NyLPC_TUInt8_FALSE; - _txbuf->buf1536[x].h.ref=0; + for(x=0;x<NUM_OF_MAX_BUF;x++){ + _txbuf->buf_max[x].h.is_lock=NyLPC_TUInt8_FALSE; + _txbuf->buf_max[x].h.ref=0; } for(x=0;x<NUM_OF_512_BUF;x++){ - _txbuf->buf512[x].h.is_lock=NyLPC_TUInt8_FALSE; - _txbuf->buf512[x].h.ref=0; + _txbuf->buf_512[x].h.is_lock=NyLPC_TUInt8_FALSE; + _txbuf->buf_512[x].h.ref=0; } for(x=0;x<NUM_OF_256_BUF;x++){ - _txbuf->buf256[x].h.is_lock=NyLPC_TUInt8_FALSE; - _txbuf->buf256[x].h.ref=0; + _txbuf->buf_256[x].h.is_lock=NyLPC_TUInt8_FALSE; + _txbuf->buf_256[x].h.ref=0; } for(x=0;x<NUM_OF_128_BUF;x++){ - _txbuf->buf128[x].h.is_lock=NyLPC_TUInt8_FALSE; - _txbuf->buf128[x].h.ref=0; + _txbuf->buf_128[x].h.is_lock=NyLPC_TUInt8_FALSE; + _txbuf->buf_128[x].h.ref=0; } /* Set LPC_EMAC Transmit Descriptor Registers. */ LPC_EMAC->TxDescriptor = TX_DESC_BASE; @@ -147,44 +157,44 @@ } switch(buf_type){ case 3: - for(i=0;i<NUM_OF_1536_BUF;i++){ + for(i=0;i<NUM_OF_MAX_BUF;i++){ //未参照かつ送信中でないもの。 - if(_txbuf->buf1536[i].h.ref>0 || _txbuf->buf1536[i].h.is_lock){ + if(_txbuf->buf_max[i].h.ref>0 || _txbuf->buf_max[i].h.is_lock){ continue; } - _txbuf->buf1536[i].h.ref++; - *o_size=1536; - return &(_txbuf->buf1536[i].h); + _txbuf->buf_max[i].h.ref++; + *o_size=MAX_TX_ETHERNET_FRAME_SIZE; + return &(_txbuf->buf_max[i].h); } case 2: for(i=0;i<NUM_OF_512_BUF;i++){ //未参照かつ送信中でないもの。 - if(_txbuf->buf512[i].h.ref>0 || _txbuf->buf512[i].h.is_lock){ + if(_txbuf->buf_512[i].h.ref>0 || _txbuf->buf_512[i].h.is_lock){ continue; } *o_size=512; - _txbuf->buf512[i].h.ref++; - return &(_txbuf->buf512[i].h); + _txbuf->buf_512[i].h.ref++; + return &(_txbuf->buf_512[i].h); } case 1: for(i=0;i<NUM_OF_256_BUF;i++){ //未参照かつ送信中でないもの。 - if(_txbuf->buf256[i].h.ref>0 || (_txbuf->buf256[i].h.is_lock)){ + if(_txbuf->buf_256[i].h.ref>0 || (_txbuf->buf_256[i].h.is_lock)){ continue; } *o_size=256; - _txbuf->buf256[i].h.ref++; - return &(_txbuf->buf256[i].h); + _txbuf->buf_256[i].h.ref++; + return &(_txbuf->buf_256[i].h); } default: for(i=0;i<NUM_OF_128_BUF;i++){ //未参照かつ送信中でないもの。 - if(_txbuf->buf128[i].h.ref>0 || (_txbuf->buf128[i].h.is_lock)){ + if(_txbuf->buf_128[i].h.ref>0 || (_txbuf->buf_128[i].h.is_lock)){ continue; } *o_size=128; - _txbuf->buf128[i].h.ref++; - return &(_txbuf->buf128[i].h); + _txbuf->buf_128[i].h.ref++; + return &(_txbuf->buf_128[i].h); } } return NULL; @@ -279,9 +289,11 @@ if (i_size > ETH_FRAG_SIZE){ i_size = ETH_FRAG_SIZE; } + //送信処理 TX_DESC_PACKET( Index ) = ( unsigned long )(i_buf+1); - TX_DESC_CTRL( Index ) = ( i_size | TCTRL_LAST | TCTRL_INT ); + //See UM10360.pdf Table 181. Transmit descriptor control word + TX_DESC_CTRL( Index ) = ((i_size-1) | TCTRL_LAST | TCTRL_INT ); LPC_EMAC->TxProduceIndex = IndexNext; return; }
--- a/core/driver/uip/EtherDev_DP83848C.c Thu Oct 03 04:53:11 2013 +0000 +++ b/core/driver/uip/EtherDev_DP83848C.c Fri Oct 18 12:40:09 2013 +0000 @@ -107,7 +107,7 @@ #define emacWAIT_FOR_LINK_TO_ESTABLISH_MS 500 /* Short delay used in several places during the initialisation process. */ -#define emacSHORT_DELAY_MS 2 +#define emacSHORT_DELAY_MS 10 /* Hardware specific bit definitions. */ #define emacPINSEL2_VALUE ( 0x50150105 ) @@ -200,8 +200,6 @@ EthDev_LPC17xx_prevRxDescriptor(); EthDev_LPC17xx_prevTxDescriptor(); - /* Receive broadcast and perfect match packets */ - LPC_EMAC->RxFilterCtrl = RFC_UCAST_EN | RFC_BCAST_EN | RFC_PERFECT_EN; /* Setup the PHY. */ prvConfigurePHY(); @@ -213,19 +211,19 @@ } /* Receive Broadcast and Perfect Match Packets */ - LPC_EMAC->RxFilterCtrl = RFC_BCAST_EN | RFC_PERFECT_EN; - - /* Reset all interrupts */ - LPC_EMAC->IntClear = 0xffff; - - /* Enable receive and transmit mode of MAC Ethernet core */ - LPC_EMAC->Command |= ( CR_RX_EN | CR_TX_EN ); - LPC_EMAC->MAC1 |= MAC1_REC_EN; + LPC_EMAC->RxFilterCtrl = RFC_BCAST_EN | RFC_PERFECT_EN | RFC_MCAST_EN; //Ethernetの割込み開始設定 NyLPC_cIsr_enterCritical(); { + /* Reset all interrupts */ + LPC_EMAC->IntClear = 0xffff; LPC_EMAC->IntEnable = ( INT_RX_DONE | INT_TX_DONE ); + + /* Enable receive and transmit mode of MAC Ethernet core */ + LPC_EMAC->Command |= ( CR_RX_EN | CR_TX_EN ); + LPC_EMAC->MAC1 |= MAC1_REC_EN; + /* Set the interrupt priority to the max permissible to cause some interrupt nesting. */ NVIC_SetPriority( ENET_IRQn, configEMAC_INTERRUPT_PRIORITY );
--- a/core/driver/uip/EtherDev_LAN8720.c Thu Oct 03 04:53:11 2013 +0000 +++ b/core/driver/uip/EtherDev_LAN8720.c Fri Oct 18 12:40:09 2013 +0000 @@ -97,7 +97,7 @@ #define emacWAIT_FOR_LINK_TO_ESTABLISH_MS 500 /* Short delay used in several places during the initialisation process. */ -#define emacSHORT_DELAY_MS 2 +#define emacSHORT_DELAY_MS 10 /* Hardware specific bit definitions. */ #define emacPINSEL2_VALUE ( 0x50150105 ) @@ -194,8 +194,6 @@ EthDev_LPC17xx_prevRxDescriptor(); EthDev_LPC17xx_prevTxDescriptor(); - /* Receive broadcast and perfect match packets */ - LPC_EMAC->RxFilterCtrl = RFC_UCAST_EN | RFC_BCAST_EN | RFC_PERFECT_EN; /* Setup the PHY. */ prvConfigurePHY(); @@ -207,19 +205,18 @@ } /* Receive Broadcast and Perfect Match Packets */ - LPC_EMAC->RxFilterCtrl = RFC_BCAST_EN | RFC_PERFECT_EN; - - /* Reset all interrupts */ - LPC_EMAC->IntClear = 0xffff; - - /* Enable receive and transmit mode of MAC Ethernet core */ - LPC_EMAC->Command |= ( CR_RX_EN | CR_TX_EN ); - LPC_EMAC->MAC1 |= MAC1_REC_EN; + LPC_EMAC->RxFilterCtrl = RFC_BCAST_EN | RFC_PERFECT_EN | RFC_MCAST_EN; //Ethernetの割込み開始設定 NyLPC_cIsr_enterCritical(); { + /* Reset all interrupts */ + LPC_EMAC->IntClear = 0xffff; LPC_EMAC->IntEnable = ( INT_RX_DONE | INT_TX_DONE ); + /* Enable receive and transmit mode of MAC Ethernet core */ + LPC_EMAC->Command |= ( CR_RX_EN | CR_TX_EN ); + LPC_EMAC->MAC1 |= MAC1_REC_EN; + /* Set the interrupt priority to the max permissible to cause some interrupt nesting. */ NVIC_SetPriority( ENET_IRQn, configEMAC_INTERRUPT_PRIORITY );
--- a/core/http/NyLPC_cHttpStream.c Thu Oct 03 04:53:11 2013 +0000 +++ b/core/http/NyLPC_cHttpStream.c Fri Oct 18 12:40:09 2013 +0000 @@ -168,7 +168,10 @@ memcpy(inst->txb+inst->tx_len,src,free_size); inst->tx_len+=free_size; //書き込み - flush_func(i_inst); + if(!flush_func(i_inst)){ + //書込みエラー・・・ + return NyLPC_TBool_FALSE; + } //読み出し位置の調整 l-=free_size; src+=free_size;
--- a/core/http/NyLPC_iHttpPtrStream.h Thu Oct 03 04:53:11 2013 +0000 +++ b/core/http/NyLPC_iHttpPtrStream.h Fri Oct 18 12:40:09 2013 +0000 @@ -52,7 +52,7 @@ /** * HTTP通信タイムアウトのデフォルト値 */ -#define NyLPC_TiHttpPtrStream_DEFAULT_HTTP_TIMEOUT (5*1000) +#define NyLPC_TiHttpPtrStream_DEFAULT_HTTP_TIMEOUT (8*1000) typedef NyLPC_TInt32 (*NyLPC_TiHttpPtrStream_pread)(void* i_inst,const void** o_buf_ptr,NyLPC_TUInt32 i_timeout);
--- a/core/uip/NyLPC_cTcpSocket.c Thu Oct 03 04:53:11 2013 +0000 +++ b/core/uip/NyLPC_cTcpSocket.c Fri Oct 18 12:40:09 2013 +0000 @@ -1238,8 +1238,6 @@ } } } -// //MSSとWNDの更新 -// i_inst->uip_connr.peer_mss = i_inst->uip_connr.default_mss;//@bug じゃないのこれ。peer_mss勝手に上書きしたらダメだろ //どちらにしろ、ACK送信 if(is_new_packet && (in_tcpflag & TCP_FIN)){ //FINがあるときは、ステータスをCLOSE_WAITへセットして、ACKを返す。 @@ -1259,14 +1257,17 @@ break; case UIP_FIN_WAIT_1: //FIN受信->CLOSINGへ - if(is_new_packet && (in_tcpflag & TCP_FIN)){ - i_inst->uip_connr.rcv_nxt32++; - if(num_of_noack==0){ - //FINとACKを受信 - i_inst->tcpstateflags=UIP_TIME_WAIT; - }else{ - //FINのみ - i_inst->tcpstateflags=UIP_CLOSING; + if(is_new_packet){ + i_inst->uip_connr.rcv_nxt32+=data_size; + if(in_tcpflag & TCP_FIN){ + i_inst->uip_connr.rcv_nxt32++; + if(num_of_noack==0){ + //FINとACKを受信 + i_inst->tcpstateflags=UIP_TIME_WAIT; + }else{ + //FINのみ + i_inst->tcpstateflags=UIP_CLOSING; + } } }else if(num_of_noack==0){ //ACKのみ
--- a/core/uip/NyLPC_uip.h Thu Oct 03 04:53:11 2013 +0000 +++ b/core/uip/NyLPC_uip.h Fri Oct 18 12:40:09 2013 +0000 @@ -155,21 +155,7 @@ */ #define UIP_MAXRTX 8 -/** - * The maximum number of times a SYN segment should be retransmitted - * before a connection request should be deemed to have been - * unsuccessful. - * - * This should not need to be changed. - */ -#define UIP_MAXSYNRTX 5 -/** - * How long a connection should stay in the TIME_WAIT state. - * - * This configiration option has no real implication, and it should be - * left untouched. - */ -#define UIP_TIME_WAIT_TIMEOUT 120 +