12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- //
- // Created by DELL on 2024/10/18.
- //
- #ifndef GMV_GATEWAY_BOARD_MODBUS_SLAVE_H
- #define GMV_GATEWAY_BOARD_MODBUS_SLAVE_H
- #include "main.h"
- // 定义从机寄存器开始地址和长度
- #define S_REG_HOLDING_START 0
- #define S_REG_HOLDING_NREGS 30
- //#define COMMUNICATION_REG_ADDRESS 0 // 当前从机通讯地址
- #define POWER_REG_ADDRESS 0 // 电源地址
- #define WORK_MODE_REG_ADDRESS 1 // 运行模式
- #define FAN_SPEED_REG_ADDRESS 4 // 风扇转速
- #define SET_TEMP_REG_ADDRESS 14 // 设定温度
- #define INNER_GROUP1_REG_ADDRESS 10
- #define INNER_GROUP2_REG_ADDRESS 11
- #define TEMP_ON_FFX_ADDRESS 17
- #define TEMP_OFF_FFX_ADDRESS 18
- #define INNER_ERROR1_REG_ADDRESS 20 //40021
- #define INNER_ERROR2_REG_ADDRESS 21 //40022
- #define INNER_ERROR3_REG_ADDRESS 22
- #define INNER_ERROR4_REG_ADDRESS 23
- #define LED_ERROR_GPIO_Port GPIOB
- #define LED_ERROR_Pin GPIO_PIN_12
- /**
- * 开启485从机
- * @param address 从机地址
- */
- void start_485_slave(uint8_t address);
- /**
- * 设置故障位
- * @param offset 位偏移量
- */
- void set_err_code(uint8_t offset);
- /**
- * 清除故障位
- * @param offset 位偏移量
- */
- void clear_err_code(uint8_t offset);
- /**
- * 设置一个寄存器的值
- * @param regAddress
- */
- void set_reg_value(uint16_t regAddress, uint16_t value);
- /**
- * 读取一个寄存器的值
- * @param regAddress
- * @return
- */
- uint16_t get_reg_value(uint16_t regAddress);
- #endif //GMV_GATEWAY_BOARD_MODBUS_SLAVE_H
|