mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Rename Kconfig options (components/freemodbus)
This commit is contained in:
parent
64c2aa15aa
commit
976d2a4b7f
@ -1,6 +1,6 @@
|
|||||||
menu "Modbus configuration"
|
menu "Modbus configuration"
|
||||||
|
|
||||||
config MB_MASTER_TIMEOUT_MS_RESPOND
|
config FMB_MASTER_TIMEOUT_MS_RESPOND
|
||||||
int "Slave respond timeout (Milliseconds)"
|
int "Slave respond timeout (Milliseconds)"
|
||||||
default 150
|
default 150
|
||||||
range 50 400
|
range 50 400
|
||||||
@ -9,7 +9,7 @@ menu "Modbus configuration"
|
|||||||
If master sends a frame which is not broadcast, it has to wait sometime for slave response.
|
If master sends a frame which is not broadcast, it has to wait sometime for slave response.
|
||||||
if slave is not respond in this time, the master will process timeout error.
|
if slave is not respond in this time, the master will process timeout error.
|
||||||
|
|
||||||
config MB_MASTER_DELAY_MS_CONVERT
|
config FMB_MASTER_DELAY_MS_CONVERT
|
||||||
int "Slave conversion delay (Milliseconds)"
|
int "Slave conversion delay (Milliseconds)"
|
||||||
default 200
|
default 200
|
||||||
range 50 400
|
range 50 400
|
||||||
@ -18,7 +18,7 @@ menu "Modbus configuration"
|
|||||||
If master sends a broadcast frame, it has to wait conversion time to delay,
|
If master sends a broadcast frame, it has to wait conversion time to delay,
|
||||||
then master can send next frame.
|
then master can send next frame.
|
||||||
|
|
||||||
config MB_QUEUE_LENGTH
|
config FMB_QUEUE_LENGTH
|
||||||
int "Modbus serial task queue length"
|
int "Modbus serial task queue length"
|
||||||
range 0 200
|
range 0 200
|
||||||
default 20
|
default 20
|
||||||
@ -26,7 +26,7 @@ menu "Modbus configuration"
|
|||||||
Modbus serial driver queue length. It is used by event queue task.
|
Modbus serial driver queue length. It is used by event queue task.
|
||||||
See the serial driver API for more information.
|
See the serial driver API for more information.
|
||||||
|
|
||||||
config MB_SERIAL_TASK_STACK_SIZE
|
config FMB_SERIAL_TASK_STACK_SIZE
|
||||||
int "Modbus serial task stack size"
|
int "Modbus serial task stack size"
|
||||||
range 768 8192
|
range 768 8192
|
||||||
default 2048
|
default 2048
|
||||||
@ -34,7 +34,7 @@ menu "Modbus configuration"
|
|||||||
Modbus serial task stack size for event queue task.
|
Modbus serial task stack size for event queue task.
|
||||||
It may be adjusted when debugging is enabled (for example).
|
It may be adjusted when debugging is enabled (for example).
|
||||||
|
|
||||||
config MB_SERIAL_BUF_SIZE
|
config FMB_SERIAL_BUF_SIZE
|
||||||
int "Modbus serial task RX/TX buffer size"
|
int "Modbus serial task RX/TX buffer size"
|
||||||
range 0 2048
|
range 0 2048
|
||||||
default 256
|
default 256
|
||||||
@ -43,33 +43,33 @@ menu "Modbus configuration"
|
|||||||
This buffer is used for modbus frame transfer. The Modbus protocol maximum
|
This buffer is used for modbus frame transfer. The Modbus protocol maximum
|
||||||
frame size is 256 bytes. Bigger size can be used for non standard implementations.
|
frame size is 256 bytes. Bigger size can be used for non standard implementations.
|
||||||
|
|
||||||
config MB_SERIAL_TASK_PRIO
|
config FMB_SERIAL_TASK_PRIO
|
||||||
int "Modbus serial task priority"
|
int "Modbus serial task priority"
|
||||||
range 3 10
|
range 3 10
|
||||||
default 10
|
default 10
|
||||||
help
|
help
|
||||||
Modbus UART driver event task priority.
|
Modbus UART driver event task priority.
|
||||||
The priority of Modbus controller task is equal to (CONFIG_MB_SERIAL_TASK_PRIO - 1).
|
The priority of Modbus controller task is equal to (CONFIG_FMB_SERIAL_TASK_PRIO - 1).
|
||||||
|
|
||||||
config MB_CONTROLLER_SLAVE_ID_SUPPORT
|
config FMB_CONTROLLER_SLAVE_ID_SUPPORT
|
||||||
bool "Modbus controller slave ID support"
|
bool "Modbus controller slave ID support"
|
||||||
default n
|
default n
|
||||||
help
|
help
|
||||||
Modbus slave ID support enable.
|
Modbus slave ID support enable.
|
||||||
When enabled the Modbus <Report Slave ID> command is supported by stack.
|
When enabled the Modbus <Report Slave ID> command is supported by stack.
|
||||||
|
|
||||||
config MB_CONTROLLER_SLAVE_ID
|
config FMB_CONTROLLER_SLAVE_ID
|
||||||
hex "Modbus controller slave ID"
|
hex "Modbus controller slave ID"
|
||||||
range 0 4294967295
|
range 0 4294967295
|
||||||
default 0x00112233
|
default 0x00112233
|
||||||
depends on MB_CONTROLLER_SLAVE_ID_SUPPORT
|
depends on FMB_CONTROLLER_SLAVE_ID_SUPPORT
|
||||||
help
|
help
|
||||||
Modbus slave ID value to identify modbus device
|
Modbus slave ID value to identify modbus device
|
||||||
in the network using <Report Slave ID> command.
|
in the network using <Report Slave ID> command.
|
||||||
Most significant byte of ID is used as short device ID and
|
Most significant byte of ID is used as short device ID and
|
||||||
other three bytes used as long ID.
|
other three bytes used as long ID.
|
||||||
|
|
||||||
config MB_CONTROLLER_NOTIFY_TIMEOUT
|
config FMB_CONTROLLER_NOTIFY_TIMEOUT
|
||||||
int "Modbus controller notification timeout (ms)"
|
int "Modbus controller notification timeout (ms)"
|
||||||
range 0 200
|
range 0 200
|
||||||
default 20
|
default 20
|
||||||
@ -77,7 +77,7 @@ menu "Modbus configuration"
|
|||||||
Modbus controller notification timeout in milliseconds.
|
Modbus controller notification timeout in milliseconds.
|
||||||
This timeout is used to send notification about accessed parameters.
|
This timeout is used to send notification about accessed parameters.
|
||||||
|
|
||||||
config MB_CONTROLLER_NOTIFY_QUEUE_SIZE
|
config FMB_CONTROLLER_NOTIFY_QUEUE_SIZE
|
||||||
int "Modbus controller notification queue size"
|
int "Modbus controller notification queue size"
|
||||||
range 0 200
|
range 0 200
|
||||||
default 20
|
default 20
|
||||||
@ -85,7 +85,7 @@ menu "Modbus configuration"
|
|||||||
Modbus controller notification queue size.
|
Modbus controller notification queue size.
|
||||||
The notification queue is used to get information about accessed parameters.
|
The notification queue is used to get information about accessed parameters.
|
||||||
|
|
||||||
config MB_CONTROLLER_STACK_SIZE
|
config FMB_CONTROLLER_STACK_SIZE
|
||||||
int "Modbus controller stack size"
|
int "Modbus controller stack size"
|
||||||
range 0 8192
|
range 0 8192
|
||||||
default 4096
|
default 4096
|
||||||
@ -93,7 +93,7 @@ menu "Modbus configuration"
|
|||||||
Modbus controller task stack size. The Stack size may be adjusted when
|
Modbus controller task stack size. The Stack size may be adjusted when
|
||||||
debug mode is used which requires more stack size (for example).
|
debug mode is used which requires more stack size (for example).
|
||||||
|
|
||||||
config MB_EVENT_QUEUE_TIMEOUT
|
config FMB_EVENT_QUEUE_TIMEOUT
|
||||||
int "Modbus stack event queue timeout (ms)"
|
int "Modbus stack event queue timeout (ms)"
|
||||||
range 0 500
|
range 0 500
|
||||||
default 20
|
default 20
|
||||||
@ -101,21 +101,21 @@ menu "Modbus configuration"
|
|||||||
Modbus stack event queue timeout in milliseconds. This may help to optimize
|
Modbus stack event queue timeout in milliseconds. This may help to optimize
|
||||||
Modbus stack event processing time.
|
Modbus stack event processing time.
|
||||||
|
|
||||||
config MB_TIMER_PORT_ENABLED
|
config FMB_TIMER_PORT_ENABLED
|
||||||
bool "Modbus slave stack use timer for 3.5T symbol time measurement"
|
bool "Modbus slave stack use timer for 3.5T symbol time measurement"
|
||||||
default y
|
default y
|
||||||
help
|
help
|
||||||
If this option is set the Modbus stack uses timer for T3.5 time measurement.
|
If this option is set the Modbus stack uses timer for T3.5 time measurement.
|
||||||
Else the internal UART TOUT timeout is used for 3.5T symbol time measurement.
|
Else the internal UART TOUT timeout is used for 3.5T symbol time measurement.
|
||||||
|
|
||||||
config MB_TIMER_GROUP
|
config FMB_TIMER_GROUP
|
||||||
int "Modbus Timer group number"
|
int "Modbus Timer group number"
|
||||||
range 0 1
|
range 0 1
|
||||||
default 0
|
default 0
|
||||||
help
|
help
|
||||||
Modbus Timer group number that is used for timeout measurement.
|
Modbus Timer group number that is used for timeout measurement.
|
||||||
|
|
||||||
config MB_TIMER_INDEX
|
config FMB_TIMER_INDEX
|
||||||
int "Modbus Timer index in the group"
|
int "Modbus Timer index in the group"
|
||||||
range 0 1
|
range 0 1
|
||||||
default 0
|
default 0
|
||||||
|
@ -21,14 +21,14 @@
|
|||||||
#include "esp_modbus_callbacks.h" // for modbus callbacks function pointers declaration
|
#include "esp_modbus_callbacks.h" // for modbus callbacks function pointers declaration
|
||||||
#include "mbc_serial_slave.h" // for create function of serial port
|
#include "mbc_serial_slave.h" // for create function of serial port
|
||||||
|
|
||||||
#ifdef CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT
|
#ifdef CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT
|
||||||
|
|
||||||
#define MB_ID_BYTE0(id) ((uint8_t)(id))
|
#define MB_ID_BYTE0(id) ((uint8_t)(id))
|
||||||
#define MB_ID_BYTE1(id) ((uint8_t)(((uint16_t)(id) >> 8) & 0xFF))
|
#define MB_ID_BYTE1(id) ((uint8_t)(((uint16_t)(id) >> 8) & 0xFF))
|
||||||
#define MB_ID_BYTE2(id) ((uint8_t)(((uint32_t)(id) >> 16) & 0xFF))
|
#define MB_ID_BYTE2(id) ((uint8_t)(((uint32_t)(id) >> 16) & 0xFF))
|
||||||
#define MB_ID_BYTE3(id) ((uint8_t)(((uint32_t)(id) >> 24) & 0xFF))
|
#define MB_ID_BYTE3(id) ((uint8_t)(((uint32_t)(id) >> 24) & 0xFF))
|
||||||
|
|
||||||
#define MB_CONTROLLER_SLAVE_ID (CONFIG_MB_CONTROLLER_SLAVE_ID)
|
#define MB_CONTROLLER_SLAVE_ID (CONFIG_FMB_CONTROLLER_SLAVE_ID)
|
||||||
#define MB_SLAVE_ID_SHORT (MB_ID_BYTE3(MB_CONTROLLER_SLAVE_ID))
|
#define MB_SLAVE_ID_SHORT (MB_ID_BYTE3(MB_CONTROLLER_SLAVE_ID))
|
||||||
|
|
||||||
// Slave ID constant
|
// Slave ID constant
|
||||||
@ -127,7 +127,7 @@ esp_err_t mbc_slave_start()
|
|||||||
MB_SLAVE_CHECK((slave_interface_ptr->start != NULL),
|
MB_SLAVE_CHECK((slave_interface_ptr->start != NULL),
|
||||||
ESP_ERR_INVALID_STATE,
|
ESP_ERR_INVALID_STATE,
|
||||||
"Slave interface is not correctly initialized.");
|
"Slave interface is not correctly initialized.");
|
||||||
#ifdef CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT
|
#ifdef CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT
|
||||||
// Set the slave ID if the KConfig option is selected
|
// Set the slave ID if the KConfig option is selected
|
||||||
eMBErrorCode status = eMBSetSlaveID(MB_SLAVE_ID_SHORT, TRUE, (UCHAR*)mb_slave_id, sizeof(mb_slave_id));
|
eMBErrorCode status = eMBSetSlaveID(MB_SLAVE_ID_SHORT, TRUE, (UCHAR*)mb_slave_id, sizeof(mb_slave_id));
|
||||||
MB_SLAVE_CHECK((status == MB_ENOERR), ESP_ERR_INVALID_STATE, "mb stack set slave ID failure.");
|
MB_SLAVE_CHECK((status == MB_ENOERR), ESP_ERR_INVALID_STATE, "mb stack set slave ID failure.");
|
||||||
@ -252,4 +252,4 @@ eMBErrorCode eMBRegInputCB(UCHAR * pucRegBuffer, USHORT usAddress,
|
|||||||
"Slave interface is not correctly initialized.");
|
"Slave interface is not correctly initialized.");
|
||||||
error = slave_interface_ptr->slave_reg_cb_input(pucRegBuffer, usAddress, usNRegs);
|
error = slave_interface_ptr->slave_reg_cb_input(pucRegBuffer, usAddress, usNRegs);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
#include "driver/uart.h" // for UART types
|
#include "driver/uart.h" // for UART types
|
||||||
|
|
||||||
#define MB_CONTROLLER_STACK_SIZE (CONFIG_MB_CONTROLLER_STACK_SIZE) // Stack size for Modbus controller
|
#define MB_CONTROLLER_STACK_SIZE (CONFIG_FMB_CONTROLLER_STACK_SIZE) // Stack size for Modbus controller
|
||||||
#define MB_CONTROLLER_PRIORITY (CONFIG_MB_SERIAL_TASK_PRIO - 1) // priority of MB controller task
|
#define MB_CONTROLLER_PRIORITY (CONFIG_FMB_SERIAL_TASK_PRIO - 1) // priority of MB controller task
|
||||||
|
|
||||||
// Default port defines
|
// Default port defines
|
||||||
#define MB_DEVICE_ADDRESS (1) // Default slave device address in Modbus
|
#define MB_DEVICE_ADDRESS (1) // Default slave device address in Modbus
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
#define MB_INST_MIN_SIZE (2) // The minimal size of Modbus registers area in bytes
|
#define MB_INST_MIN_SIZE (2) // The minimal size of Modbus registers area in bytes
|
||||||
#define MB_INST_MAX_SIZE (65535 * 2) // The maximum size of Modbus area in bytes
|
#define MB_INST_MAX_SIZE (65535 * 2) // The maximum size of Modbus area in bytes
|
||||||
|
|
||||||
#define MB_CONTROLLER_NOTIFY_QUEUE_SIZE (CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE) // Number of messages in parameter notification queue
|
#define MB_CONTROLLER_NOTIFY_QUEUE_SIZE (CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE) // Number of messages in parameter notification queue
|
||||||
#define MB_CONTROLLER_NOTIFY_TIMEOUT (pdMS_TO_TICKS(CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT)) // notification timeout
|
#define MB_CONTROLLER_NOTIFY_TIMEOUT (pdMS_TO_TICKS(CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT)) // notification timeout
|
||||||
|
|
||||||
#define MB_SLAVE_TAG "MB_CONTROLLER_SLAVE"
|
#define MB_SLAVE_TAG "MB_CONTROLLER_SLAVE"
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ PR_BEGIN_EXTERN_C
|
|||||||
#define MB_FUNC_OTHER_REP_SLAVEID_BUF ( 32 )
|
#define MB_FUNC_OTHER_REP_SLAVEID_BUF ( 32 )
|
||||||
|
|
||||||
/*! \brief If the <em>Report Slave ID</em> function should be enabled. */
|
/*! \brief If the <em>Report Slave ID</em> function should be enabled. */
|
||||||
#define MB_FUNC_OTHER_REP_SLAVEID_ENABLED ( CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT )
|
#define MB_FUNC_OTHER_REP_SLAVEID_ENABLED ( CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT )
|
||||||
|
|
||||||
/*! \brief If the <em>Read Input Registers</em> function should be enabled. */
|
/*! \brief If the <em>Read Input Registers</em> function should be enabled. */
|
||||||
#define MB_FUNC_READ_INPUT_ENABLED ( 1 )
|
#define MB_FUNC_READ_INPUT_ENABLED ( 1 )
|
||||||
@ -138,11 +138,11 @@ PR_BEGIN_EXTERN_C
|
|||||||
#if MB_MASTER_RTU_ENABLED || MB_MASTER_ASCII_ENABLED
|
#if MB_MASTER_RTU_ENABLED || MB_MASTER_ASCII_ENABLED
|
||||||
/*! \brief If master send a broadcast frame, the master will wait time of convert to delay,
|
/*! \brief If master send a broadcast frame, the master will wait time of convert to delay,
|
||||||
* then master can send other frame */
|
* then master can send other frame */
|
||||||
#define MB_MASTER_DELAY_MS_CONVERT ( CONFIG_MB_MASTER_DELAY_MS_CONVERT )
|
#define MB_MASTER_DELAY_MS_CONVERT ( CONFIG_FMB_MASTER_DELAY_MS_CONVERT )
|
||||||
/*! \brief If master send a frame which is not broadcast,the master will wait sometime for slave.
|
/*! \brief If master send a frame which is not broadcast,the master will wait sometime for slave.
|
||||||
* And if slave is not respond in this time,the master will process this timeout error.
|
* And if slave is not respond in this time,the master will process this timeout error.
|
||||||
* Then master can send other frame */
|
* Then master can send other frame */
|
||||||
#define MB_MASTER_TIMEOUT_MS_RESPOND ( CONFIG_MB_MASTER_TIMEOUT_MS_RESPOND )
|
#define MB_MASTER_TIMEOUT_MS_RESPOND ( CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND )
|
||||||
/*! \brief The total slaves in Modbus Master system.
|
/*! \brief The total slaves in Modbus Master system.
|
||||||
* \note : The slave ID must be continuous from 1.*/
|
* \note : The slave ID must be continuous from 1.*/
|
||||||
#define MB_MASTER_TOTAL_SLAVE_NUM ( 247 )
|
#define MB_MASTER_TOTAL_SLAVE_NUM ( 247 )
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
static xQueueHandle xQueueHdl;
|
static xQueueHandle xQueueHdl;
|
||||||
|
|
||||||
#define MB_EVENT_QUEUE_SIZE (1)
|
#define MB_EVENT_QUEUE_SIZE (1)
|
||||||
#define MB_EVENT_QUEUE_TIMEOUT (pdMS_TO_TICKS(CONFIG_MB_EVENT_QUEUE_TIMEOUT))
|
#define MB_EVENT_QUEUE_TIMEOUT (pdMS_TO_TICKS(CONFIG_FMB_EVENT_QUEUE_TIMEOUT))
|
||||||
|
|
||||||
/* ----------------------- Start implementation -----------------------------*/
|
/* ----------------------- Start implementation -----------------------------*/
|
||||||
BOOL
|
BOOL
|
||||||
|
@ -61,14 +61,14 @@
|
|||||||
#define MB_UART_RTS (CONFIG_MB_UART_RTS)
|
#define MB_UART_RTS (CONFIG_MB_UART_RTS)
|
||||||
|
|
||||||
#define MB_BAUD_RATE_DEFAULT (115200)
|
#define MB_BAUD_RATE_DEFAULT (115200)
|
||||||
#define MB_QUEUE_LENGTH (CONFIG_MB_QUEUE_LENGTH)
|
#define MB_QUEUE_LENGTH (CONFIG_FMB_QUEUE_LENGTH)
|
||||||
|
|
||||||
#define MB_SERIAL_TASK_PRIO (CONFIG_MB_SERIAL_TASK_PRIO)
|
#define MB_SERIAL_TASK_PRIO (CONFIG_FMB_SERIAL_TASK_PRIO)
|
||||||
#define MB_SERIAL_TASK_STACK_SIZE (CONFIG_MB_SERIAL_TASK_STACK_SIZE)
|
#define MB_SERIAL_TASK_STACK_SIZE (CONFIG_FMB_SERIAL_TASK_STACK_SIZE)
|
||||||
#define MB_SERIAL_TOUT (3) // 3.5*8 = 28 ticks, TOUT=3 -> ~24..33 ticks
|
#define MB_SERIAL_TOUT (3) // 3.5*8 = 28 ticks, TOUT=3 -> ~24..33 ticks
|
||||||
|
|
||||||
// Set buffer size for transmission
|
// Set buffer size for transmission
|
||||||
#define MB_SERIAL_BUF_SIZE (CONFIG_MB_SERIAL_BUF_SIZE)
|
#define MB_SERIAL_BUF_SIZE (CONFIG_FMB_SERIAL_BUF_SIZE)
|
||||||
|
|
||||||
// Note: This code uses mixed coding standard from legacy IDF code and used freemodbus stack
|
// Note: This code uses mixed coding standard from legacy IDF code and used freemodbus stack
|
||||||
|
|
||||||
|
@ -54,14 +54,14 @@
|
|||||||
/* ----------------------- Defines ------------------------------------------*/
|
/* ----------------------- Defines ------------------------------------------*/
|
||||||
|
|
||||||
#define MB_BAUD_RATE_DEFAULT (115200)
|
#define MB_BAUD_RATE_DEFAULT (115200)
|
||||||
#define MB_QUEUE_LENGTH (CONFIG_MB_QUEUE_LENGTH)
|
#define MB_QUEUE_LENGTH (CONFIG_FMB_QUEUE_LENGTH)
|
||||||
|
|
||||||
#define MB_SERIAL_TASK_PRIO (CONFIG_MB_SERIAL_TASK_PRIO)
|
#define MB_SERIAL_TASK_PRIO (CONFIG_FMB_SERIAL_TASK_PRIO)
|
||||||
#define MB_SERIAL_TASK_STACK_SIZE (CONFIG_MB_SERIAL_TASK_STACK_SIZE)
|
#define MB_SERIAL_TASK_STACK_SIZE (CONFIG_FMB_SERIAL_TASK_STACK_SIZE)
|
||||||
#define MB_SERIAL_TOUT (3) // 3.5*8 = 28 ticks, TOUT=3 -> ~24..33 ticks
|
#define MB_SERIAL_TOUT (3) // 3.5*8 = 28 ticks, TOUT=3 -> ~24..33 ticks
|
||||||
|
|
||||||
// Set buffer size for transmission
|
// Set buffer size for transmission
|
||||||
#define MB_SERIAL_BUF_SIZE (CONFIG_MB_SERIAL_BUF_SIZE)
|
#define MB_SERIAL_BUF_SIZE (CONFIG_FMB_SERIAL_BUF_SIZE)
|
||||||
#define MB_SERIAL_TX_TOUT_MS (100)
|
#define MB_SERIAL_TX_TOUT_MS (100)
|
||||||
#define MB_SERIAL_TX_TOUT_TICKS pdMS_TO_TICKS(MB_SERIAL_TX_TOUT_MS) // timeout for transmission
|
#define MB_SERIAL_TX_TOUT_TICKS pdMS_TO_TICKS(MB_SERIAL_TX_TOUT_MS) // timeout for transmission
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@
|
|||||||
#include "sdkconfig.h"
|
#include "sdkconfig.h"
|
||||||
#include "port_serial_slave.h"
|
#include "port_serial_slave.h"
|
||||||
|
|
||||||
#ifdef CONFIG_MB_TIMER_PORT_ENABLED
|
#ifdef CONFIG_FMB_TIMER_PORT_ENABLED
|
||||||
|
|
||||||
#define MB_US50_FREQ (20000) // 20kHz 1/20000 = 50mks
|
#define MB_US50_FREQ (20000) // 20kHz 1/20000 = 50mks
|
||||||
#define MB_DISCR_TIME_US (50) // 50uS = one discreet for timer
|
#define MB_DISCR_TIME_US (50) // 50uS = one discreet for timer
|
||||||
@ -61,8 +61,8 @@
|
|||||||
#define MB_TIMER_DIVIDER ((TIMER_BASE_CLK / 1000000UL) * MB_DISCR_TIME_US - 1) // divider for 50uS
|
#define MB_TIMER_DIVIDER ((TIMER_BASE_CLK / 1000000UL) * MB_DISCR_TIME_US - 1) // divider for 50uS
|
||||||
#define MB_TIMER_WITH_RELOAD (1)
|
#define MB_TIMER_WITH_RELOAD (1)
|
||||||
|
|
||||||
static const USHORT usTimerIndex = CONFIG_MB_TIMER_INDEX; // Modbus Timer index used by stack
|
static const USHORT usTimerIndex = CONFIG_FMB_TIMER_INDEX; // Modbus Timer index used by stack
|
||||||
static const USHORT usTimerGroupIndex = CONFIG_MB_TIMER_GROUP; // Modbus Timer group index used by stack
|
static const USHORT usTimerGroupIndex = CONFIG_FMB_TIMER_GROUP; // Modbus Timer group index used by stack
|
||||||
|
|
||||||
static timg_dev_t *MB_TG[2] = {&TIMERG0, &TIMERG1};
|
static timg_dev_t *MB_TG[2] = {&TIMERG0, &TIMERG1};
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ static void IRAM_ATTR vTimerGroupIsr(void *param)
|
|||||||
|
|
||||||
BOOL xMBPortTimersInit(USHORT usTim1Timerout50us)
|
BOOL xMBPortTimersInit(USHORT usTim1Timerout50us)
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_MB_TIMER_PORT_ENABLED
|
#ifdef CONFIG_FMB_TIMER_PORT_ENABLED
|
||||||
MB_PORT_CHECK((usTim1Timerout50us > 0), FALSE,
|
MB_PORT_CHECK((usTim1Timerout50us > 0), FALSE,
|
||||||
"Modbus timeout discreet is incorrect.");
|
"Modbus timeout discreet is incorrect.");
|
||||||
esp_err_t xErr;
|
esp_err_t xErr;
|
||||||
@ -123,7 +123,7 @@ BOOL xMBPortTimersInit(USHORT usTim1Timerout50us)
|
|||||||
|
|
||||||
void vMBPortTimersEnable()
|
void vMBPortTimersEnable()
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_MB_TIMER_PORT_ENABLED
|
#ifdef CONFIG_FMB_TIMER_PORT_ENABLED
|
||||||
ESP_ERROR_CHECK(timer_pause(usTimerGroupIndex, usTimerIndex));
|
ESP_ERROR_CHECK(timer_pause(usTimerGroupIndex, usTimerIndex));
|
||||||
ESP_ERROR_CHECK(timer_set_counter_value(usTimerGroupIndex, usTimerIndex, 0ULL));
|
ESP_ERROR_CHECK(timer_set_counter_value(usTimerGroupIndex, usTimerIndex, 0ULL));
|
||||||
ESP_ERROR_CHECK(timer_enable_intr(usTimerGroupIndex, usTimerIndex));
|
ESP_ERROR_CHECK(timer_enable_intr(usTimerGroupIndex, usTimerIndex));
|
||||||
@ -133,7 +133,7 @@ void vMBPortTimersEnable()
|
|||||||
|
|
||||||
void vMBPortTimersDisable()
|
void vMBPortTimersDisable()
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_MB_TIMER_PORT_ENABLED
|
#ifdef CONFIG_FMB_TIMER_PORT_ENABLED
|
||||||
ESP_ERROR_CHECK(timer_pause(usTimerGroupIndex, usTimerIndex));
|
ESP_ERROR_CHECK(timer_pause(usTimerGroupIndex, usTimerIndex));
|
||||||
ESP_ERROR_CHECK(timer_set_counter_value(usTimerGroupIndex, usTimerIndex, 0ULL));
|
ESP_ERROR_CHECK(timer_set_counter_value(usTimerGroupIndex, usTimerIndex, 0ULL));
|
||||||
// Disable timer interrupt
|
// Disable timer interrupt
|
||||||
@ -143,7 +143,7 @@ void vMBPortTimersDisable()
|
|||||||
|
|
||||||
void vMBPortTimerClose()
|
void vMBPortTimerClose()
|
||||||
{
|
{
|
||||||
#ifdef CONFIG_MB_TIMER_PORT_ENABLED
|
#ifdef CONFIG_FMB_TIMER_PORT_ENABLED
|
||||||
ESP_ERROR_CHECK(timer_pause(usTimerGroupIndex, usTimerIndex));
|
ESP_ERROR_CHECK(timer_pause(usTimerGroupIndex, usTimerIndex));
|
||||||
ESP_ERROR_CHECK(timer_disable_intr(usTimerGroupIndex, usTimerIndex));
|
ESP_ERROR_CHECK(timer_disable_intr(usTimerGroupIndex, usTimerIndex));
|
||||||
#endif
|
#endif
|
||||||
|
@ -50,8 +50,8 @@
|
|||||||
#define MB_TIMER_WITH_RELOAD (1)
|
#define MB_TIMER_WITH_RELOAD (1)
|
||||||
|
|
||||||
// Timer group and timer number to measure time (configurable in KConfig)
|
// Timer group and timer number to measure time (configurable in KConfig)
|
||||||
#define MB_TIMER_INDEX CONFIG_MB_TIMER_INDEX
|
#define MB_TIMER_INDEX CONFIG_FMB_TIMER_INDEX
|
||||||
#define MB_TIMER_GROUP CONFIG_MB_TIMER_GROUP
|
#define MB_TIMER_GROUP CONFIG_FMB_TIMER_GROUP
|
||||||
|
|
||||||
#define MB_TIMER_IO_LED 0
|
#define MB_TIMER_IO_LED 0
|
||||||
|
|
||||||
|
18
components/freemodbus/sdkconfig.rename
Normal file
18
components/freemodbus/sdkconfig.rename
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# sdkconfig replacement configurations for deprecated options formatted as
|
||||||
|
# CONFIG_DEPRECATED_OPTION CONFIG_NEW_OPTION
|
||||||
|
|
||||||
|
CONFIG_MB_MASTER_TIMEOUT_MS_RESPOND CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND
|
||||||
|
CONFIG_MB_MASTER_DELAY_MS_CONVERT CONFIG_FMB_MASTER_DELAY_MS_CONVERT
|
||||||
|
CONFIG_MB_QUEUE_LENGTH CONFIG_FMB_QUEUE_LENGTH
|
||||||
|
CONFIG_MB_SERIAL_TASK_STACK_SIZE CONFIG_FMB_SERIAL_TASK_STACK_SIZE
|
||||||
|
CONFIG_MB_SERIAL_BUF_SIZE CONFIG_FMB_SERIAL_BUF_SIZE
|
||||||
|
CONFIG_MB_SERIAL_TASK_PRIO CONFIG_FMB_SERIAL_TASK_PRIO
|
||||||
|
CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT
|
||||||
|
CONFIG_MB_CONTROLLER_SLAVE_ID CONFIG_FMB_CONTROLLER_SLAVE_ID
|
||||||
|
CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT
|
||||||
|
CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE
|
||||||
|
CONFIG_MB_CONTROLLER_STACK_SIZE CONFIG_FMB_CONTROLLER_STACK_SIZE
|
||||||
|
CONFIG_MB_EVENT_QUEUE_TIMEOUT CONFIG_FMB_EVENT_QUEUE_TIMEOUT
|
||||||
|
CONFIG_MB_TIMER_PORT_ENABLED CONFIG_FMB_TIMER_PORT_ENABLED
|
||||||
|
CONFIG_MB_TIMER_GROUP CONFIG_FMB_TIMER_GROUP
|
||||||
|
CONFIG_MB_TIMER_INDEX CONFIG_FMB_TIMER_INDEX
|
@ -95,7 +95,7 @@ static esp_err_t mbc_serial_slave_start(void)
|
|||||||
(eMBParity)mbs_opts->mbs_comm.parity);
|
(eMBParity)mbs_opts->mbs_comm.parity);
|
||||||
MB_SLAVE_CHECK((status == MB_ENOERR), ESP_ERR_INVALID_STATE,
|
MB_SLAVE_CHECK((status == MB_ENOERR), ESP_ERR_INVALID_STATE,
|
||||||
"mb stack initialization failure, eMBInit() returns (0x%x).", status);
|
"mb stack initialization failure, eMBInit() returns (0x%x).", status);
|
||||||
#ifdef CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT
|
#ifdef CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT
|
||||||
status = eMBSetSlaveID(MB_SLAVE_ID_SHORT, TRUE, (UCHAR*)mb_slave_id, sizeof(mb_slave_id));
|
status = eMBSetSlaveID(MB_SLAVE_ID_SHORT, TRUE, (UCHAR*)mb_slave_id, sizeof(mb_slave_id));
|
||||||
MB_SLAVE_CHECK((status == MB_ENOERR), ESP_ERR_INVALID_STATE, "mb stack set slave ID failure.");
|
MB_SLAVE_CHECK((status == MB_ENOERR), ESP_ERR_INVALID_STATE, "mb stack set slave ID failure.");
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,8 +23,8 @@
|
|||||||
#include "esp_modbus_common.h" // for common defines
|
#include "esp_modbus_common.h" // for common defines
|
||||||
|
|
||||||
/* ----------------------- Defines ------------------------------------------*/
|
/* ----------------------- Defines ------------------------------------------*/
|
||||||
#define MB_CONTROLLER_NOTIFY_QUEUE_SIZE (CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE) // Number of messages in parameter notification queue
|
#define MB_CONTROLLER_NOTIFY_QUEUE_SIZE (CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE) // Number of messages in parameter notification queue
|
||||||
#define MB_CONTROLLER_NOTIFY_TIMEOUT (pdMS_TO_TICKS(CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT)) // notification timeout
|
#define MB_CONTROLLER_NOTIFY_TIMEOUT (pdMS_TO_TICKS(CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT)) // notification timeout
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @brief Initialize Modbus controller and stack
|
* @brief Initialize Modbus controller and stack
|
||||||
|
@ -66,7 +66,7 @@ The blocking call to function waits for event specified in the input parameter a
|
|||||||
|
|
||||||
.. doxygenfunction:: mbc_slave_get_param_info
|
.. doxygenfunction:: mbc_slave_get_param_info
|
||||||
|
|
||||||
The function gets information about accessed parameters from modbus controller event queue. The KConfig 'CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE' key can be used to configure the notification queue size. The timeout parameter allows to specify timeout for waiting notification. The :cpp:type:`mb_param_info_t` structure contain information about accessed parameter.
|
The function gets information about accessed parameters from modbus controller event queue. The KConfig 'CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE' key can be used to configure the notification queue size. The timeout parameter allows to specify timeout for waiting notification. The :cpp:type:`mb_param_info_t` structure contain information about accessed parameter.
|
||||||
|
|
||||||
|
|
||||||
Modbus serial master interface API overview
|
Modbus serial master interface API overview
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
#
|
#
|
||||||
# Modbus configuration
|
# Modbus configuration
|
||||||
#
|
#
|
||||||
CONFIG_MB_TIMER_PORT_ENABLED=y
|
CONFIG_FMB_TIMER_PORT_ENABLED=y
|
||||||
CONFIG_MB_TIMER_GROUP=0
|
CONFIG_FMB_TIMER_GROUP=0
|
||||||
CONFIG_MB_TIMER_INDEX=0
|
CONFIG_FMB_TIMER_INDEX=0
|
||||||
CONFIG_MB_MASTER_DELAY_MS_CONVERT=200
|
CONFIG_FMB_MASTER_DELAY_MS_CONVERT=200
|
||||||
CONFIG_MB_MASTER_TIMEOUT_MS_RESPOND=150
|
CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND=150
|
||||||
CONFIG_MB_UART_RXD=22
|
CONFIG_MB_UART_RXD=22
|
||||||
CONFIG_MB_UART_TXD=23
|
CONFIG_MB_UART_TXD=23
|
||||||
CONFIG_MB_UART_RTS=18
|
CONFIG_MB_UART_RTS=18
|
||||||
|
@ -3,4 +3,4 @@
|
|||||||
#
|
#
|
||||||
CONFIG_MB_UART_RXD=22
|
CONFIG_MB_UART_RXD=22
|
||||||
CONFIG_MB_UART_TXD=23
|
CONFIG_MB_UART_TXD=23
|
||||||
CONFIG_MB_UART_RTS=18
|
CONFIG_MB_UART_RTS=18
|
||||||
|
Loading…
Reference in New Issue
Block a user