/* * Copyright (c) 2018-2018, ARM Limited, All Rights Reserved * SPDX-License-Identifier: Apache-2.0 * * Licensed under the Apache License, Version 2.0 (the "License"); you may * not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef USB_TESTER_H #define USB_TESTER_H /* These headers are included for child class. */ #include "USBDescriptor.h" #include "USBDevice_Types.h" #include "EventQueue.h" #include "USBDevice.h" class USBTester: public USBDevice { public: /* * Constructor * * @param vendor_id Your vendor_id * @param product_id Your product_id * @param product_release Your preoduct_release * @param connect_blocking define if the connection must be blocked if USB not plugged in */ USBTester(uint16_t vendor_id, uint16_t product_id, uint16_t product_release, bool connect_blocking); ~USBTester(); protected: /* * Get device descriptor. Warning: this method has to store the length of the report descriptor in reportLength. * * @returns pointer to the device descriptor */ virtual const uint8_t *device_desc(); /* * Get string product descriptor * * @returns pointer to the string product descriptor */ virtual const uint8_t *string_iproduct_desc(); /* * Get string interface descriptor * * @returns pointer to the string interface descriptor */ virtual const uint8_t *string_iinterface_desc(); /* * Get configuration descriptor * * @returns pointer to the configuration descriptor */ virtual const uint8_t *configuration_desc(); protected: uint8_t bulk_in; uint8_t bulk_out; uint8_t int_in; uint8_t int_out; EventQueue *queue; virtual void callback_state_change(DeviceState new_state); virtual void callback_request(const setup_packet_t *setup); virtual void callback_request_xfer_done(const setup_packet_t *setup, bool aborted); virtual void callback_set_configuration(uint8_t configuration); virtual void callback_set_interface(uint16_t interface, uint8_t alternate); virtual void epbulk_out_callback(usb_ep_t endpoint); virtual void epint_out_callback(usb_ep_t endpoint); uint8_t ctrl_buf[2048]; }; #endif