|
ChibiOS/RT
2.5.1 |
00001 /* 00002 ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010, 00003 2011,2012 Giovanni Di Sirio. 00004 00005 This file is part of ChibiOS/RT. 00006 00007 ChibiOS/RT is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation; either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 ChibiOS/RT is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with this program. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 00021 /** 00022 * @file evtimer.c 00023 * @brief Events Generator Timer code. 00024 * 00025 * @addtogroup event_timer 00026 * @{ 00027 */ 00028 00029 #include "ch.h" 00030 #include "evtimer.h" 00031 00032 static void tmrcb(void *p) { 00033 EvTimer *etp = p; 00034 00035 chSysLockFromIsr(); 00036 chEvtBroadcastI(&etp->et_es); 00037 chVTSetI(&etp->et_vt, etp->et_interval, tmrcb, etp); 00038 chSysUnlockFromIsr(); 00039 } 00040 00041 /** 00042 * @brief Starts the timer 00043 * @details If the timer was already running then the function has no effect. 00044 * 00045 * @param etp pointer to an initialized @p EvTimer structure. 00046 */ 00047 void evtStart(EvTimer *etp) { 00048 00049 chSysLock(); 00050 00051 if (!chVTIsArmedI(&etp->et_vt)) 00052 chVTSetI(&etp->et_vt, etp->et_interval, tmrcb, etp); 00053 00054 chSysUnlock(); 00055 } 00056 00057 /** 00058 * @brief Stops the timer. 00059 * @details If the timer was already stopped then the function has no effect. 00060 * 00061 * @param etp pointer to an initialized @p EvTimer structure. 00062 */ 00063 void evtStop(EvTimer *etp) { 00064 00065 chVTReset(&etp->et_vt); 00066 } 00067 00068 /** @} */