forked from espressif/esp-modbus
Add support for esp32c2 target
This commit is contained in:
@ -77,8 +77,8 @@ build_idf_latest:
|
|||||||
extends: .build_template
|
extends: .build_template
|
||||||
image: espressif/idf:latest
|
image: espressif/idf:latest
|
||||||
variables:
|
variables:
|
||||||
EXAMPLE_TARGETS: "esp32 esp32s2 esp32s3 esp32c3"
|
EXAMPLE_TARGETS: "esp32 esp32s2 esp32s3 esp32c3 esp32c2"
|
||||||
TEST_TARGETS: "esp32 esp32s3"
|
TEST_TARGETS: "esp32 esp32s3 esp32c2"
|
||||||
# GNU Make based build system is not supported starting from IDF v5.0
|
# GNU Make based build system is not supported starting from IDF v5.0
|
||||||
SKIP_GNU_MAKE_BUILD: 1
|
SKIP_GNU_MAKE_BUILD: 1
|
||||||
|
|
||||||
|
@ -222,7 +222,11 @@ BOOL xMBPortSerialInit(UCHAR ucPORT, ULONG ulBaudRate,
|
|||||||
.stop_bits = UART_STOP_BITS_1,
|
.stop_bits = UART_STOP_BITS_1,
|
||||||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
|
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
|
||||||
.rx_flow_ctrl_thresh = 2,
|
.rx_flow_ctrl_thresh = 2,
|
||||||
.source_clk = UART_SCLK_APB
|
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
|
||||||
|
.source_clk = UART_SCLK_DEFAULT,
|
||||||
|
#else
|
||||||
|
.source_clk = UART_SCLK_APB,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
// Set UART config
|
// Set UART config
|
||||||
xErr = uart_param_config(ucUartNumber, &xUartConfig);
|
xErr = uart_param_config(ucUartNumber, &xUartConfig);
|
||||||
|
@ -293,7 +293,11 @@ BOOL xMBMasterPortSerialInit( UCHAR ucPORT, ULONG ulBaudRate, UCHAR ucDataBits,
|
|||||||
.stop_bits = UART_STOP_BITS_1,
|
.stop_bits = UART_STOP_BITS_1,
|
||||||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
|
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
|
||||||
.rx_flow_ctrl_thresh = 2,
|
.rx_flow_ctrl_thresh = 2,
|
||||||
|
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
|
||||||
|
.source_clk = UART_SCLK_DEFAULT,
|
||||||
|
#else
|
||||||
.source_clk = UART_SCLK_APB,
|
.source_clk = UART_SCLK_APB,
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
// Set UART config
|
// Set UART config
|
||||||
xErr = uart_param_config(ucUartNumber, &xUartConfig);
|
xErr = uart_param_config(ucUartNumber, &xUartConfig);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
| Supported Targets | ESP32 | ESP32-S2 | ESP32-S3 | ESP32-C3 |
|
| Supported Targets | ESP32 | ESP32-S2 | ESP32-S3 | ESP32-C3 | ESP32-C2 |
|
||||||
| ----------------- | ----- | -------- | -------- | -------- |
|
| ----------------- | ----- | -------- | -------- | -------- | -------- |
|
||||||
|
|
||||||
# Modbus Master Example
|
# Modbus Master Example
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ Configure the slave address for each slave in the Modbus segment (the CONFIG_MB_
|
|||||||
```
|
```
|
||||||
--------------------------------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------------------------------
|
||||||
| UART Interface | #define | Default ESP32 Pin | Default pins for | External RS485 Driver Pin |
|
| UART Interface | #define | Default ESP32 Pin | Default pins for | External RS485 Driver Pin |
|
||||||
| | | | ESP32-S2(S3, C3) | |
|
| | | | ESP32-S2(S3, C3, C2) | |
|
||||||
| ----------------------|--------------------|-----------------------|-----------------------|---------------------------|
|
| ----------------------|--------------------|-----------------------|-----------------------|---------------------------|
|
||||||
| Transmit Data (TxD) | CONFIG_MB_UART_TXD | GPIO23 | GPIO9 | DI |
|
| Transmit Data (TxD) | CONFIG_MB_UART_TXD | GPIO23 | GPIO9 | DI |
|
||||||
| Receive Data (RxD) | CONFIG_MB_UART_RXD | GPIO22 | GPIO8 | RO |
|
| Receive Data (RxD) | CONFIG_MB_UART_RXD | GPIO22 | GPIO8 | RO |
|
||||||
|
@ -4,8 +4,8 @@ menu "Modbus Example Configuration"
|
|||||||
int "UART port number"
|
int "UART port number"
|
||||||
range 0 2 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S3
|
range 0 2 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S3
|
||||||
default 2 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S3
|
default 2 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S3
|
||||||
range 0 1 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32C3
|
range 0 1 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C2
|
||||||
default 1 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32C3
|
default 1 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C2
|
||||||
help
|
help
|
||||||
UART communication port number for Modbus example.
|
UART communication port number for Modbus example.
|
||||||
|
|
||||||
@ -23,7 +23,8 @@ menu "Modbus Example Configuration"
|
|||||||
range 0 46 if IDF_TARGET_ESP32S2
|
range 0 46 if IDF_TARGET_ESP32S2
|
||||||
range 0 47 if IDF_TARGET_ESP32S3
|
range 0 47 if IDF_TARGET_ESP32S3
|
||||||
range 0 19 if IDF_TARGET_ESP32C3
|
range 0 19 if IDF_TARGET_ESP32C3
|
||||||
default 8 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3
|
range 0 20 if IDF_TARGET_ESP32C2
|
||||||
|
default 8 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C2
|
||||||
help
|
help
|
||||||
GPIO number for UART RX pin. See UART documentation for more information
|
GPIO number for UART RX pin. See UART documentation for more information
|
||||||
about available pin numbers for UART.
|
about available pin numbers for UART.
|
||||||
@ -35,7 +36,8 @@ menu "Modbus Example Configuration"
|
|||||||
range 0 46 if IDF_TARGET_ESP32S2
|
range 0 46 if IDF_TARGET_ESP32S2
|
||||||
range 0 47 if IDF_TARGET_ESP32S3
|
range 0 47 if IDF_TARGET_ESP32S3
|
||||||
range 0 19 if IDF_TARGET_ESP32C3
|
range 0 19 if IDF_TARGET_ESP32C3
|
||||||
default 9 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3
|
range 0 20 if IDF_TARGET_ESP32C2
|
||||||
|
default 9 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C2
|
||||||
help
|
help
|
||||||
GPIO number for UART TX pin. See UART documentation for more information
|
GPIO number for UART TX pin. See UART documentation for more information
|
||||||
about available pin numbers for UART.
|
about available pin numbers for UART.
|
||||||
@ -47,7 +49,8 @@ menu "Modbus Example Configuration"
|
|||||||
range 0 46 if IDF_TARGET_ESP32S2
|
range 0 46 if IDF_TARGET_ESP32S2
|
||||||
range 0 47 if IDF_TARGET_ESP32S3
|
range 0 47 if IDF_TARGET_ESP32S3
|
||||||
range 0 19 if IDF_TARGET_ESP32C3
|
range 0 19 if IDF_TARGET_ESP32C3
|
||||||
default 10 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3
|
range 0 20 if IDF_TARGET_ESP32C2
|
||||||
|
default 10 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C2
|
||||||
help
|
help
|
||||||
GPIO number for UART RTS pin. This pin is connected to
|
GPIO number for UART RTS pin. This pin is connected to
|
||||||
~RE/DE pin of RS485 transceiver to switch direction.
|
~RE/DE pin of RS485 transceiver to switch direction.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
| Supported Targets | ESP32 | ESP32-S2 | ESP32-S3 | ESP32-C3 |
|
| Supported Targets | ESP32 | ESP32-S2 | ESP32-S3 | ESP32-C3 | ESP32-C2 |
|
||||||
| ----------------- | ----- | -------- | -------- | -------- |
|
| ----------------- | ----- | -------- | -------- | -------- | -------- |
|
||||||
|
|
||||||
# Modbus Slave Example
|
# Modbus Slave Example
|
||||||
|
|
||||||
@ -47,7 +47,7 @@ Configure the UART pins used for modbus communication using the command and tabl
|
|||||||
```
|
```
|
||||||
--------------------------------------------------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------------------------------------------------
|
||||||
| UART Interface | #define | Default ESP32 Pin | Default pins for | External RS485 Driver Pin |
|
| UART Interface | #define | Default ESP32 Pin | Default pins for | External RS485 Driver Pin |
|
||||||
| | | | ESP32-S2(S3, C3) | |
|
| | | | ESP32-S2(S3, C3, C2) | |
|
||||||
| ----------------------|--------------------|-----------------------|-----------------------|---------------------------|
|
| ----------------------|--------------------|-----------------------|-----------------------|---------------------------|
|
||||||
| Transmit Data (TxD) | CONFIG_MB_UART_TXD | GPIO23 | GPIO9 | DI |
|
| Transmit Data (TxD) | CONFIG_MB_UART_TXD | GPIO23 | GPIO9 | DI |
|
||||||
| Receive Data (RxD) | CONFIG_MB_UART_RXD | GPIO22 | GPIO8 | RO |
|
| Receive Data (RxD) | CONFIG_MB_UART_RXD | GPIO22 | GPIO8 | RO |
|
||||||
|
@ -4,8 +4,8 @@ menu "Modbus Example Configuration"
|
|||||||
int "UART port number"
|
int "UART port number"
|
||||||
range 0 2 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S3
|
range 0 2 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S3
|
||||||
default 2 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S3
|
default 2 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S3
|
||||||
range 0 1 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32C3
|
range 0 1 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C2
|
||||||
default 1 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32C3
|
default 1 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C2
|
||||||
help
|
help
|
||||||
UART communication port number for Modbus example.
|
UART communication port number for Modbus example.
|
||||||
|
|
||||||
@ -23,7 +23,8 @@ menu "Modbus Example Configuration"
|
|||||||
range 0 46 if IDF_TARGET_ESP32S2
|
range 0 46 if IDF_TARGET_ESP32S2
|
||||||
range 0 47 if IDF_TARGET_ESP32S3
|
range 0 47 if IDF_TARGET_ESP32S3
|
||||||
range 0 19 if IDF_TARGET_ESP32C3
|
range 0 19 if IDF_TARGET_ESP32C3
|
||||||
default 8 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3
|
range 0 20 if IDF_TARGET_ESP32C2
|
||||||
|
default 8 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C2
|
||||||
help
|
help
|
||||||
GPIO number for UART RX pin. See UART documentation for more information
|
GPIO number for UART RX pin. See UART documentation for more information
|
||||||
about available pin numbers for UART.
|
about available pin numbers for UART.
|
||||||
@ -35,7 +36,8 @@ menu "Modbus Example Configuration"
|
|||||||
range 0 46 if IDF_TARGET_ESP32S2
|
range 0 46 if IDF_TARGET_ESP32S2
|
||||||
range 0 47 if IDF_TARGET_ESP32S3
|
range 0 47 if IDF_TARGET_ESP32S3
|
||||||
range 0 19 if IDF_TARGET_ESP32C3
|
range 0 19 if IDF_TARGET_ESP32C3
|
||||||
default 9 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3
|
range 0 20 if IDF_TARGET_ESP32C2
|
||||||
|
default 9 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C2
|
||||||
help
|
help
|
||||||
GPIO number for UART TX pin. See UART documentation for more information
|
GPIO number for UART TX pin. See UART documentation for more information
|
||||||
about available pin numbers for UART.
|
about available pin numbers for UART.
|
||||||
@ -47,7 +49,8 @@ menu "Modbus Example Configuration"
|
|||||||
range 0 46 if IDF_TARGET_ESP32S2
|
range 0 46 if IDF_TARGET_ESP32S2
|
||||||
range 0 47 if IDF_TARGET_ESP32S3
|
range 0 47 if IDF_TARGET_ESP32S3
|
||||||
range 0 19 if IDF_TARGET_ESP32C3
|
range 0 19 if IDF_TARGET_ESP32C3
|
||||||
default 10 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3
|
range 0 20 if IDF_TARGET_ESP32C2
|
||||||
|
default 10 if IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3 || IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C2
|
||||||
help
|
help
|
||||||
GPIO number for UART RTS pin. This pin is connected to
|
GPIO number for UART RTS pin. This pin is connected to
|
||||||
~RE/DE pin of RS485 transceiver to switch direction.
|
~RE/DE pin of RS485 transceiver to switch direction.
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
| Supported Targets | ESP32 | ESP32-S2 | ESP32-S3 | ESP32-C3 |
|
| Supported Targets | ESP32 | ESP32-S2 | ESP32-S3 | ESP32-C3 | ESP32-C2 |
|
||||||
| ----------------- | ----- | -------- | -------- | -------- |
|
| ----------------- | ----- | -------- | -------- | -------- | -------- |
|
||||||
|
|
||||||
# Modbus TCP Master Example
|
# Modbus TCP Master Example
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
| Supported Targets | ESP32 | ESP32-S2 | ESP32-S3 | ESP32-C3 |
|
| Supported Targets | ESP32 | ESP32-S2 | ESP32-S3 | ESP32-C3 | ESP32-C2 |
|
||||||
| ----------------- | ----- | -------- | -------- | -------- |
|
| ----------------- | ----- | -------- | -------- | -------- | -------- |
|
||||||
|
|
||||||
# Modbus Slave Example
|
# Modbus Slave Example
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user