基本信息
源码名称:STM32F103+W5500 DNS域名解析
源码大小:0.34M
文件格式:.zip
开发语言:C/C++
更新时间:2021-06-17
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300

本次赞助数额为: 2 元 
   源码介绍
单片机STM32F103C8T6连接W5500解析域名IP。

#include "usart.h"
#include "device.h"
#include "spi2.h"
#include "ult.h"
#include "socket.h"
#include "w5500.h"
#include "24c16.h"
#include "md5.h"
#include "string.h"
#include "config.h"
#include "dns.h"

extern uint8 txsize[];										// 引用外部变量,声明Socket发送缓存大小
extern uint8 rxsize[];										// 引用外部变量,声明Socket接收缓存大小

uint8 buffer[2048];												// 定义一个2KB的数组,用来存放Socket的通信数据

int main(void)
{
	uint8 len,dns_flag=0;										// 定义串口输入的数据长度、初始化DNS标志位
	
	/***** MCU时钟初始化 *****/							  
	Systick_Init(72);	
	
	/***** 中断配置 *****/
	NVIC_Configuration();
	
	/***** GPIO、SPI初始化 *****/
	GPIO_Configuration();			
	WIZ_SPI_Init();
	
	/***** 串口初始化 *****/
	USART1_Init(); 		
	
	/***** 初始化eeprom *****/
  at24c16_init();
	
	/***** 硬重启W5500 *****/
	Reset_W5500();
			
	/***** IP信息配置 *****/	
	set_default();
	set_network();
 
	printf("W5500 Init Complete!\r\n");
  printf("Start DNS Test!\r\n");	
	printf("\r\nInput the domain name(eg>>www.baidu.com):");	
	
	while(1)
	{ 	
		if(USART_RX_STA&0x8000)								// 串口数据发送
		{				   
			len=USART_RX_STA&0x3fff;
			memcpy(buffer,USART_RX_BUF,len);
			USART_RX_STA=0;
			memset(USART_RX_BUF,0,len 1);
			printf("\r\n[ %s ]'s IP Address is:\r\n",buffer);
			dns_flag=1;													// DNS标志位置1
		}
		if(dns_flag==1)
		{			
			if(dns_num>=6)											// DNS次数≥6
			{
				dns_flag=0;												// DNS标志位清0
				dns_num=0;												// dns_num清0
				printf("\r\nInput the domain name(eg>>www.baidu.com):");
			}
			else
				do_dns(buffer);										// DNS过程
		}
	}
}