How to create a composite HID device using NCS?

Hi,

I'm implementing a composite hid device using nrf connect sdk 2.0.0, I do checked the hid-cdc and hid alone samples but there's still few problems that confused me a lot.

1. How to create as many interfaces and dedicated endpoints as I want (I'm well aware of the hardware limitation and it won't be a problem), like both IN and OUT for interface 0 and IN alone for interface 1?

2.How to create something like irq handler in ncs so I can handle the interrupt OUT endpoint without polling the buffer?

3.What Kconfig options do I need?

I made my purpose using another usb stack on another chip, but ncs confuses me a lot. I find it quite hard to understand how descriptors are handled.

Thanks in advance.

Parents
  • Hi,

    I will look into your case and return with more information tomorrow.

    Regards,
    Sigurd Hellesvik

  • Is there any progress? I got enough endpoints (IN*2 and OUT*2) with sufficient size (all 64 bytes), but I still wonder if there is a more appropriate way.

  • Hi,

    1. How to create as many interfaces and dedicated endpoints as I want (I'm well aware of the hardware limitation and it won't be a problem), like both IN and OUT for interface 0 and IN alone for interface 1?

    From the hid-cdc sample, I believe you can add interfaces by adding them to the devicetree, as seen in app.overlay.

    For the built-in HID support in Zephyr/NCS, Interrupt OUT endpoint can be enabled by the Kconfig option ENABLE_HID_INT_OUT_EP, and because it is Kconfig option the effect is global, any USB HID interface would have OUT endpoint enabled. The only workaround is to use HID core code in Zephyr as reference and implement own specific interface.

    2.How to create something like irq handler in ncs so I can handle the interrupt OUT endpoint without polling the buffer?

    I can see that the USB Human Interface Devices (HID) support has some types for callbacks.
    We have no examples showcasing these, so you would have to use them with only guidance from these docs.

    Our Bluetooth Low Energy HIDS Mouse has another solution to this: polling in a Workqueue Thread, see the sample code.

    I asked our developers about this as well, and they say:
    There is struct hid_ops which can be passed as argument to the function usb_hid_register_device(), see samples/subsys/usb/hid/src/main.c, int_in_ready callback can be used for notification when a packet has been transmitted (to the host) and int_out_ready when there is a new OUT packet.

    3.What Kconfig options do I need?

    I think you will find all the configurations you need in the examples I listed above. Other than that, our VS Code nRF Kconfig extension and our Kconfig search are useful tools.

    See options such as ENABLE_HID_INT_OUT_EP, HID_INTERRUPT_EP_MPS and anything prefixed with USB_HID_.

    Does this answer your questions?

    Regards,
    Sigurd Hellesvik

Reply
  • Hi,

    1. How to create as many interfaces and dedicated endpoints as I want (I'm well aware of the hardware limitation and it won't be a problem), like both IN and OUT for interface 0 and IN alone for interface 1?

    From the hid-cdc sample, I believe you can add interfaces by adding them to the devicetree, as seen in app.overlay.

    For the built-in HID support in Zephyr/NCS, Interrupt OUT endpoint can be enabled by the Kconfig option ENABLE_HID_INT_OUT_EP, and because it is Kconfig option the effect is global, any USB HID interface would have OUT endpoint enabled. The only workaround is to use HID core code in Zephyr as reference and implement own specific interface.

    2.How to create something like irq handler in ncs so I can handle the interrupt OUT endpoint without polling the buffer?

    I can see that the USB Human Interface Devices (HID) support has some types for callbacks.
    We have no examples showcasing these, so you would have to use them with only guidance from these docs.

    Our Bluetooth Low Energy HIDS Mouse has another solution to this: polling in a Workqueue Thread, see the sample code.

    I asked our developers about this as well, and they say:
    There is struct hid_ops which can be passed as argument to the function usb_hid_register_device(), see samples/subsys/usb/hid/src/main.c, int_in_ready callback can be used for notification when a packet has been transmitted (to the host) and int_out_ready when there is a new OUT packet.

    3.What Kconfig options do I need?

    I think you will find all the configurations you need in the examples I listed above. Other than that, our VS Code nRF Kconfig extension and our Kconfig search are useful tools.

    See options such as ENABLE_HID_INT_OUT_EP, HID_INTERRUPT_EP_MPS and anything prefixed with USB_HID_.

    Does this answer your questions?

    Regards,
    Sigurd Hellesvik

Children
Related