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.
Dependents: BLE_Thermometer MAXWSNENV_demo
wsf_timer.h
00001 /*************************************************************************************************/ 00002 /*! 00003 * \file wsf_timer.h 00004 * 00005 * \brief Timer service. 00006 * 00007 * $Date: 2013-07-19 17:17:05 -0700 (Fri, 19 Jul 2013) $ 00008 * $Revision: 843 $ 00009 * 00010 * Copyright (c) 2009-2016 ARM Limited. All rights reserved. 00011 * 00012 * SPDX-License-Identifier: LicenseRef-PBL 00013 * 00014 * Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use 00015 * this file except in compliance with the License. You may obtain a copy of the License at 00016 * 00017 * https://www.mbed.com/licenses/PBL-1.0 00018 * 00019 * See the License for the specific language governing permissions and limitations under the License. 00020 */ 00021 /*************************************************************************************************/ 00022 #ifndef WSF_TIMER_H 00023 #define WSF_TIMER_H 00024 00025 #include "wsf_os.h" 00026 00027 #ifdef __cplusplus 00028 extern "C" { 00029 #endif 00030 00031 /************************************************************************************************** 00032 Macros 00033 **************************************************************************************************/ 00034 00035 /************************************************************************************************** 00036 Data Types 00037 **************************************************************************************************/ 00038 00039 /*! Timer ticks data type */ 00040 typedef uint16_t wsfTimerTicks_t ; 00041 00042 /*! Timer structure */ 00043 typedef struct wsfTimer_tag 00044 { 00045 struct wsfTimer_tag *pNext; /*! pointer to next timer in queue */ 00046 wsfTimerTicks_t ticks ; /*! number of ticks until expiration */ 00047 wsfHandlerId_t handlerId ; /*! event handler for this timer */ 00048 bool_t isStarted ; /*! TRUE if timer has been started */ 00049 wsfMsgHdr_t msg ; /*! application-defined timer event parameters */ 00050 } wsfTimer_t ; 00051 00052 00053 /************************************************************************************************** 00054 Function Declarations 00055 **************************************************************************************************/ 00056 00057 /*************************************************************************************************/ 00058 /*! 00059 * \fn WsfTimerInit 00060 * 00061 * \brief Initialize the timer service. This function should only be called once 00062 * upon system initialization. 00063 * 00064 * \param msPerTick Sets the number of milliseconds per timer tick. 00065 * 00066 * \return None. 00067 */ 00068 /*************************************************************************************************/ 00069 void WsfTimerInit(uint8_t msPerTick); 00070 00071 /*************************************************************************************************/ 00072 /*! 00073 * \fn WsfTimerStartSec 00074 * 00075 * \brief Start a timer in units of seconds. Before this function is called parameter 00076 * pTimer->handlerId must be set to the event handler for this timer and parameter 00077 * pTimer->msg must be set to any application-defined timer event parameters. 00078 * 00079 * \param pTimer Pointer to timer. 00080 * \param sec Seconds until expiration. 00081 * 00082 * \return None. 00083 */ 00084 /*************************************************************************************************/ 00085 void WsfTimerStartSec(wsfTimer_t *pTimer, wsfTimerTicks_t sec); 00086 00087 /*************************************************************************************************/ 00088 /*! 00089 * \fn WsfTimerStartMs 00090 * 00091 * \brief Start a timer in units of milliseconds. 00092 * 00093 * \param pTimer Pointer to timer. 00094 * \param ms Milliseconds until expiration. 00095 * 00096 * \return None. 00097 */ 00098 /*************************************************************************************************/ 00099 void WsfTimerStartMs(wsfTimer_t *pTimer, wsfTimerTicks_t ms); 00100 00101 /*************************************************************************************************/ 00102 /*! 00103 * \fn WsfTimerStop 00104 * 00105 * \brief Stop a timer. 00106 * 00107 * \param pTimer Pointer to timer. 00108 * 00109 * \return None. 00110 */ 00111 /*************************************************************************************************/ 00112 void WsfTimerStop(wsfTimer_t *pTimer); 00113 00114 /*************************************************************************************************/ 00115 /*! 00116 * \fn WsfTimerUpdate 00117 * 00118 * \brief Update the timer service with the number of elapsed ticks. This function is 00119 * typically called only from timer porting code. 00120 * 00121 * \param ticks Number of ticks since last update. 00122 * 00123 * \return None. 00124 */ 00125 /*************************************************************************************************/ 00126 void WsfTimerUpdate(wsfTimerTicks_t ticks ); 00127 00128 /*************************************************************************************************/ 00129 /*! 00130 * \fn WsfTimerNextExpiration 00131 * 00132 * \brief Return the number of ticks until the next timer expiration. Note that this 00133 * function can return zero even if a timer is running, indicating the timer 00134 * has expired but has not yet been serviced. 00135 * 00136 * \param pTimerRunning Returns TRUE if a timer is running, FALSE if no timers running. 00137 * 00138 * \return The number of ticks until the next timer expiration. 00139 */ 00140 /*************************************************************************************************/ 00141 wsfTimerTicks_t WsfTimerNextExpiration(bool_t *pTimerRunning); 00142 00143 /*************************************************************************************************/ 00144 /*! 00145 * \fn WsfTimerServiceExpired 00146 * 00147 * \brief Service expired timers for the given task. This function is typically called only 00148 * WSF OS porting code. 00149 * 00150 * \param taskId OS Task ID of task servicing timers. 00151 * 00152 * \return Pointer to next expired timer or NULL if there are no expired timers. 00153 */ 00154 /*************************************************************************************************/ 00155 wsfTimer_t *WsfTimerServiceExpired(wsfTaskId_t taskId); 00156 00157 #ifdef __cplusplus 00158 }; 00159 #endif 00160 00161 #endif /* WSF_TIMER_H */
Generated on Tue Jul 12 2022 19:59:22 by
1.7.2