Skip to content

Commit f1d2bd7

Browse files
authored
Merge pull request #89 from espressif/esp32-s3-support
Update 2 from 23022022
2 parents 3c8f0bb + 4d1c417 commit f1d2bd7

File tree

805 files changed

+81128
-15914
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

805 files changed

+81128
-15914
lines changed

.github/scripts/install-platformio-esp32.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
export PLATFORMIO_ESP32_PATH="$HOME/.platformio/packages/framework-arduinoespressif32"
44
PLATFORMIO_ESP32_URL="https://github.com/platformio/platform-espressif32.git#feature/arduino-idf-master"
55

6-
XTENSA32_TOOLCHAIN_VERSION="8.4.0+2021r2-patch2"
7-
XTENSA32S2_TOOLCHAIN_VERSION="8.4.0+2021r2-patch2"
8-
RISCV_TOOLCHAIN_VERSION="8.4.0+2021r2-patch2"
6+
TOOLCHAIN_VERSION="8.4.0+2021r2-patch2"
97
ESPTOOLPY_VERSION="~1.30100.0"
108
ESPRESSIF_ORGANIZATION_NAME="espressif"
119

@@ -28,11 +26,13 @@ replace_script+="del data['packages']['framework-arduinoespressif32']['owner'];"
2826
# Use toolchain packages from the "espressif" organization
2927
replace_script+="data['packages']['toolchain-xtensa-esp32']['owner']='$ESPRESSIF_ORGANIZATION_NAME';"
3028
replace_script+="data['packages']['toolchain-xtensa-esp32s2']['owner']='$ESPRESSIF_ORGANIZATION_NAME';"
29+
replace_script+="data['packages']['toolchain-xtensa-esp32s3']['owner']='$ESPRESSIF_ORGANIZATION_NAME';"
3130
replace_script+="data['packages']['toolchain-riscv32-esp']['owner']='$ESPRESSIF_ORGANIZATION_NAME';"
3231
# Update versions to use the upstream
33-
replace_script+="data['packages']['toolchain-xtensa-esp32']['version']='$XTENSA32_TOOLCHAIN_VERSION';"
34-
replace_script+="data['packages']['toolchain-xtensa-esp32s2']['version']='$XTENSA32S2_TOOLCHAIN_VERSION';"
35-
replace_script+="data['packages']['toolchain-riscv32-esp']['version']='$RISCV_TOOLCHAIN_VERSION';"
32+
replace_script+="data['packages']['toolchain-xtensa-esp32']['version']='$TOOLCHAIN_VERSION';"
33+
replace_script+="data['packages']['toolchain-xtensa-esp32s2']['version']='$TOOLCHAIN_VERSION';"
34+
replace_script+="data['packages']['toolchain-xtensa-esp32s3']['version']='$TOOLCHAIN_VERSION';"
35+
replace_script+="data['packages']['toolchain-riscv32-esp']['version']='$TOOLCHAIN_VERSION';"
3636
# esptool.py may require an upstream version (for now platformio is the owner)
3737
replace_script+="data['packages']['tool-esptoolpy']['version']='$ESPTOOLPY_VERSION';"
3838
# Save results

.github/scripts/on-push.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ if [ "$BUILD_PIO" -eq 0 ]; then
6363

6464
FQBN_ESP32="espressif:esp32:esp32:PSRAM=enabled,PartitionScheme=huge_app"
6565
FQBN_ESP32S2="espressif:esp32:esp32s2:PSRAM=enabled,PartitionScheme=huge_app"
66+
FQBN_ESP32S3="espressif:esp32:esp32s3:PSRAM=opi,PartitionScheme=huge_app"
6667
FQBN_ESP32C3="espressif:esp32:esp32c3:PartitionScheme=huge_app"
6768

6869
SKETCHES_ESP32="\
@@ -78,6 +79,7 @@ if [ "$BUILD_PIO" -eq 0 ]; then
7879

7980
build "esp32" $FQBN_ESP32 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32
8081
build "esp32s2" $FQBN_ESP32S2 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32XX
82+
build "esp32s3" $FQBN_ESP32S3 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32
8183
build "esp32c3" $FQBN_ESP32C3 $CHUNK_INDEX $CHUNKS_CNT $SKETCHES_ESP32XX
8284
else
8385
source ./${SCRIPTS_DIR}/install-platformio-esp32.sh
@@ -96,6 +98,8 @@ else
9698
# build_pio_sketch "$BOARD" "$OPTIONS" "$PLATFORMIO_ESP32_PATH/libraries/WiFiClientSecure/examples/WiFiClientSecure/WiFiClientSecure.ino"
9799

