update 1.8
This commit is contained in:
@@ -11,12 +11,12 @@
|
||||
*******************************************************************************/
|
||||
/*
|
||||
*@Note
|
||||
DNS example ,demonstrate that DHCP automatically obtains an IP address and then requests domain name resolution.
|
||||
DNS example ,demonstrate that DHCP automatically obtains
|
||||
an IP address and then requests domain name resolution.
|
||||
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
|
||||
@@ -56,7 +56,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;
|
||||
@@ -182,7 +182,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]); //DNS server address provided by the router
|
||||
printf("DNS2: %d.%d.%d.%d \r\n", p[16], p[17], p[18], p[19]);
|
||||
@@ -211,16 +211,19 @@ int main(void)
|
||||
|
||||
Delay_Init();
|
||||
USART_Printf_Init(115200); //USART initialize
|
||||
printf("DNS Test\r\n");
|
||||
printf("SystemClk:%d\r\n",SystemCoreClock);
|
||||
printf("net version:%x\n",WCHNET_GetVer());
|
||||
if( WCHNET_LIB_VER != WCHNET_GetVer() ){
|
||||
printf("DNS 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
|
||||
|
||||
Reference in New Issue
Block a user