update 1.8
This commit is contained in:
@@ -11,12 +11,11 @@
|
||||
*******************************************************************************/
|
||||
/*
|
||||
*@Note
|
||||
IPRaw_PING example, demonstrate the PING feature.
|
||||
IPRaw_PING example, demonstrate the PING function.
|
||||
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 "PING.h"
|
||||
|
||||
@@ -56,16 +55,14 @@ void mStopIfError(u8 iError)
|
||||
void TIM2_Init( void )
|
||||
{
|
||||
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure={0};
|
||||
|
||||
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;
|
||||
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
|
||||
TIM_ITConfig(TIM2, TIM_IT_Update ,ENABLE);
|
||||
|
||||
TIM_Cmd(TIM2, ENABLE);
|
||||
TIM_ClearITPendingBit(TIM2, TIM_IT_Update );
|
||||
NVIC_EnableIRQ(TIM2_IRQn);
|
||||
@@ -80,17 +77,17 @@ void TIM2_Init( void )
|
||||
*/
|
||||
void WCHNET_CreateIPRawSocket(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.SourPort = IPRawProto; //In IPRAW mode, SourPort is the protocol type
|
||||
TmpSocketInf.ProtoType = PROTO_TYPE_IP_RAW;
|
||||
TmpSocketInf.RecvStartPoint = (u32)SocketRecvBuf;
|
||||
TmpSocketInf.RecvBufLen = RECE_BUF_LEN ;
|
||||
i = WCHNET_SocketCreat(&SocketId,&TmpSocketInf);
|
||||
mStopIfError(i);
|
||||
memset((void *)&TmpSocketInf,0,sizeof(SOCK_INF));
|
||||
memcpy((void *)TmpSocketInf.IPAddr,DESIP,4);
|
||||
TmpSocketInf.SourPort = IPRawProto; //In IPRAW mode, SourPort is the protocol type
|
||||
TmpSocketInf.ProtoType = PROTO_TYPE_IP_RAW;
|
||||
TmpSocketInf.RecvStartPoint = (u32)SocketRecvBuf;
|
||||
TmpSocketInf.RecvBufLen = RECE_BUF_LEN ;
|
||||
i = WCHNET_SocketCreat(&SocketId,&TmpSocketInf);
|
||||
mStopIfError(i);
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
@@ -179,24 +176,28 @@ int main(void)
|
||||
|
||||
Delay_Init();
|
||||
USART_Printf_Init(115200); //USART initialize
|
||||
printf("IPRaw_PING Test\r\n");
|
||||
printf("SystemClk:%d\r\n",SystemCoreClock);
|
||||
printf("IPRaw_PING 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");
|
||||
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();
|
||||
i = ETH_LibInit(IPAddr,GWIPAddr,IPMask,MACAddr); //Ethernet library initialize
|
||||
mStopIfError(i);
|
||||
if(i == WCHNET_ERR_SUCCESS) printf("WCHNET_LibInit Success\r\n");
|
||||
WCHNET_CreateIPRawSocket(); //create IPRAW socket
|
||||
InitParameter( );
|
||||
InitPING( );
|
||||
InitParameter();
|
||||
InitPING();
|
||||
|
||||
while(1)
|
||||
{
|
||||
/*Ethernet library main task function,
|
||||
|
||||
Reference in New Issue
Block a user