mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-22 22:38:08 +00:00
trezorhal: make webusb more robust
This commit is contained in:
parent
08c145c4da
commit
399d6d2f65
@ -217,22 +217,37 @@ static void usb_webusb_class_deinit(USBD_HandleTypeDef *dev, usb_webusb_state_t
|
||||
|
||||
static int usb_webusb_class_setup(USBD_HandleTypeDef *dev, usb_webusb_state_t *state, USBD_SetupReqTypedef *req) {
|
||||
|
||||
if ((req->bmRequest & USB_REQ_TYPE_MASK) != USB_REQ_TYPE_STANDARD) {
|
||||
return USBD_OK;
|
||||
switch (req->bmRequest & USB_REQ_TYPE_MASK) {
|
||||
|
||||
// Class request
|
||||
case USB_REQ_TYPE_CLASS:
|
||||
switch (req->bRequest) {
|
||||
default:
|
||||
USBD_CtlError(dev, req);
|
||||
return USBD_FAIL;
|
||||
}
|
||||
break;
|
||||
|
||||
// Interface & Endpoint request
|
||||
case USB_REQ_TYPE_STANDARD:
|
||||
switch (req->bRequest) {
|
||||
|
||||
case USB_REQ_SET_INTERFACE:
|
||||
state->alt_setting = req->wValue;
|
||||
USBD_CtlSendStatus(dev);
|
||||
return USBD_OK;
|
||||
|
||||
case USB_REQ_GET_INTERFACE:
|
||||
USBD_CtlSendData(dev, &state->alt_setting, sizeof(state->alt_setting));
|
||||
return USBD_OK;
|
||||
default:
|
||||
USBD_CtlError(dev, req);
|
||||
return USBD_FAIL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
switch (req->bRequest) {
|
||||
case USB_REQ_SET_INTERFACE:
|
||||
state->alt_setting = req->wValue;
|
||||
USBD_CtlSendStatus(dev);
|
||||
return USBD_OK;
|
||||
case USB_REQ_GET_INTERFACE:
|
||||
USBD_CtlSendData(dev, &state->alt_setting, sizeof(state->alt_setting));
|
||||
return USBD_OK;
|
||||
default:
|
||||
USBD_CtlError(dev, req);
|
||||
return USBD_FAIL;
|
||||
}
|
||||
return USBD_OK;
|
||||
}
|
||||
|
||||
static void usb_webusb_class_data_in(USBD_HandleTypeDef *dev, usb_webusb_state_t *state, uint8_t ep_num) {
|
||||
|
Loading…
Reference in New Issue
Block a user