12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #ifndef __MODBUS_H
- #define __MODBUS_H
- // #include "bms_config.h"
- #include "fly_param.h"
- // #include "bmu_param.h"
- #include "includes.h"
- #include "iwdg.h"
- #include "uart1.h"
- #include "uart3.h"
- typedef unsigned char MODBUS_INT8U;
- typedef signed char MODBUS_INT8S;
- typedef unsigned short MODBUS_INT16U;
- typedef signed short MODBUS_INT16S;
- typedef unsigned int MODBUS_INT32U;
- typedef signed int MODBUS_INT32S;
- typedef void (*txfun_p)(const INT8U *buf, INT16U len);
- #define MODBUS_GAIN(VALUE1, VALUE2) ((MODBUS_INT32U)(VALUE1) * (VALUE2))
- #define MODBUS_SUBTRACT(VALUE1, VALUE2) ((MODBUS_INT32U)(VALUE1) - (VALUE2))
- #define MODBUS_DIVISION(DIVISOR, DIVIDEND) (((MODBUS_INT32U)(DIVISOR) + (DIVIDEND) / 2) / (DIVIDEND))
- #define MODBUS_ABS(VALUE1) (((VALUE1) < 0) ? (-(VALUE1)) : (VALUE1))
- #define BUF_LEN_128 128
- #define BUF_LEN_256 256
- #define BUF_LEN_512 512
- #define RACK_NUM 1u
- #define BUF_LEN_768 768
- #define GROUP_NUMBER_MAX 15
- #define VOL_TMP_PAGE_NUM 32
- #define BUF_LEN_256 256
- #define BUF_LEN_512 512
- #define RACK_NUM 1u
- #define BUF_LEN_768 768
- #define GROUP_NUMBER_MAX 15
- #define VOL_TMP_PAGE_NUM 32
- #define FUNC_03 3
- #define FUNC_05 5
- #define FUNC_06 6
- #define FUNC_10 16
- // samkoon COM def
- #define COUNT_INDEX_H 4
- #define COUNT_INDEX_L 5
- #define REGISTER_ADDR_H 2
- #define REGISTER_ADDR_L 3
- #define FUNCTION_CODE_INDEX 1
- // samkoon address def
- #define MODBUS_ADDR_SOC 0x4101 // 电池簇SOC寄存器地址
- #define MODBUS_ADDR_CELL 0x4301 // 单体电压寄存器地址
- #define MODBUS_ADDR_TEMP 0x55c1 // 单体温度寄存器地址
- #define MODBUS_ADDR_READ_KA 0x1001 // 继电器状态读地址
- #define MODBUS_ADDR_RACK_REMOTE 0xC9 //
- #define MODBUS_RACK_END 0x4120 // 电池簇SOC寄存器地址
- #define MODBUS_CELL_END 0x4490
- #define MODBUS_TEMP_END 0x5750
- #define MODBUS_KA_END 0x1009
- #define MODBUS_ADDR_RACK_REMOTE_END 0xE7
- void modbus_master_task(void);
- void modbus_slave_task(void);
- #endif
|