2009-08-16 13:07:24 +00:00
|
|
|
/*
|
2014-07-26 09:06:28 +00:00
|
|
|
ChibiOS - Copyright (C) 2006-2014 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.h
|
|
|
|
* @brief Events Generator Timer structures and macros.
|
|
|
|
*
|
2009-08-16 13:07:24 +00:00
|
|
|
* @addtogroup event_timer
|
|
|
|
* @{
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _EVTIMER_H_
|
|
|
|
#define _EVTIMER_H_
|
|
|
|
|
2013-09-20 12:25:11 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Module constants. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Module pre-compile time settings. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Derived constants and error checks. */
|
|
|
|
/*===========================================================================*/
|
2012-04-09 14:51:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Module dependencies check.
|
|
|
|
*/
|
2013-09-20 12:25:11 +00:00
|
|
|
#if !CH_CFG_USE_EVENTS
|
|
|
|
#error "Event Timers require CH_CFG_USE_EVENTS"
|
2012-04-09 14:51:29 +00:00
|
|
|
#endif
|
|
|
|
|
2013-09-20 12:25:11 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Module data structures and types. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2009-08-16 13:07:24 +00:00
|
|
|
/**
|
2013-09-20 12:25:11 +00:00
|
|
|
* @brief Type of a event timer structure.
|
2009-08-16 13:07:24 +00:00
|
|
|
*/
|
|
|
|
typedef struct {
|
2013-09-20 12:25:11 +00:00
|
|
|
virtual_timer_t et_vt;
|
|
|
|
event_source_t et_es;
|
|
|
|
systime_t et_interval;
|
|
|
|
} event_timer_t;
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* Module macros. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
|
|
|
/*===========================================================================*/
|
|
|
|
/* External declarations. */
|
|
|
|
/*===========================================================================*/
|
2009-08-16 13:07:24 +00:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2013-09-20 12:25:11 +00:00
|
|
|
void evtObjectInit(event_timer_t *etp, systime_t time);
|
|
|
|
void evtStart(event_timer_t *etp);
|
2009-08-16 13:07:24 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-09-20 12:25:11 +00:00
|
|
|
/*===========================================================================*/
|
|
|
|
/* Module inline functions. */
|
|
|
|
/*===========================================================================*/
|
|
|
|
|
2009-08-16 13:07:24 +00:00
|
|
|
/**
|
2013-09-20 12:25:11 +00:00
|
|
|
* @brief Stops the timer.
|
|
|
|
* @details If the timer was already stopped then the function has no effect.
|
2009-08-16 13:07:24 +00:00
|
|
|
*
|
2013-09-20 12:25:11 +00:00
|
|
|
* @param[in] etp pointer to an initialized @p event_timer_t structure.
|
2009-08-16 13:07:24 +00:00
|
|
|
*/
|
2013-09-20 12:25:11 +00:00
|
|
|
static inline void vevtStop(event_timer_t *etp) {
|
|
|
|
|
|
|
|
chVTReset(&etp->et_vt);
|
2009-08-16 13:07:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* _EVTIMER_H_ */
|
|
|
|
|
|
|
|
/** @} */
|