mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-01 18:50:34 +03:00
refactor(usb): Remove use of usb_phy_action() from unit tests
Currently, USB Host unit tests that require a software triggered disconnection/ reconnection rely on the 'usb_phy_action()' function. This commit replaces those calls with 'hcd_port_command()' or 'usb_host_lib_set_root_port_power()'. Note: Also removed 'test_usb_common.h/c' as it is no longer necessary are the function call replacements.
This commit is contained in:
committed by
Tomas Rezucha
parent
318c69a671
commit
802ab4c2cc
@@ -2,6 +2,5 @@ idf_component_register(SRCS "dev_hid.c"
|
||||
"dev_isoc.c"
|
||||
"dev_msc.c"
|
||||
"mock_msc.c"
|
||||
"test_usb_common.c"
|
||||
INCLUDE_DIRS "."
|
||||
REQUIRES usb unity)
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "esp_err.h"
|
||||
#include "hal/usb_phy_types.h"
|
||||
#include "esp_private/usb_phy.h"
|
||||
#include "test_usb_common.h"
|
||||
#include "unity.h"
|
||||
|
||||
static usb_phy_handle_t phy_hdl = NULL;
|
||||
|
||||
void test_usb_init_phy(void)
|
||||
{
|
||||
// Initialize the internal USB PHY to connect to the USB OTG peripheral
|
||||
usb_phy_config_t phy_config = {
|
||||
.controller = USB_PHY_CTRL_OTG,
|
||||
.target = USB_PHY_TARGET_INT,
|
||||
.otg_mode = USB_OTG_MODE_HOST,
|
||||
.otg_speed = USB_PHY_SPEED_UNDEFINED, // In Host mode, the speed is determined by the connected device
|
||||
.ext_io_conf = NULL,
|
||||
.otg_io_conf = NULL,
|
||||
};
|
||||
TEST_ASSERT_EQUAL_MESSAGE(ESP_OK, usb_new_phy(&phy_config, &phy_hdl), "Failed to init USB PHY");
|
||||
}
|
||||
|
||||
void test_usb_deinit_phy(void)
|
||||
{
|
||||
// Deinitialize the internal USB PHY
|
||||
TEST_ASSERT_EQUAL_MESSAGE(ESP_OK, usb_del_phy(phy_hdl), "Failed to delete PHY");
|
||||
phy_hdl = NULL;
|
||||
}
|
||||
|
||||
void test_usb_set_phy_state(bool connected, TickType_t delay_ticks)
|
||||
{
|
||||
if (delay_ticks > 0) {
|
||||
// Delay of 0 ticks causes a yield. So skip if delay_ticks is 0.
|
||||
vTaskDelay(delay_ticks);
|
||||
}
|
||||
ESP_ERROR_CHECK(usb_phy_action(phy_hdl, (connected) ? USB_PHY_ACTION_HOST_ALLOW_CONN : USB_PHY_ACTION_HOST_FORCE_DISCONN));
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include "freertos/FreeRTOS.h"
|
||||
|
||||
/**
|
||||
* @brief Initialize the internal USB PHY and USB Controller for USB Host testing
|
||||
*/
|
||||
void test_usb_init_phy(void);
|
||||
|
||||
/**
|
||||
* @brief Deinitialize the internal USB PHY and USB Controller after USB Host testing
|
||||
*/
|
||||
void test_usb_deinit_phy(void);
|
||||
|
||||
/**
|
||||
* @brief For the USB PHY into the connected or disconnected state
|
||||
*
|
||||
* @param connected For into connected state if true, disconnected if false
|
||||
* @param delay_ticks Delay in ticks before forcing state
|
||||
*/
|
||||
void test_usb_set_phy_state(bool connected, TickType_t delay_ticks);
|
||||
Reference in New Issue
Block a user