2020-03-30 17:51:31 +08:00
|
|
|
|
#ifndef __PROTOCOL__H
|
|
|
|
|
|
#define __PROTOCOL__H
|
|
|
|
|
|
|
|
|
|
|
|
#include "Arduino.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*֡ͷ����*/
|
2022-07-06 14:21:26 +08:00
|
|
|
|
#define FRAME_HEADER_LENGTH 1U
|
2020-03-30 17:51:31 +08:00
|
|
|
|
|
|
|
|
|
|
/*֡β����(��У���)*/
|
2022-07-06 14:21:26 +08:00
|
|
|
|
#define FRAME_TAIL_LENGTH 1U
|
2020-03-30 17:51:31 +08:00
|
|
|
|
|
|
|
|
|
|
/*֡ͷ��ͬ�ֽ�*/
|
2022-07-06 14:21:26 +08:00
|
|
|
|
#define FRAME_HEAD_SAME_FA 0xFA
|
2020-03-30 17:51:31 +08:00
|
|
|
|
|
|
|
|
|
|
/*���ջ���������*/
|
2022-07-06 14:21:26 +08:00
|
|
|
|
#define RX_BUF_LENGTH 64U
|
|
|
|
|
|
#define RX_END_LENGTH 1U
|
2020-03-30 17:51:31 +08:00
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2022-07-06 14:21:26 +08:00
|
|
|
|
uint8_t cmd_id;
|
|
|
|
|
|
uint8_t ack_flag;
|
|
|
|
|
|
uint8_t *cmd_value;
|
|
|
|
|
|
uint16_t cmd_length;
|
2020-03-30 17:51:31 +08:00
|
|
|
|
} PayloadData;
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
2022-07-06 14:21:26 +08:00
|
|
|
|
uint8_t src;
|
|
|
|
|
|
uint8_t dst;
|
|
|
|
|
|
uint8_t seq;
|
|
|
|
|
|
uint8_t res;
|
|
|
|
|
|
PayloadData payload;
|
2020-03-30 17:51:31 +08:00
|
|
|
|
} CmdData;
|
|
|
|
|
|
|
|
|
|
|
|
/*����Э�鹫������*/
|
|
|
|
|
|
typedef struct {
|
2022-07-06 14:21:26 +08:00
|
|
|
|
volatile uint8_t step; /*switch �����ת����*/
|
|
|
|
|
|
volatile int8_t tmpCnt; /*���ڼ�������ʱ����*/
|
|
|
|
|
|
volatile uint8_t aRxBufIndex; /*�������ݻ���������*/
|
|
|
|
|
|
volatile uint8_t aRxCrcIndex; /*��β���ݻ���������*/
|
|
|
|
|
|
uint8_t aRxCrc[RX_END_LENGTH];
|
|
|
|
|
|
uint8_t aRxBuf[RX_BUF_LENGTH];
|
2020-03-30 17:51:31 +08:00
|
|
|
|
} protocolComType_t;
|
|
|
|
|
|
|
|
|
|
|
|
extern void protocol_rec_put(uint8_t data);
|
|
|
|
|
|
extern void protocol_send_data(CmdData dat);
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|