-
Notifications
You must be signed in to change notification settings - Fork 792
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
319 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
version: "0.1.2" | ||
version: "0.2.0" | ||
targets: | ||
- esp32s2 | ||
- esp32s3 | ||
description: esp-iot-solution USB Host driver | ||
url: https://github.com/espressif/esp-iot-solution | ||
description: Simple USB Host driver maintained in esp-iot-solution | ||
url: https://github.com/espressif/esp-iot-solution/tree/master/components/usb/iot_usbh | ||
repository: https://github.com/espressif/esp-iot-solution/tree/master/components/usb/iot_usbh | ||
issues: https://github.com/espressif/esp-iot-solution/issues | ||
dependencies: | ||
idf: ">=4.4.1" | ||
cmake_utilities: "0.*" | ||
cmake_utilities: "0.*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# The following lines of boilerplate have to be in your project's CMakeLists | ||
# in this exact order for cmake to work correctly | ||
cmake_minimum_required(VERSION 3.16) | ||
|
||
set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components" | ||
"../../iot_usbh") | ||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
project(iot_usbh_test) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
idf_component_register(SRC_DIRS "." | ||
INCLUDE_DIRS "." | ||
PRIV_REQUIRES unity test_utils iot_usbh) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <string.h> | ||
#include "freertos/FreeRTOS.h" | ||
#include "freertos/task.h" | ||
#include "unity.h" | ||
#include "esp_log.h" | ||
#include "iot_usbh.h" | ||
|
||
#define TEST_MEMORY_LEAK_THRESHOLD (-400) | ||
|
||
TEST_CASE("iot_usbh init/deinit", "[iot_usbh]") | ||
{ | ||
for (size_t i = 0; i < 5; i++) { | ||
usbh_port_config_t config = DEFAULT_USBH_PORT_CONFIG(); | ||
usbh_port_handle_t port_hdl = iot_usbh_port_init(&config); | ||
TEST_ASSERT_NOT_NULL(port_hdl); | ||
TEST_ASSERT_EQUAL(ESP_OK, iot_usbh_port_start(port_hdl)); | ||
vTaskDelay(pdMS_TO_TICKS(2000)); | ||
TEST_ASSERT_EQUAL(ESP_OK, iot_usbh_port_deinit(port_hdl)); | ||
} | ||
|
||
usbh_port_config_t config = DEFAULT_USBH_PORT_CONFIG(); | ||
usbh_port_handle_t port_hdl = iot_usbh_port_init(&config); | ||
TEST_ASSERT_NOT_NULL(port_hdl); | ||
TEST_ASSERT_EQUAL(ESP_OK, iot_usbh_port_start(port_hdl)); | ||
vTaskDelay(pdMS_TO_TICKS(1000)); | ||
TEST_ASSERT_EQUAL(ESP_OK, iot_usbh_port_stop(port_hdl)); | ||
vTaskDelay(pdMS_TO_TICKS(1000)); | ||
TEST_ASSERT_EQUAL(ESP_OK, iot_usbh_port_start(port_hdl)); | ||
vTaskDelay(pdMS_TO_TICKS(1000)); | ||
TEST_ASSERT_EQUAL(ESP_OK, iot_usbh_port_deinit(port_hdl)); | ||
vTaskDelay(pdMS_TO_TICKS(1000)); | ||
} | ||
|
||
static size_t before_free_8bit; | ||
static size_t before_free_32bit; | ||
|
||
static void check_leak(size_t before_free, size_t after_free, const char *type) | ||
{ | ||
ssize_t delta = after_free - before_free; | ||
printf("MALLOC_CAP_%s: Before %u bytes free, After %u bytes free (delta %d)\n", type, before_free, after_free, delta); | ||
TEST_ASSERT_MESSAGE(delta >= TEST_MEMORY_LEAK_THRESHOLD, "memory leak"); | ||
} | ||
|
||
void setUp(void) | ||
{ | ||
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT); | ||
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT); | ||
} | ||
|
||
void tearDown(void) | ||
{ | ||
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT); | ||
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT); | ||
check_leak(before_free_8bit, after_free_8bit, "8BIT"); | ||
check_leak(before_free_32bit, after_free_32bit, "32BIT"); | ||
} | ||
|
||
void app_main(void) | ||
{ | ||
printf("IOT USBH TEST \n"); | ||
unity_run_menu(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
''' | ||
Steps to run these cases: | ||
- Build | ||
- . ${IDF_PATH}/export.sh | ||
- pip install idf_build_apps | ||
- python tools/build_apps.py components/usb/iot_usbh/test_apps -t esp32s3 | ||
- Test | ||
- pip install -r tools/requirements/requirement.pytest.txt | ||
- pytest components/usb/iot_usbh/test_apps --target esp32s3 | ||
''' | ||
|
||
import pytest | ||
from pytest_embedded import Dut | ||
|
||
@pytest.mark.target('esp32s2') | ||
@pytest.mark.target('esp32s3') | ||
@pytest.mark.env('usb_4g') | ||
@pytest.mark.timeout(60 * 60) | ||
def test_iot_usbh(dut: Dut)-> None: | ||
dut.expect_exact('Press ENTER to see the list of tests.') | ||
dut.write('*') | ||
dut.expect_unity_test_output(timeout = 1000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# For IDF 5.0 | ||
CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ_240=y | ||
CONFIG_FREERTOS_HZ=1000 | ||
CONFIG_ESP_TASK_WDT_EN=n | ||
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=4096 | ||
|
||
# For IDF4.4 | ||
CONFIG_ESP32S2_DEFAULT_CPU_FREQ_240=y | ||
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y | ||
CONFIG_ESP_TASK_WDT=n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,15 @@ | ||
version: "0.1.3" | ||
version: "0.2.0" | ||
targets: | ||
- esp32s2 | ||
- esp32s3 | ||
description: esp-iot-solution USB Host CDC driver | ||
url: https://github.com/espressif/esp-iot-solution | ||
description: Simple USB Host CDC driver maintained in esp-iot-solution | ||
url: https://github.com/espressif/esp-iot-solution/tree/master/components/usb/iot_usbh_cdc | ||
repository: https://github.com/espressif/esp-iot-solution/tree/master/components/usb/iot_usbh_cdc | ||
issues: https://github.com/espressif/esp-iot-solution/issues | ||
dependencies: | ||
idf: ">=4.4.1" | ||
cmake_utilities: "0.*" | ||
iot_usbh: | ||
version: ">=0.1.2" | ||
version: "0.*" | ||
public: true | ||
override_path: "../iot_usbh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.