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
  • > What would constitute an "interface"? Does it encapsulate a class with the associated class methods?

    Interface is as name suggest a way to communicate with a device regarding one specific data exchange.
    A class can contain multiple interfaces, for example CDC class contains communication and data interfaces, over communication interface status changes are reported and over data interface data are exchanged in both directions.

    > Where in the code does it bind the "interface" to the class?
    >For example, if a device declares that it has three interface, how does it associates each interface to the actual firmware codes?

    Depends on the code but each interface has an unique number inside of device and each class contains 1 or more interfaces, this is all described in configuration descriptor, then host when it parses the configuration descriptor finds out what your device consists of, which classes and which interfaces.
    This depends on firmware but usually by interface index, as each interface has unique index in a device (or more exactly in each device configuration as a device can have more than one configurations possible).

    > When the host request for an "interface", what would it get in return or what would be the purpose of asking for an interface?

    If you are talking about SetInterface that is a way of activating a particular interface, if you are talking about control request from/to interface, that is a way for host to control controllable functionality of interface.

Reply
  • > What would constitute an "interface"? Does it encapsulate a class with the associated class methods?

    Interface is as name suggest a way to communicate with a device regarding one specific data exchange.
    A class can contain multiple interfaces, for example CDC class contains communication and data interfaces, over communication interface status changes are reported and over data interface data are exchanged in both directions.

    > Where in the code does it bind the "interface" to the class?
    >For example, if a device declares that it has three interface, how does it associates each interface to the actual firmware codes?

    Depends on the code but each interface has an unique number inside of device and each class contains 1 or more interfaces, this is all described in configuration descriptor, then host when it parses the configuration descriptor finds out what your device consists of, which classes and which interfaces.
    This depends on firmware but usually by interface index, as each interface has unique index in a device (or more exactly in each device configuration as a device can have more than one configurations possible).

    > When the host request for an "interface", what would it get in return or what would be the purpose of asking for an interface?

    If you are talking about SetInterface that is a way of activating a particular interface, if you are talking about control request from/to interface, that is a way for host to control controllable functionality of interface.

Children