MCU
Loading...
Searching...
No Matches
ThermistorInterface.cpp
Go to the documentation of this file.
2
3
4
5
7{
8 _msg_queue = msg_output_queue;
9
10}
11
12
14{
15 FRONT_THERMISTORS_t front_thermistors;
16 //scale by 500 for easy packing
17 front_thermistors.thermistor_motor_fl_ro = HYTECH_thermistor_motor_fl_ro_toS(therm_fl);
18 front_thermistors.thermistor_motor_fr_ro = HYTECH_thermistor_motor_fr_ro_toS(therm_fr);
19
20 enqueue_CAN_front_thermistors<FRONT_THERMISTORS_t>(&front_thermistors, &Pack_FRONT_THERMISTORS_hytech);
21}
22
23template<typename U>
24void ThermistorInterface::enqueue_CAN_front_thermistors(U* structure, uint32_t (* pack_function)(U*, uint8_t*, uint8_t*, uint8_t*))
25{
26 CAN_message_t can_msg;
27 can_msg.id = pack_function(structure, can_msg.buf, &can_msg.len, (uint8_t*) &can_msg.flags.extended);
28 uint8_t buf[sizeof(CAN_message_t)] = {};
29 memmove(buf, &can_msg, sizeof(CAN_message_t));
30 _msg_queue->push_back(buf, sizeof(CAN_message_t));
31}
32
33void ThermistorInterface::tick(const AnalogConversion_s &raw_therm_fl, const AnalogConversion_s &raw_therm_fr)
34
35{
36
37 auto fl_channel = _front_thermistors.get(MCU15_THERM_FL_CHANNEL);
38 auto fr_channel = _front_thermistors.get(MCU15_THERM_FR_CHANNEL);
39
40 therm_fl = fl_channel.convert((uint16_t)raw_therm_fl.raw);
41 therm_fr = fr_channel.convert((uint16_t)raw_therm_fr.raw);
43}
Circular_Buffer< uint8_t,(uint32_t) 128, sizeof(CAN_message_t)> CANBufferType
const int MCU15_THERM_FR_CHANNEL
const int MCU15_THERM_FL_CHANNEL
CANBufferType * _msg_queue
void tick(const AnalogConversion_s &raw_therm_fl, const AnalogConversion_s &raw_therm_fr)
Thermistors< MCU15_NUM_THERMISTORS > _front_thermistors
void enqueue_CAN_front_thermistors(U *structure, uint32_t(*pack_function)(U *, uint8_t *, uint8_t *, uint8_t *))
ThermistorInterface(CANBufferType *msg_output_queue)