Caching the advertising data and the scan response.
Fork of MaximBLE by
exactLE/wsf/include/wsf_timer.h@1:4e764337d5c5, 2016-03-22 (annotated)
- Committer:
- kgills
- Date:
- Tue Mar 22 18:16:10 2016 +0000
- Revision:
- 1:4e764337d5c5
- Parent:
- 0:b562096246b3
Caching the advertising data and scan response.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
enginerd | 0:b562096246b3 | 1 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 2 | /*! |
enginerd | 0:b562096246b3 | 3 | * \file wsf_timer.h |
enginerd | 0:b562096246b3 | 4 | * |
enginerd | 0:b562096246b3 | 5 | * \brief Timer service. |
enginerd | 0:b562096246b3 | 6 | * |
enginerd | 0:b562096246b3 | 7 | * $Date: 2013-07-19 17:17:05 -0700 (Fri, 19 Jul 2013) $ |
enginerd | 0:b562096246b3 | 8 | * $Revision: 843 $ |
enginerd | 0:b562096246b3 | 9 | * |
enginerd | 0:b562096246b3 | 10 | * Copyright (c) 2009-2016 ARM Limited. All rights reserved. |
enginerd | 0:b562096246b3 | 11 | * |
enginerd | 0:b562096246b3 | 12 | * SPDX-License-Identifier: LicenseRef-PBL |
enginerd | 0:b562096246b3 | 13 | * |
enginerd | 0:b562096246b3 | 14 | * Licensed under the Permissive Binary License, Version 1.0 (the "License"); you may not use |
enginerd | 0:b562096246b3 | 15 | * this file except in compliance with the License. You may obtain a copy of the License at |
enginerd | 0:b562096246b3 | 16 | * |
enginerd | 0:b562096246b3 | 17 | * https://www.mbed.com/licenses/PBL-1.0 |
enginerd | 0:b562096246b3 | 18 | * |
enginerd | 0:b562096246b3 | 19 | * See the License for the specific language governing permissions and limitations under the License. |
enginerd | 0:b562096246b3 | 20 | */ |
enginerd | 0:b562096246b3 | 21 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 22 | #ifndef WSF_TIMER_H |
enginerd | 0:b562096246b3 | 23 | #define WSF_TIMER_H |
enginerd | 0:b562096246b3 | 24 | |
enginerd | 0:b562096246b3 | 25 | #include "wsf_os.h" |
enginerd | 0:b562096246b3 | 26 | |
enginerd | 0:b562096246b3 | 27 | #ifdef __cplusplus |
enginerd | 0:b562096246b3 | 28 | extern "C" { |
enginerd | 0:b562096246b3 | 29 | #endif |
enginerd | 0:b562096246b3 | 30 | |
enginerd | 0:b562096246b3 | 31 | /************************************************************************************************** |
enginerd | 0:b562096246b3 | 32 | Macros |
enginerd | 0:b562096246b3 | 33 | **************************************************************************************************/ |
enginerd | 0:b562096246b3 | 34 | |
enginerd | 0:b562096246b3 | 35 | /************************************************************************************************** |
enginerd | 0:b562096246b3 | 36 | Data Types |
enginerd | 0:b562096246b3 | 37 | **************************************************************************************************/ |
enginerd | 0:b562096246b3 | 38 | |
enginerd | 0:b562096246b3 | 39 | /*! Timer ticks data type */ |
enginerd | 0:b562096246b3 | 40 | typedef uint16_t wsfTimerTicks_t; |
enginerd | 0:b562096246b3 | 41 | |
enginerd | 0:b562096246b3 | 42 | /*! Timer structure */ |
enginerd | 0:b562096246b3 | 43 | typedef struct wsfTimer_tag |
enginerd | 0:b562096246b3 | 44 | { |
enginerd | 0:b562096246b3 | 45 | struct wsfTimer_tag *pNext; /*! pointer to next timer in queue */ |
enginerd | 0:b562096246b3 | 46 | wsfTimerTicks_t ticks; /*! number of ticks until expiration */ |
enginerd | 0:b562096246b3 | 47 | wsfHandlerId_t handlerId; /*! event handler for this timer */ |
enginerd | 0:b562096246b3 | 48 | bool_t isStarted; /*! TRUE if timer has been started */ |
enginerd | 0:b562096246b3 | 49 | wsfMsgHdr_t msg; /*! application-defined timer event parameters */ |
enginerd | 0:b562096246b3 | 50 | } wsfTimer_t; |
enginerd | 0:b562096246b3 | 51 | |
enginerd | 0:b562096246b3 | 52 | |
enginerd | 0:b562096246b3 | 53 | /************************************************************************************************** |
enginerd | 0:b562096246b3 | 54 | Function Declarations |
enginerd | 0:b562096246b3 | 55 | **************************************************************************************************/ |
enginerd | 0:b562096246b3 | 56 | |
enginerd | 0:b562096246b3 | 57 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 58 | /*! |
enginerd | 0:b562096246b3 | 59 | * \fn WsfTimerInit |
enginerd | 0:b562096246b3 | 60 | * |
enginerd | 0:b562096246b3 | 61 | * \brief Initialize the timer service. This function should only be called once |
enginerd | 0:b562096246b3 | 62 | * upon system initialization. |
enginerd | 0:b562096246b3 | 63 | * |
enginerd | 0:b562096246b3 | 64 | * \param msPerTick Sets the number of milliseconds per timer tick. |
enginerd | 0:b562096246b3 | 65 | * |
enginerd | 0:b562096246b3 | 66 | * \return None. |
enginerd | 0:b562096246b3 | 67 | */ |
enginerd | 0:b562096246b3 | 68 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 69 | void WsfTimerInit(uint8_t msPerTick); |
enginerd | 0:b562096246b3 | 70 | |
enginerd | 0:b562096246b3 | 71 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 72 | /*! |
enginerd | 0:b562096246b3 | 73 | * \fn WsfTimerStartSec |
enginerd | 0:b562096246b3 | 74 | * |
enginerd | 0:b562096246b3 | 75 | * \brief Start a timer in units of seconds. Before this function is called parameter |
enginerd | 0:b562096246b3 | 76 | * pTimer->handlerId must be set to the event handler for this timer and parameter |
enginerd | 0:b562096246b3 | 77 | * pTimer->msg must be set to any application-defined timer event parameters. |
enginerd | 0:b562096246b3 | 78 | * |
enginerd | 0:b562096246b3 | 79 | * \param pTimer Pointer to timer. |
enginerd | 0:b562096246b3 | 80 | * \param sec Seconds until expiration. |
enginerd | 0:b562096246b3 | 81 | * |
enginerd | 0:b562096246b3 | 82 | * \return None. |
enginerd | 0:b562096246b3 | 83 | */ |
enginerd | 0:b562096246b3 | 84 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 85 | void WsfTimerStartSec(wsfTimer_t *pTimer, wsfTimerTicks_t sec); |
enginerd | 0:b562096246b3 | 86 | |
enginerd | 0:b562096246b3 | 87 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 88 | /*! |
enginerd | 0:b562096246b3 | 89 | * \fn WsfTimerStartMs |
enginerd | 0:b562096246b3 | 90 | * |
enginerd | 0:b562096246b3 | 91 | * \brief Start a timer in units of milliseconds. |
enginerd | 0:b562096246b3 | 92 | * |
enginerd | 0:b562096246b3 | 93 | * \param pTimer Pointer to timer. |
enginerd | 0:b562096246b3 | 94 | * \param ms Milliseconds until expiration. |
enginerd | 0:b562096246b3 | 95 | * |
enginerd | 0:b562096246b3 | 96 | * \return None. |
enginerd | 0:b562096246b3 | 97 | */ |
enginerd | 0:b562096246b3 | 98 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 99 | void WsfTimerStartMs(wsfTimer_t *pTimer, wsfTimerTicks_t ms); |
enginerd | 0:b562096246b3 | 100 | |
enginerd | 0:b562096246b3 | 101 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 102 | /*! |
enginerd | 0:b562096246b3 | 103 | * \fn WsfTimerStop |
enginerd | 0:b562096246b3 | 104 | * |
enginerd | 0:b562096246b3 | 105 | * \brief Stop a timer. |
enginerd | 0:b562096246b3 | 106 | * |
enginerd | 0:b562096246b3 | 107 | * \param pTimer Pointer to timer. |
enginerd | 0:b562096246b3 | 108 | * |
enginerd | 0:b562096246b3 | 109 | * \return None. |
enginerd | 0:b562096246b3 | 110 | */ |
enginerd | 0:b562096246b3 | 111 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 112 | void WsfTimerStop(wsfTimer_t *pTimer); |
enginerd | 0:b562096246b3 | 113 | |
enginerd | 0:b562096246b3 | 114 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 115 | /*! |
enginerd | 0:b562096246b3 | 116 | * \fn WsfTimerUpdate |
enginerd | 0:b562096246b3 | 117 | * |
enginerd | 0:b562096246b3 | 118 | * \brief Update the timer service with the number of elapsed ticks. This function is |
enginerd | 0:b562096246b3 | 119 | * typically called only from timer porting code. |
enginerd | 0:b562096246b3 | 120 | * |
enginerd | 0:b562096246b3 | 121 | * \param ticks Number of ticks since last update. |
enginerd | 0:b562096246b3 | 122 | * |
enginerd | 0:b562096246b3 | 123 | * \return None. |
enginerd | 0:b562096246b3 | 124 | */ |
enginerd | 0:b562096246b3 | 125 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 126 | void WsfTimerUpdate(wsfTimerTicks_t ticks); |
enginerd | 0:b562096246b3 | 127 | |
enginerd | 0:b562096246b3 | 128 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 129 | /*! |
enginerd | 0:b562096246b3 | 130 | * \fn WsfTimerNextExpiration |
enginerd | 0:b562096246b3 | 131 | * |
enginerd | 0:b562096246b3 | 132 | * \brief Return the number of ticks until the next timer expiration. Note that this |
enginerd | 0:b562096246b3 | 133 | * function can return zero even if a timer is running, indicating the timer |
enginerd | 0:b562096246b3 | 134 | * has expired but has not yet been serviced. |
enginerd | 0:b562096246b3 | 135 | * |
enginerd | 0:b562096246b3 | 136 | * \param pTimerRunning Returns TRUE if a timer is running, FALSE if no timers running. |
enginerd | 0:b562096246b3 | 137 | * |
enginerd | 0:b562096246b3 | 138 | * \return The number of ticks until the next timer expiration. |
enginerd | 0:b562096246b3 | 139 | */ |
enginerd | 0:b562096246b3 | 140 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 141 | wsfTimerTicks_t WsfTimerNextExpiration(bool_t *pTimerRunning); |
enginerd | 0:b562096246b3 | 142 | |
enginerd | 0:b562096246b3 | 143 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 144 | /*! |
enginerd | 0:b562096246b3 | 145 | * \fn WsfTimerServiceExpired |
enginerd | 0:b562096246b3 | 146 | * |
enginerd | 0:b562096246b3 | 147 | * \brief Service expired timers for the given task. This function is typically called only |
enginerd | 0:b562096246b3 | 148 | * WSF OS porting code. |
enginerd | 0:b562096246b3 | 149 | * |
enginerd | 0:b562096246b3 | 150 | * \param taskId OS Task ID of task servicing timers. |
enginerd | 0:b562096246b3 | 151 | * |
enginerd | 0:b562096246b3 | 152 | * \return Pointer to next expired timer or NULL if there are no expired timers. |
enginerd | 0:b562096246b3 | 153 | */ |
enginerd | 0:b562096246b3 | 154 | /*************************************************************************************************/ |
enginerd | 0:b562096246b3 | 155 | wsfTimer_t *WsfTimerServiceExpired(wsfTaskId_t taskId); |
enginerd | 0:b562096246b3 | 156 | |
enginerd | 0:b562096246b3 | 157 | #ifdef __cplusplus |
enginerd | 0:b562096246b3 | 158 | }; |
enginerd | 0:b562096246b3 | 159 | #endif |
enginerd | 0:b562096246b3 | 160 | |
enginerd | 0:b562096246b3 | 161 | #endif /* WSF_TIMER_H */ |