mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-17 05:32:55 +08:00
should fix #184
only response up to EP0 size with get device descriptor if not addressed.
This commit is contained in:
parent
71a4076e73
commit
f6a65720e5
@ -44,6 +44,7 @@ typedef struct {
|
|||||||
struct TU_ATTR_PACKED
|
struct TU_ATTR_PACKED
|
||||||
{
|
{
|
||||||
volatile uint8_t connected : 1;
|
volatile uint8_t connected : 1;
|
||||||
|
volatile uint8_t addressed : 1;
|
||||||
volatile uint8_t configured : 1;
|
volatile uint8_t configured : 1;
|
||||||
volatile uint8_t suspended : 1;
|
volatile uint8_t suspended : 1;
|
||||||
|
|
||||||
@ -478,6 +479,7 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
|||||||
// Depending on mcu, status phase could be sent either before or after changing device address
|
// Depending on mcu, status phase could be sent either before or after changing device address
|
||||||
// Therefore DCD must include zero-length status response
|
// Therefore DCD must include zero-length status response
|
||||||
dcd_set_address(rhport, (uint8_t) p_request->wValue);
|
dcd_set_address(rhport, (uint8_t) p_request->wValue);
|
||||||
|
_usbd_dev.addressed = 1;
|
||||||
return true; // skip status
|
return true; // skip status
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -752,7 +754,17 @@ static bool process_get_descriptor(uint8_t rhport, tusb_control_request_t const
|
|||||||
switch(desc_type)
|
switch(desc_type)
|
||||||
{
|
{
|
||||||
case TUSB_DESC_DEVICE:
|
case TUSB_DESC_DEVICE:
|
||||||
return tud_control_xfer(rhport, p_request, (void*) tud_descriptor_device_cb(), sizeof(tusb_desc_device_t));
|
{
|
||||||
|
uint16_t len = sizeof(tusb_desc_device_t);
|
||||||
|
|
||||||
|
// Only send up to EP0 Packet Size if not addressed
|
||||||
|
if ((CFG_TUD_ENDPOINT0_SIZE < sizeof(tusb_desc_device_t)) && !_usbd_dev.addressed)
|
||||||
|
{
|
||||||
|
len = CFG_TUD_ENDPOINT0_SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tud_control_xfer(rhport, p_request, (void*) tud_descriptor_device_cb(), len);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TUSB_DESC_BOS:
|
case TUSB_DESC_BOS:
|
||||||
@ -820,6 +832,7 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr)
|
|||||||
|
|
||||||
case DCD_EVENT_UNPLUGGED:
|
case DCD_EVENT_UNPLUGGED:
|
||||||
_usbd_dev.connected = 0;
|
_usbd_dev.connected = 0;
|
||||||
|
_usbd_dev.addressed = 0;
|
||||||
_usbd_dev.configured = 0;
|
_usbd_dev.configured = 0;
|
||||||
_usbd_dev.suspended = 0;
|
_usbd_dev.suspended = 0;
|
||||||
osal_queue_send(_usbd_q, event, in_isr);
|
osal_queue_send(_usbd_q, event, in_isr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user