98100
python -m platformio ci --board "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/WiFi/examples/WiFiClient" --project-option="board_build.mcu = esp32s2" --project-option="board_build.partitions = huge_app.csv"
101+
python -m platformio ci --board "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/WiFi/examples/WiFiClient" --project-option="board_build.mcu = esp32s3" --project-option="board_build.partitions = huge_app.csv"
102+
python -m platformio ci --board "$BOARD" "$PLATFORMIO_ESP32_PATH/libraries/WiFi/examples/WiFiClient" --project-option="board_build.mcu = esp32c3" --project-option="board_build.partitions = huge_app.csv"
99103

100104
#build_pio_sketches "$BOARD" "$OPTIONS" "$PLATFORMIO_ESP32_PATH/libraries"
101105
fi

platform.txt

Lines changed: 4 additions & 4 deletions
Large diffs are not rendered by default.

tools/esptool.py

Lines changed: 582 additions & 180 deletions
Large diffs are not rendered by default.

tools/platformio-build-esp32.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@
304304
"UNITY_INCLUDE_CONFIG_H",
305305
"WITH_POSIX",
306306
"_GNU_SOURCE",
307-
("IDF_VER", '\\"v4.4-98-geb3797dc3f\\"'),
307+
("IDF_VER", '\\"v4.4-263-g000d3823bb\\"'),
308308
"ESP_PLATFORM",
309309
"_POSIX_READER_WRITER_LOCKS",
310310
"ARDUINO_ARCH_ESP32",

tools/platformio-build-esp32c3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@
294294
"UNITY_INCLUDE_CONFIG_H",
295295
"WITH_POSIX",
296296
"_GNU_SOURCE",
297-
("IDF_VER", '\\"v4.4-98-geb3797dc3f\\"'),
297+
("IDF_VER", '\\"v4.4-263-g000d3823bb\\"'),
298298
"ESP_PLATFORM",
299299
"_POSIX_READER_WRITER_LOCKS",
300300
"ARDUINO_ARCH_ESP32",

tools/platformio-build-esp32s2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@
291291
"UNITY_INCLUDE_CONFIG_H",
292292
"WITH_POSIX",
293293
"_GNU_SOURCE",
294-
("IDF_VER", '\\"v4.4-98-geb3797dc3f\\"'),
294+
("IDF_VER", '\\"v4.4-263-g000d3823bb\\"'),
295295
"ESP_PLATFORM",
296296
"_POSIX_READER_WRITER_LOCKS",
297297
"ARDUINO_ARCH_ESP32",

tools/platformio-build-esp32s3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@
308308
"UNITY_INCLUDE_CONFIG_H",
309309
"WITH_POSIX",
310310
"_GNU_SOURCE",
311-
("IDF_VER", '\\"v4.4-98-geb3797dc3f\\"'),
311+
("IDF_VER", '\\"v4.4-263-g000d3823bb\\"'),
312312
"ESP_PLATFORM",
313313
"_POSIX_READER_WRITER_LOCKS",
314314
"ARDUINO_ARCH_ESP32",
16 Bytes
Binary file not shown.
16 Bytes
Binary file not shown.
16 Bytes
Binary file not shown.
16 Bytes
Binary file not shown.

tools/sdk/esp32/include/config/sdkconfig.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@
419419
#define CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE 1
420420
#define CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC 1
421421
#define CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN 16384
422+
#define CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE 1
422423
#define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE 1
423424
#define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL 1
424425
#define CONFIG_MBEDTLS_HARDWARE_AES 1
@@ -554,6 +555,7 @@
554555
#define CONFIG_GC032A_SUPPORT 1
555556
#define CONFIG_GC0308_SUPPORT 1
556557
#define CONFIG_BF3005_SUPPORT 1
558+
#define CONFIG_BF20A6_SUPPORT 1
557559
#define CONFIG_SCCB_HARDWARE_I2C_PORT1 1
558560
#define CONFIG_SCCB_CLK_FREQ 100000
559561
#define CONFIG_GC_SENSOR_SUBSAMPLE_MODE 1

tools/sdk/esp32/include/esp32-camera/driver/include/sensor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ typedef enum {
2727
GC032A_PID = 0x232a,
2828
GC0308_PID = 0x9b,
2929
BF3005_PID = 0x30,
30+
BF20A6_PID = 0x20a6,
3031
} camera_pid_t;
3132

