rename request recipient macro
This commit is contained in:
@@ -19,7 +19,7 @@ int hub_custom_request_handler(struct usb_setup_packet *setup, uint8_t **data, u
|
||||
setup->bRequest);
|
||||
|
||||
if (((setup->bmRequestType & USB_REQUEST_TYPE_MASK) == USB_REQUEST_CLASS) &&
|
||||
((setup->bmRequestType & USB_REQUEST_RECIPIENT_MASK) == USB_REQUEST_TO_DEVICE) &&
|
||||
((setup->bmRequestType & USB_REQUEST_RECIPIENT_MASK) == USB_REQUEST_RECIPIENT_DEVICE) &&
|
||||
(setup->bRequest == HUB_REQUEST_GET_DESCRIPTOR)) {
|
||||
uint8_t value = (uint8_t)(setup->wValue >> 8);
|
||||
uint8_t intf_num = (uint8_t)setup->wIndex;
|
||||
@@ -36,7 +36,7 @@ int hub_custom_request_handler(struct usb_setup_packet *setup, uint8_t **data, u
|
||||
}
|
||||
|
||||
else if (((setup->bmRequestType & USB_REQUEST_TYPE_MASK) == USB_REQUEST_CLASS) &&
|
||||
((setup->bmRequestType & USB_REQUEST_RECIPIENT_MASK) == USB_REQUEST_TO_OTHER)) {
|
||||
((setup->bmRequestType & USB_REQUEST_RECIPIENT_MASK) == USB_REQUEST_RECIPIENT_OTHER)) {
|
||||
uint8_t hub_port_feature = (uint8_t)(setup->wValue);
|
||||
uint8_t hub_port = (uint8_t)setup->wIndex;
|
||||
|
||||
|
||||
@@ -51,12 +51,12 @@
|
||||
#define USB_REQUEST_RESERVED (3U << USB_REQUEST_TYPE_SHIFT)
|
||||
#define USB_REQUEST_TYPE_MASK (3U << USB_REQUEST_TYPE_SHIFT)
|
||||
|
||||
#define USB_REQUEST_RECIPIENT_SHIFT 0U /* Bits 0:4: Recipient */
|
||||
#define USB_REQUEST_TO_DEVICE (0U << USB_REQUEST_RECIPIENT_SHIFT)
|
||||
#define USB_REQUEST_TO_INTERFACE (1U << USB_REQUEST_RECIPIENT_SHIFT)
|
||||
#define USB_REQUEST_TO_ENDPOINT (2U << USB_REQUEST_RECIPIENT_SHIFT)
|
||||
#define USB_REQUEST_TO_OTHER (3U << USB_REQUEST_RECIPIENT_SHIFT)
|
||||
#define USB_REQUEST_RECIPIENT_MASK (3U << USB_REQUEST_RECIPIENT_SHIFT)
|
||||
#define USB_REQUEST_RECIPIENT_SHIFT 0U /* Bits 0:4: Recipient */
|
||||
#define USB_REQUEST_RECIPIENT_DEVICE (0U << USB_REQUEST_RECIPIENT_SHIFT)
|
||||
#define USB_REQUEST_RECIPIENT_INTERFACE (1U << USB_REQUEST_RECIPIENT_SHIFT)
|
||||
#define USB_REQUEST_RECIPIENT_ENDPOINT (2U << USB_REQUEST_RECIPIENT_SHIFT)
|
||||
#define USB_REQUEST_RECIPIENT_OTHER (3U << USB_REQUEST_RECIPIENT_SHIFT)
|
||||
#define USB_REQUEST_RECIPIENT_MASK (3U << USB_REQUEST_RECIPIENT_SHIFT)
|
||||
|
||||
/* USB Standard Request Codes */
|
||||
#define USB_REQUEST_GET_STATUS 0x00
|
||||
|
||||
@@ -736,21 +736,21 @@ static int usbd_standard_request_handler(struct usb_setup_packet *setup, uint8_t
|
||||
int rc = 0;
|
||||
|
||||
switch (setup->bmRequestType & USB_REQUEST_RECIPIENT_MASK) {
|
||||
case USB_REQUEST_TO_DEVICE:
|
||||
case USB_REQUEST_RECIPIENT_DEVICE:
|
||||
if (usbd_std_device_req_handler(setup, data, len) == false) {
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case USB_REQUEST_TO_INTERFACE:
|
||||
case USB_REQUEST_RECIPIENT_INTERFACE:
|
||||
if (usbd_std_interface_req_handler(setup, data, len) == false) {
|
||||
rc = -1;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case USB_REQUEST_TO_ENDPOINT:
|
||||
case USB_REQUEST_RECIPIENT_ENDPOINT:
|
||||
if (usbd_std_endpoint_req_handler(setup, data, len) == false) {
|
||||
rc = -1;
|
||||
}
|
||||
@@ -779,7 +779,7 @@ static int usbd_class_request_handler(struct usb_setup_packet *setup, uint8_t **
|
||||
{
|
||||
USBD_LOG_DBG("bRequest 0x%02x, wIndex 0x%04x\r\n", setup->bRequest, setup->wIndex);
|
||||
|
||||
if ((setup->bmRequestType & USB_REQUEST_RECIPIENT_MASK) != USB_REQUEST_TO_INTERFACE) {
|
||||
if ((setup->bmRequestType & USB_REQUEST_RECIPIENT_MASK) != USB_REQUEST_RECIPIENT_INTERFACE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -815,7 +815,7 @@ static int usbd_vendor_request_handler(struct usb_setup_packet *setup, uint8_t *
|
||||
{
|
||||
USBD_LOG_DBG("bRequest 0x%02x, wValue0x%04x, wIndex 0x%04x\r\n", setup->bRequest, setup->wValue, setup->wIndex);
|
||||
|
||||
// if((setup->bmRequestType & USB_REQUEST_RECIPIENT_MASK) != USB_REQUEST_TO_DEVICE)
|
||||
// if((setup->bmRequestType & USB_REQUEST_RECIPIENT_MASK) != USB_REQUEST_RECIPIENT_DEVICE)
|
||||
// {
|
||||
// return -1;
|
||||
// }
|
||||
@@ -889,7 +889,7 @@ static int usbd_custom_request_handler(struct usb_setup_packet *setup, uint8_t *
|
||||
{
|
||||
USBD_LOG_DBG("bRequest 0x%02x, wIndex 0x%04x\r\n", setup->bRequest, setup->wIndex);
|
||||
|
||||
if ((setup->bmRequestType & USB_REQUEST_RECIPIENT_MASK) != USB_REQUEST_TO_INTERFACE) {
|
||||
if ((setup->bmRequestType & USB_REQUEST_RECIPIENT_MASK) != USB_REQUEST_RECIPIENT_INTERFACE) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user