初始提交
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#ifndef CPY_PROT_H
|
||||
#define CPY_PROT_H
|
||||
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "main.h"
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
#define DAQ_HEADER 0x55AA
|
||||
#define DAQ_DATA_MIN_LEN 10
|
||||
#define CRC_LEN 2
|
||||
|
||||
|
||||
typedef enum {
|
||||
CPY_PROT_CMD_HEARTBEAT = 0x01,
|
||||
CPY_PROT_CMD_VERSION,
|
||||
CPY_PROT_CMD_PARAM_READ,
|
||||
CPY_PROT_CMD_PARAM_WRITE,
|
||||
CPY_PROT_CMD_SAMPLE_LEN,
|
||||
CPY_PROT_CMD_SAMPLE_DATA,
|
||||
CPY_PROT_CMD_IAP,
|
||||
CPY_PROT_CMD_BOOT_BLOCKING,
|
||||
CPY_PROT_CMD_JUMP_APP,
|
||||
CPY_PROT_CMD_RESET,
|
||||
CPY_PROT_CMD_OTP_READ,
|
||||
CPY_PROT_CMD_OTP_WRITE,
|
||||
CPY_PROT_CMD_RESET_FACTORY,
|
||||
|
||||
CPY_PROT_CMD_ACK = 0x80,
|
||||
CPY_PROT_CMD_ERROR = 0xC0,
|
||||
} cpy_prot_cmd_t;
|
||||
|
||||
//1字节对齐
|
||||
#pragma pack(1)
|
||||
typedef struct {
|
||||
uint16_t header;
|
||||
uint8_t cmd;
|
||||
uint16_t len;
|
||||
uint8_t data[DAQ_DATA_MIN_LEN];
|
||||
} daq_packet_t;
|
||||
#pragma pack()
|
||||
|
||||
#define DATA_LEN_2_PACKET_LEN(data_len) ((data_len) < DAQ_DATA_MIN_LEN ? (sizeof(daq_packet_t) + CRC_LEN) : ((data_len) + sizeof(daq_packet_t) - DAQ_DATA_MIN_LEN + CRC_LEN))
|
||||
|
||||
|
||||
void cpyProtInit(void);
|
||||
int daq_send_packet(uint8_t cmd, const uint8_t *data, uint16_t len);
|
||||
|
||||
|
||||
#endif // CPY_PROT_H
|
||||
Reference in New Issue
Block a user