Using TUD_CONFIG_DESCRIPTOR and TUD_HID_DESCRIPTOR in tinyusb library for USB device creation

384 Views Asked by At

I need help for creating an USB HID device using tinyusb library.

When I looked offical usb documentation. I saw something like belown picture

enter image description here

tiny usb library has a typedef for device descriptor but I didnt find any typedef for Configuration and interface descriptor. That library uses TUD_CONFIG_DESCRIPTOR and TUD_HID_DESCRIPTOR macro for that.

And these macros are :

#define TUD_CONFIG_DESCRIPTOR(config_num, _itfcount, _stridx, _total_len, _attribute, _power_ma) \
  9, TUSB_DESC_CONFIGURATION, U16_TO_U8S_LE(_total_len), _itfcount, config_num, _stridx, TU_BIT(7) | _attribute, (_power_ma)/2

#define TUD_HID_DESCRIPTOR(_itfnum, _stridx, _boot_protocol, _report_desc_len, _epin, _epsize, _ep_interval) \
  /* Interface */\
  9, TUSB_DESC_INTERFACE, _itfnum, 0, 1, TUSB_CLASS_HID, (uint8_t)((_boot_protocol) ? (uint8_t)HID_SUBCLASS_BOOT : 0), _boot_protocol, _stridx,\
  /* HID descriptor */\
  9, HID_DESC_TYPE_HID, U16_TO_U8S_LE(0x0111), 0, 1, HID_DESC_TYPE_REPORT, U16_TO_U8S_LE(_report_desc_len),\
  /* Endpoint In */\
  7, TUSB_DESC_ENDPOINT, _epin, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_epsize), _ep_interval

So I did not get how can I use these macros parameters.

Thanks for helps

Did not find any documentation

0

There are 0 best solutions below