aboutsummaryrefslogtreecommitdiffstats
path: root/os/rt/src/chvt.c
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2017-10-12 13:31:42 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2017-10-12 13:31:42 +0000
commit4d0b8bdf6e8c27242b38f69c0831eb2a0ddb689f (patch)
tree7288ed8f896b3b7852e736657e5edbcb7da81cae /os/rt/src/chvt.c
parentd8b32d7f63c8453135249734f8b542856947e83a (diff)
downloadChibiOS-4d0b8bdf6e8c27242b38f69c0831eb2a0ddb689f.tar.gz
ChibiOS-4d0b8bdf6e8c27242b38f69c0831eb2a0ddb689f.tar.bz2
ChibiOS-4d0b8bdf6e8c27242b38f69c0831eb2a0ddb689f.zip
Added support for "large virtual timers", those allows for intervals greater than the system time capability. To be tested.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/rt5_dev_point1@10814 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/rt/src/chvt.c')
-rw-r--r--os/rt/src/chvt.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/os/rt/src/chvt.c b/os/rt/src/chvt.c
index 4d887b8c4..f627436b4 100644
--- a/os/rt/src/chvt.c
+++ b/os/rt/src/chvt.c
@@ -146,9 +146,18 @@ void chVTDoSetI(virtual_timer_t *vtp, sysinterval_t delay,
p = p->next;
}
else if (delta < p->delta) {
- /* A small delay that will become the first element in the delta list
- and next deadline.*/
- port_timer_set_alarm(chTimeAddX(ch.vtlist.lasttime, delta));
+ sysinterval_t deadline_delta;
+
+ /* A small delay that will become the first element in the delta list
+ and next deadline.*/
+ deadline_delta = delta;
+#if CH_CFG_INTERVALS_SIZE > CH_CFG_ST_RESOLUTION
+ /* The delta could be too large for the physical timer to handle.*/
+ if (deadline_delta > (sysinterval_t)TIME_MAX_SYSTIME) {
+ deadline_delta = (sysinterval_t)TIME_MAX_SYSTIME;
+ }
+#endif
+ port_timer_set_alarm(chTimeAddX(ch.vtlist.lasttime, deadline_delta));
}
}
#else /* CH_CFG_ST_TIMEDELTA == 0 */
@@ -207,7 +216,7 @@ void chVTDoResetI(virtual_timer_t *vtp) {
is the last of the list, restoring it.*/
ch.vtlist.delta = (sysinterval_t)-1;
#else /* CH_CFG_ST_TIMEDELTA > 0 */
- sysinterval_t nowdelta, delta;
+ sysinterval_t nowdelta, delta, deadline_delta;
/* If the timer is not the first of the list then it is simply unlinked
else the operation is more complex.*/
@@ -263,7 +272,15 @@ void chVTDoResetI(virtual_timer_t *vtp) {
delta = (systime_t)CH_CFG_ST_TIMEDELTA;
}
- port_timer_set_alarm(chTimeAddX(ch.vtlist.lasttime, nowdelta + delta));
+ /* Next deadline.*/
+ deadline_delta = nowdelta + delta;
+#if CH_CFG_INTERVALS_SIZE > CH_CFG_ST_RESOLUTION
+ /* The delta could be too large for the physical timer to handle.*/
+ if (deadline_delta > (sysinterval_t)TIME_MAX_SYSTIME) {
+ deadline_delta = (sysinterval_t)TIME_MAX_SYSTIME;
+ }
+#endif
+ port_timer_set_alarm(chTimeAddX(ch.vtlist.lasttime, deadline_delta));
#endif /* CH_CFG_ST_TIMEDELTA > 0 */
}