diff --git a/lib/interfaces/include/IRTSSensor.h b/lib/interfaces/include/IRTSSensor.h new file mode 100644 index 0000000..1f616fe --- /dev/null +++ b/lib/interfaces/include/IRTSSensor.h @@ -0,0 +1,48 @@ +#ifndef IRTSSENSORINTERFACE_H +#define IRTSSENSORINTERFACE_H + +#include "FlexCAN_T4.h" +#include "SharedFirmwareTypes.h" + +#define UNPACK_AND_POPULATE_TEMP(WHEEL, MSGNUM, CH1, CH2, CH3, CH4) \ + WHEEL##_IRTS_##MSGNUM##_t unpacked_sensor_data; \ + Unpack_##WHEEL##_IRTS_##MSGNUM##_hytech(&unpacked_sensor_data, msg.buf, msg.len); \ + latest_sensor_data.infrared_temp[CH1 - 1] = unpacked_sensor_data.WHEEL##IRTS_T##CH1##_ro; \ + latest_sensor_data.infrared_temp[CH1] = unpacked_sensor_data.WHEEL##IRTS_T##CH2##_ro; \ + latest_sensor_data.infrared_temp[CH1 + 1] = unpacked_sensor_data.WHEEL##IRTS_T##CH3##_ro; \ + latest_sensor_data.infrared_temp[CH1 + 2] = unpacked_sensor_data.WHEEL##IRTS_T##CH4##_ro; \ + +class IRTSSensorInterface +{ + public: + // LF wheel + void receive_IRTS_sensor_temp_lf_ch1_ch4(const CAN_message_t &msg, unsigned long curr_millis); + void receive_IRTS_sensor_temp_lf_ch5_ch8(const CAN_message_t &msg, unsigned long curr_millis); + void receive_IRTS_sensor_temp_lf_ch9_ch12(const CAN_message_t &msg, unsigned long curr_millis); + void receive_IRTS_sensor_temp_lf_ch13_ch16(const CAN_message_t &msg, unsigned long curr_millis); + + // RF wheel + void receive_IRTS_sensor_temp_rf_ch1_ch4(const CAN_message_t &msg, unsigned long curr_millis); + void receive_IRTS_sensor_temp_rf_ch5_ch8(const CAN_message_t &msg, unsigned long curr_millis); + void receive_IRTS_sensor_temp_rf_ch9_ch12(const CAN_message_t &msg, unsigned long curr_millis); + void receive_IRTS_sensor_temp_rf_ch13_ch16(const CAN_message_t &msg, unsigned long curr_millis); + + // LR wheel + void receive_IRTS_sensor_temp_lr_ch1_ch4(const CAN_message_t &msg, unsigned long curr_millis); + void receive_IRTS_sensor_temp_lr_ch5_ch8(const CAN_message_t &msg, unsigned long curr_millis); + void receive_IRTS_sensor_temp_lr_ch9_ch12(const CAN_message_t &msg, unsigned long curr_millis); + void receive_IRTS_sensor_temp_lr_ch13_ch16(const CAN_message_t &msg, unsigned long curr_millis); + + // RR wheel + void receive_IRTS_sensor_temp_rr_ch1_ch4(const CAN_message_t &msg, unsigned long curr_millis); + void receive_IRTS_sensor_temp_rr_ch5_ch8(const CAN_message_t &msg, unsigned long curr_millis); + void receive_IRTS_sensor_temp_rr_ch9_ch12(const CAN_message_t &msg, unsigned long curr_millis); + void receive_IRTS_sensor_temp_rr_ch13_ch16(const CAN_message_t &msg, unsigned long curr_millis); + + IRTSSensorData_s get_latest_sensor_data() const; + + private: + IRTSSensorData_s latest_sensor_data; +}; + +#endif \ No newline at end of file diff --git a/lib/interfaces/src/IRTSSensor.cpp b/lib/interfaces/src/IRTSSensor.cpp new file mode 100644 index 0000000..70b8bd4 --- /dev/null +++ b/lib/interfaces/src/IRTSSensor.cpp @@ -0,0 +1,81 @@ +#include "IRTSSensorInterface.h" +#include "FlexCAN_T4.h" +#include "hytech.h" + +// LF wheel +void IRTSSensorInterface::receive_IRTS_sensor_temp_lf_ch1_ch4(const CAN_message_t &msg, unsigned long curr_millis) +{ + UNPACK_AND_POPULATE_TEMP(FL, 1, 1, 2, 3, 4); +} +void IRTSSensorInterface::receive_IRTS_sensor_temp_lf_ch5_ch8(const CAN_message_t &msg, unsigned long curr_millis) +{ + UNPACK_AND_POPULATE_TEMP(FL, 2, 5, 6, 7, 8); +} +void IRTSSensorInterface::receive_IRTS_sensor_temp_lf_ch9_ch12(const CAN_message_t &msg, unsigned long curr_millis) +{ + UNPACK_AND_POPULATE_TEMP(FL, 3, 9, 10, 11, 12); +} +void IRTSSensorInterface::receive_IRTS_sensor_temp_lf_ch13_ch16(const CAN_message_t &msg, unsigned long curr_millis) +{ + UNPACK_AND_POPULATE_TEMP(FL, 4, 13, 14, 15, 16); +} + +// RF wheel +void IRTSSensorInterface::receive_IRTS_sensor_temp_rf_ch1_ch4(const CAN_message_t &msg, unsigned long curr_millis) +{ + UNPACK_AND_POPULATE_TEMP(RF, 1, 1, 2, 3, 4); +} +void IRTSSensorInterface::receive_IRTS_sensor_temp_rf_ch5_ch8(const CAN_message_t &msg, unsigned long curr_millis) +{ + UNPACK_AND_POPULATE_TEMP(RF, 2, 5, 6, 7, 8); +} +void IRTSSensorInterface::receive_IRTS_sensor_temp_rf_ch9_ch12(const CAN_message_t &msg, unsigned long curr_millis) +{ + UNPACK_AND_POPULATE_TEMP(RF, 3, 9, 10, 11, 12); +} +void IRTSSensorInterface::receive_IRTS_sensor_temp_rf_ch13_ch16(const CAN_message_t &msg, unsigned long curr_millis) +{ + UNPACK_AND_POPULATE_TEMP(RF, 4, 13, 14, 15, 16); +} + + +// LFR wheel +void IRTSSensorInterface::receive_IRTS_sensor_temp_lr_ch1_ch4(const CAN_message_t &msg, unsigned long curr_millis) +{ + UNPACK_AND_POPULATE_TEMP(LR, 1, 1, 2, 3, 4); +} +void IRTSSensorInterface::receive_IRTS_sensor_temp_lr_ch5_ch8(const CAN_message_t &msg, unsigned long curr_millis) +{ + UNPACK_AND_POPULATE_TEMP(LR, 2, 5, 6, 7, 8); +} +void IRTSSensorInterface::receive_IRTS_sensor_temp_lr_ch9_ch12(const CAN_message_t &msg, unsigned long curr_millis) +{ + UNPACK_AND_POPULATE_TEMP(LR, 3, 9, 10, 11, 12); +} +void IRTSSensorInterface::receive_IRTS_sensor_temp_lr_ch13_ch16(const CAN_message_t &msg, unsigned long curr_millis) +{ + UNPACK_AND_POPULATE_TEMP(LR, 4, 13, 14, 15, 16); +} + +// RR wheel +void IRTSSensorInterface::receive_IRTS_sensor_temp_rr_ch1_ch4(const CAN_message_t &msg, unsigned long curr_millis) +{ + UNPACK_AND_POPULATE_TEMP(RR, 1, 1, 2, 3, 4); +} +void IRTSSensorInterface::receive_IRTS_sensor_temp_rr_ch5_ch8(const CAN_message_t &msg, unsigned long curr_millis) +{ + UNPACK_AND_POPULATE_TEMP(RR, 2, 5, 6, 7, 8); +} +void IRTSSensorInterface::receive_IRTS_sensor_temp_rr_ch9_ch12(const CAN_message_t &msg, unsigned long curr_millis) +{ + UNPACK_AND_POPULATE_TEMP(RR, 3, 9, 10, 11, 12); +} +void IRTSSensorInterface::receive_IRTS_sensor_temp_rr_ch13_ch16(const CAN_message_t &msg, unsigned long curr_millis) +{ + UNPACK_AND_POPULATE_TEMP(RR, 4, 13, 14, 15, 16); +} + +IRTSSensorData_s IRTSSensorInterface::get_latest_sensor_data() const +{ + return latest_sensor_data; +} \ No newline at end of file