Added RFCU support in virtual timers.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14444 27425a3e-05d8-49a3-a47f-9c15f0e5edd8
This commit is contained in:
Giovanni Di Sirio 2021-05-30 10:32:27 +00:00
parent 9504545dfe
commit 28df00609a
1 changed files with 34 additions and 4 deletions

View File

@ -470,10 +470,27 @@ void chVTDoTickI(void) {
now = chVTGetSystemTimeX();
nowdelta = chTimeDiffX(lasttime, now);
#if !defined(CH_VT_RFCU_DISABLED)
/* Checking if the required reload is feasible.*/
if (nowdelta > vtp->reload) {
/* System time is already past the deadline, logging the fault and
proceeding with a minimum delay.*/
chDbgAssert(false, "skipped deadline");
chRFCUCollectFaultsI(CH_RFCU_VT_SKIPPED_DEADLINE);
delay = (sysinterval_t)0;
}
else {
/* Enqueuing the timer again using the calculated delta.*/
delay = vtp->reload - nowdelta;
}
#else
chDbgAssert(nowdelta <= vtp->reload, "skipped deadline");
/* Enqueuing the timer again using the calculated delta.*/
delay = vtp->reload - nowdelta;
#endif
/* Special case where the timers list is empty.*/
if (ch_dlist_isempty(&vtlp->dlist)) {
@ -516,11 +533,24 @@ void chVTDoTickI(void) {
#endif
/* Update alarm time to next timer.*/
port_timer_set_alarm(chTimeAddX(now, delta));
{
sysinterval_t next_alarm = chTimeAddX(now, delta);
port_timer_set_alarm(next_alarm);
#if !defined(CH_VT_RFCU_DISABLED)
if (chTimeDiffX(vtlp->lasttime, chVTGetSystemTimeX()) >
chTimeDiffX(vtlp->lasttime, next_alarm)) {
chDbgAssert(false, "insufficient delta");
chRFCUCollectFaultsI(CH_RFCU_VT_INSUFFICIENT_DELTA);
}
#else
chDbgAssert(chTimeDiffX(vtlp->lasttime, chVTGetSystemTimeX()) <=
chTimeDiffX(vtlp->lasttime, chTimeAddX(now, delta)),
chTimeDiffX(vtlp->lasttime, next_alarm),
"insufficient delta");
#endif
}
#endif /* CH_CFG_ST_TIMEDELTA > 0 */
}