新手上路
- 积分
- 43
- 金钱
- 43
- 注册时间
- 2018-7-9
- 在线时间
- 23 小时
|
20金钱
本帖最后由 憧憬明天 于 2024-5-16 15:33 编辑
连接网线,并且界面有刷新的时候(比如键盘操作,或者条形进度条更新进度),屏幕会随机的颤抖一下。
界面没有刷新动作或者不连网线的时候,都不会抖。
- void USR_LWIP_Init(void)
- {
- struct netif* ptNetIf;
- u32 iLocalIp = g_SetInfo.uiIpLocal;
- u32 iNetMsk = g_SetInfo.uiNetMsk;
- u32 iGw = g_SetInfo.uiGw;
- /* Initilialize the LwIP stack with RTOS */
- tcpip_init( NULL, NULL );
- #if LWIP_DHCP
- /* IP addresses initialization with DHCP (IPv4) */
- lwipdev.tIpLocal.addr = 0;
- lwipdev.tNetMask.addr = 0;
- lwipdev.tGateWay.addr = 0;
- #endif
- /* add the network interface (IPv4/IPv6) with RTOS */
- IP4_ADDR(&lwipdev.tIpLocal,iLocalIp&0xff,(iLocalIp>>8)&0xff,(iLocalIp>>16)&0xff,(iLocalIp>>24)&0xff);
- IP4_ADDR(&lwipdev.tNetMask,iNetMsk&0xff,(iNetMsk>>8)&0xff,(iNetMsk>>16)&0xff,(iNetMsk>>24)&0xff);
- IP4_ADDR(&lwipdev.tGateWay,iGw&0xff,(iGw>>8)&0xff,(iGw>>16)&0xff,(iGw>>24)&0xff);
- ptNetIf = netif_add(&lwip_netif, &(lwipdev.tIpLocal), &(lwipdev.tNetMask), &(lwipdev.tGateWay),NULL,ðernetif_init,&tcpip_input);
- /* Registers the default network interface */
- netif_set_default(&lwip_netif);
- if(netif_is_link_up(&lwip_netif))
- {
- /* When the netif is fully configured this function must be called */
- netif_set_up(&lwip_netif);
- }
- else
- {
- /* When the netif link is down this function must be called */
- netif_set_down(&lwip_netif);
- }
-
- /* Set the link callback function, this function is called on change of link status*/
- netif_set_link_callback(&lwip_netif, ethernetif_update_config);
- #if LWIP_DHCP
- /* Start DHCP negotiation for a network interface (IPv4) */
- lwipdev.dhcpstatus = 0;
- dhcp_start(&lwip_netif);
- #endif
- xTaskCreate((TaskFunction_t )ethernetif_set_link,
- (const char* )"ethernetif_set_link",
- (uint16_t )NET_LINK_SIZE,
- (void* )&lwip_netif,
- (UBaseType_t )NET_LINK_PRIO,
- (TaskHandle_t* )&NetLink_Handler);
- }
- void ethernetif_set_link(void *argument)
- {
- uint32_t regvalue = 0;
- struct netif *gnetif = (struct netif *)argument;
-
- for(;;)
- {
- /* Read PHY_BSR*/
- HAL_ETH_ReadPHYRegister(Ð_Handler, PHY_BSR, ®value);
-
- regvalue &= PHY_LINKED_STATUS;
-
- /* Check whether the netif link down and the PHY link is up */
- if(!netif_is_link_up(gnetif) && (regvalue))
- {
- /* network cable is connected */
- netif_set_link_up(gnetif);
- }
- else if(netif_is_link_up(gnetif) && (!regvalue))
- {
- /* network cable is dis-connected */
- netif_set_link_down(gnetif);
- }
-
- /* Suspend thread for 200 ms */
- vTaskDelay(200);
- }
- }
复制代码
|
|