From ac6150f4a6ad5e0c3ec9fc3bb2e1c14fa1054da7 Mon Sep 17 00:00:00 2001 From: muhaidong Date: Tue, 6 May 2025 14:46:45 +0800 Subject: [PATCH] feat(phy): add 11ax rate for cert test --- .../esp_phy/include/esp_phy_cert_test.h | 19 +++++- examples/phy/cert_test/main/cmd_phy.c | 59 ++++++++++++++++++- examples/phy/cert_test/main/cmd_phy.h | 10 +++- 3 files changed, 85 insertions(+), 3 deletions(-) diff --git a/components/esp_phy/include/esp_phy_cert_test.h b/components/esp_phy/include/esp_phy_cert_test.h index 75e6b5e093..97dc390061 100644 --- a/components/esp_phy/include/esp_phy_cert_test.h +++ b/components/esp_phy/include/esp_phy_cert_test.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -37,6 +37,19 @@ typedef enum { PHY_RATE_MCS5 = 0x15, PHY_RATE_MCS6 = 0x16, PHY_RATE_MCS7 = 0x17, +#if CONFIG_SOC_WIFI_HE_SUPPORT + // 11ax + PHY_RATE_11AX_MCS0 = 0x20, + PHY_RATE_11AX_MCS1 = 0x21, + PHY_RATE_11AX_MCS2 = 0x22, + PHY_RATE_11AX_MCS3 = 0x23, + PHY_RATE_11AX_MCS4 = 0x24, + PHY_RATE_11AX_MCS5 = 0x25, + PHY_RATE_11AX_MCS6 = 0x26, + PHY_RATE_11AX_MCS7 = 0x27, + PHY_RATE_11AX_MCS8 = 0x28, + PHY_RATE_11AX_MCS9 = 0x29, +#endif//CONFIG_SOC_WIFI_HE_SUPPORT PHY_WIFI_RATE_MAX } esp_phy_wifi_rate_t; @@ -188,6 +201,10 @@ void esp_phy_bt_tx_tone(uint32_t start, uint32_t chan, uint32_t power); */ void esp_phy_get_rx_result(esp_phy_rx_result_t *rx_result); +#if CONFIG_SOC_WIFI_HE_SUPPORT +void esp_phy_11ax_tx_set(uint32_t he_format, uint32_t ru_index); +#endif + #ifdef __cplusplus } #endif diff --git a/examples/phy/cert_test/main/cmd_phy.c b/examples/phy/cert_test/main/cmd_phy.c index a1cda33955..55249104ee 100644 --- a/examples/phy/cert_test/main/cmd_phy.c +++ b/examples/phy/cert_test/main/cmd_phy.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -26,6 +26,9 @@ static phy_args_t phy_args; static phy_wifi_tx_t phy_wifi_tx_args; static phy_wifi_rx_t phy_wifi_rx_args; static phy_wifiscwout_t phy_wifiscwout_args; +#if CONFIG_SOC_WIFI_HE_SUPPORT +static phy_wifi_11ax_tx_set_t phy_wifi_11ax_tx_set_args; +#endif//CONFIG_SOC_WIFI_HE_SUPPORT #endif #if SOC_BT_SUPPORTED static phy_ble_tx_t phy_ble_tx_args; @@ -240,6 +243,44 @@ static int esp_phy_wifiscwout_func(int argc, char **argv) return 0; } + +#if CONFIG_SOC_WIFI_HE_SUPPORT +static int esp_phy_wifi_11ax_tx_set_func(int argc, char **argv) +{ + uint32_t he_format; + uint32_t ru_index = 0; + int nerrors = arg_parse(argc, argv, (void **) &phy_wifi_11ax_tx_set_args); + if (nerrors != 0) { + arg_print_errors(stderr, phy_wifi_11ax_tx_set_args.end, argv[0]); + return 1; + } + + if (phy_wifi_11ax_tx_set_args.he_format->count == 1) { + he_format = phy_wifi_11ax_tx_set_args.he_format->ival[0]; + } else { + ESP_LOGE(TAG, "Please enter the HE format 1:HESU, 2:HEER, 3:HETB, 0:exit 11ax mode"); + return 1; + } + + if (he_format > 3) { + ESP_LOGE(TAG, "HE format 1:HESU, 2:HEER, 3:HETB, 0:exit 11ax mode"); + return 1; + } + + if (he_format == 3) { + if (phy_wifi_11ax_tx_set_args.ru_index->count == 1) { + ru_index = phy_wifi_11ax_tx_set_args.ru_index->ival[0]; + } else { + ru_index = 0; + ESP_LOGW(TAG, "Default ru_index is 0"); + } + } + + esp_phy_11ax_tx_set(he_format, ru_index); + return 0; +} +#endif//CONFIG_SOC_WIFI_HE_SUPPORT + #endif #if SOC_BT_SUPPORTED @@ -541,6 +582,22 @@ void register_phy_cmd(void) .argtable = &phy_wifiscwout_args }; ESP_ERROR_CHECK( esp_console_cmd_register(&wifiscwout_cmd) ); + +#if CONFIG_SOC_WIFI_HE_SUPPORT + phy_wifi_11ax_tx_set_args.he_format = arg_int0("f", "he_format" , "" , "1:HESU, 2:HEER, 3:HETB, 0:exit 11ax mode"); + phy_wifi_11ax_tx_set_args.ru_index = arg_int0("i", "ru_index" , "" , "0~8, 37~40, 53~54, 61,\ + ru_index is only effective in HETB mode. In other modes, this parameter can be omitted or set to 0, with the default value being 0"); + phy_wifi_11ax_tx_set_args.end = arg_end(1); + + const esp_console_cmd_t esp_11ax_tx_set_cmd = { + .command = "phy_11ax_tx_set", + .help = "WiFi 11ax TX set command", + .hint = NULL, + .func = &esp_phy_wifi_11ax_tx_set_func, + .argtable = &phy_wifi_11ax_tx_set_args + }; + ESP_ERROR_CHECK( esp_console_cmd_register(&esp_11ax_tx_set_cmd) ); +#endif//CONFIG_SOC_WIFI_HE_SUPPORT #endif #if SOC_BT_SUPPORTED diff --git a/examples/phy/cert_test/main/cmd_phy.h b/examples/phy/cert_test/main/cmd_phy.h index 2fb178ca33..744b03ede0 100644 --- a/examples/phy/cert_test/main/cmd_phy.h +++ b/examples/phy/cert_test/main/cmd_phy.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ @@ -53,6 +53,14 @@ typedef struct { uint32_t channel; esp_phy_wifi_rate_t rate; } phy_wifi_rx_s; + +#if CONFIG_SOC_WIFI_HE_SUPPORT +typedef struct { + struct arg_int *he_format; + struct arg_int *ru_index; + struct arg_end *end; +} phy_wifi_11ax_tx_set_t; +#endif//CONFIG_SOC_WIFI_HE_SUPPORT #endif #if SOC_BT_SUPPORTED