1menu "Modbus configuration"
2
3    config FMB_COMM_MODE_TCP_EN
4        bool "Enable Modbus stack support for TCP communication mode"
5        default y
6        help
7                Enable Modbus TCP option for stack.
8
9    config FMB_TCP_PORT_DEFAULT
10        int "Modbus TCP port number"
11        range 0 65535
12        default 502
13        depends on FMB_COMM_MODE_TCP_EN
14        help
15                Modbus default port number used by Modbus TCP stack
16
17    config FMB_TCP_PORT_MAX_CONN
18        int "Maximum allowed connections for TCP stack"
19        range 1 6
20        default 5
21        depends on FMB_COMM_MODE_TCP_EN
22        help
23                Maximum allowed connections number for Modbus TCP stack.
24                This is used by Modbus master and slave port layer to establish connections.
25                This parameter may decrease performance of Modbus stack and can cause
26                increasing of processing time (increase only if absolutely necessary).
27
28    config FMB_TCP_CONNECTION_TOUT_SEC
29        int "Modbus TCP connection timeout"
30        range 1 3600
31        default 20
32        depends on FMB_COMM_MODE_TCP_EN
33        help
34                Modbus TCP connection timeout in seconds.
35                Once expired the current connection with the client will be closed
36                and Modbus slave will be waiting for new connection to accept.
37
38    config FMB_COMM_MODE_RTU_EN
39        bool "Enable Modbus stack support for RTU mode"
40        default y
41        help
42                Enable RTU Modbus communication mode option for Modbus serial stack.
43
44    config FMB_COMM_MODE_ASCII_EN
45        bool "Enable Modbus stack support for ASCII mode"
46        default y
47        help
48                Enable ASCII Modbus communication mode option for Modbus serial stack.
49
50    config FMB_MASTER_TIMEOUT_MS_RESPOND
51        int "Slave respond timeout (Milliseconds)"
52        default 150
53        range 50 3000
54        help
55                If master sends a frame which is not broadcast, it has to wait sometime for slave response.
56                if slave is not respond in this time, the master will process timeout error.
57
58    config FMB_MASTER_DELAY_MS_CONVERT
59        int "Slave conversion delay (Milliseconds)"
60        default 200
61        range 50 400
62        help
63                If master sends a broadcast frame, it has to wait conversion time to delay,
64                then master can send next frame.
65
66    config FMB_QUEUE_LENGTH
67        int "Modbus serial task queue length"
68        range 0 200
69        default 20
70        help
71                Modbus serial driver queue length. It is used by event queue task.
72                See the serial driver API for more information.
73
74    config FMB_PORT_TASK_STACK_SIZE
75        int "Modbus port task stack size"
76        range 2048 8192
77        default 4096
78        help
79                Modbus port task stack size for rx/tx event processing.
80                It may be adjusted when debugging is enabled (for example).
81
82    config FMB_SERIAL_BUF_SIZE
83        int "Modbus serial task RX/TX buffer size"
84        range 0 2048
85        default 256
86        help
87                Modbus serial task RX and TX buffer size for UART driver initialization.
88                This buffer is used for modbus frame transfer. The Modbus protocol maximum
89                frame size is 256 bytes. Bigger size can be used for non standard implementations.
90
91    config FMB_SERIAL_ASCII_BITS_PER_SYMB
92        int "Number of data bits per ASCII character"
93        default 8
94        range 7 8
95        depends on FMB_COMM_MODE_ASCII_EN
96        help
97                This option defines the number of data bits per ASCII character.
98
99    config FMB_SERIAL_ASCII_TIMEOUT_RESPOND_MS
100        int "Response timeout for ASCII communication mode (ms)"
101        default 1000
102        range 300 2000
103        depends on FMB_COMM_MODE_ASCII_EN
104        help
105                This option defines response timeout of slave in milliseconds for ASCII communication mode.
106                Thus the timeout will expire and allow the master program to handle the error.
107
108    config FMB_PORT_TASK_PRIO
109        int "Modbus port task priority"
110        range 3 23
111        default 10
112        help
113                Modbus port data processing task priority.
114                The priority of Modbus controller task is equal to (CONFIG_FMB_PORT_TASK_PRIO - 1).
115
116    choice FMB_PORT_TASK_AFFINITY
117        prompt "Modbus task affinity"
118        default FMB_PORT_TASK_AFFINITY_CPU0
119        depends on !FREERTOS_UNICORE
120        help
121            Allows setting the core affinity of the Modbus controller task, i.e. whether the task is pinned to
122            particular CPU, or allowed to run on any CPU.
123
124        config FMB_PORT_TASK_AFFINITY_NO_AFFINITY
125            bool "No affinity"
126        config FMB_PORT_TASK_AFFINITY_CPU0
127            bool "CPU0"
128        config FMB_PORT_TASK_AFFINITY_CPU1
129            bool "CPU1"
130
131    endchoice
132
133    config FMB_PORT_TASK_AFFINITY
134        hex
135        default FREERTOS_NO_AFFINITY if FMB_PORT_TASK_AFFINITY_NO_AFFINITY || FREERTOS_UNICORE
136        default 0x0 if FMB_PORT_TASK_AFFINITY_CPU0
137        default 0x1 if FMB_PORT_TASK_AFFINITY_CPU1
138
139    config FMB_CONTROLLER_SLAVE_ID_SUPPORT
140        bool "Modbus controller slave ID support"
141        default y
142        help
143                Modbus slave ID support enable.
144                When enabled the Modbus <Report Slave ID> command is supported by stack.
145
146    config FMB_CONTROLLER_SLAVE_ID
147        hex "Modbus controller slave ID"
148        range 0 4294967295
149        default 0x00112233
150        depends on FMB_CONTROLLER_SLAVE_ID_SUPPORT
151        help
152                Modbus slave ID value to identify modbus device
153                in the network using <Report Slave ID> command.
154                Most significant byte of ID is used as short device ID and
155                other three bytes used as long ID.
156
157    config FMB_CONTROLLER_NOTIFY_TIMEOUT
158        int "Modbus controller notification timeout (ms)"
159        range 0 200
160        default 20
161        help
162                Modbus controller notification timeout in milliseconds.
163                This timeout is used to send notification about accessed parameters.
164
165    config FMB_CONTROLLER_NOTIFY_QUEUE_SIZE
166        int "Modbus controller notification queue size"
167        range 0 200
168        default 20
169        help
170                Modbus controller notification queue size.
171                The notification queue is used to get information about accessed parameters.
172
173    config FMB_CONTROLLER_STACK_SIZE
174        int "Modbus controller stack size"
175        range 0 8192
176        default 4096
177        help
178                Modbus controller task stack size. The Stack size may be adjusted when
179                debug mode is used which requires more stack size (for example).
180
181    config FMB_EVENT_QUEUE_TIMEOUT
182        int "Modbus stack event queue timeout (ms)"
183        range 0 500
184        default 20
185        help
186                Modbus stack event queue timeout in milliseconds. This may help to optimize
187                Modbus stack event processing time.
188
189    config FMB_TIMER_PORT_ENABLED
190        bool "Modbus stack use timer for 3.5T symbol time measurement"
191        default n
192        help
193                If this option is set the Modbus stack uses timer for T3.5 time measurement.
194                Else the internal UART TOUT timeout is used for 3.5T symbol time measurement.
195
196    config FMB_TIMER_GROUP
197        int "Slave Timer group number"
198        range 0 1
199        default 0
200        help
201                Modbus slave Timer group number that is used for timeout measurement.
202
203    config FMB_TIMER_INDEX
204        int "Slave Timer index in the group"
205        range 0 1
206        default 0
207        help
208                Modbus slave Timer Index in the group that is used for timeout measurement.
209
210    config FMB_MASTER_TIMER_GROUP
211        int "Master Timer group number"
212        range 0 1
213        default FMB_TIMER_GROUP
214        help
215                Modbus master Timer group number that is used for timeout measurement.
216
217    config FMB_MASTER_TIMER_INDEX
218        int "Master Timer index"
219        range 0 1
220        default FMB_TIMER_INDEX
221        help
222                Modbus master Timer Index in the group that is used for timeout measurement.
223                Note: Modbus master and slave should have different timer index to be able to work simultaneously.
224
225    config FMB_TIMER_ISR_IN_IRAM
226        bool "Place timer interrupt handler into IRAM"
227        default n
228        select UART_ISR_IN_IRAM
229        help
230                This option places Modbus timer IRQ handler into IRAM.
231                This allows to avoid delays related to processing of non-IRAM-safe interrupts
232                during a flash write operation (NVS updating a value, or some other
233                flash API which has to perform an read/write operation and disable CPU cache).
234                This option has dependency with the UART_ISR_IN_IRAM option which places UART interrupt
235                handler into IRAM to prevent delays related to processing of UART events.
236
237endmenu
238