From c0e43f15bded0184838b1bb6b6eb031f0aae87ad Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Mon, 13 Sep 2021 08:53:39 +0000 Subject: [PATCH] Documented a coding choice. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@14756 27425a3e-05d8-49a3-a47f-9c15f0e5edd8 --- os/rt/src/chvt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/os/rt/src/chvt.c b/os/rt/src/chvt.c index 416cc23a9..d52ed465f 100644 --- a/os/rt/src/chvt.c +++ b/os/rt/src/chvt.c @@ -85,7 +85,11 @@ static void vt_set_alarm(systime_t now, sysinterval_t delay) { port_timer_set_alarm(chTimeAddX(now, delay)); /* Check on current time, we need to detect the error condition where - current time skipped past the calculated deadline.*/ + current time skipped past the calculated deadline. + Note that the "<" condition is intentional, we want to make sure + that the alarm is set before the deadline is reached because the + comparison could happen on the transition depending on the timer + architecture.*/ newnow = chVTGetSystemTimeX(); nowdelta = chTimeDiffX(now, newnow); if (nowdelta < delay) { @@ -101,6 +105,7 @@ static void vt_set_alarm(systime_t now, sysinterval_t delay) { } #if !defined(CH_VT_RFCU_DISABLED) + /* Checking if a skip occurred.*/ if (currdelta > CH_CFG_ST_TIMEDELTA) { chRFCUCollectFaultsI(CH_RFCU_VT_INSUFFICIENT_DELTA); }