cancel
Showing results for 
Search instead for 
Did you mean: 

STM3241G-Eval + LwIP + USB_Host_Library Problem with handling USB devices

Posted on July 21, 2016 at 09:41

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, &ethernetif_init, &ethernet_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, &ethernetif_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.

1 REPLY 1
Posted on July 21, 2016 at 09:57

It is about sort of initialize. When I inited first the LwIP then USB problem gone. But I want to learn its reason. Thanks.