165 lines
3.8 KiB
C
165 lines
3.8 KiB
C
|
#ifndef BSP_HMI_H_
|
|||
|
#define BSP_HMI_H_
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
extern "C" {
|
|||
|
#endif
|
|||
|
|
|||
|
#include "kit_macro.h"
|
|||
|
|
|||
|
#define HMI_BRROCAST_TYPE (0xFu)
|
|||
|
#define HMI_BRROCAST_ADDR (0xFFu)
|
|||
|
#define HMI_DATA_POS (6u)
|
|||
|
#define HMI_FUNC_CODE_POS (5u)
|
|||
|
#define HMI_DEVICE_TYPE_POS (3u)
|
|||
|
#define HMI_SLAVE_ADDR_POS (4u)
|
|||
|
#define HMI_BUF_LEN_POS (1u)
|
|||
|
|
|||
|
#define HMI_PROC_BRROCAST_TYPE (0xFFu)
|
|||
|
#define HMI_PROC_BRROCAST_ADDR (0xFFu)
|
|||
|
|
|||
|
#define HMI_PROTOCOL_DATA_POS (11u)
|
|||
|
#define HMI_PROTOCOL_START_POS (0u) //<2F><>ʼ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>stx<74><78>
|
|||
|
#define HMI_PROTOCOL_BUF_LEN_POS (2u) //<2F>ֽڳ<D6BD><DAB3><EFBFBD> (bytelen)
|
|||
|
#define HMI_PROTOCOL_SEND_TYPE_POS (4u) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
#define HMI_PROTOCOL_RECV_TYPE_POS (5u) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
#define HMI_PROTOCOL_CMD_POS (6u) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
#define HMI_PROTOCOL_FUN_POS (7u) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
#define HMI_PROTOCOL_SRLI_POS (8u) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (serial1)
|
|||
|
#define HMI_PROTOCOL_SRLII_POS (9u) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (serial1)
|
|||
|
#define HMI_PROTOCOL_SRLIII_POS (10u)//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (serial1)
|
|||
|
|
|||
|
#define HMI_PROTOCOL_MIN_LEN (13u)//˽<><CBBD>Э<EFBFBD><D0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
|
|||
|
kHmiMainFun_Info = 0x01,
|
|||
|
kHmiMainFun_Cfg,
|
|||
|
kHmiMainFun_Ctrl,
|
|||
|
}HmiMainFunc;
|
|||
|
|
|||
|
|
|||
|
//<2F>ӹ<EFBFBD><D3B9><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
kHmiSubFun_0x10= 0x10,
|
|||
|
kHmiSubFun_0x01 = 0x01,
|
|||
|
kHmiSubFun_0x02 = 0x02,
|
|||
|
}HmiSubFunc;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
kHmiMainCmd_Test = 0x01,
|
|||
|
kHmiMainCmd_Info,
|
|||
|
kHmiMainCmd_Cfg,
|
|||
|
kHmiMainCmd_Boot,
|
|||
|
kHmiMainCmd_Log,
|
|||
|
kHmiMainCmd_Tool,
|
|||
|
}HmiMainCmd;
|
|||
|
|
|||
|
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
kHmiToolSubCmd_Reserve,
|
|||
|
kHmiToolSubCmd_HandShake,
|
|||
|
kHmiToolSubCmd_TestItem,
|
|||
|
kHmiToolSubCmd_End,
|
|||
|
}HmiToolSubCmd;
|
|||
|
|
|||
|
typedef enum
|
|||
|
{
|
|||
|
kHmiOccupy_None,
|
|||
|
kHmiOccupy_Request,
|
|||
|
kHmiOccupy_Forward,
|
|||
|
kHmiOccupy_End,
|
|||
|
}HmiOccupy;
|
|||
|
|
|||
|
struct _HmiItem;
|
|||
|
typedef bool (*HmiSendCall)(uint8_t comm_dev, uint8_t *buf, int32_t len);
|
|||
|
typedef void (*Fun07Call)(struct _HmiItem *item, uint8_t sub_fun, uint8_t *buf, int32_t len);
|
|||
|
typedef void (*HmiFuncCall)(struct _HmiItem *item, uint8_t main_fun, uint8_t sub_fun, uint8_t *buf, uint16_t len);
|
|||
|
typedef void (*HmiRxIntCtrlCall)(uint8_t comm_dev, bool is_en);
|
|||
|
|
|||
|
typedef struct _HmiItem
|
|||
|
{
|
|||
|
uint8_t rcv_addr;
|
|||
|
uint8_t rcv_addr1;
|
|||
|
uint8_t rcv_addr2;
|
|||
|
uint8_t rcv_addr3;
|
|||
|
uint8_t main_func;
|
|||
|
uint8_t sub_func;
|
|||
|
uint8_t snd_type;
|
|||
|
uint8_t rcv_type;
|
|||
|
uint8_t comm_dev;
|
|||
|
uint8_t dev_addr;
|
|||
|
HmiOccupy occupy;
|
|||
|
uint16_t time_out;
|
|||
|
|
|||
|
uint16_t occupy_dly;
|
|||
|
uint16_t buf_pos;
|
|||
|
uint16_t buf_len;
|
|||
|
uint32_t tick;
|
|||
|
uint8_t * comm_buf;
|
|||
|
struct _HmiItem *fwd_item;
|
|||
|
HmiFuncCall func_call;
|
|||
|
HmiSendCall send_call;
|
|||
|
HmiRxIntCtrlCall ctrl_rx_int_call;
|
|||
|
Fun07Call fun_07_call;
|
|||
|
|
|||
|
|
|||
|
} HmiItem;
|
|||
|
|
|||
|
|
|||
|
#define HMI_STATIC_INIT(_name, _buf, _buf_len, _comm_dev,_send_call, _ctrl_rx_int_call, _func_call) \
|
|||
|
HmiItem _name = \
|
|||
|
{ \
|
|||
|
0, \
|
|||
|
0, \
|
|||
|
0, \
|
|||
|
0, \
|
|||
|
0, \
|
|||
|
0, \
|
|||
|
0, \
|
|||
|
0, \
|
|||
|
(_comm_dev), \
|
|||
|
0, \
|
|||
|
(kHmiOccupy_None), \
|
|||
|
0, \
|
|||
|
0, \
|
|||
|
0, \
|
|||
|
(_buf_len), \
|
|||
|
0, \
|
|||
|
_buf,\
|
|||
|
NULL, \
|
|||
|
_func_call, \
|
|||
|
_send_call, \
|
|||
|
_ctrl_rx_int_call, \
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
void bsp_hmi_neg_send(HmiItem *item, uint16_t ex_code);
|
|||
|
void bsp_hmi_set_dev_addr(HmiItem *item, uint8_t addr);
|
|||
|
void bsp_hmi_set_comm_dev(HmiItem *item, uint8_t dev);
|
|||
|
void bsp_hmi_set_fun_07_call(HmiItem *item, Fun07Call call);
|
|||
|
void bsp_hmi_pos_send(HmiItem *item, uint8_t *buf,uint16_t len);
|
|||
|
|
|||
|
void bsp_hmi_analyse(HmiItem *item, bool is_reflesh);
|
|||
|
void bsp_hmi_push_data(HmiItem *item, uint8_t *buf, uint16_t len);
|
|||
|
bool bsp_hmi_forward(HmiItem *rcv_item, HmiItem *fwd_item, uint16_t len);
|
|||
|
bool bsp_hmi_request(HmiItem *item, uint8_t master_type, uint8_t slave_type, uint8_t slave_addr, uint8_t main_fun, uint8_t sub_fun, uint8_t *buf, uint16_t len, uint16_t time_out);
|
|||
|
|
|||
|
//Ĭ<><C4AC>Э<EFBFBD>鷢<EFBFBD>ͽӿ<CDBD>
|
|||
|
void bsp_hmi_send(HmiItem *item, uint8_t *buf,uint16_t len);
|
|||
|
|
|||
|
#ifdef __cplusplus
|
|||
|
}
|
|||
|
#endif
|
|||
|
|
|||
|
#endif
|