mirror of
				https://github.com/espressif/esp-idf.git
				synced 2025-10-30 20:51:41 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			59 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			59 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			C
		
	
	
	
	
	
| /*
 | |
|  * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
 | |
|  *
 | |
|  * SPDX-License-Identifier: CC0-1.0
 | |
|  */
 | |
| 
 | |
| #include "unity.h"
 | |
| #include "unity_test_runner.h"
 | |
| #include "unity_test_utils_memory.h"
 | |
| #include "freertos/FreeRTOS.h"
 | |
| #include "freertos/task.h"
 | |
| #include "esp_private/usb_phy.h"
 | |
| #include "unity.h"
 | |
| 
 | |
| static usb_phy_handle_t phy_hdl = NULL;
 | |
| 
 | |
| void setUp(void)
 | |
| {
 | |
|     unity_utils_record_free_mem();
 | |
| 
 | |
|     // Configure USB PHY for USB Device
 | |
|     usb_phy_config_t phy_config = {
 | |
|         .controller = USB_PHY_CTRL_OTG,
 | |
|         .target = USB_PHY_TARGET_INT,
 | |
|         .otg_mode = USB_OTG_MODE_DEVICE,
 | |
|     };
 | |
|     TEST_ASSERT_EQUAL_MESSAGE(ESP_OK, usb_new_phy(&phy_config, &phy_hdl), "Failed to init USB Device PHY");
 | |
| }
 | |
| 
 | |
| void tearDown(void)
 | |
| {
 | |
|     // Short delay to allow task to be cleaned up
 | |
|     vTaskDelay(10);
 | |
|     // Deinitialize the internal USB PHY
 | |
|     TEST_ASSERT_EQUAL_MESSAGE(ESP_OK, usb_del_phy(phy_hdl), "Failed to delete USB Device PHY");
 | |
|     phy_hdl = NULL;
 | |
|     unity_utils_evaluate_leaks();
 | |
| }
 | |
| 
 | |
| void app_main(void)
 | |
| {
 | |
|     //  ____ ___  ___________________    __                   __
 | |
|     // |    |   \/   _____/\______   \ _/  |_  ____   _______/  |_
 | |
|     // |    |   /\_____  \  |    |  _/ \   __\/ __ \ /  ___/\   __\.
 | |
|     // |    |  / /        \ |    |   \  |  | \  ___/ \___ \  |  |
 | |
|     // |______/ /_______  / |______  /  |__|  \___  >____  > |__|
 | |
|     //                  \/         \/             \/     \/
 | |
|     printf(" ____ ___  ___________________    __                   __   \r\n");
 | |
|     printf("|    |   \\/   _____/\\______   \\ _/  |_  ____   _______/  |_ \r\n");
 | |
|     printf("|    |   /\\_____  \\  |    |  _/ \\   __\\/ __ \\ /  ___/\\   __\\\r\n");
 | |
|     printf("|    |  / /        \\ |    |   \\  |  | \\  ___/ \\___ \\  |  |  \r\n");
 | |
|     printf("|______/ /_______  / |______  /  |__|  \\___  >____  > |__|  \r\n");
 | |
|     printf("                 \\/         \\/             \\/     \\/        \r\n");
 | |
| 
 | |
|     unity_utils_setup_heap_record(80);
 | |
|     unity_utils_set_leak_level(128);
 | |
|     unity_run_menu();
 | |
| }
 |