From cfdd5f0ef77606ee12aca6ea54b866c70d38a15b Mon Sep 17 00:00:00 2001 From: Alex Lisitsyn Date: Tue, 12 Nov 2019 22:16:55 +0800 Subject: [PATCH] freemodbus: configure timer handler placement place timer interrupt handler into flash by default; add default settings for timer and UART interrupts to place them into IRAM into example defaults; CONFIG_FMB_TIMER_PORT_ENABLED default = n, when enabled, the UART_ISR_IN_IRAM set to y --- components/freemodbus/Kconfig | 10 ++++++---- components/freemodbus/modbus/include/mbconfig.h | 4 ++-- components/freemodbus/modbus/include/mbport.h | 2 +- examples/protocols/modbus_master/sdkconfig.defaults | 1 + examples/protocols/modbus_slave/sdkconfig.defaults | 4 ++++ 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/components/freemodbus/Kconfig b/components/freemodbus/Kconfig index cc908a5c3a..5de67fe018 100644 --- a/components/freemodbus/Kconfig +++ b/components/freemodbus/Kconfig @@ -122,14 +122,16 @@ menu "Modbus configuration" help Modbus Timer Index in the group that is used for timeout measurement. - config FMB_ISR_IN_IRAM - bool "Place interrupt handlers into IRAM" - default y + config FMB_TIMER_ISR_IN_IRAM + bool "Place timer interrupt handler into IRAM" + default n select UART_ISR_IN_IRAM help - This option places Modbus IRQ handlers into IRAM. + This option places Modbus timer IRQ handler into IRAM. This allows to avoid delays related to processing of non-IRAM-safe interrupts during a flash write operation (NVS updating a value, or some other flash API which has to perform an read/write operation and disable CPU cache). + This option has dependency with the UART_ISR_IN_IRAM option which places UART interrupt + handler into IRAM to prevent delays related to processing of UART events. endmenu diff --git a/components/freemodbus/modbus/include/mbconfig.h b/components/freemodbus/modbus/include/mbconfig.h index a20bcedc27..72971e4482 100644 --- a/components/freemodbus/modbus/include/mbconfig.h +++ b/components/freemodbus/modbus/include/mbconfig.h @@ -130,8 +130,8 @@ PR_BEGIN_EXTERN_C /*! \brief If the Read/Write Multiple Registers function should be enabled. */ #define MB_FUNC_READWRITE_HOLDING_ENABLED ( 1 ) -/*! \brief Check the option to place handlers into IRAM */ -#define MB_ISR_IN_IRAM ( CONFIG_FMB_ISR_IN_IRAM ) +/*! \brief Check the option to place timer handler into IRAM */ +#define MB_PORT_TIMER_ISR_IN_IRAM ( CONFIG_FMB_TIMER_ISR_IN_IRAM ) /*! @} */ #ifdef __cplusplus diff --git a/components/freemodbus/modbus/include/mbport.h b/components/freemodbus/modbus/include/mbport.h index 3a5a7a6803..aef79b5114 100644 --- a/components/freemodbus/modbus/include/mbport.h +++ b/components/freemodbus/modbus/include/mbport.h @@ -43,7 +43,7 @@ PR_BEGIN_EXTERN_C #define MB_PORT_SERIAL_ISR_FLAG ESP_INTR_FLAG_LOWMED #endif -#if MB_ISR_IN_IRAM +#if MB_PORT_TIMER_ISR_IN_IRAM #define MB_PORT_ISR_ATTR IRAM_ATTR #define MB_PORT_TIMER_ISR_FLAG ESP_INTR_FLAG_IRAM #else diff --git a/examples/protocols/modbus_master/sdkconfig.defaults b/examples/protocols/modbus_master/sdkconfig.defaults index 98e7ac19fe..8a793342ed 100644 --- a/examples/protocols/modbus_master/sdkconfig.defaults +++ b/examples/protocols/modbus_master/sdkconfig.defaults @@ -4,6 +4,7 @@ CONFIG_FMB_TIMER_PORT_ENABLED=y CONFIG_FMB_TIMER_GROUP=0 CONFIG_FMB_TIMER_INDEX=0 +CONFIG_FMB_TIMER_ISR_IN_IRAM=y CONFIG_FMB_MASTER_DELAY_MS_CONVERT=200 CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND=150 CONFIG_MB_UART_RXD=22 diff --git a/examples/protocols/modbus_slave/sdkconfig.defaults b/examples/protocols/modbus_slave/sdkconfig.defaults index e79d7fa624..76378f03f9 100644 --- a/examples/protocols/modbus_slave/sdkconfig.defaults +++ b/examples/protocols/modbus_slave/sdkconfig.defaults @@ -4,3 +4,7 @@ CONFIG_MB_UART_RXD=22 CONFIG_MB_UART_TXD=23 CONFIG_MB_UART_RTS=18 +CONFIG_FMB_TIMER_PORT_ENABLED=y +CONFIG_FMB_TIMER_GROUP=0 +CONFIG_FMB_TIMER_INDEX=0 +CONFIG_FMB_TIMER_ISR_IN_IRAM=y