训练营PLSR题目
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

56 строки
1.8 KiB

  1. #ifndef __MODBUS_H__
  2. #define __MODBUS_H__
  3. /* 调用库 */
  4. #include "usart.h"
  5. #include "sram.h"
  6. #include "crc.h"
  7. #include <string.h>
  8. #include <stdlib.h>
  9. /* 宏定义 */
  10. #define READ_COIL_CODE 0x01
  11. #define WRUTE_MUL_COIL_CODE 0x0f
  12. #define READ_REGUSTER_CODE 0x03
  13. #define READ_EXREGUSTER_CODE 0x30
  14. #define WRITE_COIL_CODE 0x05
  15. #define WRITE_MUL_REGISTER_CODE 0x10
  16. #define WRITE_MUL_EXREGISTER_CODE 0x31
  17. #define GET_HISTORY_CODE 0x55
  18. #define READ_ODD_REGUSTER_CODE 0x33
  19. #define WRITE_ONLY_REGISTER 0x06
  20. #define SLAVES_ADDRES 0x01
  21. /* 函数声明 */
  22. void ErrorBack(uint8_t buffer[], uint16_t longth);
  23. void ProcessModbusFrame(uint8_t buffer[], uint16_t longth);
  24. void ReadCoilProcess (uint8_t buffer[], uint16_t longth);
  25. void WriteMulCoilProcess(uint8_t buffer[], uint16_t longth);
  26. void ReadRegisterProcess(uint8_t buffer[], uint16_t longth);
  27. void WriteMulRegisterProcess(uint8_t buffer[], uint16_t longth);
  28. void WriteCoilProcess(uint8_t buffer[], uint16_t longth);
  29. void ReadOddRegisterProcess(uint8_t buffer[], uint16_t longth);
  30. void ReadEXRegisterProcess(uint8_t buffer[], uint16_t longth);
  31. void WriteEXRegisterProcess(uint8_t buffer[], uint16_t longth);
  32. void WriteOnlyRegister(uint8_t buffer[], uint16_t longth);
  33. void SaveHistory(uint8_t buffer[], uint16_t longth);
  34. void LoadHistory(void);
  35. void GetHistory(uint8_t buffer[], uint16_t longth);
  36. void ModbusLoadSRAM(void);
  37. void ModbusSaveSRAM(void);
  38. /* 变量定义 */
  39. extern uint8_t History[3][512]; /*存放历史的地方*/
  40. extern uint8_t HistoryLongth[3];/*历史数据大小的计数*/
  41. extern uint8_t HistoryLocation; /*当前历史存放到了第几条*/
  42. extern uint8_t Flash_data[20]; /*存入flash的数据*/
  43. extern uint8_t SaveFlag;
  44. extern uint8_t Register_H[16384]; ///<寄存器的高字节
  45. extern uint8_t Register_L[16384]; ///<寄存器的低字节
  46. #endif