Files
DTU-LCD/Middlewares/Modbus/MODBUS.h

57 lines
2.1 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/******************************************************************************
* @file MODBUS.h
* @brief Modbus RTU 协议通信处理模块头文件
* @details 本文件声明了 Modbus RTU 通信相关的接口函数包括主处理、LOGO 显示、
* 轮询计数与初始化等。配合 MODBUS.c 使用,通过 RS485 与从站通信。
* @author 阜阳师范大学物电学院
* @version V0.01
* @date 2026.1.23
* @note 通信协议Modbus RTU
* 通信接口RS485
* 主站地址0x01
******************************************************************************/
#ifndef MODBUS_H__
#define MODBUS_H__
#include "./SYSTEM/sys/sys.h"
#include "./SYSTEM/delay/delay.h"
#include "key.h"
/* ============================================================================
* 函数声明
* ============================================================================ */
/**
* @brief Modbus 通信主处理函数(远程图片处理)
* @param key 按键值KEY_TYPE用于上报按键事件
* @param flag 连接标志(传入当前连接状态,用于更新)
* @note 处理接收帧、按键上报、定时刷新、应答超时等;采用 138 端处理图片、
* 整体上传显示的方式刷图。需在周期任务中调用。
* @retval 更新后的连接标志1=已连接0=未连接/超时)
*/
uint8_t RS485_Process(KEY_TYPE key, uint8_t flag);
/**
* @brief 从 Flash 读取 LOGO 并显示
* @note 调用 BMP_Get 读 Flash再 LOGO_Printf 显示,合计延时约 2s
* @retval 无
*/
void NL_LOGO_Printf(void);
/**
* @brief 轮询计数处理(需在 5ms 周期定时器中调用)
* @note 递增 RT_count若 ACK_COUNT_ABLE 置位则递增 ACK_count用于超时检测
* @retval 无
*/
void Process_Count(void);
/**
* @brief Modbus 轮询与应答相关变量初始化
* @note 清零超时、应答计数等标志,置位 CMD_ACK 允许发送。上电或重新建立通信前调用
* @retval 无
*/
void Process_Init(void);
#endif /* MODBUS_H__ */