EC600U_esp32_iap_uart/EC600U_t2n/include/ModbusS.h

52 lines
1.3 KiB
C
Raw Permalink Normal View History

2024-02-05 17:39:56 +08:00
#ifndef _MODBUS_H
#define _MODBUS_H
#include <stdint.h>
//#define uint8_t unsigned char
//#define uint16_t unsigned short
//#define uint32 unsigned int
#define setBit(Add) gBitVar[(Add) >> 3] |= (1 << ((Add)&0x07))
#define clrBit(Add) gBitVar[(Add) >> 3] &= ~(1 << ((Add)&0x07))
//#define ModBusTxData uart1_tx
extern uint16_t crc16(uint8_t *puchMsg, uint16_t usDataLen);
extern int ModbusSlaveProcess(uint8_t *txbuf, uint8_t *rxbuf, uint16_t rxLen, int is_crc);
extern void modbus(void);
extern void ModbusSetLocalReg(uint16_t addr, uint16_t value);
// #define local 1
int isBitHI(uint16_t Add);
void xorBit(uint16_t Add);
void WriteBit(uint16_t Add, uint8_t bit_value);
#define gBIT_SIZE 128
#define gWORD_SIZE 8192
extern uint8_t gBitVar[(gBIT_SIZE + 7) / 8];
extern uint16_t gWordVar[gWORD_SIZE];
// typedef struct
// {
// int16_t csq; 16
// uint16_t net_status; 17
// uint16_t gps_view;
// uint16_t gps_use;
// uint16_t gps_status;
// int16_t speed; // 速度
// int16_t TEMP; // 温度
// } ui_data_t;
void modbus(void);
#define REG_IMEI (512+32)
#define REG_CCID (512+48)
#define REG_CSQ (512+16)
#define REG_NET_STATUS (512+17)
#define REG_VIEW_STAS (512+18)
#define REG_USE_STAS (512+19)
#define REG_GPS_STATUS (512+20)
#define REG_UPDATE_STATUS (512+31)
#define REG_UBLOX_CFG_REQ REG_GPS_STATUS
#endif