Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
timer.h
00001 /* 00002 / _____) _ | | 00003 ( (____ _____ ____ _| |_ _____ ____| |__ 00004 \____ \| ___ | (_ _) ___ |/ ___) _ \ 00005 _____) ) ____| | | || |_| ____( (___| | | | 00006 (______/|_____)_|_|_| \__)_____)\____)_| |_| 00007 (C)2013 Semtech 00008 00009 Description: Timer objects and scheduling management 00010 00011 License: Revised BSD License, see LICENSE.TXT file include in the project 00012 00013 Maintainer: Miguel Luis and Gregory Cristian 00014 */ 00015 #ifndef __TIMER_H__ 00016 #define __TIMER_H__ 00017 00018 #include "mbed.h" 00019 00020 /*! 00021 * \brief Timer object description 00022 */ 00023 typedef struct TimerEvent_s 00024 { 00025 uint32_t value; 00026 void ( *Callback )( void ); 00027 Ticker Timer; 00028 }TimerEvent_t; 00029 00030 /*! 00031 * \brief Timer time variable definition 00032 */ 00033 #ifndef TimerTime_t 00034 typedef uint32_t TimerTime_t; 00035 #endif 00036 00037 /*! 00038 * \brief Inializes the timer used to get current time. 00039 * 00040 * \remark Current time corresponds to the time since system startup 00041 */ 00042 void TimerTimeCounterInit( void ); 00043 00044 /*! 00045 * \brief Initializes the timer object 00046 * 00047 * \remark TimerSetValue function must be called before starting the timer. 00048 * this function initializes timestamp and reload value at 0. 00049 * 00050 * \param [IN] obj Structure containing the timer object parameters 00051 * \param [IN] callback Function callback called at the end of the timeout 00052 */ 00053 void TimerInit( TimerEvent_t *obj, void ( *callback )( void ) ); 00054 00055 /*! 00056 * \brief Starts and adds the timer object to the list of timer events 00057 * 00058 * \param [IN] obj Structure containing the timer object parameters 00059 */ 00060 void TimerStart( TimerEvent_t *obj ); 00061 00062 /*! 00063 * \brief Stops and removes the timer object from the list of timer events 00064 * 00065 * \param [IN] obj Structure containing the timer object parameters 00066 */ 00067 void TimerStop( TimerEvent_t *obj ); 00068 00069 /*! 00070 * \brief Resets the timer object 00071 * 00072 * \param [IN] obj Structure containing the timer object parameters 00073 */ 00074 void TimerReset( TimerEvent_t *obj ); 00075 00076 /*! 00077 * \brief Set timer new timeout value 00078 * 00079 * \param [IN] obj Structure containing the timer object parameters 00080 * \param [IN] value New timer timeout value 00081 */ 00082 void TimerSetValue( TimerEvent_t *obj, uint32_t value ); 00083 00084 /*! 00085 * \brief Read the current time 00086 * 00087 * \retval time returns current time 00088 */ 00089 TimerTime_t TimerGetCurrentTime( void ); 00090 00091 /*! 00092 * \brief Return the Time elapsed since a fix moment in Time 00093 * 00094 * \param [IN] savedTime fix moment in Time 00095 * \retval time returns elapsed time 00096 */ 00097 TimerTime_t TimerGetElapsedTime( TimerTime_t savedTime ); 00098 00099 /*! 00100 * \brief Return the Time elapsed since a fix moment in Time 00101 * 00102 * \param [IN] eventInFuture fix moment in the future 00103 * \retval time returns difference between now and future event 00104 */ 00105 TimerTime_t TimerGetFutureTime( TimerTime_t eventInFuture ); 00106 00107 #endif // __TIMER_H__
Generated on Tue Jul 12 2022 19:00:54 by
