fix union

This commit is contained in:
Rémi Heredero 2023-09-04 07:33:33 +02:00
parent 11c95d9fd6
commit 24f63b261b

View File

@ -34,9 +34,7 @@ typedef union {
uint8_t byte2; uint8_t byte2;
uint8_t byte3; uint8_t byte3;
} separate; } separate;
struct { uint32_t full;
uint32_t bytes;
} full;
} CAN_4_BYTES; } CAN_4_BYTES;
void CAN_init(){ void CAN_init(){
@ -55,6 +53,7 @@ bool CAN_processEvent(Event* ev) {
evIDT evid = Event_getId(ev); evIDT evid = Event_getId(ev);
uint64_t data = Event_getData(ev); uint64_t data = Event_getData(ev);
CAN_4_BYTES tmpData;
switch (me->state) { // onState switch (me->state) { // onState
@ -72,8 +71,7 @@ bool CAN_processEvent(Event* ev) {
uint32_t canData = (uint32_t) data; uint32_t canData = (uint32_t) data;
data = data>>32; data = data>>32;
CAN_4_BYTES tmpData; tmpData.full = data;
tmpData.full.bytes = data;
uint8_t idMsg = tmpData.separate.byte0; uint8_t idMsg = tmpData.separate.byte0;
idMsg = idMsg >> 4; idMsg = idMsg >> 4;
idMsg = idMsg & 0xF; idMsg = idMsg & 0xF;