aboutsummaryrefslogtreecommitdiffstats
path: root/fw
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2025-11-08 10:26:23 -0500
committerSam Anthony <sam@samanthony.xyz>2025-11-08 10:26:23 -0500
commitb6f66e394ad3f18b3dccea674b5c041f5a22fb41 (patch)
tree9a8ea15d60a4a529be8db634b8e83d9e8aa78533 /fw
parent9b562121464ea21ba8c8b4d3783d3f873746ee00 (diff)
downloadcan-gauge-interface-b6f66e394ad3f18b3dccea674b5c041f5a22fb41.zip
swap signal byte_order to reflect amended dbc spec
Diffstat (limited to 'fw')
-rw-r--r--fw/main.c2
-rw-r--r--fw/serial.c2
-rw-r--r--fw/signal.h6
3 files changed, 5 insertions, 5 deletions
diff --git a/fw/main.c b/fw/main.c
index b7b1efd..243f6b0 100644
--- a/fw/main.c
+++ b/fw/main.c
@@ -286,7 +286,7 @@ setSigFmt(const CanFrame *frame) {
// Unpack Encoding
sigFmt.start = frame->data[4u];
sigFmt.size = frame->data[5u];
- sigFmt.order = (frame->data[6u] & 0x80) ? BIG_ENDIAN : LITTLE_ENDIAN;
+ sigFmt.order = (frame->data[6u] & 0x80) ? LITTLE_ENDIAN : BIG_ENDIAN;
sigFmt.isSigned = frame->data[6u] & 0x40;
// Save to EEPROM
diff --git a/fw/serial.c b/fw/serial.c
index fd60bcd..b763524 100644
--- a/fw/serial.c
+++ b/fw/serial.c
@@ -111,7 +111,7 @@ serReadSigFmt(EepromAddr addr, SigFmt *sig) {
}
sig->start = buf[0u];
sig->size = buf[1u];
- sig->order = (buf[2u] & 0x80) ? BIG_ENDIAN : LITTLE_ENDIAN;
+ sig->order = (buf[2u] & 0x80) ? LITTLE_ENDIAN : BIG_ENDIAN;
sig->isSigned = buf[2u] & 0x40;
return OK;
diff --git a/fw/signal.h b/fw/signal.h
index 8bbc120..6489c6f 100644
--- a/fw/signal.h
+++ b/fw/signal.h
@@ -15,8 +15,8 @@
// Byte order
typedef enum {
- LITTLE_ENDIAN = 0,
- BIG_ENDIAN,
+ BIG_ENDIAN = 0,
+ LITTLE_ENDIAN,
} ByteOrder;
// A Signal Format defines how a DBC signal is encoded in a CAN frame.
@@ -24,7 +24,7 @@ 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
+ ByteOrder order; // big-endian/little-endian
bool isSigned;
} SigFmt;