diff options
Diffstat (limited to 'fw/signal.h')
| -rw-r--r-- | fw/signal.h | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/fw/signal.h b/fw/signal.h new file mode 100644 index 0000000..8bbc120 --- /dev/null +++ b/fw/signal.h @@ -0,0 +1,33 @@ +/** DBC Signals. + * See "DBC File Format Documentation" v.01/2007 + * + * Device PIC16F1459 + * Compiler: XC8 v3.00 + * + * Usage: + * + * #include <stdbool.h> + * #include <stdint.h> + * #include "types.h" + * #include "can.h" + * #include "signal.h" + */ + +// Byte order +typedef enum { + LITTLE_ENDIAN = 0, + BIG_ENDIAN, +} ByteOrder; + +// A Signal Format defines how a DBC signal is encoded in a CAN frame. +typedef struct { + CanId id; // ID of message containing the signal + U8 start; // start bit -- position of signal within DATA FIELD + U8 size; // size of the signal in bits + ByteOrder order; // little-endian/big-endian + bool isSigned; +} SigFmt; + +// Extract the raw signal value out of a CAN frame's DATA FIELD. +// Assumes the frame's ID matches that of the signal. +Status sigPluck(const SigFmt *sig, const CanFrame *frame, Number *raw); |