3233
typedef enum {
@@ -40,6 +41,7 @@ typedef enum {
4041
CAMERA_GC032A,
4142
CAMERA_GC0308,
4243
CAMERA_BF3005,
44+
CAMERA_BF20A6,
4345
CAMERA_MODEL_MAX,
4446
CAMERA_NONE,
4547
} camera_model_t;
@@ -55,6 +57,7 @@ typedef enum {
5557
GC032A_SCCB_ADDR = 0x21,// 0x42 >> 1
5658
GC0308_SCCB_ADDR = 0x21,// 0x42 >> 1
5759
BF3005_SCCB_ADDR = 0x6E,
60+
BF20A6_SCCB_ADDR = 0x6E,
5861
} camera_sccb_addr_t;
5962

6063
typedef enum {

tools/sdk/esp32/include/esp_adc_cal/include/esp_adc_cal.h

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
// See the License for the specific language governing permissions and
13-
// limitations under the License.
1+
/*
2+
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
146

157
#ifndef __ESP_ADC_CAL_H__
168
#define __ESP_ADC_CAL_H__

tools/sdk/esp32/include/esp_hw_support/include/esp_chip_info.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ typedef enum {
3333
#define CHIP_FEATURE_BLE BIT(4) //!< Chip has Bluetooth LE
3434
#define CHIP_FEATURE_BT BIT(5) //!< Chip has Bluetooth Classic
3535
#define CHIP_FEATURE_IEEE802154 BIT(6) //!< Chip has IEEE 802.15.4
36+
#define CHIP_FEATURE_EMB_PSRAM BIT(7) //!< Chip has embedded psram
3637

3738
/**
3839
* @brief The structure represents information about the chip

tools/sdk/esp32/include/esp_ipc/include/esp_ipc_isr.h

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -22,20 +22,6 @@ extern "C" {
2222
*/
2323
typedef void (*esp_ipc_isr_func_t)(void* arg);
2424

25-
/**
26-
* @brief Initialize the IPC ISR feature
27-
*
28-
* This function initializes the IPC ISR feature and must be called before any other esp_ipc_isr...() functions.
29-
* The IPC ISR feature allows for callbacks (written in assembly) to be run on a particular CPU in the context of a
30-
* High Priority Interrupt.
31-
*
32-
* - This function will register a High Priority Interrupt on each CPU. The priority of the interrupts is dependent on
33-
* the CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL option.
34-
* - Callbacks written in assembly can then run in context of the registered High Priority Interrupts
35-
* - Callbacks can be executed by calling esp_ipc_isr_asm_call() or esp_ipc_isr_asm_call_blocking()
36-
*/
37-
void esp_ipc_isr_init(void);
38-
3925
/**
4026
* @brief Execute an assembly callback on the other CPU
4127
*

tools/sdk/esp32/include/esp_lcd/include/esp_lcd_panel_rgb.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -64,7 +64,7 @@ typedef struct {
6464
unsigned int hsync_idle_low: 1; /*!< The hsync signal is low in IDLE state */
6565
unsigned int vsync_idle_low: 1; /*!< The vsync signal is low in IDLE state */
6666
unsigned int de_idle_high: 1; /*!< The de signal is high in IDLE state */
67-
unsigned int pclk_active_neg: 1; /*!< The display will write data lines when there's a falling edge on PCLK */
67+
unsigned int pclk_active_neg: 1; /*!< Whether the display data is clocked out at the falling edge of PCLK */
6868
unsigned int pclk_idle_high: 1; /*!< The PCLK stays at high level in IDLE phase */
6969
} flags;
7070
} esp_lcd_rgb_timing_t;
@@ -92,6 +92,8 @@ typedef struct {
9292
lcd_clock_source_t clk_src; /*!< Clock source for the RGB LCD peripheral */
9393
esp_lcd_rgb_timing_t timings; /*!< RGB timing parameters */
9494
size_t data_width; /*!< Number of data lines */
95+
size_t sram_trans_align; /*!< Alignment for framebuffer that allocated in SRAM */
96+
size_t psram_trans_align; /*!< Alignment for framebuffer that allocated in PSRAM */
9597
int hsync_gpio_num; /*!< GPIO used for HSYNC signal */
9698
int vsync_gpio_num; /*!< GPIO used for VSYNC signal */
9799
int de_gpio_num; /*!< GPIO used for DE signal, set to -1 if it's not used */

tools/sdk/esp32/include/esp_phy/include/phy.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
2+
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*/
@@ -99,6 +99,13 @@ void phy_freq_mem_backup(bool backup_en, uint32_t *mem);
9999
void phy_bbpll_en_usb(bool en);
100100
#endif
101101

102+
#if CONFIG_IDF_TARGET_ESP32S2
103+
/**
104+
* @brief Phy version select for ESP32S2
105+
*/
106+
void phy_eco_version_sel(uint8_t chip_ver);
107+
#endif
108+
102109
#ifdef __cplusplus
103110
}
104111
#endif

