mirror of
https://github.com/espressif/esp-idf.git
synced 2025-12-02 15:23:21 +00:00
refactor(usb): Split test device descriptors from mock class files
Previously, descriptors of the test devices were stored direclty in the mock device files (e.g., "mock_[hid|msc].[h|c]"). This commit splits out the device descriptors to separate files (e.g., "dev_[hid|msc].c") along with getter functions. Users that want to run the tests locally on a different device simply need to update the "dev_[hid|msc].c" file for their device.
This commit is contained in:
80
components/usb/test_apps/common/dev_hid.h
Normal file
80
components/usb/test_apps/common/dev_hid.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdint.h>
|
||||
#include "usb/usb_types_ch9.h"
|
||||
#include "usb/usb_types_stack.h"
|
||||
|
||||
/*
|
||||
Some tests where the ESP (acting as host) will require that a particular test
|
||||
device acting as an HID mouse be connected. That test device's information and descriptors are defined in this file.
|
||||
|
||||
If you are connecting a different device, please update the descriptors in
|
||||
dev_hid.c accordingly.
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Initialize the test device
|
||||
*
|
||||
* @note Call this before running tests. This is necessary due to IDF-9886
|
||||
*/
|
||||
void dev_hid_init(void);
|
||||
|
||||
/**
|
||||
* @brief Get the test device's descriptor
|
||||
*
|
||||
* @param[in] speed Test device's current speed
|
||||
* @return Device descriptor
|
||||
*/
|
||||
const usb_device_desc_t *dev_hid_get_dev_desc(usb_speed_t speed);
|
||||
|
||||
/**
|
||||
* @brief Get the test device's configuration descriptor
|
||||
*
|
||||
* @param[in] speed Test device's current speed
|
||||
* @return Configuration descriptor
|
||||
*/
|
||||
const usb_config_desc_t *dev_hid_get_config_desc(usb_speed_t speed);
|
||||
|
||||
/**
|
||||
* @brief Get the test device's HID interface descriptor
|
||||
*
|
||||
* @param[in] speed Test device's current speed
|
||||
* @return HID interface descriptor
|
||||
*/
|
||||
const usb_intf_desc_t *dev_hid_get_intf_desc(usb_speed_t speed);
|
||||
|
||||
/**
|
||||
* @brief Get the test device's HID interrupt IN endpoint descriptor
|
||||
*
|
||||
* @param[in] speed Test device's current speed
|
||||
* @return Interrupt IN endpoint descriptor
|
||||
*/
|
||||
const usb_ep_desc_t *dev_hid_get_in_ep_desc(usb_speed_t speed);
|
||||
|
||||
/**
|
||||
* @brief Get the test device's manufacturer string descriptor
|
||||
*
|
||||
* @return Manufacturer string descriptor
|
||||
*/
|
||||
const usb_str_desc_t *dev_hid_get_str_desc_manu(void);
|
||||
|
||||
/**
|
||||
* @brief Get the test device's product string descriptor
|
||||
*
|
||||
* @return Product string descriptor
|
||||
*/
|
||||
const usb_str_desc_t *dev_hid_get_str_desc_prod(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user