Arrow / Mbed OS DAPLink Reset
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers usbd_core_winusb.c Source File

usbd_core_winusb.c

Go to the documentation of this file.
00001 /**
00002  * @file    usbd_core_winusb.c
00003  * @brief   WinUSB Device driver
00004  *
00005  * DAPLink Interface Firmware
00006  * Copyright (c) 2009-2016, ARM Limited, All Rights Reserved
00007  * SPDX-License-Identifier: Apache-2.0
00008  *
00009  * Licensed under the Apache License, Version 2.0 (the "License"); you may
00010  * not use this file except in compliance with the License.
00011  * You may obtain a copy of the License at
00012  *
00013  * http://www.apache.org/licenses/LICENSE-2.0
00014  *
00015  * Unless required by applicable law or agreed to in writing, software
00016  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
00017  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00018  * See the License for the specific language governing permissions and
00019  * limitations under the License.
00020  */
00021 
00022 #include <string.h>
00023 
00024 #include "rl_usb.h"
00025 #include "usb_for_lib.h"
00026 
00027 /*
00028  *  USB Device Endpoint 0 Event Callback - WinUSB specific handling (Setup Request To Device)
00029  *    Parameters:      none
00030  *    Return Value:    TRUE - Setup vendor request ok, FALSE - Setup vendor request not supported
00031  */
00032 
00033 __weak BOOL USBD_EndPoint0_Setup_WinUSB_ReqToDevice(void)
00034 {
00035     U8  *pD;
00036     U32 len;
00037 
00038     BOOL success = (__FALSE);
00039     if (USBD_SetupPacket.bRequest == usbd_winusb_vendor_code) {         /* vendor code correct? */
00040         switch (USBD_SetupPacket.wIndex) {
00041             case WINUSB_REQUEST_GET_DESCRIPTOR_SET:
00042                 pD = (U8 *)USBD_WinUSBDescriptorSetDescriptor;
00043                 USBD_EP0Data.pData = pD;
00044                 len = ((WINUSB_DESCRIPTOR_SET_HEADER *)pD)->wTotalLength;
00045                 success = (__TRUE);
00046                 break;
00047 
00048             default:
00049                 break;
00050         }
00051     }
00052 
00053     if (success) {
00054         if (len < USBD_SetupPacket.wLength) {
00055             USBD_EP0Data.Count = len;
00056             if (!(len & (usbd_max_packet0 - 1))) {
00057                 USBD_ZLP = 1;
00058             }
00059         } else {
00060             USBD_EP0Data.Count = USBD_SetupPacket.wLength;
00061         }
00062 
00063         USBD_DataInStage();
00064     }
00065 
00066     return success;
00067 }