Skip to content

Commit 7cf1118

Browse files
committed
stm32/usbdev: Optionally pass through vendor requests to Setup function.
Signed-off-by: Damien George <[email protected]>
1 parent f46269a commit 7cf1118

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

ports/stm32/usbd_conf.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
#endif
5050
#define USBD_DEBUG_LEVEL 0
5151

52+
// Whether the core USBD driver passes through vendor device requests to the class implementation.
53+
#ifndef USBD_ENABLE_VENDOR_DEVICE_REQUESTS
54+
#define USBD_ENABLE_VENDOR_DEVICE_REQUESTS (0)
55+
#endif
56+
5257
// For MCUs with a device-only USB peripheral
5358
#define USBD_PMA_RESERVE (64)
5459
#define USBD_PMA_NUM_FIFO (16) // Maximum 8 endpoints, 2 FIFOs each

ports/stm32/usbdev/core/src/usbd_ctlreq.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ USBD_StatusTypeDef USBD_StdDevReq (USBD_HandleTypeDef *pdev , USBD_SetupReqType
120120
{
121121
USBD_StatusTypeDef ret = USBD_OK;
122122

123+
#if USBD_ENABLE_VENDOR_DEVICE_REQUESTS
124+
// Pass through vendor device requests directly to the implementation.
125+
// It must call `USBD_CtlError(pdev, req);` if it does not respond to the request.
126+
if ((req->bmRequest & 0xe0) == 0xc0) {
127+
return pdev->pClass->Setup (pdev, req);
128+
}
129+
#endif
130+
123131
switch (req->bRequest)
124132
{
125133
case USB_REQ_GET_DESCRIPTOR:

0 commit comments

Comments
 (0)