diff options
-rw-r--r-- | chip/stm32/usb.c | 9 | ||||
-rw-r--r-- | include/usb.h | 12 |
2 files changed, 21 insertions, 0 deletions
diff --git a/chip/stm32/usb.c b/chip/stm32/usb.c index 64bff8bd40..82c1337a40 100644 --- a/chip/stm32/usb.c +++ b/chip/stm32/usb.c @@ -83,6 +83,15 @@ static int desc_left; /* pointer to descriptor data if any */ static const uint8_t *desc_ptr; +void usb_read_setup_packet(usb_uint *buffer, struct usb_setup_packet *packet) +{ + packet->bmRequestType = buffer[0] & 0xff; + packet->bRequest = buffer[0] >> 8; + packet->wValue = buffer[1]; + packet->wIndex = buffer[2]; + packet->wLength = buffer[3]; +} + /* Requests on the control endpoint (aka EP0) */ static void ep0_rx(void) { diff --git a/include/usb.h b/include/usb.h index 2b9db32811..0c96b19db1 100644 --- a/include/usb.h +++ b/include/usb.h @@ -194,6 +194,15 @@ struct usb_endpoint_descriptor { #define USB_BC12_CHARGE_VOLTAGE 5000 /* mV */ +/* Setup Packet */ +struct usb_setup_packet { + uint8_t bmRequestType; + uint8_t bRequest; + uint16_t wValue; + uint16_t wIndex; + uint16_t wLength; +}; + /* Helpers for descriptors */ #define WIDESTR(quote) WIDESTR2(quote) @@ -242,6 +251,9 @@ struct stm32_endpoint { extern struct stm32_endpoint btable_ep[]; +/* Read from USB RAM into a usb_setup_packet struct */ +void usb_read_setup_packet(usb_uint *buffer, struct usb_setup_packet *packet); + /* Copy data to the USB dedicated RAM and take care of the weird addressing */ static inline void memcpy_usbram(usb_uint *ebuf, const uint8_t *src, int size) { |