Skip to content

Commit

Permalink
Update usbd_core.c
Browse files Browse the repository at this point in the history
Added Vendor Commands management
  • Loading branch information
martinloren authored Jan 29, 2019
1 parent cd45f60 commit 05fd52e
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions STM32/cores/arduino/usb/usbd_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
/* Includes ------------------------------------------------------------------*/
#include "usbd_core.h"

//Handle Vendor Commands on EP0
__weak void VendorCommand(USBD_SetupReqTypedef* req) { }

/** @addtogroup STM32_USBD_DEVICE_LIBRARY
* @{
*/
Expand Down Expand Up @@ -267,6 +270,15 @@ USBD_StatusTypeDef USBD_LL_SetupStage(USBD_HandleTypeDef *pdev, uint8_t *psetup)

pdev->ep0_state = USBD_EP0_SETUP;
pdev->ep0_data_len = pdev->request.wLength;

//Handle Vendor Command with Request Code 0x40
if ((pdev->request.bmRequest & 0x40) == 0x40) {
VendorCommand(&pdev->request); //Get Vendor setup request (no data)
//If there is data len then must take data or Setup will fail
//Send ACK if no other trasmission required (so dont make Host to fail request)
if (pdev->request.wLength == 0) USBD_CtlSendStatus(pdev); //ACK by sending 0 len packet
return USBD_OK;
}

switch (pdev->request.bmRequest & 0x1F)
{
Expand Down

1 comment on commit 05fd52e

@martinloren
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added management for Vendor Commands

Please sign in to comment.