Merge branch 'master' into edpt_ISO_xfer
This commit is contained in:
+27
-14
@@ -699,13 +699,21 @@ static bool process_control_request(uint8_t rhport, tusb_control_request_t const
|
||||
// notable requests are: GET HID REPORT DESCRIPTOR, SET_INTERFACE, GET_INTERFACE
|
||||
if ( !invoke_class_control(rhport, driver, p_request) )
|
||||
{
|
||||
// For GET_INTERFACE, it is mandatory to respond even if the class
|
||||
// driver doesn't use alternate settings.
|
||||
TU_VERIFY( TUSB_REQ_TYPE_STANDARD == p_request->bmRequestType_bit.type &&
|
||||
TUSB_REQ_GET_INTERFACE == p_request->bRequest);
|
||||
// For GET_INTERFACE and SET_INTERFACE, it is mandatory to respond even if the class
|
||||
// driver doesn't use alternate settings or implement this
|
||||
TU_VERIFY(TUSB_REQ_TYPE_STANDARD == p_request->bmRequestType_bit.type);
|
||||
|
||||
uint8_t alternate = 0;
|
||||
tud_control_xfer(rhport, p_request, &alternate, 1);
|
||||
if (TUSB_REQ_GET_INTERFACE == p_request->bRequest)
|
||||
{
|
||||
uint8_t alternate = 0;
|
||||
tud_control_xfer(rhport, p_request, &alternate, 1);
|
||||
}else if (TUSB_REQ_SET_INTERFACE == p_request->bRequest)
|
||||
{
|
||||
tud_control_status(rhport, p_request);
|
||||
} else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -992,11 +1000,15 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr)
|
||||
switch (event->event_id)
|
||||
{
|
||||
case DCD_EVENT_UNPLUGGED:
|
||||
_usbd_dev.connected = 0;
|
||||
_usbd_dev.addressed = 0;
|
||||
_usbd_dev.cfg_num = 0;
|
||||
_usbd_dev.suspended = 0;
|
||||
osal_queue_send(_usbd_q, event, in_isr);
|
||||
// UNPLUGGED event can be bouncing, only processing if we are currently connected
|
||||
if ( _usbd_dev.connected )
|
||||
{
|
||||
_usbd_dev.connected = 0;
|
||||
_usbd_dev.addressed = 0;
|
||||
_usbd_dev.cfg_num = 0;
|
||||
_usbd_dev.suspended = 0;
|
||||
osal_queue_send(_usbd_q, event, in_isr);
|
||||
}
|
||||
break;
|
||||
|
||||
case DCD_EVENT_SOF:
|
||||
@@ -1004,9 +1016,10 @@ void dcd_event_handler(dcd_event_t const * event, bool in_isr)
|
||||
break;
|
||||
|
||||
case DCD_EVENT_SUSPEND:
|
||||
// NOTE: When plugging/unplugging device, the D+/D- state are unstable and can accidentally meet the
|
||||
// SUSPEND condition ( Idle for 3ms ). Some MCUs such as SAMD doesn't distinguish suspend vs disconnect as well.
|
||||
// We will skip handling SUSPEND/RESUME event if not currently connected
|
||||
// NOTE: When plugging/unplugging device, the D+/D- state are unstable and
|
||||
// can accidentally meet the SUSPEND condition ( Bus Idle for 3ms ).
|
||||
// In addition, some MCUs such as SAMD or boards that haven no VBUS detection cannot distinguish
|
||||
// suspended vs disconnected. We will skip handling SUSPEND/RESUME event if not currently connected
|
||||
if ( _usbd_dev.connected )
|
||||
{
|
||||
_usbd_dev.suspended = 1;
|
||||
|
||||
+4
-3
@@ -254,6 +254,7 @@ TU_ATTR_WEAK bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb
|
||||
7, TUSB_DESC_ENDPOINT, _epin, TUSB_XFER_INTERRUPT, U16_TO_U8S_LE(_epsize), _ep_interval
|
||||
|
||||
//------------- MIDI -------------//
|
||||
// MIDI v1.0 is based on Audio v1.0
|
||||
|
||||
#define TUD_MIDI_DESC_HEAD_LEN (9 + 9 + 9 + 7)
|
||||
#define TUD_MIDI_DESC_HEAD(_itfnum, _stridx, _numcables) \
|
||||
@@ -289,10 +290,10 @@ TU_ATTR_WEAK bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb
|
||||
/* MS Out Jack (External), connected to In Jack Embedded */\
|
||||
9, TUSB_DESC_CS_INTERFACE, MIDI_CS_INTERFACE_OUT_JACK, MIDI_JACK_EXTERNAL, TUD_MIDI_JACKID_OUT_EXT(_cablenum), 1, TUD_MIDI_JACKID_IN_EMB(_cablenum), 1, 0
|
||||
|
||||
#define TUD_MIDI_DESC_EP_LEN(_numcables) (7 + 4 + (_numcables))
|
||||
#define TUD_MIDI_DESC_EP_LEN(_numcables) (9 + 4 + (_numcables))
|
||||
#define TUD_MIDI_DESC_EP(_epout, _epsize, _numcables) \
|
||||
/* Endpoint */\
|
||||
7, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0,\
|
||||
/* Endpoint: Note Audio v1.0's endpoint has 9 bytes instead of 7 */\
|
||||
9, TUSB_DESC_ENDPOINT, _epout, TUSB_XFER_BULK, U16_TO_U8S_LE(_epsize), 0, 0, 0, \
|
||||
/* MS Endpoint (connected to embedded jack) */\
|
||||
(uint8_t)(4 + (_numcables)), TUSB_DESC_CS_ENDPOINT, MIDI_CS_ENDPOINT_GENERAL, _numcables
|
||||
|
||||
|
||||
Reference in New Issue
Block a user