Files
2019-11-29 20:48:25 +08:00

47 lines
1.2 KiB
C
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#ifndef __PROTOCOL__H
#define __PROTOCOL__H
#include "Arduino.h"
/*֡ͷ*/
#define FRAME_HEADER_LENGTH 1U
/*֡β(У)*/
#define FRAME_TAIL_LENGTH 1U
/*֡ͷֽͬ*/
#define FRAME_HEAD_SAME_FA 0xFA
/*ջ*/
#define RX_BUF_LENGTH 64U
#define RX_END_LENGTH 1U
typedef struct {
uint8_t cmd_id;
uint8_t ack_flag;
uint8_t *cmd_value;
uint16_t cmd_length;
} PayloadData;
typedef struct {
uint8_t src;
uint8_t dst;
uint8_t seq;
uint8_t res;
PayloadData payload;
} CmdData;
/*Э*/
typedef struct {
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];
} protocolComType_t;
extern void protocol_rec_put(uint8_t data);
extern void protocol_send_data(CmdData dat);
#endif