diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-10-26 10:45:42 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2008-10-26 10:45:42 +0000 |
commit | 3c4cadc596f201c3377de40a62685b3b9d7b9de1 (patch) | |
tree | 1b02fbfeb8823d24ad53a6860a070fd5e0a70bce /src/chvt.c | |
parent | 79280551050445d86045df9e160af2f9c85b40a3 (diff) | |
download | ChibiOS-3c4cadc596f201c3377de40a62685b3b9d7b9de1.tar.gz ChibiOS-3c4cadc596f201c3377de40a62685b3b9d7b9de1.tar.bz2 ChibiOS-3c4cadc596f201c3377de40a62685b3b9d7b9de1.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@484 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src/chvt.c')
-rw-r--r-- | src/chvt.c | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/src/chvt.c b/src/chvt.c index 77978e16c..03847c44e 100644 --- a/src/chvt.c +++ b/src/chvt.c @@ -40,36 +40,32 @@ void chVTInit(void) { /**
* Enables a virtual timer.
* @param vtp the \p VirtualTimer structure pointer
- * @param time the number of time ticks, the value zero is allowed with
- * meaning "infinite". In this case the structure is initialized
- * but not inserted in the delta list, the timer will never be
- * triggered.
+ * @param time the number of time ticks, the value zero is not allowed
* @param vtfunc the timer callback function. After invoking the callback
* the timer is disabled and the structure can be disposed or
* reused.
* @param par a parameter that will be passed to the callback function
* @note Must be called with the interrupts disabled.
- * @note The associated function is invoked by an interrupt handler.
+ * @note The associated function is invoked from an interrupt handler.
*/
void chVTSetI(VirtualTimer *vtp, systime_t time, vtfunc_t vtfunc, void *par) {
+ VirtualTimer *p;
+
+ chDbgAssert(time != 0, "chvt.c, chVTSetI()");
vtp->vt_par = par;
vtp->vt_func = vtfunc;
- if (time) {
- VirtualTimer *p = vtlist.vt_next;
- while (p->vt_time < time) {
- time -= p->vt_time;
- p = p->vt_next;
- }
-
- vtp->vt_prev = (vtp->vt_next = p)->vt_prev;
- vtp->vt_prev->vt_next = p->vt_prev = vtp;
- vtp->vt_time = time;
- if (p != (void *)&vtlist)
- p->vt_time -= time;
+ p = vtlist.vt_next;
+ while (p->vt_time < time) {
+ time -= p->vt_time;
+ p = p->vt_next;
}
- else
- vtp->vt_next = vtp->vt_prev = vtp; // Allows a chVTResetI() on the fake timer.
+
+ vtp->vt_prev = (vtp->vt_next = p)->vt_prev;
+ vtp->vt_prev->vt_next = p->vt_prev = vtp;
+ vtp->vt_time = time;
+ if (p != (void *)&vtlist)
+ p->vt_time -= time;
}
/**
|