This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Beginner question on what constitutes a device USB interface

Been reading through the USB document and going through the codes but still having a bit of trouble grasping the concept of an interface.
What would constitute an "interface"? Does it encapsulate a class with the associated class methods?
Where in the code does it bind the "interface" to the class?
When the host request for an "interface", what would it get in return or what would be the purpose of asking for an interface?
For example, if a device declares that it has three interface, how does it associates each interface to the actual firmware codes?
Thanks.

Parents
  • Hi John,

    Thanks for the link. I actually was reading the same document and reading the codes but it's taking awhile to digest all the information.

    I am trying to use the STM32F4 in device mode with USB to interface to the PC. The STM32F4 will then be controlled from the PC to talk to other devices using either I2C or general purpose I/O. I am thinking of using HID interface because it seems like the driver is already part of the OS so a little less work. Currently I am using the STM USART to talk to the PC but I am trying to switch to USB because it's a better solution.

    I was able to get some of the USB example such as the DFU, HID mouse ... to work but some of the concepts are still a little bit muddy.

Reply
  • Hi John,

    Thanks for the link. I actually was reading the same document and reading the codes but it's taking awhile to digest all the information.

    I am trying to use the STM32F4 in device mode with USB to interface to the PC. The STM32F4 will then be controlled from the PC to talk to other devices using either I2C or general purpose I/O. I am thinking of using HID interface because it seems like the driver is already part of the OS so a little less work. Currently I am using the STM USART to talk to the PC but I am trying to switch to USB because it's a better solution.

    I was able to get some of the USB example such as the DFU, HID mouse ... to work but some of the concepts are still a little bit muddy.

Children
  • I don't know much about USB, but Milorad Cvjetkovic knows USB very well.
    Back to your last question,
    -> Would USBD_HandleTypeDef be considered an interface or a configuration?

    I believe USBD_HandleTypeDef represents an USB device.

    /**
    * @brief  USBD_SetClassConfig
    *        Configure device and start the interface
    * @param  pdev: device instance
    * @param  cfgidx: configuration index
    * @retval status
    */
    
    USBD_StatusTypeDef USBD_SetClassConfig(USBD_HandleTypeDef  *pdev, uint8_t cfgidx)
    {
      USBD_StatusTypeDef   ret = USBD_FAIL;
    
      if(pdev->pClass != NULL)
      {
        /* Set configuration  and Start the Class*/
        if(pdev->pClass->Init(pdev, cfgidx) == 0)
        {
          ret = USBD_OK;
        }
      }
      return ret;
    }
    
    /**
    * @brief  USBD_ClrClassConfig
    *         Clear current configuration
    * @param  pdev: device instance
    * @param  cfgidx: configuration index
    * @retval status: USBD_StatusTypeDef
    */
    USBD_StatusTypeDef USBD_ClrClassConfig(USBD_HandleTypeDef  *pdev, uint8_t cfgidx)
    {
      /* Clear configuration  and Deinitialize the Class process*/
      pdev->pClass->DeInit(pdev, cfgidx);
      return USBD_OK;
    }