银杏科技有限公司旗下技术文档发布平台 | |||
技术支持电话 | 0379-69926675-801 | ||
技术支持邮件 | Gingko@vip.163.com | ||
购买链接 | 点击购买 | ||
版本 | 日期 | 作者 | 修改内容 |
---|---|---|---|
V0.1 | 20201021 | FMJ | 初次建立 |
int main(void) { /* USER CODE BEGIN 1 */ int cnt; /* USER CODE END 1 */ /*MCU Configuration-----------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ i2c.initialize(); axp152.initialize(); axp152.set_dcdc1(3500);//[ARM & FPGA BK1/2/6 &OTHER] axp152.set_dcdc2(1200);//[FPGA INT & PLL D] axp152.set_aldo1(2500);//[FPGA PLL A] axp152.set_dcdc4(3300);//[POWER_OUTPUT] axp152.set_dcdc3(3300);//[FPGA BK4][Adjustable] axp152.set_aldo2(3300);//[FPGA BK3][Adjustable] axp152.set_dldo1(3300);//[FPGA BK7][Adjustable] axp152.set_dldo2(3300);//[FPGA BK5][Adjustable] /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); MX_ETH_Init(); MX_USART2_UART_Init(); /* USER CODE BEGIN 2 */ usart2.printf("\033[1;32;40m");//设置字体终端为绿色 usart2.printf("\r\nHello, I am iCore4T!\r\n"); //串口信息输出 //LWIP初始化 while(lwip.initialize())//lwip初始化 { //ETH初始化失败 usart2.printf("\r\nETH initialize error!\r\n\r\n"); } NETMPU_Config(); eth_tcps.initialize(); usart2.initialize(115200); /* USER CODE END 2 */ /* Infinite loop */ /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ if((cnt ++ / 800000) % 2){ LED_ON; }else{ LED_OFF; } lwip.periodic_handle(); key.process(); //tcp process if(eth_tcps.receive_ok_flag == 1){ eth_tcps.receive_ok_flag = 0; eth_tcps.send_data(eth_tcps.tcppcbnew); } } /* USER CODE END 3 */ }
static void dns_test(const char *hostname) { struct ip_addr cipaddr_DNS; //获取域名信息 dns_gethostbyname(hostname,&cipaddr_DNS,NULL,NULL); //将解析到的IP转换为字符串 char *ptr = ip_ntoa(&cipaddr_DNS); usart2.printf("解析 %s 网址\r\n",hostname); usart2.printf("解析的DNS: %s\r\n",ptr); }
static void process(void) { //按键处理 if(key.value != key.bak_value){ switch(key.value){ case ARM_KEY: lwip.lwip_dhcp_task();//获取DHCP信息 my_dns.dns_test("www.baidu.com");//对百度进行域名解析 break; } key.bak_value = key.value; } }