summaryrefslogtreecommitdiff
path: root/cesar/hal/leon/src
diff options
context:
space:
mode:
authorlaranjeiro2009-05-05 16:22:57 +0000
committerlaranjeiro2009-05-05 16:22:57 +0000
commit480a56ceb7af3698a9853cf5902d0c9ebde60124 (patch)
tree32c6b3e6acfd58f51ae21eb3390c7eb4eb551646 /cesar/hal/leon/src
parent81fb4b53e882b2dc300d50a2356b8899f0fc770d (diff)
hal/leon: (Closes #360)
* On the program function of the leon if the date has already passed it calls directly the callback. git-svn-id: svn+ssh://pessac/svn/cesar/trunk@4592 017c9cb6-072f-447c-8318-d5b54f68fe89
Diffstat (limited to 'cesar/hal/leon/src')
-rw-r--r--cesar/hal/leon/src/timer.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/cesar/hal/leon/src/timer.c b/cesar/hal/leon/src/timer.c
index f6ff0fe7ba..fe30bdb9f3 100644
--- a/cesar/hal/leon/src/timer.c
+++ b/cesar/hal/leon/src/timer.c
@@ -145,15 +145,24 @@ leon_timer_program (leon_timer_t *ctx, u32 date)
dbg_assert (ctx->status == LEON_TIMER_STATUS_STOP);
leon_date = PHY_DATE_TO_LEON_DATE (date - phy_date (ctx->phy));
- dbg_assert (!(leon_date & ~LEON_TIMER_REGISTER_MASK));
-
- /** Reconfigure the timer. */
- *leon_timer_config = LEON_TIMER_CONFIG_DISABLE;
- *leon_timer_reload = leon_date;
- /** reload and enable the timer. */
- *leon_timer_config = LEON_TIMER_CONFIG_LOAD | LEON_TIMER_CONFIG_ENABLE;
-
- ctx->status = LEON_TIMER_STATUS_RUNNING;
+ if (!(leon_date & ~LEON_TIMER_REGISTER_MASK))
+ {
+ /** Reconfigure the timer. */
+ *leon_timer_config = LEON_TIMER_CONFIG_DISABLE;
+ *leon_timer_reload = leon_date;
+ /** reload and enable the timer. */
+ *leon_timer_config = LEON_TIMER_CONFIG_LOAD | LEON_TIMER_CONFIG_ENABLE;
+
+ ctx->status = LEON_TIMER_STATUS_RUNNING;
+ }
+ else
+ {
+ /* Date is already in the past, call directly the callback. */
+ // call back the callback function.
+ dbg_assert (ctx->cb);
+ ctx->status = LEON_TIMER_STATUS_STOP;
+ (ctx->cb) (ctx->user_data);
+ }
}
/**