30 lines
765 B
C
30 lines
765 B
C
|
#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);
|
||
|
|
||
|
|
||
|
|
||
|
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 12288
|
||
|
extern uint8_t gBitVar[(gBIT_SIZE + 7) / 8];
|
||
|
extern uint16_t gWordVar[gWORD_SIZE];
|
||
|
|
||
|
void modbus(void);
|
||
|
void rs485_send(void *buf, uint16_t len);
|
||
|
|
||
|
#endif
|