Group baton_defs¶
Frame layout, frame types, payload prefixes and byte-order helpers. More...
Public Static Functions¶
| Type | Name |
|---|---|
| uint8_t | baton_ctrl (uint8_t type, bool first, uint8_t seq) Build a control byte. |
| bool | baton_ctrl_first (uint8_t ctrl) FIRST flag of a control byte. |
| uint8_t | baton_ctrl_seq (uint8_t ctrl) Sequence number of a control byte. |
| uint8_t | baton_ctrl_type (uint8_t ctrl) Frame type of a control byte. |
| uint16_t | baton_get_u16be (const uint8_t * data) Read a big-endian 16-bit value. |
| uint32_t | baton_get_u32le (const uint8_t * data) Read a little-endian 32-bit value. |
| void | baton_put_u16be (uint8_t * data, uint16_t value) Write a 16-bit value in big-endian order. |
| void | baton_put_u32le (uint8_t * data, uint32_t value) Write a 32-bit value in little-endian order. |
Macros¶
| Type | Name |
|---|---|
| define | BATON_ACKB_VALID 0x80UACKB byte: bit 7 = valid, bits 3..0 = acknowledged sequence number. |
| define | BATON_ADDR_BROADCAST 0xFFUDestination address meaning "every other node on the bus". |
| define | BATON_CRC_SIZE 2UCRC-16, transmitted high byte first. |
| define | BATON_FRAME_OVERHEAD ([**BATON\_HEADER\_SIZE**](group__baton__defs.md#define-baton_header_size) + [**BATON\_CRC\_SIZE**](group__baton__defs.md#define-baton_crc_size))Bytes of a frame that are not payload. |
| define | BATON_FT_ACK 3USlave to slave: acknowledges one DATA frame. |
| define | BATON_FT_DATA 2USlave to slave: messages, acknowledged with ACK. |
| define | BATON_FT_POLL 0UMaster to slave: grants the bus for one slot, may carry messages. |
| define | BATON_FT_RESP 1USlave to master: ends the slot, may carry messages. |
| define | BATON_HEADER_SIZE 5USYNC, DST, SRC, CTRL and LEN. |
| define | BATON_SEQ_MASK 0x0FUMask of the sequence number in CTRL and ACKB. |
| define | BATON_SYNC 0xA5UFirst byte of every frame. |
| define | BATON_TLV_HEADER_SIZE 2UOne message inside a payload: id, length, data (TLV). |
Detailed Description¶
The wire format is described in docs/protocol.md: SYNC | DST | SRC | CTRL | LEN | PAYLOAD[LEN] | CRC16 (big endian), CRC-16/CCITT-FALSE over DST..PAYLOAD, CTRL = TYPE[7:6] | FIRST[5] | reserved[4] | SEQ[3:0].
Public Static Functions Documentation¶
function baton_ctrl¶
Build a control byte.
Parameters:
typeFrame type (BATON_FT_*), 0..3.firstFIRST flag: set until the receiver acknowledged a frame after a restart.seqSequence number, only bits 3..0 are used.
Returns:
Control byte.
function baton_ctrl_first¶
FIRST flag of a control byte.
function baton_ctrl_seq¶
Sequence number of a control byte.
function baton_ctrl_type¶
Frame type of a control byte.
function baton_get_u16be¶
Read a big-endian 16-bit value.
function baton_get_u32le¶
Read a little-endian 32-bit value.
function baton_put_u16be¶
Write a 16-bit value in big-endian order.
function baton_put_u32le¶
Write a 32-bit value in little-endian order.
Macro Definition Documentation¶
define BATON_ACKB_VALID¶
ACKB byte: bit 7 = valid, bits 3..0 = acknowledged sequence number.
define BATON_ADDR_BROADCAST¶
Destination address meaning "every other node on the bus".
define BATON_CRC_SIZE¶
CRC-16, transmitted high byte first.
define BATON_FRAME_OVERHEAD¶
Bytes of a frame that are not payload.
define BATON_FT_ACK¶
Slave to slave: acknowledges one DATA frame.
define BATON_FT_DATA¶
Slave to slave: messages, acknowledged with ACK.
define BATON_FT_POLL¶
Master to slave: grants the bus for one slot, may carry messages.
define BATON_FT_RESP¶
Slave to master: ends the slot, may carry messages.
define BATON_HEADER_SIZE¶
SYNC, DST, SRC, CTRL and LEN.
define BATON_SEQ_MASK¶
Mask of the sequence number in CTRL and ACKB.
define BATON_SYNC¶
First byte of every frame.
define BATON_TLV_HEADER_SIZE¶
One message inside a payload: id, length, data (TLV).