Skip to content

Commit

Permalink
CAN: more accurate time intervals (mck1117#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
dron0gus authored Jan 31, 2025
1 parent 694df74 commit 0c169da
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion firmware/can.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ void CanTxThread(void*)
{
chRegSetThreadName("CAN Tx");

// Current system time.
systime_t prev = chVTGetSystemTime();

while(1)
{
for (int ch = 0; ch < AFR_CHANNELS; ch++) {
SendCanForChannel(ch);
}

chThdSleepMilliseconds(WBO_TX_PERIOD_MS);
prev = chThdSleepUntilWindowed(prev, chTimeAddX(prev, TIME_MS2I(WBO_TX_PERIOD_MS)));
}
}

Expand Down

0 comments on commit 0c169da

Please sign in to comment.