aboutsummaryrefslogtreecommitdiffstats
path: root/os/various/evtimer.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/various/evtimer.c')
-rw-r--r--os/various/evtimer.c59
1 files changed, 40 insertions, 19 deletions
diff --git a/os/various/evtimer.c b/os/various/evtimer.c
index a077529da..38c8cb872 100644
--- a/os/various/evtimer.c
+++ b/os/various/evtimer.c
@@ -25,40 +25,61 @@
#include "ch.h"
#include "evtimer.h"
+/*===========================================================================*/
+/* Module local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Module local functions. */
+/*===========================================================================*/
+
static void tmrcb(void *p) {
- EvTimer *etp = p;
+ event_timer_t *etp = p;
- chSysLockFromIsr();
+ chSysLockFromISR();
chEvtBroadcastI(&etp->et_es);
- chVTSetI(&etp->et_vt, etp->et_interval, tmrcb, etp);
- chSysUnlockFromIsr();
+ chVTDoSetI(&etp->et_vt, etp->et_interval, tmrcb, etp);
+ chSysUnlockFromISR();
}
+/*===========================================================================*/
+/* Module exported functions. */
+/*===========================================================================*/
+
/**
- * @brief Starts the timer
- * @details If the timer was already running then the function has no effect.
+ * @brief Initializes an @p event_timer_t structure.
*
- * @param etp pointer to an initialized @p EvTimer structure.
+ * @param[out] etp the @p event_timer_t structure to be initialized
+ * @param[in] time the interval in system ticks
*/
-void evtStart(EvTimer *etp) {
-
- chSysLock();
+void evtObjectInit(event_timer_t *etp, systime_t time) {
- if (!chVTIsArmedI(&etp->et_vt))
- chVTSetI(&etp->et_vt, etp->et_interval, tmrcb, etp);
-
- chSysUnlock();
+ chEvtObjectInit(&etp->et_es);
+ chVTObjectInit(&etp->et_vt);
+ etp->et_interval = time;
}
/**
- * @brief Stops the timer.
- * @details If the timer was already stopped then the function has no effect.
+ * @brief Starts the timer
+ * @details If the timer was already running then the function has no effect.
*
- * @param etp pointer to an initialized @p EvTimer structure.
+ * @param[in] etp pointer to an initialized @p event_timer_t structure.
*/
-void evtStop(EvTimer *etp) {
+void evtStart(event_timer_t *etp) {
- chVTReset(&etp->et_vt);
+ chVTSet(&etp->et_vt, etp->et_interval, tmrcb, etp);
}
/** @} */