1 /* Copyright 2018 Espressif Systems (Shanghai) PTE LTD
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14 */
15 
16 //  mbc_tcp_master.h Modbus controller TCP master implementation header file
17 
18 #ifndef _MODBUS_TCP_CONTROLLER_MASTER
19 #define _MODBUS_TCP_CONTROLLER_MASTER
20 
21 #include <stdint.h>                 // for standard int types definition
22 #include <stddef.h>                 // for NULL and std defines
23 #include "esp_modbus_common.h"      // for common defines
24 
25 /* ----------------------- Defines ------------------------------------------*/
26 #define MB_INST_MIN_SIZE                    (2) // The minimal size of Modbus registers area in bytes
27 #define MB_INST_MAX_SIZE                    (CONFIG_MB_INST_MAX_SIZE) // The maximum size of Modbus area in bytes
28 
29 #define MB_CONTROLLER_NOTIFY_QUEUE_SIZE     (CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE) // Number of messages in parameter notification queue
30 #define MB_CONTROLLER_NOTIFY_TIMEOUT        (pdMS_TO_TICKS(CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT)) // notification timeout
31 
32 /**
33  * @brief Create Modbus Master controller and stack for TCP port
34  *
35  * @param[out] handler handler(pointer) to master data structure
36  * @return
37  *     - ESP_OK   Success
38  *     - ESP_ERR_NO_MEM Parameter error
39  */
40 esp_err_t mbc_tcp_master_create(void** handler);
41 
42 #endif // _MODBUS_TCP_CONTROLLER_SLAVE
43