This commit is contained in:
hathach
2021-03-10 11:31:50 +07:00
parent 4a73b6a219
commit 38ebb8502d

View File

@@ -169,9 +169,11 @@ void tud_resume_cb(void)
bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request) bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_request_t const * request)
{ {
// nothing to with DATA & ACK stage // 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->bmRequestType_bit.type)
{
case TUSB_REQ_TYPE_VENDOR:
switch (request->bRequest) switch (request->bRequest)
{ {
case VENDOR_REQUEST_WEBUSB: case VENDOR_REQUEST_WEBUSB:
@@ -192,18 +194,19 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
return false; return false;
} }
default: default: break;
return false;
} }
} else if ( break;
request->bmRequestType_bit.type == TUSB_REQ_TYPE_CLASS &&
request->bRequest == 0x22) { case TUSB_REQ_TYPE_CLASS:
// Webserial simulate the CDC_REQUEST_SET_CONTROL_LINE_STATE (0x22) to if (request->bRequest == 0x22)
// connect and disconnect. {
// Webserial simulate the CDC_REQUEST_SET_CONTROL_LINE_STATE (0x22) to connect and disconnect.
web_serial_connected = (request->wValue != 0); web_serial_connected = (request->wValue != 0);
// Always lit LED if connected // Always lit LED if connected
if ( web_serial_connected ) { if ( web_serial_connected )
{
board_led_write(true); board_led_write(true);
blink_interval_ms = BLINK_ALWAYS_ON; blink_interval_ms = BLINK_ALWAYS_ON;
@@ -216,6 +219,10 @@ bool tud_vendor_control_xfer_cb(uint8_t rhport, uint8_t stage, tusb_control_requ
// response with status OK // response with status OK
return tud_control_status(rhport, request); return tud_control_status(rhport, request);
} }
break;
default: break;
}
// stall unknown request // stall unknown request
return false; return false;