71 lines
1.5 KiB
C
71 lines
1.5 KiB
C
|
|
#ifndef __RS485_TASK_H
|
||
|
|
#define __RS485_TASK_H
|
||
|
|
|
||
|
|
#include "bsp.h"
|
||
|
|
#include "Public.h"
|
||
|
|
|
||
|
|
#define RS485_RX_BUFF_LEN_MAX 64
|
||
|
|
|
||
|
|
typedef struct {
|
||
|
|
SensorComm_m Com;
|
||
|
|
uint16_t SensorType;
|
||
|
|
}SensorTypes_t;
|
||
|
|
|
||
|
|
typedef enum {
|
||
|
|
RS485_OUT_VOLTAGE_OV,
|
||
|
|
RS485_OUT_VOLTAGE_5V,
|
||
|
|
RS485_OUT_VOLTAGE_12V,
|
||
|
|
}RS485Vol_m;
|
||
|
|
|
||
|
|
typedef struct {
|
||
|
|
uint8_t Header;
|
||
|
|
uint8_t SlvAddr;
|
||
|
|
uint8_t Cmd;
|
||
|
|
//uint16_t DevType;
|
||
|
|
uint8_t PayloadLen;
|
||
|
|
}__attribute__((packed))FrameHeader_t, *FrameHeader;
|
||
|
|
|
||
|
|
typedef enum {
|
||
|
|
RS485_SENSOR_CMD_NULL,
|
||
|
|
RS485_SENSOR_CMD_CAIL,
|
||
|
|
RS485_SENSOR_CMD_READ,
|
||
|
|
RS485_SENSOR_CMD_QUERY,
|
||
|
|
RS485_SENSOR_CMD_SET_ADDR,
|
||
|
|
RS485_SENSOR_CMD_SET_INV_TIME,
|
||
|
|
RS485_SENSOR_CMD_TIME_SYNC,
|
||
|
|
RS485_SENSOR_CMD_END,
|
||
|
|
}RS485SensorCmd_m;
|
||
|
|
|
||
|
|
//´«¸ÐÆ÷Êý¾Ý·¢ËͽṹÌå
|
||
|
|
typedef struct {
|
||
|
|
bool SendFlag;
|
||
|
|
uint8_t SensorCnt;
|
||
|
|
uint8_t SensorErrCnt[SENSOR_NUM_MAX];
|
||
|
|
uint8_t ReadSensorCnt;
|
||
|
|
int32_t ReadSensorInterval;
|
||
|
|
RS485SensorCmd_m Cmd;
|
||
|
|
uint8_t SensorAddr;
|
||
|
|
uint16_t SensorType;
|
||
|
|
uint8_t CmdParaLen;
|
||
|
|
uint8_t *CmdPara;
|
||
|
|
uint8_t RS485RxBuff[RS485_RX_BUFF_LEN_MAX];
|
||
|
|
uint8_t RS485RxLen;
|
||
|
|
uint8_t RS485TimeOutCnt;
|
||
|
|
uint32_t RS485CommUnitReadTimeDelay;
|
||
|
|
uint8_t SendUnitCommIdx;
|
||
|
|
rt_sem_t RS485Rev_Sem;
|
||
|
|
bool InitOverFlag;
|
||
|
|
CommUnitData_t SensorData;
|
||
|
|
}SensorCommPara_t, *SensorCommPara;
|
||
|
|
|
||
|
|
void RS485CmdSend(GateWayPara GateWay, uint8_t CommUintAddr, SensorCommPara SensorComm);
|
||
|
|
void RS485Ch1_Thread_Entry(void *parameter);
|
||
|
|
void RS485Ch2_Thread_Entry(void *parameter);
|
||
|
|
void RS485RxOverhandler(void);
|
||
|
|
|
||
|
|
extern SensorCommPara_t SComm1Para;
|
||
|
|
extern SensorCommPara_t SComm2Para;
|
||
|
|
#endif
|
||
|
|
|
||
|
|
|