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 -11
View File
@@ -16,7 +16,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"
u8 MACAddr[6]; //MAC address
@@ -60,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;
@@ -126,9 +125,10 @@ void WCHNET_DataLoopback(u8 id)
}
#else
u32 len, totallen;
u8 *p = MyBuf;
u8 *p = MyBuf, TransCnt = 255;
len = WCHNET_SocketRecvLen(id, NULL); //query length
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){
@@ -136,7 +136,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
@@ -217,6 +218,8 @@ void WCHNET_HandleGlobalInt(void)
* @brief DHCPCallBack
*
* @param status - status returned by DHCP
* 0x00 - Success
* 0x01 - Failure
* arg - Data returned by DHCP
*
* @return DHCP status
@@ -246,7 +249,7 @@ u8 WCHNET_DHCPCallBack(u8 status, void *arg)
(u16)IPAddr[2], (u16)IPAddr[3]);
printf("GWIPAddr = %d.%d.%d.%d \r\n", (u16)GWIPAddr[0], (u16)GWIPAddr[1],
(u16)GWIPAddr[2], (u16)GWIPAddr[3]);
printf("IPAddr = %d.%d.%d.%d \r\n", (u16)IPMask[0], (u16)IPMask[1],
printf("IPMask = %d.%d.%d.%d \r\n", (u16)IPMask[0], (u16)IPMask[1],
(u16)IPMask[2], (u16)IPMask[3]);
printf("DNS1: %d.%d.%d.%d \r\n", p[12], p[13], p[14], p[15]);
printf("DNS2: %d.%d.%d.%d \r\n", p[16], p[17], p[18], p[19]);
@@ -278,16 +281,19 @@ int main(void)
Delay_Init();
USART_Printf_Init(115200); //USART initialize
printf("DHCP Test\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("DHCP 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()){
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();
WCHNET_DHCPSetHostname("WCHNET"); //Configure DHCP host name