support class drivers implemented by application

This commit is contained in:
hathach
2020-04-29 10:49:58 +07:00
parent b52bc894f8
commit c14c0cfc9f
2 changed files with 88 additions and 51 deletions

View File

@@ -33,6 +33,29 @@
extern "C" {
#endif
//--------------------------------------------------------------------+
// Class Drivers
//--------------------------------------------------------------------+
typedef struct
{
#if CFG_TUSB_DEBUG >= 2
char const* name;
#endif
void (* init ) (void);
void (* reset ) (uint8_t rhport);
bool (* open ) (uint8_t rhport, tusb_desc_interface_t const * desc_intf, uint16_t* p_length);
bool (* control_request ) (uint8_t rhport, tusb_control_request_t const * request);
bool (* control_complete ) (uint8_t rhport, tusb_control_request_t const * request);
bool (* xfer_cb ) (uint8_t rhport, uint8_t ep_addr, xfer_result_t event, uint32_t xferred_bytes);
void (* sof ) (uint8_t rhport); /* optional */
} usbd_class_driver_t;
// Invoked when initializing device stack to get additional class drivers.
// Can optionally implemented by application to extend/overwrite class driver support.
usbd_class_driver_t const* usbd_app_driver_get_cb(uint8_t* driver_count) TU_ATTR_WEAK;
//--------------------------------------------------------------------+
// USBD Endpoint API
//--------------------------------------------------------------------+