diff options
Diffstat (limited to 'usb_common.h')
-rw-r--r-- | usb_common.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/usb_common.h b/usb_common.h new file mode 100644 index 0000000..f0ed844 --- /dev/null +++ b/usb_common.h @@ -0,0 +1,49 @@ +#ifndef _USB_COMMON_H_ +#define _USB_COMMON_H_ + +/* Strings ********************************************************************/ + +enum { + /* Be sure to keep this list in-sync with + * usb_common.c:tud_descriptor_string_cb() */ + STRID_LANGID = 0, + STRID_MANUF, + STRID_PRODUCT, + STRID_SERIAL, + STRID_CFG, + STRID_KBD_IFC, + + STRID_NONE = 0, +}; + +/* Globals ********************************************************************/ + +extern uint8_t cfgnum_std; +void usb_common_init(void); + +/* Main utilities *************************************************************/ + +/** + * Declare a new TUD configuration. + * + * @param iConfiguration : ID of the string descriptor describing this configuration + * @param bmAttributes : bitmap of flags; TUSB_DESC_CONFIG_ATT_{REMOTE_WAKUP,SELF_POWERED} + * @param bMaxPower_mA : maximum power consumption of the device when in this configuration, in mA + * @return the configuration number for the created config + */ +uint8_t usb_add_config(uint8_t iConfiguration, uint8_t bmAttributes, uint8_t bMaxPower_mA); + +/** + * Add an interface to a configuration that has been created with usb_add_config(). + * + * @param cfg_num : the value returned from usb_add_config() + * @param ifc_len : the length of ifc_Dat + * @param ifc_dat : the raw descriptor data for the interface (probably created by + * TUD_{CLASS}_DESCRIPTOR(); grep TinyUSB/src/device/usbd.h for '#define + * TUD_\S*_DESCRIPTOR(_itfnum'). The interface number in this data is overwritten with the + * appropriate number for this config. + * @return the interface number for the added interface + */ +uint8_t usb_add_interface(uint8_t cfg_num, uint16_t ifc_len, uint8_t *ifc_dat); + +#endif /* _USB_COMMON_H_ */ |