mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
follow up to suggestion to pr 155
This commit is contained in:
parent
ac8c343fef
commit
9c5ae0369b
@ -125,7 +125,8 @@ typedef enum
|
||||
{
|
||||
TUSB_REQ_TYPE_STANDARD = 0,
|
||||
TUSB_REQ_TYPE_CLASS,
|
||||
TUSB_REQ_TYPE_VENDOR
|
||||
TUSB_REQ_TYPE_VENDOR,
|
||||
TUSB_REQ_TYPE_INVALID
|
||||
} tusb_request_type_t;
|
||||
|
||||
typedef enum
|
||||
|
@ -62,7 +62,7 @@ typedef struct {
|
||||
static usbd_device_t _usbd_dev = { 0 };
|
||||
|
||||
// Invalid driver ID in itf2drv[] ep2drv[][] mapping
|
||||
enum { DRVID_INVALID = 0xff };
|
||||
enum { DRVID_INVALID = 0xFFu };
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// Class Driver
|
||||
@ -349,6 +349,8 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
{
|
||||
usbd_control_set_complete_callback(NULL);
|
||||
|
||||
TU_ASSERT(p_request->bmRequestType_bit.type < TUSB_REQ_TYPE_INVALID);
|
||||
|
||||
// Vendor request
|
||||
if ( p_request->bmRequestType_bit.type == TUSB_REQ_TYPE_VENDOR )
|
||||
{
|
||||
@ -470,7 +472,8 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
// GET HID REPORT DESCRIPTOR falls into this case
|
||||
// stall control endpoint if driver return false
|
||||
usbd_control_set_complete_callback(usbd_class_drivers[drvid].control_complete);
|
||||
TU_ASSERT(usbd_class_drivers[drvid].control_request(rhport, p_request));
|
||||
TU_ASSERT(usbd_class_drivers[drvid].control_request != NULL &&
|
||||
usbd_class_drivers[drvid].control_request(rhport, p_request));
|
||||
break;
|
||||
}
|
||||
}else
|
||||
@ -478,7 +481,8 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
// forward to class driver: "non-STD request to Interface"
|
||||
// stall control endpoint if driver return false
|
||||
usbd_control_set_complete_callback(usbd_class_drivers[drvid].control_complete);
|
||||
TU_ASSERT(usbd_class_drivers[drvid].control_request(rhport, p_request));
|
||||
TU_ASSERT(usbd_class_drivers[drvid].control_request != NULL &&
|
||||
usbd_class_drivers[drvid].control_request(rhport, p_request));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -499,7 +503,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
// We will forward all request targeted endpoint to its class driver
|
||||
// - For non-standard request: driver can ACK or Stall the request by return true/false
|
||||
// - For standard request: usbd decide the ACK stage regardless of driver return value
|
||||
bool ret;
|
||||
bool ret = false;
|
||||
|
||||
if ( TUSB_REQ_TYPE_STANDARD != p_request->bmRequestType_bit.type )
|
||||
{
|
||||
@ -507,8 +511,11 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
usbd_control_set_complete_callback(usbd_class_drivers[drv_id].control_complete);
|
||||
}
|
||||
|
||||
// Invoke class driver first
|
||||
// Invoke class driver first if available
|
||||
if ( usbd_class_drivers[drv_id].control_request )
|
||||
{
|
||||
ret = usbd_class_drivers[drv_id].control_request(rhport, p_request);
|
||||
}
|
||||
|
||||
// Then handle if it is standard request
|
||||
if ( TUSB_REQ_TYPE_STANDARD == p_request->bmRequestType_bit.type )
|
||||
|
Loading…
x
Reference in New Issue
Block a user