[hal] Expose CAN timestamp base clock (#5357)

This commit is contained in:
Ryan Blue
2023-06-07 12:54:03 -04:00
committed by GitHub
parent 91cbcea841
commit 1c00a52b67
9 changed files with 81 additions and 28 deletions

View File

@@ -10,8 +10,11 @@
namespace frc {
struct CANData {
/** Contents of the CAN packet. */
uint8_t data[8];
/** Length of packet in bytes. */
int32_t length;
/** CAN frame timestamp in milliseconds. */
uint64_t timestamp;
};
@@ -158,6 +161,15 @@ class CAN {
*/
bool ReadPacketTimeout(int apiId, int timeoutMs, CANData* data);
/**
* Reads the current value of the millisecond-resolution timer that CANData
* timestamps are based on
*
* @return Current value of timer used as a base time for CANData timestamps
* in milliseconds
*/
static uint64_t GetTimestampBaseTime();
static constexpr HAL_CANManufacturer kTeamManufacturer = HAL_CAN_Man_kTeamUse;
static constexpr HAL_CANDeviceType kTeamDeviceType =
HAL_CAN_Dev_kMiscellaneous;