29#ifndef PROTOCORE_C37118_H
30#define PROTOCORE_C37118_H
39#define C37118_SYNC_LEADER 0xAA
40#define C37118_TYPE_SHIFT 4
41#define C37118_TYPE_MASK 0x07
42#define C37118_VERSION_MASK 0x0F
45#define C37118_TYPE_DATA 0
46#define C37118_TYPE_HEADER 1
47#define C37118_TYPE_CFG1 2
48#define C37118_TYPE_CFG2 3
49#define C37118_TYPE_CMD 4
50#define C37118_TYPE_CFG3 5
52#define C37118_VERSION_2005 1
53#define C37118_VERSION_2011 2
56#define C37118_CMD_DATA_OFF 1
57#define C37118_CMD_DATA_ON 2
58#define C37118_CMD_SEND_HDR 3
59#define C37118_CMD_SEND_CFG1 4
60#define C37118_CMD_SEND_CFG2 5
61#define C37118_CMD_SEND_CFG3 6
63#define C37118_MIN_FRAME 16
66uint16_t pc_c37118_crc(
const uint8_t *data,
size_t len);
74size_t pc_c37118_build_frame(uint8_t *buf,
size_t cap, uint8_t type, uint8_t version, uint16_t idcode, uint32_t soc,
75 uint32_t fracsec,
const uint8_t *payload,
size_t payload_len);
78size_t pc_c37118_build_command(uint8_t *buf,
size_t cap, uint16_t idcode, uint32_t soc, uint32_t fracsec, uint16_t cmd);
98bool pc_c37118_parse_frame(
const uint8_t *buf,
size_t len, C37118Frame *out);
101bool pc_c37118_parse_command(
const C37118Frame *f, uint16_t *cmd);
106#define C37118_UNLOCKED_UNDER_10S 0
107#define C37118_UNLOCKED_10_100S 1
108#define C37118_UNLOCKED_100_1000S 2
109#define C37118_UNLOCKED_OVER_1000S 3
112#define C37118_TRIGGER_MANUAL 0
113#define C37118_TRIGGER_MAG_LOW 1
114#define C37118_TRIGGER_MAG_HIGH 2
115#define C37118_TRIGGER_PHASE_ANGLE 3
116#define C37118_TRIGGER_FREQ 4
117#define C37118_TRIGGER_DFDT 5
126 bool sorted_by_arrival;
130 uint8_t time_quality;
131 uint8_t unlocked_time;
132 uint8_t trigger_reason;
139bool pc_c37118_decode_stat(
const C37118Frame *f, C37118Stat *out);
User-facing configuration for ProtoCore.