From 236d1dcfa431e79405fb83075bed851e176a713b 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 * Original commit: espressif/esp-idf@cfdd5f0ef77606ee12aca6ea54b866c70d38a15b --- components/freemodbus/Kconfig | 10 ++++++---- components/freemodbus/modbus/include/mbconfig.h | 4 ++-- components/freemodbus/modbus/include/mbport.h | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/components/freemodbus/Kconfig b/components/freemodbus/Kconfig index cc908a5..5de67fe 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 a20bced..72971e4 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 3a5a7a6..aef79b5 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