CanTxMessage::setShortValueMsb

This commit is contained in:
rusefillc 2024-02-26 18:02:46 -05:00
parent fe684febdf
commit cfbcedfe2a
2 changed files with 9 additions and 0 deletions

View File

@ -119,6 +119,12 @@ void CanTxMessage::setShortValue(uint16_t value, size_t offset) {
m_frame.data8[offset + 1] = value >> 8;
}
// MOTOROLA order, MSB (Most Significant Byte/Big Endian) comes first.
void CanTxMessage::setShortValueMsb(uint16_t value, size_t offset) {
m_frame.data8[offset] = value >> 8;
m_frame.data8[offset + 1] = value & 0xFF;
}
void CanTxMessage::setBit(size_t byteIdx, size_t bitIdx) {
m_frame.data8[byteIdx] |= 1 << bitIdx;
}

View File

@ -57,6 +57,9 @@ public:
*/
void setShortValue(uint16_t value, size_t offset);
// Same as above but big endian
void setShortValueMsb(uint16_t value, size_t offset);
/**
* @brief Set a single bit in the transmit buffer. Useful for single-bit flags.
*/