update 1.8
This commit is contained in:
@@ -110,7 +110,7 @@ void UART_Interrupt_Init(void)
|
||||
*
|
||||
* @return none
|
||||
* */
|
||||
void BSP_Uart_Init(void)
|
||||
void BSP_Uart_Init(uint32_t baudrate )
|
||||
{
|
||||
USART_InitTypeDef USART_InitStructure = {0};
|
||||
|
||||
@@ -131,7 +131,7 @@ void BSP_Uart_Init(void)
|
||||
|
||||
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
|
||||
|
||||
USART_InitStructure.USART_BaudRate = BAUD_RATE;
|
||||
USART_InitStructure.USART_BaudRate = baudrate;
|
||||
USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
||||
USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
||||
USART_InitStructure.USART_Parity = USART_Parity_No;
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
#include "net_config.h"
|
||||
|
||||
/* Global define */
|
||||
#define BAUD_RATE 1000000
|
||||
#define BAUD_RATE 921600
|
||||
|
||||
#define size(a) (sizeof(a) / sizeof(*(a)))
|
||||
|
||||
#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
|
||||
|
||||
#define UART_RX_DMA_SIZE 2048 //Must be a power of 2 ( a%2^n = a&(2^n - 1) )
|
||||
#define UART_RX_DMA_SIZE RECE_BUF_LEN
|
||||
|
||||
#define ETH_RECEIVE_SIZE RECE_BUF_LEN
|
||||
|
||||
@@ -47,7 +47,7 @@ struct uart_data
|
||||
|
||||
extern struct uart_data uart_data_t;
|
||||
|
||||
extern void BSP_Uart_Init(void);
|
||||
extern void BSP_Uart_Init(uint32_t baudrate );
|
||||
|
||||
#endif /* end of bsp_uart.h */
|
||||
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
* microcontroller manufactured by Nanjing Qinheng Microelectronics.
|
||||
*******************************************************************************/
|
||||
#include "ch32v20x_it.h"
|
||||
#include <wchnet.h>
|
||||
#include "eth_driver.h"
|
||||
#include "bsp_uart.h"
|
||||
|
||||
@@ -87,6 +86,8 @@ void DMA1_Channel7_IRQHandler(void)
|
||||
DMA_Cmd(DMA1_Channel7,DISABLE);
|
||||
uart_data_t.uart_tx_dma_state = IDLE;
|
||||
uart_data_t.tx_read++;
|
||||
/* Prevent access from out-of-bounds */
|
||||
uart_data_t.tx_read = (uart_data_t.tx_read)%UART_TX_BUF_NUM;
|
||||
uart_data_t.tx_remainBuffNum++;
|
||||
DMA_ClearITPendingBit(DMA1_IT_TC7);
|
||||
}
|
||||
|
||||
@@ -12,27 +12,26 @@
|
||||
/*
|
||||
*@Note
|
||||
ETH_UART example demonstrates data transparency between Ethernet and UART.
|
||||
By default, 1000000 baud rate (can be changed in bsp_uart.h) is used for serial port data transmission.
|
||||
By default, 921600 baud rate (can be changed in bsp_uart.h) is used for serial port data transmission.
|
||||
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 "bsp_uart.h"
|
||||
|
||||
u8 MACAddr[6]; //MAC address
|
||||
u8 IPAddr[4] = {192,168,1,10}; //IP address
|
||||
u8 GWIPAddr[4] = {192,168,1,1}; //Gateway IP address
|
||||
u8 IPMask[4] = {255,255,255,0}; //subnet mask
|
||||
u8 DESIP[4] = {192,168,1,100}; //destination IP address
|
||||
u8 MACAddr[6]; //MAC address
|
||||
u8 IPAddr[4] = {192, 168, 1, 10}; //IP address
|
||||
u8 GWIPAddr[4] = {192, 168, 1, 1}; //Gateway IP address
|
||||
u8 IPMask[4] = {255, 255, 255, 0}; //subnet mask
|
||||
u8 DESIP[4] = {192, 168, 1, 100}; //destination IP address
|
||||
|
||||
u8 SocketId; //socket id
|
||||
u8 SocketRecvBuf[RECE_BUF_LEN]; //socket data buff
|
||||
u16 desport = 1000; //destination port
|
||||
u16 srcport = 1000; //source port
|
||||
u8 SocketId; //socket id
|
||||
u8 SocketRecvBuf[RECE_BUF_LEN]; //socket data buff
|
||||
u16 desport = 1000; //destination port
|
||||
u16 srcport = 1000; //source port
|
||||
|
||||
u8 TCPConnValid = 0; //0 disconnected 1 connect
|
||||
u8 TCPConnValid = 0; //0 disconnected 1 connect
|
||||
|
||||
/*********************************************************************
|
||||
* @fn mStopIfError
|
||||
@@ -62,7 +61,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;
|
||||
@@ -83,20 +82,20 @@ void TIM2_Init( void )
|
||||
*/
|
||||
void WCHNET_CreateTcpSocket(void)
|
||||
{
|
||||
u8 i;
|
||||
SOCK_INF TmpSocketInf;
|
||||
u8 i;
|
||||
SOCK_INF TmpSocketInf;
|
||||
|
||||
memset((void *)&TmpSocketInf,0,sizeof(SOCK_INF));
|
||||
memcpy((void *)TmpSocketInf.IPAddr,DESIP,4);
|
||||
TmpSocketInf.DesPort = desport;
|
||||
TmpSocketInf.SourPort = srcport;
|
||||
TmpSocketInf.ProtoType = PROTO_TYPE_TCP;
|
||||
TmpSocketInf.RecvBufLen = RECE_BUF_LEN;
|
||||
i = WCHNET_SocketCreat(&SocketId,&TmpSocketInf);
|
||||
printf("WCHNET_SocketCreat %d\r\n",SocketId);
|
||||
mStopIfError(i);
|
||||
i = WCHNET_SocketConnect(SocketId);
|
||||
mStopIfError(i);
|
||||
memset((void *)&TmpSocketInf,0,sizeof(SOCK_INF));
|
||||
memcpy((void *)TmpSocketInf.IPAddr,DESIP,4);
|
||||
TmpSocketInf.DesPort = desport;
|
||||
TmpSocketInf.SourPort = srcport;
|
||||
TmpSocketInf.ProtoType = PROTO_TYPE_TCP;
|
||||
TmpSocketInf.RecvBufLen = RECE_BUF_LEN;
|
||||
i = WCHNET_SocketCreat(&SocketId,&TmpSocketInf);
|
||||
printf("WCHNET_SocketCreat %d\r\n",SocketId);
|
||||
mStopIfError(i);
|
||||
i = WCHNET_SocketConnect(SocketId);
|
||||
mStopIfError(i);
|
||||
}
|
||||
|
||||
|
||||
@@ -109,59 +108,30 @@ void WCHNET_CreateTcpSocket(void)
|
||||
*/
|
||||
void uartRxAndSendDataToETH(void)
|
||||
{
|
||||
int ret = -1;
|
||||
u8 *p;
|
||||
uint32_t temp = 0;
|
||||
uint32_t len = 0;
|
||||
uint32_t len_1 = 0;
|
||||
uint32_t readindex = 0;
|
||||
|
||||
temp = DMA1_Channel6->CNTR;
|
||||
|
||||
/* uart rx dma CNTR not equal to last, indicating that data is received*/
|
||||
if(temp != uart_data_t.last_RX_DMA_length)
|
||||
{
|
||||
/* calculate the length of the received data */
|
||||
uart_data_t.rx_write += (uart_data_t.last_RX_DMA_length - temp) & (UART_RX_DMA_SIZE - 1);
|
||||
|
||||
/* update last rx dma CNTR */
|
||||
uart_data_t.last_RX_DMA_length = temp;
|
||||
|
||||
/*calculate the length of the RX_buffer */
|
||||
len = uart_data_t.rx_write - uart_data_t.rx_read;
|
||||
|
||||
/* RX_buffer is full */
|
||||
if(len > UART_RX_DMA_SIZE)
|
||||
if(temp < uart_data_t.last_RX_DMA_length)
|
||||
{
|
||||
printf("uart2 RX DMA Buff is full!\r\n");
|
||||
len = 0;
|
||||
uart_data_t.rx_read = 0;
|
||||
uart_data_t.rx_write = 0;
|
||||
uart_data_t.last_RX_DMA_length = 0;
|
||||
len = uart_data_t.last_RX_DMA_length - temp;
|
||||
}
|
||||
|
||||
/* send data starting from rx_read to RX_buffer end */
|
||||
len_1 = MIN(len,UART_RX_DMA_SIZE-(uart_data_t.rx_read&(UART_RX_DMA_SIZE-1)));
|
||||
|
||||
if(len_1 != 0)
|
||||
{
|
||||
ret = WCHNET_SocketSend(SocketId, &uart_data_t.RX_buffer[uart_data_t.rx_read&(UART_RX_DMA_SIZE-1)], &len_1);
|
||||
if (ret == 0)
|
||||
{
|
||||
uart_data_t.rx_read += len_1;
|
||||
}
|
||||
}
|
||||
|
||||
/* send the rest of the data(if any) at beginning of RX_buffer */
|
||||
if( (len-len_1) != 0)
|
||||
{
|
||||
len_1 = len-len_1;
|
||||
ret = WCHNET_SocketSend(SocketId, &uart_data_t.RX_buffer[0], &len_1);
|
||||
if (ret == 0)
|
||||
{
|
||||
uart_data_t.rx_read += len_1;
|
||||
}
|
||||
else {
|
||||
len = uart_data_t.last_RX_DMA_length;
|
||||
}
|
||||
readindex = UART_RX_DMA_SIZE - uart_data_t.last_RX_DMA_length;
|
||||
p = &uart_data_t.RX_buffer[readindex];
|
||||
WCHNET_SocketSend(SocketId, p, &len);
|
||||
uart_data_t.last_RX_DMA_length -= len;
|
||||
if(uart_data_t.last_RX_DMA_length == 0)
|
||||
uart_data_t.last_RX_DMA_length = UART_RX_DMA_SIZE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
@@ -173,16 +143,13 @@ void uartRxAndSendDataToETH(void)
|
||||
*/
|
||||
void uartTx(void)
|
||||
{
|
||||
uint16_t read_buf = 0;
|
||||
|
||||
if(uart_data_t.uart_tx_dma_state == IDLE)
|
||||
{
|
||||
/* eth has received data */
|
||||
if(uart_data_t.tx_remainBuffNum < UART_TX_BUF_NUM)
|
||||
{
|
||||
read_buf = (uart_data_t.tx_read)%UART_TX_BUF_NUM;
|
||||
DMA1_Channel7->MADDR = (uint32_t) &uart_data_t.TX_buffer[read_buf];
|
||||
DMA1_Channel7->CNTR = uart_data_t.TX_data_length[read_buf];
|
||||
DMA1_Channel7->MADDR = (uint32_t) &uart_data_t.TX_buffer[uart_data_t.tx_read];
|
||||
DMA1_Channel7->CNTR = uart_data_t.TX_data_length[uart_data_t.tx_read];
|
||||
uart_data_t.uart_tx_dma_state = BUSY;
|
||||
DMA_Cmd(DMA1_Channel7,ENABLE);
|
||||
}
|
||||
@@ -201,21 +168,21 @@ void uartTx(void)
|
||||
void ETHRx(u8 socketid)
|
||||
{
|
||||
u32 len;
|
||||
uint8_t write_buf = 0;
|
||||
int8_t receive_state = -1;
|
||||
|
||||
len = WCHNET_SocketRecvLen(socketid, NULL); /* query length */
|
||||
|
||||
if( uart_data_t.tx_remainBuffNum > 0)
|
||||
{
|
||||
write_buf = (uart_data_t.tx_write)%UART_TX_BUF_NUM;
|
||||
/* socket receive */
|
||||
receive_state = WCHNET_SocketRecv(socketid, uart_data_t.TX_buffer[write_buf], &len);
|
||||
receive_state = WCHNET_SocketRecv(socketid, uart_data_t.TX_buffer[uart_data_t.tx_write], &len);
|
||||
if(receive_state == WCHNET_ERR_SUCCESS)
|
||||
{
|
||||
uart_data_t.TX_data_length[write_buf] = len;
|
||||
uart_data_t.TX_data_length[uart_data_t.tx_write] = len;
|
||||
|
||||
uart_data_t.tx_write++;
|
||||
/* Prevent access from out-of-bounds */
|
||||
uart_data_t.tx_write = (uart_data_t.tx_write)%UART_TX_BUF_NUM;
|
||||
|
||||
uart_data_t.tx_remainBuffNum--;
|
||||
}
|
||||
@@ -278,26 +245,26 @@ void WCHNET_HandleGlobalInt(void)
|
||||
intstat = WCHNET_GetGlobalInt(); //get global interrupt flag
|
||||
if(intstat & GINT_STAT_UNREACH) //Unreachable interrupt
|
||||
{
|
||||
printf("GINT_STAT_UNREACH\r\n");
|
||||
printf("GINT_STAT_UNREACH\r\n");
|
||||
}
|
||||
if(intstat & GINT_STAT_IP_CONFLI) //IP conflict
|
||||
{
|
||||
printf("GINT_STAT_IP_CONFLI\r\n");
|
||||
}
|
||||
if(intstat & GINT_STAT_PHY_CHANGE) //PHY status change
|
||||
{
|
||||
i = WCHNET_GetPHYStatus(); //socket related interrupt
|
||||
if(i&PHY_Linked_Status)
|
||||
printf("PHY Link Success\r\n");
|
||||
}
|
||||
if(intstat & GINT_STAT_SOCKET)
|
||||
{
|
||||
for(i = 0; i < WCHNET_MAX_SOCKET_NUM; i ++)
|
||||
{
|
||||
socketint = WCHNET_GetSocketInt(i);
|
||||
if(socketint)WCHNET_HandleSockInt(i,socketint);
|
||||
}
|
||||
}
|
||||
if(intstat & GINT_STAT_IP_CONFLI) //IP conflict
|
||||
{
|
||||
printf("GINT_STAT_IP_CONFLI\r\n");
|
||||
}
|
||||
if(intstat & GINT_STAT_PHY_CHANGE) //PHY status change
|
||||
{
|
||||
i = WCHNET_GetPHYStatus(); //socket related interrupt
|
||||
if(i&PHY_Linked_Status)
|
||||
printf("PHY Link Success\r\n");
|
||||
}
|
||||
if(intstat & GINT_STAT_SOCKET)
|
||||
{
|
||||
for(i = 0; i < WCHNET_MAX_SOCKET_NUM; i ++)
|
||||
{
|
||||
socketint = WCHNET_GetSocketInt(i);
|
||||
if(socketint)WCHNET_HandleSockInt(i,socketint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
@@ -313,19 +280,22 @@ int main(void)
|
||||
|
||||
Delay_Init();
|
||||
USART_Printf_Init(115200); //USART initialize
|
||||
printf("ETH_UART\r\n");
|
||||
printf("SystemClk:%d\r\n",SystemCoreClock);
|
||||
printf("net version:%x\n",WCHNET_GetVer());
|
||||
if( WCHNET_LIB_VER != WCHNET_GetVer() ){
|
||||
printf("version error.\n");
|
||||
printf("ETH_UART\r\n");
|
||||
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()){
|
||||
printf("version error.\n");
|
||||
}
|
||||
WCHNET_GetMacAddr(MACAddr); //get the chip MAC address
|
||||
printf("mac addr:");
|
||||
for(i = 0; i < 6; i++)
|
||||
printf("%x ",MACAddr[i]);
|
||||
printf("%x ", MACAddr[i]);
|
||||
printf("\n");
|
||||
TIM2_Init();
|
||||
BSP_Uart_Init(); //USART2 initialize
|
||||
BSP_Uart_Init(BAUD_RATE); //USART2 initialize
|
||||
i = ETH_LibInit(IPAddr,GWIPAddr,IPMask,MACAddr); //Ethernet library initialize
|
||||
mStopIfError(i);
|
||||
if(i == WCHNET_ERR_SUCCESS) printf("WCHNET_LibInit Success\r\n");
|
||||
@@ -336,7 +306,7 @@ int main(void)
|
||||
{
|
||||
/*Ethernet library main task function,
|
||||
* which needs to be called cyclically*/
|
||||
WCHNET_MainTask();
|
||||
WCHNET_MainTask();
|
||||
/*Query the Ethernet global interrupt,
|
||||
* if there is an interrupt, call the global interrupt handler*/
|
||||
if(WCHNET_QueryGlobalInt())
|
||||
|
||||
@@ -29,10 +29,12 @@ extern "C" {
|
||||
#define WCHNET_NUM_TCP_LISTEN 0 /* 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 1460 /* 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