47 lines
1.2 KiB
C
47 lines
1.2 KiB
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 1024
|
||
|
extern uint8_t gBitVar[(gBIT_SIZE+7)/8];
|
||
|
extern uint16_t gWordVar[gWORD_SIZE];
|
||
|
extern uint16_t modbus_addr;
|
||
|
|
||
|
// #include "usart.h"
|
||
|
// #include "gpio.h"
|
||
|
// #include "main.h"
|
||
|
#define BUFFER_SIZE 2000
|
||
|
extern uint8_t rx_buffer[256];
|
||
|
extern uint8_t tx_buffer[256];
|
||
|
extern uint16_t rx_buff_len;
|
||
|
// extern __IO uint8_t recv_end_flag;
|
||
|
extern uint8_t recv_end_flag;
|
||
|
extern void modbus_recv_mode(void);
|
||
|
extern void usart2_dma_recv_start(void);
|
||
|
extern void modbus_send(uint8_t *buf, uint8_t len);
|
||
|
// extern void save_flow_cfg(void);
|
||
|
extern int check_mastrt_recv(void);
|
||
|
|
||
|
void ModBusWordWriteHook(uint16_t addr, uint16_t length);
|
||
|
|
||
|
#endif
|
||
|
|