29#ifndef PROTOCORE_C37118_H
30#define PROTOCORE_C37118_H
34#if PROTOCORE_ENABLE_C37118
38#define C37118_SYNC_LEADER 0xAA
39#define C37118_TYPE_SHIFT 4
40#define C37118_TYPE_MASK 0x07
41#define C37118_VERSION_MASK 0x0F
44#define C37118_TYPE_DATA 0
45#define C37118_TYPE_HEADER 1
46#define C37118_TYPE_CFG1 2
47#define C37118_TYPE_CFG2 3
48#define C37118_TYPE_CMD 4
49#define C37118_TYPE_CFG3 5
51#define C37118_VERSION_2005 1
52#define C37118_VERSION_2011 2
55#define C37118_CMD_DATA_OFF 1
56#define C37118_CMD_DATA_ON 2
57#define C37118_CMD_SEND_HDR 3
58#define C37118_CMD_SEND_CFG1 4
59#define C37118_CMD_SEND_CFG2 5
60#define C37118_CMD_SEND_CFG3 6
62#define C37118_MIN_FRAME 16
65uint16_t protocore_c37118_crc(
const uint8_t *data,
size_t len);
73size_t protocore_c37118_build_frame(uint8_t *buf,
size_t cap, uint8_t type, uint8_t version, uint16_t idcode,
74 uint32_t soc, uint32_t fracsec,
const uint8_t *payload,
size_t payload_len);
77size_t protocore_c37118_build_command(uint8_t *buf,
size_t cap, uint16_t idcode, uint32_t soc, uint32_t fracsec,
98proto_bool protocore_c37118_parse_frame(
const uint8_t *buf,
size_t len, C37118Frame *out);
101proto_bool protocore_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
130 uint8_t time_quality;
131 uint8_t unlocked_time;
132 uint8_t trigger_reason;
139proto_bool protocore_c37118_decode_stat(
const C37118Frame *f, C37118Stat *out);
#define PROTOCORE_BEGIN_DECLS
Give a header's declarations C linkage, so their symbol names carry no parameter types.
_Bool proto_bool
The truth value.
#define PROTOCORE_END_DECLS