remove control from class driver array

This commit is contained in:
hathach 2018-11-14 23:39:58 +07:00
parent 5757918df4
commit 95cd6c3a2f
3 changed files with 11 additions and 20 deletions

View File

@ -54,9 +54,6 @@ void controld_reset(uint8_t rhport) {
control_state.current_stage = CONTROL_STAGE_SETUP;
}
void controld_init(void) {
}
// Helper to send STATUS (zero length) packet
// Note dir is value of direction bit in setup packet (i.e DATA stage direction)
static inline bool dcd_control_status(uint8_t rhport, uint8_t dir)

View File

@ -76,8 +76,6 @@ tusb_error_t tud_control_interface_control_cb(uint8_t rhport, uint8_t interface,
//--------------------------------------------------------------------+
// INTERNAL API
//--------------------------------------------------------------------+
void controld_init(void);
tusb_error_t controld_open(uint8_t rhport, tusb_desc_interface_t const * p_interface_desc, uint16_t *p_length);
// This tracks the state of a control request.

View File

@ -104,16 +104,6 @@ typedef struct {
static usbd_class_driver_t const usbd_class_drivers[] =
{
{
.class_code = TUSB_CLASS_UNSPECIFIED,
.init = controld_init,
.open = NULL,
.control_request = NULL,
.control_request_complete = NULL,
.xfer_cb = controld_xfer_cb,
.sof = NULL,
.reset = controld_reset
},
#if CFG_TUD_CDC
{
.class_code = TUSB_CLASS_CDC,
@ -223,9 +213,8 @@ static void usbd_reset(uint8_t rhport)
tu_varclr(&_usbd_dev);
memset(_usbd_dev.itf2drv, 0xff, sizeof(_usbd_dev.itf2drv)); // invalid mapping
memset(_usbd_dev.ep2drv , 0xff, sizeof(_usbd_dev.ep2drv )); // invalid mapping
// Always map the 0th endpoint to the control driver.
_usbd_dev.ep2drv[TUSB_DIR_IN][0] = 0;
_usbd_dev.ep2drv[TUSB_DIR_OUT][0] = 0;
controld_reset(rhport);
for (uint8_t i = 0; i < USBD_CLASS_DRIVER_COUNT; i++)
{
@ -253,10 +242,17 @@ static void usbd_task_body(void)
{
// Invoke the class callback associated with the endpoint address
uint8_t const ep_addr = event.xfer_complete.ep_addr;
uint8_t const drv_id = _usbd_dev.ep2drv[edpt_dir(ep_addr)][edpt_number(ep_addr)];
if ( drv_id < USBD_CLASS_DRIVER_COUNT )
if ( 0 == edpt_number(ep_addr) )
{
// control transfer
controld_xfer_cb(event.rhport, ep_addr, event.xfer_complete.result, event.xfer_complete.len);
}
else
{
uint8_t const drv_id = _usbd_dev.ep2drv[edpt_dir(ep_addr)][edpt_number(ep_addr)];
TU_ASSERT(drv_id < USBD_CLASS_DRIVER_COUNT,);
usbd_class_drivers[drv_id].xfer_cb(event.rhport, ep_addr, event.xfer_complete.result, event.xfer_complete.len);
}
}