forked from espressif/esp-modbus
add cpp test-app, fix atomcs issue (+workaround v5.0)
This commit is contained in:
1 parent
a2a16545fc
commit
138382bf0d
13 files changed
+192
-21
No files matched your search
@@ -4,18 +4,16 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <inttypes.h>
|
||||
#include "sdkconfig.h" // for KConfig options
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if __has_include("esp_idf_version.h")
|
||||
#include "esp_idf_version.h"
|
||||
#endif
|
||||
|
||||
#include <inttypes.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* ----------------------- Defines ------------------------------------------*/
|
||||
/*! \defgroup modbus_cfg Modbus Configuration
|
||||
@@ -48,8 +46,8 @@ extern "C" {
|
||||
|
||||
#ifdef ESP_IDF_VERSION
|
||||
|
||||
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 0))
|
||||
// Features supported from 4.4
|
||||
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0))
|
||||
// Features supported from v5.0
|
||||
#define MB_TIMER_SUPPORTS_ISR_DISPATCH_METHOD 1
|
||||
#endif
|
||||
|
||||
|
||||
@@ -5,16 +5,30 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "stdatomic.h"
|
||||
#include "mb_config.h"
|
||||
#include "mb_types.h"
|
||||
|
||||
#define MB_ATTR_WEAK __attribute__ ((weak))
|
||||
#if __has_include("esp_idf_version.h")
|
||||
#include "esp_idf_version.h"
|
||||
#define IS_OLD_IDF_VER (IDF_VERSION <= ESP_IDF_VERSION_VAL(5, 0, 0))
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
// Workaround for atomics incompatibility issue under CPP.
|
||||
#if defined(__cplusplus) && IS_OLD_IDF_VER
|
||||
#include <atomic>
|
||||
#define _Atomic(T) std::atomic<T>
|
||||
#else
|
||||
#include <stdatomic.h>
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MB_ATTR_WEAK __attribute__ ((weak))
|
||||
|
||||
typedef enum _mb_comm_mode mb_mode_type_t;
|
||||
|
||||
#if (CONFIG_FMB_COMM_MODE_ASCII_EN || CONFIG_FMB_COMM_MODE_RTU_EN)
|
||||
@@ -98,7 +112,7 @@ typedef struct _uid_info {
|
||||
uint16_t uid; /*!< node unit ID (UID) field for MBAP frame */
|
||||
uint16_t port; /*!< node port number */
|
||||
mb_comm_mode_t proto; /*!< protocol type */
|
||||
atomic_int state; /*!< node state */
|
||||
_Atomic(int) state; /*!< node state */
|
||||
void *inst; /*!< pointer to linked instance */
|
||||
} mb_uid_info_t;
|
||||
|
||||
|
||||
Reference in new issue
Block a user