update 1.8
This commit is contained in:
@@ -60,12 +60,12 @@
|
||||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler.1731377187" name="GNU RISC-V Cross C Compiler" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.c.compiler">
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths.1567947810" name="Include paths (-I)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.include.paths" useByScannerDiscovery="true" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/User}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/HTTP}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Peripheral/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/NetLib}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Peripheral/inc}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Ld}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Debug}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/Core}""/>
|
||||
<listOptionValue builtIn="false" value=""${workspace_loc:/${ProjName}/HTTP}""/>
|
||||
</option>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.2020844713" name="Language standard" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std" useByScannerDiscovery="true" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.std.gnu99" valueType="enumerated"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs.177116515" name="Defined symbols (-D)" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.c.compiler.defs" useByScannerDiscovery="true" valueType="definedSymbols">
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<project>
|
||||
<configuration id="ilg.gnumcueclipse.managedbuild.cross.riscv.config.elf.release.1008047074" name="obj">
|
||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1893369213083458118" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD "${INPUTS}"" prefer-non-shared="true">
|
||||
<language-scope id="org.eclipse.cdt.core.gcc"/>
|
||||
<language-scope id="org.eclipse.cdt.core.g++"/>
|
||||
</provider>
|
||||
</extension>
|
||||
</configuration>
|
||||
</project>
|
||||
@@ -1,4 +0,0 @@
|
||||
eclipse.preferences.version=1
|
||||
encoding//HTTP/HTTPS.c=UTF-8
|
||||
encoding//Peripheral/inc/ch32v20x.h=UTF-8
|
||||
encoding//User/main.c=UTF-8
|
||||
+434
-349
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@
|
||||
#ifndef __HTTPS_H__
|
||||
#define __HTTPS_H__
|
||||
#include "debug.h"
|
||||
#include "wchnet.h"
|
||||
#include "eth_driver.h"
|
||||
|
||||
/*Address where configuration
|
||||
* information is stored*/
|
||||
@@ -24,40 +24,42 @@
|
||||
#define BASIC_CFG_ADDR ((uint32_t)0x0801FC00)
|
||||
#define PORT_CFG_ADDR ((uint32_t)0x0801FD00)
|
||||
#define LOGIN_CFG_ADDR ((uint32_t)0x0801FE00)
|
||||
#define BASIC_CFG_LEN 40
|
||||
#define PORT_CFG_LEN 40
|
||||
#define LOGIN_CFG_LEN 40
|
||||
#define BASIC_CFG_LEN (sizeof(Basic_Cfg_t))
|
||||
#define PORT_CFG_LEN (sizeof(Port_Cfg_t))
|
||||
#define LOGIN_CFG_LEN (sizeof(Login_Cfg_t))
|
||||
|
||||
|
||||
#define MAX_URL_SIZE 128
|
||||
#define MAX_URL_SIZE 32
|
||||
#define HTTP_SERVER_PORT 80
|
||||
|
||||
/* HTTP请求方法 */
|
||||
/* HTTP request method*/
|
||||
#define METHOD_ERR 0
|
||||
#define METHOD_GET 1
|
||||
#define METHOD_HEAD 2
|
||||
#define METHOD_POST 3
|
||||
|
||||
/* HTTP请求类型 */
|
||||
/* HTTP request URL */
|
||||
#define PTYPE_ERR 0
|
||||
#define PTYPE_HTML 1
|
||||
#define PTYPE_PNG 2
|
||||
#define PTYPE_CSS 3
|
||||
#define PTYPE_GIF 4
|
||||
|
||||
/*WCHNET网页通信协议定义*/
|
||||
/*WCHNET communication Mode*/
|
||||
#define MODE_TCPSERVER 0
|
||||
#define MODE_TCPCLIENT 1
|
||||
|
||||
/* HTML Doc. for ERROR */
|
||||
#define RES_HTMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n" //HTML type response message, the last two \r\n must have
|
||||
#define RES_HTMLHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\nContent-Length:"
|
||||
|
||||
#define RES_PNGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/png\r\n\r\n" //PNG type response message, the last two \r\n must have
|
||||
#define RES_PNGHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/png\r\nContent-Length:"
|
||||
|
||||
#define RES_CSSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/css\r\n\r\n" //CSS type response message, the last two \r\n must have
|
||||
#define RES_CSSHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: text/css\r\nContent-Length:"
|
||||
|
||||
#define RES_GIFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/gif\r\nContent-Length:"
|
||||
|
||||
#define RES_END "\r\n\r\n"
|
||||
|
||||
#define RES_GIFHEAD_OK "HTTP/1.1 200 OK\r\nContent-Type: image/gif\r\n\r\n" //GIF type response message, the last two \r\n must have
|
||||
/*-----------------*/
|
||||
|
||||
typedef struct Basic_Cfg //Basic configuration parameters
|
||||
{
|
||||
@@ -66,25 +68,25 @@ typedef struct Basic_Cfg //Basic configuration parameters
|
||||
u8 ip[4];
|
||||
u8 mask[4];
|
||||
u8 gateway[4];
|
||||
} *Basic_Cfg;
|
||||
} Basic_Cfg_t;
|
||||
|
||||
|
||||
typedef struct Port_Cfg //Port configuration parameters
|
||||
typedef struct Port_Cfg //Port configuration parameters
|
||||
{
|
||||
u8 flag[2]; //Configuration information verification code: 0x57,0xab
|
||||
u8 mode;
|
||||
u8 src_port[2];
|
||||
u8 des_ip[4];
|
||||
u8 des_port[2];
|
||||
} *Port_Cfg;
|
||||
} Port_Cfg_t;
|
||||
|
||||
|
||||
typedef struct Login_Cfg //Login configuration parameters
|
||||
typedef struct Login_Cfg //Login configuration parameters
|
||||
{
|
||||
u8 flag[2]; //Configuration information verification code: 0x57,0xab
|
||||
u8 user[10];
|
||||
u8 pass[10];
|
||||
} *Login_Cfg;
|
||||
} Login_Cfg_t;
|
||||
|
||||
|
||||
typedef struct _st_http_request //Browser request information
|
||||
@@ -97,22 +99,16 @@ typedef struct _st_http_request //Browser request information
|
||||
typedef struct Para_Tab //Configuration information parameter table
|
||||
{
|
||||
char *para; //Configuration item name
|
||||
char value[20]; //Configuration item value
|
||||
char value[30]; //Configuration item value
|
||||
}Parameter;
|
||||
|
||||
extern Basic_Cfg Basic_CfgBuf;
|
||||
extern Basic_Cfg_t Basic_CfgBuf;
|
||||
|
||||
extern Login_Cfg Login_CfgBuf;
|
||||
extern Login_Cfg_t Login_CfgBuf;
|
||||
|
||||
extern Port_Cfg Port_CfgBuf;
|
||||
extern Port_Cfg_t Port_CfgBuf;
|
||||
|
||||
extern st_http_request *http_request;
|
||||
|
||||
extern u8 basicbuf[BASIC_CFG_LEN];
|
||||
|
||||
extern u8 portbuf[PORT_CFG_LEN];
|
||||
|
||||
extern u8 loginbuf[LOGIN_CFG_LEN];
|
||||
extern st_http_request http_request;
|
||||
|
||||
extern u8 Basic_Default[BASIC_CFG_LEN];
|
||||
|
||||
@@ -122,9 +118,7 @@ extern u8 Port_Default[PORT_CFG_LEN];
|
||||
|
||||
extern u8 httpweb[200] ;
|
||||
|
||||
extern u8 RecvBuffer[];
|
||||
|
||||
extern u8 DealDataflag;
|
||||
extern u8 HTTPDataBuffer[];
|
||||
|
||||
extern u8 socket;
|
||||
|
||||
@@ -132,7 +126,7 @@ extern void ParseHttpRequest(st_http_request *, char *);
|
||||
|
||||
extern void ParseURLType(char *, char *);
|
||||
|
||||
extern void MakeHttpResponse(unsigned char *, char);
|
||||
void MakeHttpResponse(u8 *buf, char type, u32 len );
|
||||
|
||||
extern char *GetURLName(char* url);
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
#include "ch32v20x_it.h"
|
||||
#include <wchnet.h>
|
||||
#include "eth_driver.h"
|
||||
|
||||
void NMI_Handler(void) __attribute__((interrupt("WCH-Interrupt-fast")));
|
||||
|
||||
@@ -18,7 +18,6 @@ For details on the selection of engineering chips,
|
||||
please refer to the "CH32V20x Evaluation Board Manual" under the CH32V20xEVT\EVT\PUB folder.
|
||||
*/
|
||||
#include "string.h"
|
||||
#include "debug.h"
|
||||
#include "eth_driver.h"
|
||||
#include "HTTPS.h"
|
||||
|
||||
@@ -27,11 +26,10 @@ u8 IPAddr[4]; //IP address
|
||||
u8 GWIPAddr[4]; //Gateway IP address
|
||||
u8 IPMask[4]; //subnet mask
|
||||
|
||||
u8 DealDataflag = 0;
|
||||
u8 SocketId, SocketIdForListen, RecvBuffer[RECE_BUF_LEN];
|
||||
u8 SocketId, SocketIdForListen;
|
||||
u8 RecvBuffer[RECE_BUF_LEN], HTTPDataBuffer[RECE_BUF_LEN];
|
||||
u8 SocketRecvBuf[WCHNET_MAX_SOCKET_NUM][RECE_BUF_LEN]; //socket receive buffer
|
||||
u16 DESPORT, SRCPORT; //port
|
||||
|
||||
/*********************************************************************
|
||||
* @fn mStopIfError
|
||||
*
|
||||
@@ -61,7 +59,7 @@ void TIM2_Init(void)
|
||||
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
|
||||
|
||||
TIM_TimeBaseStructure.TIM_Period = SystemCoreClock / 1000000 - 1;
|
||||
TIM_TimeBaseStructure.TIM_Period = SystemCoreClock / 1000000;
|
||||
TIM_TimeBaseStructure.TIM_Prescaler = WCHNETTIMERPERIOD * 1000 - 1;
|
||||
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
|
||||
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
|
||||
@@ -176,12 +174,14 @@ void WCHNET_HandleSockInt(u8 socketid, u8 intstat)
|
||||
if (intstat & SINT_STAT_RECV) //receive data
|
||||
{
|
||||
len = WCHNET_SocketRecvLen(socketid, NULL);
|
||||
printf("WCHNET_SocketRecvLen %d socket id %d\r\n", len, socketid);
|
||||
if (len) {
|
||||
WCHNET_SocketRecv(socketid, RecvBuffer, &len);
|
||||
DealDataflag = 1;
|
||||
if (SocketInf[socketid].SourPort == HTTP_SERVER_PORT) { // receive HTTP data
|
||||
socket = socketid;
|
||||
WCHNET_SocketRecv(socketid, HTTPDataBuffer, &len);
|
||||
Web_Server();
|
||||
}
|
||||
else //receive the data of the configured socket
|
||||
WCHNET_SocketRecv(socketid, RecvBuffer, &len);
|
||||
printf("socketid:%d Received data length:%d\r\n",socketid, len);
|
||||
}
|
||||
if (intstat & SINT_STAT_CONNECT) //connect successfully
|
||||
{
|
||||
@@ -195,7 +195,7 @@ void WCHNET_HandleSockInt(u8 socketid, u8 intstat)
|
||||
if (intstat & SINT_STAT_TIM_OUT) //timeout disconnect
|
||||
{
|
||||
printf("TCP Timeout\r\n");
|
||||
WCHNET_CreateCfgSocket(Port_CfgBuf->mode, Port_CfgBuf->des_ip, DESPORT, SRCPORT);
|
||||
WCHNET_CreateCfgSocket(Port_CfgBuf.mode, Port_CfgBuf.des_ip, DESPORT, SRCPORT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -267,9 +267,12 @@ int main(void)
|
||||
USART_Printf_Init(115200); //USART initialize
|
||||
GPIOInit();
|
||||
printf("WEB SERVER\r\n");
|
||||
printf("SystemClk:%d\r\n", SystemCoreClock);
|
||||
if((SystemCoreClock == 60000000) || (SystemCoreClock == 120000000))
|
||||
printf("SystemClk:%d\r\n", SystemCoreClock);
|
||||
else
|
||||
printf("Error: Please choose 60MHz and 120MHz clock when using Ethernet!\r\n");
|
||||
printf("net version:%x\n", WCHNET_GetVer());
|
||||
if ( WCHNET_LIB_VER != WCHNET_GetVer()) {
|
||||
if (WCHNET_LIB_VER != WCHNET_GetVer()) {
|
||||
printf("version error.\n");
|
||||
}
|
||||
/*After the button(PB6) is pressed, initialize
|
||||
@@ -281,37 +284,34 @@ int main(void)
|
||||
WCHNET_RestoreDefaults();
|
||||
}
|
||||
}
|
||||
WEB_READ( BASIC_CFG_ADDR, (u8 *)Basic_CfgBuf, BASIC_CFG_LEN ); //Read configuration information
|
||||
WEB_READ( PORT_CFG_ADDR, (u8 *)Port_CfgBuf, PORT_CFG_LEN );
|
||||
WEB_READ( LOGIN_CFG_ADDR, (u8 *)Login_CfgBuf, LOGIN_CFG_LEN );
|
||||
if((Basic_CfgBuf->flag[0] != 0x57) || (Basic_CfgBuf->flag[1] != 0xAB)){ //Determine network configuration information flags
|
||||
WEB_READ( BASIC_CFG_ADDR, (u8 *)&Basic_CfgBuf, BASIC_CFG_LEN ); //Read configuration information
|
||||
WEB_READ( PORT_CFG_ADDR, (u8 *)&Port_CfgBuf, PORT_CFG_LEN );
|
||||
WEB_READ( LOGIN_CFG_ADDR, (u8 *)&Login_CfgBuf, LOGIN_CFG_LEN );
|
||||
if((Basic_CfgBuf.flag[0] != 0x57) || (Basic_CfgBuf.flag[1] != 0xAB)){ //Determine network configuration information flags
|
||||
WCHNET_RestoreDefaults();
|
||||
}
|
||||
else {
|
||||
if((Port_CfgBuf->flag[0] != 0x57) || (Port_CfgBuf->flag[1] != 0xAB)){ //Determine password configuration information
|
||||
if((Port_CfgBuf.flag[0] != 0x57) || (Port_CfgBuf.flag[1] != 0xAB)){ //Determine password configuration information
|
||||
WCHNET_RestoreDefaults();
|
||||
}
|
||||
else {
|
||||
if((Login_CfgBuf->flag[0] != 0x57) || (Login_CfgBuf->flag[1] != 0xAB)) //Determine password configuration information
|
||||
if((Login_CfgBuf.flag[0] != 0x57) || (Login_CfgBuf.flag[1] != 0xAB)) //Determine password configuration information
|
||||
WCHNET_RestoreDefaults();
|
||||
}
|
||||
}
|
||||
memcpy(MACAddr, Basic_CfgBuf->mac, 6);
|
||||
memcpy(IPAddr, Basic_CfgBuf->ip, 4);
|
||||
memcpy(IPMask, Basic_CfgBuf->mask, 4);
|
||||
memcpy(GWIPAddr, Basic_CfgBuf->gateway, 4);
|
||||
printf("ip:\n");
|
||||
memcpy(MACAddr, Basic_CfgBuf.mac, 6);
|
||||
memcpy(IPAddr, Basic_CfgBuf.ip, 4);
|
||||
memcpy(IPMask, Basic_CfgBuf.mask, 4);
|
||||
memcpy(GWIPAddr, Basic_CfgBuf.gateway, 4);
|
||||
printf("ip: ");
|
||||
for (i = 0; i < 4; i++)
|
||||
printf("%d.", IPAddr[i]);
|
||||
printf("\n");
|
||||
|
||||
WCHNET_GetMacAddr(MACAddr); //get the chip MAC address
|
||||
printf("mac addr:");
|
||||
for (i = 0; i < 6; i++)
|
||||
printf("mac addr: ");
|
||||
for(i = 0; i < 6; i++)
|
||||
printf("%x ", MACAddr[i]);
|
||||
printf("\n");
|
||||
http_request = (st_http_request*) RecvBuffer;
|
||||
|
||||
TIM2_Init();
|
||||
i = ETH_LibInit(IPAddr, GWIPAddr, IPMask, MACAddr); //Ethernet library initialize
|
||||
mStopIfError(i);
|
||||
@@ -319,9 +319,9 @@ int main(void)
|
||||
printf("WCHNET_LibInit Success\r\n");
|
||||
WCHNET_CreateTcpSocketListen(); //Create TCP Socket
|
||||
|
||||
DESPORT = Port_CfgBuf->des_port[0] * 256 + Port_CfgBuf->des_port[1];
|
||||
SRCPORT = Port_CfgBuf->src_port[0] * 256 + Port_CfgBuf->src_port[1];
|
||||
WCHNET_CreateCfgSocket(Port_CfgBuf->mode, Port_CfgBuf->des_ip, DESPORT, SRCPORT);
|
||||
DESPORT = Port_CfgBuf.des_port[0] * 256 + Port_CfgBuf.des_port[1];
|
||||
SRCPORT = Port_CfgBuf.src_port[0] * 256 + Port_CfgBuf.src_port[1];
|
||||
WCHNET_CreateCfgSocket(Port_CfgBuf.mode, Port_CfgBuf.des_ip, DESPORT, SRCPORT);
|
||||
Init_Para_Tab();
|
||||
|
||||
while(1)
|
||||
@@ -335,7 +335,6 @@ int main(void)
|
||||
{
|
||||
WCHNET_HandleGlobalInt();
|
||||
}
|
||||
Web_Server();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,15 +24,17 @@ extern "C" {
|
||||
|
||||
#define WCHNET_NUM_UDP 0 /* The number of UDP connections */
|
||||
|
||||
#define WCHNET_NUM_TCP 5 /* Number of TCP connections */
|
||||
#define WCHNET_NUM_TCP 3 /* Number of TCP connections */
|
||||
|
||||
#define WCHNET_NUM_TCP_LISTEN 2 /* Number of TCP listening */
|
||||
|
||||
/* The number of sockets, the maximum is 31 */
|
||||
#define WCHNET_MAX_SOCKET_NUM (WCHNET_NUM_IPRAW+WCHNET_NUM_UDP+WCHNET_NUM_TCP+WCHNET_NUM_TCP_LISTEN)
|
||||
#define WCHNET_MAX_SOCKET_NUM (WCHNET_NUM_IPRAW+WCHNET_NUM_UDP+WCHNET_NUM_TCP+WCHNET_NUM_TCP_LISTEN)
|
||||
|
||||
#define WCHNET_TCP_MSS 800 /* Size of TCP MSS*/
|
||||
|
||||
#define WCHNET_NUM_POOL_BUF (WCHNET_NUM_TCP*2+2) /* The number of POOL BUFs, the number of receive queues */
|
||||
|
||||
/*********************************************************************
|
||||
* MAC queue configuration
|
||||
*/
|
||||
@@ -49,94 +51,115 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/*********************************************************************
|
||||
* Functional configuration
|
||||
* Functional configuration
|
||||
*/
|
||||
#define WCHNET_PING_ENABLE 1 /* PING is enabled, PING is enabled by default */
|
||||
#define WCHNET_PING_ENABLE 1 /* PING is enabled, PING is enabled by default */
|
||||
|
||||
#define TCP_RETRY_COUNT 20 /* The number of TCP retransmissions, the default value is 20 */
|
||||
#define TCP_RETRY_COUNT 20 /* The number of TCP retransmissions, the default value is 20 */
|
||||
|
||||
#define TCP_RETRY_PERIOD 10 /* TCP retransmission period, the default value is 10, the unit is 50ms */
|
||||
#define TCP_RETRY_PERIOD 10 /* TCP retransmission period, the default value is 10, the unit is 50ms */
|
||||
|
||||
#define SOCKET_SEND_RETRY 1 /* Send failed retry configuration, 1: enable, 0: disable */
|
||||
#define SOCKET_SEND_RETRY 0 /* Send failed retry configuration, 1: enable, 0: disable */
|
||||
|
||||
#define CFG0_TCP_SEND_COPY 1 /* TCP send buffer copy, 1: copy, 0: not copy */
|
||||
#define FINE_DHCP_PERIOD 8 /* Fine DHCP period, the default value is 8, the unit is 250ms */
|
||||
|
||||
#define CFG0_TCP_RECV_COPY 1 /* TCP receive replication optimization, internal debugging use */
|
||||
#define CFG0_TCP_SEND_COPY 1 /* TCP send buffer copy, 1: copy, 0: not copy */
|
||||
|
||||
#define CFG0_TCP_OLD_DELETE 0 /* Delete oldest TCP connection, 1: enable, 0: disable */
|
||||
#define CFG0_TCP_RECV_COPY 1 /* TCP receive replication optimization, internal debugging use */
|
||||
|
||||
#define CFG0_TCP_OLD_DELETE 0 /* Delete oldest TCP connection, 1: enable, 0: disable */
|
||||
|
||||
#define CFG0_IP_REASS_PBUFS 0 /* Number of reassembled IP PBUFs */
|
||||
|
||||
#define CFG0_TCP_DEALY_ACK_DISABLE 1 /* 1: disable TCP delay ACK 0: enable TCP delay ACK */
|
||||
|
||||
/*********************************************************************
|
||||
* Memory related configuration
|
||||
* Memory related configuration
|
||||
*/
|
||||
/*If a single socket cannot reach full speed,
|
||||
/* If you want to achieve a higher transmission speed,
|
||||
* try to increase RECE_BUF_LEN to (WCHNET_TCP_MSS*4)
|
||||
* and increase WCHNET_NUM_TCP_SEG to (WCHNET_NUM_TCP*4)*/
|
||||
#define RECE_BUF_LEN (WCHNET_TCP_MSS*2) /* socket receive buffer size */
|
||||
|
||||
#define WCHNET_NUM_PBUF (WCHNET_MAX_SOCKET_NUM+WCHNET_NUM_TCP) /* Number of PBUF structures */
|
||||
#define WCHNET_NUM_PBUF WCHNET_NUM_POOL_BUF /* Number of PBUF structures */
|
||||
|
||||
#define WCHNET_NUM_TCP_SEG (WCHNET_NUM_TCP*2) /* The number of TCP segments used to send */
|
||||
|
||||
#define WCHNET_MEM_HEAP_SIZE (((WCHNET_TCP_MSS+0x10+54)*WCHNET_NUM_TCP_SEG)+ETH_TX_BUF_SZE+64) /* memory heap size */
|
||||
#define WCHNET_MEM_HEAP_SIZE (((WCHNET_TCP_MSS+0x10+54+8)*WCHNET_NUM_TCP_SEG)+ETH_TX_BUF_SZE+64+2*0x18) /* memory heap size */
|
||||
|
||||
#define WCHNET_NUM_ARP_TABLE 50 /* Number of ARP lists */
|
||||
|
||||
#define WCHNET_NUM_IP_REASSDATA 4 /* Number of IP segments */
|
||||
|
||||
#define CFG0_IP_REASS_PBUFS 4 /* Number of reassembled IP PBUFs */
|
||||
|
||||
#define WCHNET_MEM_ALIGNMENT 4 /* 4 byte alignment */
|
||||
|
||||
#define WCHNET_NUM_POOL_BUF (WCHNET_NUM_TCP*2+2) /* The number of POOL BUFs, the number of receive queues */
|
||||
#if CFG0_IP_REASS_PBUFS
|
||||
#define WCHNET_NUM_IP_REASSDATA 2 /* Number of reassembled IP structures */
|
||||
/*1: When using the fragmentation function,
|
||||
* ensure that the size of WCHNET_SIZE_POOL_BUF is large enough to store a single fragmented packet*/
|
||||
#define WCHNET_SIZE_POOL_BUF (((1500 + 14 + 4) + 3) & ~3) /* Buffer size for receiving a single packet */
|
||||
/*2: When creating a socket that can receive fragmented packets,
|
||||
* ensure that "RecvBufLen" member of the "struct _SOCK_INF" structure
|
||||
* (the parameter initialized when calling WCHNET_SocketCreat) is sufficient
|
||||
* to receive a complete fragmented packet */
|
||||
#else
|
||||
#define WCHNET_NUM_IP_REASSDATA 0 /* Number of reassembled IP structures */
|
||||
#define WCHNET_SIZE_POOL_BUF (((WCHNET_TCP_MSS + 40 + 14 + 4) + 3) & ~3) /* Buffer size for receiving a single packet */
|
||||
#endif
|
||||
|
||||
/* Check receive buffer */
|
||||
#if(WCHNET_NUM_POOL_BUF * WCHNET_SIZE_POOL_BUF < ETH_RX_BUF_SZE)
|
||||
#error "WCHNET_NUM_POOL_BUF or WCHNET_TCP_MSS Error"
|
||||
#error "Please Increase WCHNET_NUM_POOL_BUF or WCHNET_TCP_MSS to make sure the receive buffer is sufficient"
|
||||
#endif
|
||||
/* Check the configuration of the SOCKET quantity */
|
||||
#if( WCHNET_NUM_TCP_LISTEN && !WCHNET_NUM_TCP )
|
||||
#error "WCHNET_NUM_TCP Error)"
|
||||
#error "WCHNET_NUM_TCP Error,Please Configure WCHNET_NUM_TCP >= 1"
|
||||
#endif
|
||||
/* Check byte alignment must be a multiple of 4 */
|
||||
#if((WCHNET_MEM_ALIGNMENT % 4) || (WCHNET_MEM_ALIGNMENT == 0))
|
||||
#error "WCHNET_MEM_ALIGNMENT Error,Please Config WCHNET_MEM_ALIGNMENT = 4 * N, N >=1"
|
||||
#error "WCHNET_MEM_ALIGNMENT Error,Please Configure WCHNET_MEM_ALIGNMENT = 4 * N, N >=1"
|
||||
#endif
|
||||
/* TCP maximum segment length */
|
||||
#if((WCHNET_TCP_MSS > 1460) || (WCHNET_TCP_MSS < 60))
|
||||
#error "WCHNET_TCP_MSS Error,Please Config WCHNET_TCP_MSS >= 60 && WCHNET_TCP_MSS <= 1460"
|
||||
#error "WCHNET_TCP_MSS Error,Please Configure WCHNET_TCP_MSS >= 60 && WCHNET_TCP_MSS <= 1460"
|
||||
#endif
|
||||
/* Number of ARP cache tables */
|
||||
#if((WCHNET_NUM_ARP_TABLE > 0X7F) || (WCHNET_NUM_ARP_TABLE < 1))
|
||||
#error "WCHNET_NUM_ARP_TABLE Error,Please Config WCHNET_NUM_ARP_TABLE >= 1 && WCHNET_NUM_ARP_TABLE <= 0X7F"
|
||||
#error "WCHNET_NUM_ARP_TABLE Error,Please Configure WCHNET_NUM_ARP_TABLE >= 1 && WCHNET_NUM_ARP_TABLE <= 0X7F"
|
||||
#endif
|
||||
/* Check POOL BUF configuration */
|
||||
#if(WCHNET_NUM_POOL_BUF < 1)
|
||||
#error "WCHNET_NUM_POOL_BUF Error,Please Config WCHNET_NUM_POOL_BUF >= 1"
|
||||
#error "WCHNET_NUM_POOL_BUF Error,Please Configure WCHNET_NUM_POOL_BUF >= 1"
|
||||
#endif
|
||||
/* Check PBUF structure configuration */
|
||||
#if(WCHNET_NUM_PBUF < 1)
|
||||
#error "WCHNET_NUM_PBUF Error,Please Config WCHNET_NUM_PBUF >= 1"
|
||||
#error "WCHNET_NUM_PBUF Error,Please Configure WCHNET_NUM_PBUF >= 1"
|
||||
#endif
|
||||
/* Check IP Assignment Configuration */
|
||||
#if((WCHNET_NUM_IP_REASSDATA > 10) || (WCHNET_NUM_IP_REASSDATA < 1))
|
||||
#error "WCHNET_NUM_IP_REASSDATA Error,Please Config WCHNET_NUM_IP_REASSDATA < 10 && WCHNET_NUM_IP_REASSDATA >= 1 "
|
||||
#if(CFG0_IP_REASS_PBUFS && ((WCHNET_NUM_IP_REASSDATA > 10) || (WCHNET_NUM_IP_REASSDATA < 1)))
|
||||
#error "WCHNET_NUM_IP_REASSDATA Error,Please Configure WCHNET_NUM_IP_REASSDATA < 10 && WCHNET_NUM_IP_REASSDATA >= 1 "
|
||||
#endif
|
||||
/* Check the number of reassembled IP PBUFs */
|
||||
#if(WCHNET_IP_REASS_PBUFS > WCHNET_NUM_POOL_BUF)
|
||||
#error "WCHNET_IP_REASS_PBUFS Error,Please Config WCHNET_IP_REASS_PBUFS < WCHNET_NUM_POOL_BUF"
|
||||
#if(CFG0_IP_REASS_PBUFS > WCHNET_NUM_POOL_BUF)
|
||||
#error "WCHNET_NUM_POOL_BUF Error,Please Configure CFG0_IP_REASS_PBUFS < WCHNET_NUM_POOL_BUF"
|
||||
#endif
|
||||
|
||||
/* Check Timer period, in Ms. */
|
||||
#if(WCHNETTIMERPERIOD > 50)
|
||||
#error "WCHNETTIMERPERIOD Error,Please Config WCHNETTIMERPERIOD < 50"
|
||||
#error "WCHNETTIMERPERIOD Error,Please Configure WCHNETTIMERPERIOD < 50"
|
||||
#endif
|
||||
|
||||
/* Configuration value 0 */
|
||||
#define WCHNET_MISC_CONFIG0 (((CFG0_TCP_SEND_COPY) << 0) |\
|
||||
((CFG0_TCP_RECV_COPY) << 1) |\
|
||||
((CFG0_TCP_OLD_DELETE) << 2) |\
|
||||
((CFG0_IP_REASS_PBUFS) << 3) )
|
||||
((CFG0_IP_REASS_PBUFS) << 3) |\
|
||||
((CFG0_TCP_DEALY_ACK_DISABLE) << 8))
|
||||
/* Configuration value 1 */
|
||||
#define WCHNET_MISC_CONFIG1 (((WCHNET_MAX_SOCKET_NUM)<<0)|\
|
||||
((WCHNET_PING_ENABLE) << 13) |\
|
||||
((TCP_RETRY_COUNT) << 14) |\
|
||||
((TCP_RETRY_PERIOD) << 19) |\
|
||||
((SOCKET_SEND_RETRY) << 25) )
|
||||
((SOCKET_SEND_RETRY) << 25) |\
|
||||
((FINE_DHCP_PERIOD) << 27))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user