diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-09-20 12:25:11 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2013-09-20 12:25:11 +0000 |
commit | be933e612987ad4d0888b4baca5ba2328b4a2dd6 (patch) | |
tree | 240a5b996da630511ed975ccb43a5d200f03e95a /os/various/evtimer.c | |
parent | b295f4426ccac9cbafe9bd382a34175dffd8992a (diff) | |
download | ChibiOS-be933e612987ad4d0888b4baca5ba2328b4a2dd6.tar.gz ChibiOS-be933e612987ad4d0888b4baca5ba2328b4a2dd6.tar.bz2 ChibiOS-be933e612987ad4d0888b4baca5ba2328b4a2dd6.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6308 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/various/evtimer.c')
-rw-r--r-- | os/various/evtimer.c | 59 |
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);
}
/** @} */
|