2009-08-16 13:07:24 +00:00
|
|
|
/*
|
2013-05-11 06:08:17 +00:00
|
|
|
ChibiOS/RT - Copyright (C) 2006-2013 Giovanni Di Sirio
|
2009-08-16 13:07:24 +00:00
|
|
|
|
2013-05-11 06:08:17 +00:00
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
2009-08-16 13:07:24 +00:00
|
|
|
|
2013-05-11 06:08:17 +00:00
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
2009-08-16 13:07:24 +00:00
|
|
|
|
2013-05-11 06:08:17 +00:00
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
2009-08-16 13:07:24 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2011-06-27 15:00:05 +00:00
|
|
|
* @file evtimer.c
|
|
|
|
* @brief Events Generator Timer code.
|
|
|
|
*
|
2009-08-16 13:07:24 +00:00
|
|
|
* @addtogroup event_timer
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
2009-12-08 17:37:49 +00:00
|
|
|
#include "ch.h"
|
2009-08-16 13:07:24 +00:00
|
|
|
#include "evtimer.h"
|
|
|
|
|
|
|
|
static void tmrcb(void *p) {
|
|
|
|
EvTimer *etp = p;
|
|
|
|
|
2012-02-08 17:53:52 +00:00
|
|
|
chSysLockFromIsr();
|
2009-08-16 13:07:24 +00:00
|
|
|
chEvtBroadcastI(&etp->et_es);
|
|
|
|
chVTSetI(&etp->et_vt, etp->et_interval, tmrcb, etp);
|
2012-02-08 17:53:52 +00:00
|
|
|
chSysUnlockFromIsr();
|
2009-08-16 13:07:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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.
|
|
|
|
*/
|
|
|
|
void evtStart(EvTimer *etp) {
|
|
|
|
|
|
|
|
chSysLock();
|
|
|
|
|
|
|
|
if (!chVTIsArmedI(&etp->et_vt))
|
|
|
|
chVTSetI(&etp->et_vt, etp->et_interval, tmrcb, etp);
|
|
|
|
|
|
|
|
chSysUnlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Stops the timer.
|
|
|
|
* @details If the timer was already stopped then the function has no effect.
|
|
|
|
*
|
|
|
|
* @param etp pointer to an initialized @p EvTimer structure.
|
|
|
|
*/
|
|
|
|
void evtStop(EvTimer *etp) {
|
|
|
|
|
2012-02-08 17:53:52 +00:00
|
|
|
chVTReset(&etp->et_vt);
|
2009-08-16 13:07:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** @} */
|