wideband/firmware/can_helper.cpp

21 lines
527 B
C++
Raw Normal View History

2020-09-19 16:50:55 -07:00
#include "can_helper.h"
#include <cstring>
2020-12-12 20:06:21 -08:00
CanTxMessage::CanTxMessage(uint32_t eid, uint8_t dlc, bool isExtended) {
2022-05-07 11:15:11 -07:00
m_frame.IDE = isExtended ? CAN_IDE_EXT : CAN_IDE_STD;
m_frame.EID = eid;
m_frame.RTR = CAN_RTR_DATA;
m_frame.DLC = dlc;
memset(m_frame.data8, 0, sizeof(m_frame.data8));
2020-09-19 16:50:55 -07:00
}
CanTxMessage::~CanTxMessage() {
2022-05-07 11:15:11 -07:00
// 100 ms timeout
canTransmitTimeout(&CAND1, CAN_ANY_MAILBOX, &m_frame, TIME_MS2I(100));
2020-09-19 16:50:55 -07:00
}
uint8_t& CanTxMessage::operator[](size_t index) {
2022-05-07 11:15:11 -07:00
return m_frame.data8[index];
2020-12-08 23:16:47 -08:00
}