diff options
Diffstat (limited to 'fw/serial.h')
| -rw-r--r-- | fw/serial.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/fw/serial.h b/fw/serial.h index b071038..093b40c 100644 --- a/fw/serial.h +++ b/fw/serial.h @@ -20,19 +20,31 @@ enum { SER_SIGFMT_SIZE = 8, }; +// Serialize a U16 into a big-endian array of bytes. +void serU16Be(U8 buf[2u], U16 n); + +// Deserialize a big-endian array of bytes into a U16. +U16 deserU16Be(const U8 buf[2u]); + +// Serialize a U32 into a big-endian array of bytes. +void serU32Be(U8 buf[4u], U32 n); + +// Deserialize a big-endian array of bytes into a U32. +U32 deserU32Be(const U8 buf[4u]); + // Write a CAN ID to the EEPROM. -// CAN IDs are stored in the lower 11 or 29 bits of a little-endian U32. +// CAN IDs are stored in the lower 11 or 29 bits of a big-endian U32. // Bit 31 indicates standard/extended: 0=>std, 1=>ext. Status serWriteCanId(EepromAddr addr, const CanId *id); // Read a CAN ID from the EEPROM. -// CAN IDs are stored in the lower 11 or 29 bits of a little-endian U32. +// CAN IDs are stored in the lower 11 or 29 bits of a big-endian U32. // Bit 31 indicates standard/extended: 0=>std, 1=>ext. Status serReadCanId(EepromAddr addr, CanId *id); // Write a SigFmt to the EEPROM. // SigFmts use 8 bytes of space. -// The ID is stored little-endian in the first 4 bytes: 0--3. +// The ID is stored in the first 4 bytes: 0--3. // Start and Size occupy bytes 4 and 5. // The Byte-order and Signedness flags are bits 7 and 6 of byte 6, respectively. // Byte order: [6][7] = {0=>LE, 1=>BE}. |