tools/sdk/esp32/include/esp_rom/include/esp32h2/rom/rtc.h

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
// Copyright 2020 Espressif Systems (Shanghai) PTE LTD
2-
//
3-
// Licensed under the Apache License, Version 2.0 (the "License");
4-
// you may not use this file except in compliance with the License.
5-
// You may obtain a copy of the License at
6-
//
7-
// http://www.apache.org/licenses/LICENSE-2.0
8-
//
9-
// Unless required by applicable law or agreed to in writing, software
10-
// distributed under the License is distributed on an "AS IS" BASIS,
11-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12-
// See the License for the specific language governing permissions and
13-
// limitations under the License.
1+
/*
2+
* SPDX-FileCopyrightText: 2020-2021 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
146

157
#ifndef _ROM_RTC_H_
168
#define _ROM_RTC_H_
@@ -124,7 +116,7 @@ _Static_assert((soc_reset_reason_t)EFUSE_RESET == RESET_REASON_CORE_EFUSE_CRC, "
124116
_Static_assert((soc_reset_reason_t)USB_UART_CHIP_RESET == RESET_REASON_CORE_USB_UART, "USB_UART_CHIP_RESET != RESET_REASON_CORE_USB_UART");
125117
_Static_assert((soc_reset_reason_t)USB_JTAG_CHIP_RESET == RESET_REASON_CORE_USB_JTAG, "USB_JTAG_CHIP_RESET != RESET_REASON_CORE_USB_JTAG");
126118
_Static_assert((soc_reset_reason_t)POWER_GLITCH_RESET == RESET_REASON_CORE_PWR_GLITCH, "POWER_GLITCH_RESET != RESET_REASON_CORE_PWR_GLITCH");
127-
_Static_assert((soc_reset_reason_t)JTAG_RESET == RESET_REASON_CPU_JTAG, "JTAG_RESET != RESET_REASON_CPU_JTAG");
119+
_Static_assert((soc_reset_reason_t)JTAG_RESET == RESET_REASON_CPU0_JTAG, "JTAG_RESET != RESET_REASON_CPU0_JTAG");
128120

129121
typedef enum {
130122
NO_SLEEP = 0,
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#pragma once
8+
9+
#include "sdkconfig.h"
10+
11+
#ifdef __cplusplus
12+
extern "C" {
13+
#endif
14+
15+
#ifdef CONFIG_ESP_IPC_ISR_ENABLE
16+
17+
/**
18+
* @brief Initialize the IPC ISR feature, must be called for each CPU
19+
*
20+
* @note This function is called from ipc_task().
21+
*
22+
* This function initializes the IPC ISR feature and must be called before any other esp_ipc_isr...() functions.
23+
* The IPC ISR feature allows for callbacks (written in assembly) to be run on a particular CPU in the context of a
24+
* High Priority Interrupt.
25+
*
26+
* - This function will register a High Priority Interrupt for a CPU where it is called. The priority of the interrupts is dependent on
27+
* the CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL option.
28+
* - Callbacks written in assembly can then run in context of the registered High Priority Interrupts
29+
* - Callbacks can be executed by calling esp_ipc_isr_asm_call() or esp_ipc_isr_asm_call_blocking()
30+
*/
31+
void esp_ipc_isr_init(void);
32+
33+
#endif // CONFIG_ESP_IPC_ISR_ENABLE
34+
35+
#ifdef __cplusplus
36+
}
37+
#endif

