update 1.8

This commit is contained in:
qiyongshuang
2023-09-06 10:08:11 +08:00
parent b79c6ac80d
commit 64be955461
760 changed files with 42517 additions and 30957 deletions
+17 -13
View File
@@ -11,15 +11,15 @@
*******************************************************************************/
/*
*@Note
TCP Server example, demonstrating that TCP Server receives data and sends back after connecting to a client.
TCP Server example, demonstrating that TCP Server
receives data and sends back after connecting to a client.
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"
#define KEEPALIVE_ENABLE 1 //Enable keep alive function
#define KEEPALIVE_ENABLE 1 //Enable keep alive function
u8 MACAddr[6]; //MAC address
u8 IPAddr[4] = { 192, 168, 1, 10 }; //IP address
@@ -60,7 +60,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;
@@ -121,11 +121,11 @@ void WCHNET_DataLoopback(u8 id)
WCHNET_SocketRecv(id, NULL, &len); //Clear sent data
}
#else
u32 len, totallen;
u8 *p = MyBuf;
uint32_t len, totallen;
uint8_t *p = MyBuf, TransCnt = 255;
len = WCHNET_SocketRecvLen(id, NULL); //query length
printf("Receive Len = %02x\n", len);
printf("Receive Len = %d\r\n", len);
totallen = len;
WCHNET_SocketRecv(id, MyBuf, &len); //Read the data of the receive buffer into MyBuf
while(1){
@@ -133,7 +133,8 @@ void WCHNET_DataLoopback(u8 id)
WCHNET_SocketSend(id, p, &len); //Send the data
totallen -= len; //Subtract the sent length from the total length
p += len; //offset buffer pointer
if(totallen)continue; //If the data is not sent, continue to send
if( !--TransCnt ) break; //Timeout exit
if(totallen) continue; //If the data is not sent, continue to send
break; //After sending, exit
}
#endif
@@ -244,16 +245,19 @@ int main(void)
u8 i;
Delay_Init();
USART_Printf_Init(115200); //USART initialize
printf("TcpServer Test\r\n");
printf("SystemClk:%d\r\n", SystemCoreClock);
printf("TCPServer Test\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()) {
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]);
for(i = 0; i < 6; i++)
printf("%x ",MACAddr[i]);
printf("\n");
TIM2_Init();
i = ETH_LibInit(IPAddr, GWIPAddr, IPMask, MACAddr); //Ethernet library initialize