2016-07-21 12:41 AM
Hi I'm trying to recognize what USB device attached on the USBH OTG line and send the information over TCP with LwIP library to a server. I can recognize devices with HID standalone application. Then I've combined the LwIP TCP Client echo with it. But when I call the Netif_Config() function, USBH_HandleEnum() function not working so devices cannot be recognized. Netif_Config and USBH_HandleEnum functions exactly the same functions with application examples. My main;
int main(void)
{
HAL_Init();
SystemClock_Config();
BSP_Config();
HID_InitApplication();
USBH_Init(&hUSBH, USBH_UserProcess, 0);
USBH_RegisterClass(&hUSBH, USBH_HID_CLASS);
USBH_Start(&hUSBH);
lwip_init();
Netif_Config();
User_notification(&gnetif);
while (1)
{
USBH_Process(&hUSBH);
HID_MenuProcess();
ethernetif_input(&gnetif);
sys_check_timeouts();
}
}
void Netif_Config(void)
{
ip_addr_t ipaddr;
ip_addr_t netmask;
ip_addr_t gw;
#ifdef USE_DHCP
ipaddr.addr = 0;
netmask.addr = 0;
gw.addr = 0;
#else
IP4_ADDR(&ipaddr, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3);
IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1, NETMASK_ADDR2, NETMASK_ADDR3);
IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
#endif
netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, ðernet_input);
netif_set_default(&gnetif);
if (netif_is_link_up(&gnetif))
{
netif_set_up(&gnetif);
}
else
{
netif_set_down(&gnetif);
}
netif_set_link_callback(&gnetif, Ethernet_update_config);
}
When I close the netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, &Ethernet_input); line USBH_HandleEnum funcion is working with no problem. But I'm new in LwIP and I didn't understand why it can be.
2016-07-21 12:57 AM
It is about sort of initialize. When I inited first the LwIP then USB problem gone. But I want to learn its reason. Thanks.