成功将Modbus设置为子组件
This commit is contained in:
parent
39e6cfb3ab
commit
d53dfce90d
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -17,6 +17,7 @@
|
|||||||
"files.associations": {
|
"files.associations": {
|
||||||
"ledc.h": "c",
|
"ledc.h": "c",
|
||||||
"gpio.h": "c",
|
"gpio.h": "c",
|
||||||
"sdmmc_host.h": "c"
|
"sdmmc_host.h": "c",
|
||||||
|
"modbus_params.h": "c"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
3
components/FluxMod/CMakeLists.txt
Normal file
3
components/FluxMod/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
idf_component_register(SRCS "FluxMod.c"
|
||||||
|
REQUIRES espressif__esp-modbus
|
||||||
|
INCLUDE_DIRS "." "C:/Espressif/frameworks/esp-idf-v5.3.1/examples/protocols/modbus/mb_example_common/include")
|
||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
#include "FreeBus.h"
|
#include "FluxMod.h"
|
||||||
|
|
||||||
static const char *TAG = "MASTER_TEST";
|
static const char *TAG = "MASTER_TEST";
|
||||||
|
|
||||||
@ -14,16 +14,12 @@ const mb_parameter_descriptor_t device_parameters[] = {
|
|||||||
// Calculate number of parameters in the table
|
// Calculate number of parameters in the table
|
||||||
const uint16_t num_device_parameters = (sizeof(device_parameters)/sizeof(device_parameters[0]));
|
const uint16_t num_device_parameters = (sizeof(device_parameters)/sizeof(device_parameters[0]));
|
||||||
|
|
||||||
static esp_err_t master_init(void)
|
esp_err_t modbus_master_init(void)
|
||||||
{
|
{
|
||||||
// Initialize and start Modbus controller
|
// Initialize and start Modbus controller
|
||||||
mb_communication_info_t comm = {
|
mb_communication_info_t comm = {
|
||||||
.port = MB_PORT_NUM,
|
.port = MB_PORT_NUM,
|
||||||
#if CONFIG_MB_COMM_MODE_ASCII
|
|
||||||
.mode = MB_MODE_ASCII,
|
|
||||||
#elif CONFIG_MB_COMM_MODE_RTU
|
|
||||||
.mode = MB_MODE_RTU,
|
.mode = MB_MODE_RTU,
|
||||||
#endif
|
|
||||||
.baudrate = MB_DEV_SPEED,
|
.baudrate = MB_DEV_SPEED,
|
||||||
.parity = MB_PARITY_NONE
|
.parity = MB_PARITY_NONE
|
||||||
};
|
};
|
||||||
@ -62,4 +62,4 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/*Modbus总线初始化函数*/
|
/*Modbus总线初始化函数*/
|
||||||
static esp_err_t master_init(void);
|
esp_err_t modbus_master_init(void);
|
||||||
@ -19,6 +19,7 @@ void ReadSdCallFunc(lv_event_t * e)
|
|||||||
void F1callbackFunc(lv_event_t * e)
|
void F1callbackFunc(lv_event_t * e)
|
||||||
{
|
{
|
||||||
// Your code here
|
// Your code here
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void F2callbackFunc(lv_event_t * e)
|
void F2callbackFunc(lv_event_t * e)
|
||||||
|
|||||||
@ -3,8 +3,8 @@ if(CONFIG_EXAMPLE_LCD_IMAGE_FROM_EMBEDDED_BINARY)
|
|||||||
file(GLOB_RECURSE embedded_images images/*.c)
|
file(GLOB_RECURSE embedded_images images/*.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
idf_component_register(SRCS "FreeBus.c" "i80_controller_example_main.c" "lvgl_demo_ui.c" ${embedded_images}
|
idf_component_register(SRCS "i80_controller_example_main.c" "lvgl_demo_ui.c" ${embedded_images}
|
||||||
REQUIRES FluxUI FluxPower spiffs FluxSD
|
REQUIRES FluxUI FluxPower spiffs FluxSD FluxMod
|
||||||
INCLUDE_DIRS ".")
|
INCLUDE_DIRS ".")
|
||||||
|
|
||||||
if(CONFIG_EXAMPLE_LCD_IMAGE_FROM_FILE_SYSTEM)
|
if(CONFIG_EXAMPLE_LCD_IMAGE_FROM_FILE_SYSTEM)
|
||||||
|
|||||||
@ -23,7 +23,7 @@
|
|||||||
#include "FluxSD.h"
|
#include "FluxSD.h"
|
||||||
|
|
||||||
/*导入Modbus控制头文件*/
|
/*导入Modbus控制头文件*/
|
||||||
#include "FreeBus.h"
|
#include "FluxMod.h"
|
||||||
|
|
||||||
//新增触摸屏驱动头文件
|
//新增触摸屏驱动头文件
|
||||||
#include "driver/i2c.h"
|
#include "driver/i2c.h"
|
||||||
@ -34,6 +34,8 @@
|
|||||||
|
|
||||||
static const char *TAG = "example";
|
static const char *TAG = "example";
|
||||||
|
|
||||||
|
#include "modbus_params.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//////////////////// Please update the following configuration according to your LCD spec //////////////////////////////
|
//////////////////// Please update the following configuration according to your LCD spec //////////////////////////////
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -454,6 +456,9 @@ void app_main(void)
|
|||||||
|
|
||||||
/*初始化SD卡*/
|
/*初始化SD卡*/
|
||||||
flux_sd_init();
|
flux_sd_init();
|
||||||
|
|
||||||
|
/*初始化Modbus*/
|
||||||
|
//modbus_master_init();
|
||||||
|
|
||||||
// Lock the mutex due to the LVGL APIs are not thread-safe
|
// Lock the mutex due to the LVGL APIs are not thread-safe
|
||||||
if (example_lvgl_lock(-1)) {
|
if (example_lvgl_lock(-1)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user