mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-16 05:42:56 +00:00
clean up
This commit is contained in:
parent
4a73b6a219
commit
38ebb8502d
@ -169,52 +169,59 @@ void tud_resume_cb(void)
|
||||
bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request)
|
||||
{
|
||||
// nothing to with DATA & ACK stage
|
||||
if (stage != CONTROL_STAGE_SETUP ) return true;
|
||||
if (stage != CONTROL_STAGE_SETUP) return true;
|
||||
|
||||
if (request->bmRequestType_bit.type == TUSB_REQ_TYPE_VENDOR) {
|
||||
switch (request->bRequest)
|
||||
{
|
||||
case VENDOR_REQUEST_WEBUSB:
|
||||
// match vendor request in BOS descriptor
|
||||
// Get landing page url
|
||||
return tud_control_xfer(rhport, request, (void*) &desc_url, desc_url.bLength);
|
||||
switch (request->bmRequestType_bit.type)
|
||||
{
|
||||
case TUSB_REQ_TYPE_VENDOR:
|
||||
switch (request->bRequest)
|
||||
{
|
||||
case VENDOR_REQUEST_WEBUSB:
|
||||
// match vendor request in BOS descriptor
|
||||
// Get landing page url
|
||||
return tud_control_xfer(rhport, request, (void*) &desc_url, desc_url.bLength);
|
||||
|
||||
case VENDOR_REQUEST_MICROSOFT:
|
||||
if ( request->wIndex == 7 )
|
||||
case VENDOR_REQUEST_MICROSOFT:
|
||||
if ( request->wIndex == 7 )
|
||||
{
|
||||
// Get Microsoft OS 2.0 compatible descriptor
|
||||
uint16_t total_len;
|
||||
memcpy(&total_len, desc_ms_os_20+8, 2);
|
||||
|
||||
return tud_control_xfer(rhport, request, (void*) desc_ms_os_20, total_len);
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
default: break;
|
||||
}
|
||||
break;
|
||||
|
||||
case TUSB_REQ_TYPE_CLASS:
|
||||
if (request->bRequest == 0x22)
|
||||
{
|
||||
// Webserial simulate the CDC_REQUEST_SET_CONTROL_LINE_STATE (0x22) to connect and disconnect.
|
||||
web_serial_connected = (request->wValue != 0);
|
||||
|
||||
// Always lit LED if connected
|
||||
if ( web_serial_connected )
|
||||
{
|
||||
// Get Microsoft OS 2.0 compatible descriptor
|
||||
uint16_t total_len;
|
||||
memcpy(&total_len, desc_ms_os_20+8, 2);
|
||||
board_led_write(true);
|
||||
blink_interval_ms = BLINK_ALWAYS_ON;
|
||||
|
||||
return tud_control_xfer(rhport, request, (void*) desc_ms_os_20, total_len);
|
||||
tud_vendor_write_str("\r\nTinyUSB WebUSB device example\r\n");
|
||||
}else
|
||||
{
|
||||
return false;
|
||||
blink_interval_ms = BLINK_MOUNTED;
|
||||
}
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
} else if (
|
||||
request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS &&
|
||||
request->bRequest == 0x22) {
|
||||
// Webserial simulate the CDC_REQUEST_SET_CONTROL_LINE_STATE (0x22) to
|
||||
// connect and disconnect.
|
||||
web_serial_connected = (request->wValue != 0);
|
||||
// response with status OK
|
||||
return tud_control_status(rhport, request);
|
||||
}
|
||||
break;
|
||||
|
||||
// Always lit LED if connected
|
||||
if ( web_serial_connected ) {
|
||||
board_led_write(true);
|
||||
blink_interval_ms = BLINK_ALWAYS_ON;
|
||||
|
||||
tud_vendor_write_str("\r\nTinyUSB WebUSB device example\r\n");
|
||||
}else
|
||||
{
|
||||
blink_interval_ms = BLINK_MOUNTED;
|
||||
}
|
||||
|
||||
// response with status OK
|
||||
return tud_control_status(rhport, request);
|
||||
default: break;
|
||||
}
|
||||
|
||||
// stall unknown request
|
||||
|
Loading…
x
Reference in New Issue
Block a user