tools/sdk/esp32/include/expat/expat/expat/lib/expat.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Copyright (c) 2000-2005 Fred L. Drake, Jr. <[email protected]>
1212
Copyright (c) 2001-2002 Greg Stein <[email protected]>
1313
Copyright (c) 2002-2016 Karl Waclawek <[email protected]>
14-
Copyright (c) 2016-2021 Sebastian Pipping <[email protected]>
14+
Copyright (c) 2016-2022 Sebastian Pipping <[email protected]>
1515
Copyright (c) 2016 Cristian Rodríguez <[email protected]>
1616
Copyright (c) 2016 Thomas Beutlich <[email protected]>
1717
Copyright (c) 2017 Rhodri James <[email protected]>
@@ -1041,7 +1041,7 @@ XML_SetBillionLaughsAttackProtectionActivationThreshold(
10411041
*/
10421042
#define XML_MAJOR_VERSION 2
10431043
#define XML_MINOR_VERSION 4
1044-
#define XML_MICRO_VERSION 1
1044+
#define XML_MICRO_VERSION 3
10451045

10461046
#ifdef __cplusplus
10471047
}

tools/sdk/esp32/include/expat/port/include/expat_config.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
#define PACKAGE_NAME "expat"
6464

6565
/* Define to the full name and version of this package. */
66-
#define PACKAGE_STRING "expat 2.2.5"
66+
#define PACKAGE_STRING "expat 2.4.3"
6767

6868
/* Define to the one symbol short name of this package. */
6969
#define PACKAGE_TARNAME "expat"
@@ -72,13 +72,13 @@
7272
#define PACKAGE_URL ""
7373

7474
/* Define to the version of this package. */
75-
#define PACKAGE_VERSION "2.2.5"
75+
#define PACKAGE_VERSION "2.4.3"
7676

7777
/* Define to 1 if you have the ANSI C header files. */
7878
#define STDC_HEADERS 1
7979

8080
/* Version number of package */
81-
#define VERSION "2.2.5"
81+
#define VERSION "2.4.3"
8282

8383
/* whether byteorder is bigendian */
8484
/* #undef WORDS_BIGENDIAN */

tools/sdk/esp32/include/freemodbus/common/include/esp_modbus_common.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,24 @@
2222
extern "C" {
2323
#endif
2424

25+
#if __has_include("esp_check.h")
26+
#include "esp_check.h"
27+
28+
#define MB_RETURN_ON_FALSE(a, err_code, tag, format, ...) ESP_RETURN_ON_FALSE(a, err_code, tag, format __VA_OPT__(,) __VA_ARGS__)
29+
30+
#else
31+
32+
// if cannot include esp_check then use custom check macro
33+
34+
#define MB_RETURN_ON_FALSE(a, err_code, tag, format, ...) do { \
35+
if (!(a)) { \
36+
ESP_LOGE(tag, "%s(%d): " format, __FUNCTION__, __LINE__ __VA_OPT__(,) __VA_ARGS__); \
37+
return err_code; \
38+
} \
39+
} while(0)
40+
41+
#endif
42+
2543
#define MB_CONTROLLER_STACK_SIZE (CONFIG_FMB_CONTROLLER_STACK_SIZE) // Stack size for Modbus controller
2644
#define MB_CONTROLLER_PRIORITY (CONFIG_FMB_PORT_TASK_PRIO - 1) // priority of MB controller task
2745

tools/sdk/esp32/include/freemodbus/common/include/esp_modbus_master.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@
2525
extern "C" {
2626
#endif
2727

28+
#define MB_MASTER_CHECK(a, err_code, format, ...) MB_RETURN_ON_FALSE(a, err_code, TAG, format __VA_OPT__(,) __VA_ARGS__)
29+
30+
#define MB_MASTER_ASSERT(con) do { \
31+
if (!(con)) { ESP_LOGE(TAG, "assert errno:%d, errno_str: !(%s)", errno, strerror(errno)); assert(0 && #con); } \
32+
} while (0)
33+
2834
/*!
2935
* \brief Modbus descriptor table parameter type defines.
3036
*/

tools/sdk/esp32/include/freemodbus/common/include/esp_modbus_slave.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
extern "C" {
2929
#endif
3030

31+
#define MB_SLAVE_CHECK(a, err_code, format, ...) MB_RETURN_ON_FALSE(a, err_code, TAG, format __VA_OPT__(,) __VA_ARGS__)
32+
33+
#define MB_SLAVE_ASSERT(con) do { \
34+
if (!(con)) { ESP_LOGE(TAG, "assert errno:%d, errno_str: !(%s)", errno, strerror(errno)); assert(0 && #con); } \
35+
} while (0)
36+
3137
/**
3238
* @brief Parameter access event information type
3339
*/

0 commit comments

Comments
 (0)