Read tire temps from CAN
This commit is contained in:
@ -19,11 +19,13 @@ void Init_Can_0() {
|
||||
Can0.setNumTXBoxes(1); // reserves mailbox 0 for tx only 8 mailboxes are
|
||||
// available (the other 7 mailboxes are for rx)
|
||||
|
||||
// We only have 7 mailboxes, but want to receive 8 messages. This trick should
|
||||
// allow us to receive BCU_APS_BRAKE and BCU_ETC in the same mailbox.
|
||||
Can0.watchFor(CAN_ID_BCU_APS_BRAKE & CAN_ID_BCU_ETC,
|
||||
~(CAN_ID_BCU_APS_BRAKE ^ CAN_ID_BCU_ETC));
|
||||
Can0.watchFor(CAN_ID_BCU_SHIFT_CTRL);
|
||||
// We only have 7 mailboxes, but want to receive 9 messages. This trick should
|
||||
// allow us to receive BCU_APS_BRAKE, BCU_ETC and BCU_SHIFT_CTRL in the same
|
||||
// mailbox. It will also let through 0x506, but that shouldn't be much of an
|
||||
// issue.
|
||||
Can0.watchFor(CAN_ID_BCU_APS_BRAKE & CAN_ID_BCU_ETC & CAN_ID_BCU_SHIFT_CTRL,
|
||||
0x7FC);
|
||||
Can0.watchFor(CAN_ID_BCU_TIRES);
|
||||
Can0.watchFor(CAN_ID_BCU_LAP_TIME);
|
||||
Can0.watchFor(CAN_ID_MS4_IGN_REV_ATH);
|
||||
Can0.watchFor(CAN_ID_MS4_SPEED);
|
||||
@ -92,9 +94,18 @@ void Receive_Can_0(CAN_FRAME *temp_message) {
|
||||
Vehicle_data.gear = (temp_message->data.byte[1]) >> 5;
|
||||
break;
|
||||
}
|
||||
case CAN_ID_BCU_TIRES: { // Tire temps
|
||||
Vehicle_data.t_trl = temp_message->data.byte[1];
|
||||
Vehicle_data.t_trr = temp_message->data.byte[4];
|
||||
Vehicle_data.t_tfl = temp_message->data.byte[5];
|
||||
Vehicle_data.t_tfr = temp_message->data.byte[6];
|
||||
break;
|
||||
}
|
||||
case CAN_ID_BCU_LAP_TIME: { // lap time
|
||||
Vehicle_data.lap_time_sec = temp_message->data.byte[1];
|
||||
Vehicle_data.lap_time_msec = temp_message->data.byte[1];
|
||||
Vehicle_data.lap_time_msec =
|
||||
temp_message->data.byte[2] | ((temp_message->data.byte[3] & 0b11) << 8);
|
||||
break;
|
||||
}
|
||||
case CAN_ID_MS4_IGN_REV_ATH: { // rpm
|
||||
Vehicle_data.revol =
|
||||
|
||||
@ -11,6 +11,7 @@ FT_2018_STW_CAN.h
|
||||
#define CAN_ID_BCU_APS_BRAKE 0x500
|
||||
#define CAN_ID_BCU_ETC 0x502
|
||||
#define CAN_ID_BCU_SHIFT_CTRL 0x504
|
||||
#define CAN_ID_BCU_TIRES 0x562
|
||||
#define CAN_ID_BCU_LAP_TIME 0x570
|
||||
#define CAN_ID_MS4_IGN_REV_ATH 0x773
|
||||
#define CAN_ID_MS4_SPEED 0x775
|
||||
|
||||
Reference in New Issue
Block a user