From 2fa78094ef65e1669ac60fb0c64e7daf229dc961 Mon Sep 17 00:00:00 2001 From: Alex Lisitsyn Date: Mon, 12 Aug 2024 11:36:15 +0800 Subject: [PATCH] feat(esp_modbus): examples add support of esp32c5 target --- examples/protocols/.build-test-rules.yml | 6 ++++-- examples/protocols/modbus/serial/mb_master/README.md | 8 ++++---- .../modbus/serial/mb_master/main/Kconfig.projbuild | 10 +++++----- examples/protocols/modbus/serial/mb_slave/README.md | 8 ++++---- .../modbus/serial/mb_slave/main/Kconfig.projbuild | 10 +++++----- examples/protocols/modbus/tcp/mb_tcp_master/README.md | 4 ++-- .../modbus/tcp/mb_tcp_master/main/tcp_master.c | 4 ++-- examples/protocols/modbus/tcp/mb_tcp_slave/README.md | 4 ++-- 8 files changed, 28 insertions(+), 26 deletions(-) diff --git a/examples/protocols/.build-test-rules.yml b/examples/protocols/.build-test-rules.yml index 912fd85e41..0dfb3c43dc 100644 --- a/examples/protocols/.build-test-rules.yml +++ b/examples/protocols/.build-test-rules.yml @@ -172,12 +172,14 @@ examples/protocols/l2tap: examples/protocols/modbus: <<: *default_dependencies disable: - - if: IDF_TARGET in ["esp32c5", "esp32c61"] + - if: IDF_TARGET in ["esp32c61"] temporary: true - reason: not supported yet # TODO: [ESP32C5] IDF-8697, [ESP32C61] IDF-9298 + reason: not supported yet [ESP32C61] IDF-9298 depends_filepatterns: + - examples/common_components/protocol_examples_common/**/* - examples/protocols/modbus/mb_example_common/**/* + examples/protocols/mqtt: <<: *default_dependencies disable: diff --git a/examples/protocols/modbus/serial/mb_master/README.md b/examples/protocols/modbus/serial/mb_master/README.md index 7b28f660a2..e6de897de6 100644 --- a/examples/protocols/modbus/serial/mb_master/README.md +++ b/examples/protocols/modbus/serial/mb_master/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | # Modbus Master Example @@ -96,8 +96,8 @@ Define the communication mode parameter for master and slave in Kconfig - CONFIG Configure the slave address for each slave in the Modbus segment (the CONFIG_MB_SLAVE_ADDR in Kconfig). ``` ------------------------------------------------------------------------------------------------------------------------------ - | UART Interface | #define | Default pins for | Default pins for | External RS485 Driver Pin | - | | | ESP32 (C6) | ESP32-S2 (S3, C3, C2, H2) | | + | UART Interface | #define | Default pins for | Default pins for ESP32-S2 | External RS485 Driver Pin | + | | | ESP32 (C6, P4) | (S3, C3, C2, C5, H2) | | | ----------------------|--------------------|-----------------------|---------------------------|---------------------------| | Transmit Data (TxD) | CONFIG_MB_UART_TXD | GPIO23 | GPIO9 | DI | | Receive Data (RxD) | CONFIG_MB_UART_RXD | GPIO22 | GPIO8 | RO | diff --git a/examples/protocols/modbus/serial/mb_master/main/Kconfig.projbuild b/examples/protocols/modbus/serial/mb_master/main/Kconfig.projbuild index 7d182f27b4..b6909e585d 100644 --- a/examples/protocols/modbus/serial/mb_master/main/Kconfig.projbuild +++ b/examples/protocols/modbus/serial/mb_master/main/Kconfig.projbuild @@ -5,12 +5,12 @@ menu "Modbus Example Configuration" config MB_UART_PORT_ONE bool default y - depends on (ESP_CONSOLE_UART_NUM !=1) && (SOC_UART_NUM > 1) + depends on (ESP_CONSOLE_UART_NUM !=1) && (SOC_UART_HP_NUM > 1) config MB_UART_PORT_TWO bool default y - depends on (ESP_CONSOLE_UART_NUM !=2) && (SOC_UART_NUM > 2) + depends on (ESP_CONSOLE_UART_NUM !=2) && (SOC_UART_HP_NUM > 2) config MB_UART_PORT_NUM int "UART port number" @@ -33,7 +33,7 @@ menu "Modbus Example Configuration" range ENV_GPIO_RANGE_MIN ENV_GPIO_IN_RANGE_MAX default 22 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32C6 || IDF_TARGET_ESP32P4 default 8 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3 ||\ - IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32H2 + IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32H2 || IDF_TARGET_ESP32C5 help GPIO number for UART RX pin. See UART documentation for more information about available pin numbers for UART. @@ -43,7 +43,7 @@ menu "Modbus Example Configuration" range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX default 23 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32C6 || IDF_TARGET_ESP32P4 default 9 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3 ||\ - IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32H2 + IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32H2 || IDF_TARGET_ESP32C5 help GPIO number for UART TX pin. See UART documentation for more information about available pin numbers for UART. @@ -54,7 +54,7 @@ menu "Modbus Example Configuration" default 20 if IDF_TARGET_ESP32P4 default 18 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32C6 default 10 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3 ||\ - IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32H2 + IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32H2 || IDF_TARGET_ESP32C5 help GPIO number for UART RTS pin. This pin is connected to ~RE/DE pin of RS485 transceiver to switch direction. diff --git a/examples/protocols/modbus/serial/mb_slave/README.md b/examples/protocols/modbus/serial/mb_slave/README.md index 00db56c68d..b318a77a5c 100644 --- a/examples/protocols/modbus/serial/mb_slave/README.md +++ b/examples/protocols/modbus/serial/mb_slave/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | # Modbus Slave Example @@ -46,8 +46,8 @@ Select Modbus Example Configuration menu item. Configure the UART pins used for modbus communication using the command and table below. ``` ------------------------------------------------------------------------------------------------------------------------------ - | UART Interface | #define | Default pins for | Default pins for | External RS485 Driver Pin | - | | | ESP32 (C6) | ESP32-S2 (S3, C3, C2, H2) | | + | UART Interface | #define | Default pins for | Default pins for ESP32-S2 | External RS485 Driver Pin | + | | | ESP32 (C6, P4) | (S3, C3, C2, C5, H2) | | | ----------------------|--------------------|-----------------------|---------------------------|---------------------------| | Transmit Data (TxD) | CONFIG_MB_UART_TXD | GPIO23 | GPIO9 | DI | | Receive Data (RxD) | CONFIG_MB_UART_RXD | GPIO22 | GPIO8 | RO | diff --git a/examples/protocols/modbus/serial/mb_slave/main/Kconfig.projbuild b/examples/protocols/modbus/serial/mb_slave/main/Kconfig.projbuild index ca1b485eb8..201ef2cc18 100644 --- a/examples/protocols/modbus/serial/mb_slave/main/Kconfig.projbuild +++ b/examples/protocols/modbus/serial/mb_slave/main/Kconfig.projbuild @@ -5,12 +5,12 @@ menu "Modbus Example Configuration" config MB_UART_PORT_ONE bool default y - depends on (ESP_CONSOLE_UART_NUM !=1) && (SOC_UART_NUM > 1) + depends on (ESP_CONSOLE_UART_NUM !=1) && (SOC_UART_HP_NUM > 1) config MB_UART_PORT_TWO bool default y - depends on (ESP_CONSOLE_UART_NUM !=2) && (SOC_UART_NUM > 2) + depends on (ESP_CONSOLE_UART_NUM !=2) && (SOC_UART_HP_NUM > 2) config MB_UART_PORT_NUM int "UART port number" @@ -33,7 +33,7 @@ menu "Modbus Example Configuration" range ENV_GPIO_RANGE_MIN ENV_GPIO_IN_RANGE_MAX default 22 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32C6 || IDF_TARGET_ESP32P4 default 8 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3 ||\ - IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32H2 + IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32H2 || IDF_TARGET_ESP32C5 help GPIO number for UART RX pin. See UART documentation for more information about available pin numbers for UART. @@ -43,7 +43,7 @@ menu "Modbus Example Configuration" range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX default 23 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32C6 || IDF_TARGET_ESP32P4 default 9 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3 ||\ - IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32H2 + IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32H2 || IDF_TARGET_ESP32C5 help GPIO number for UART TX pin. See UART documentation for more information about available pin numbers for UART. @@ -54,7 +54,7 @@ menu "Modbus Example Configuration" default 20 if IDF_TARGET_ESP32P4 default 18 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32C6 default 10 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3 ||\ - IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32H2 + IDF_TARGET_ESP32C2 || IDF_TARGET_ESP32H2 || IDF_TARGET_ESP32C5 help GPIO number for UART RTS pin. This pin is connected to ~RE/DE pin of RS485 transceiver to switch direction. diff --git a/examples/protocols/modbus/tcp/mb_tcp_master/README.md b/examples/protocols/modbus/tcp/mb_tcp_master/README.md index 14e09abea7..e07f3d3203 100644 --- a/examples/protocols/modbus/tcp/mb_tcp_master/README.md +++ b/examples/protocols/modbus/tcp/mb_tcp_master/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | # Modbus TCP Master Example diff --git a/examples/protocols/modbus/tcp/mb_tcp_master/main/tcp_master.c b/examples/protocols/modbus/tcp/mb_tcp_master/main/tcp_master.c index 8a65d62653..2a762a442d 100644 --- a/examples/protocols/modbus/tcp/mb_tcp_master/main/tcp_master.c +++ b/examples/protocols/modbus/tcp/mb_tcp_master/main/tcp_master.c @@ -397,7 +397,7 @@ static int master_create_slave_list(mdns_result_t* results, char** addr_table, cid_resolve_cnt++; } } - ESP_LOGI(TAG, "Resolved %d cids, with %d IP addresses", cid_resolve_cnt, ip_index); + ESP_LOGI(TAG, "Resolved %d cids, with %d address(es)", cid_resolve_cnt, ip_index); return cid_resolve_cnt; } @@ -659,7 +659,7 @@ static esp_err_t init_services(mb_tcp_addr_type_t ip_addr_type) #elif CONFIG_MB_SLAVE_IP_FROM_STDIN int ip_cnt = master_get_slave_ip_stdin(slave_ip_address_table); if (ip_cnt) { - ESP_LOGI(TAG, "Configured %d IP addresse(s).", ip_cnt); + ESP_LOGI(TAG, "Configured %d IP address(es).", ip_cnt); } else { ESP_LOGE(TAG, "Fail to get IP address from stdin. Continue."); return ESP_ERR_NOT_FOUND; diff --git a/examples/protocols/modbus/tcp/mb_tcp_slave/README.md b/examples/protocols/modbus/tcp/mb_tcp_slave/README.md index 725bf10ced..830b5fc882 100644 --- a/examples/protocols/modbus/tcp/mb_tcp_slave/README.md +++ b/examples/protocols/modbus/tcp/mb_tcp_slave/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | # Modbus Slave Example