blob: 5a6b49584836ce17a771e09e9313980bccafe4f3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
/** Serialization of structures stored in the EEPROM.
*
* Device PIC16F1459
* Compiler: XC8 v3.00
*
* Usage:
*
* #include <stdbool.h>
* #include <stdint.h>
* #include "types.h"
* #include "eeprom.h"
* #include "can.h"
* #include "signal.h"
* #include "serial.h"
*/
// Size of structures stored in ROM
enum {
SER_CANID_SIZE = sizeof(U32),
SER_SIGFMT_SIZE = 8,
};
// Write a CAN ID to the EEPROM.
// CAN IDs are stored in the lower 11 or 29 bits of a little-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.
// 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.
// Start and Size occupy bytes 4 and 5.
// The Byte-order and Signedness flags are bits 0 and 1 of byte 6, respectively.
// Byte order: [6][0] = {0=>LE, 1=>BE}.
// Signedness: [6][1] = {0=>unsigned, 1=>signed}.
// Byte 7 is unused -- it's for alignment.
Status serWriteSigFmt(EepromAddr addr, const SigFmt *sig);
// Read a SigFmt from the EEPROM.
// See serWriteSigFmt for storage format.
Status serReadSigFmt(EepromAddr addr, SigFmt *sig);
|