|
| 1 | +/** |
| 2 | + / _____) _ | | |
| 3 | +( (____ _____ ____ _| |_ _____ ____| |__ |
| 4 | + \____ \| ___ | (_ _) ___ |/ ___) _ \ |
| 5 | + _____) ) ____| | | || |_| ____( (___| | | | |
| 6 | +(______/|_____)_|_|_| \__)_____)\____)_| |_| |
| 7 | + (C)2013 Semtech |
| 8 | +
|
| 9 | +Description: Timer objects and scheduling management |
| 10 | +
|
| 11 | +License: Revised BSD License, see LICENSE.TXT file include in the project |
| 12 | +
|
| 13 | +Maintainer: Miguel Luis and Gregory Cristian |
| 14 | +
|
| 15 | +
|
| 16 | +Copyright (c) 2017, Arm Limited and affiliates. |
| 17 | +
|
| 18 | +SPDX-License-Identifier: BSD-3-Clause |
| 19 | +*/ |
| 20 | + |
| 21 | +#ifndef MBED_LORAWAN_SYS_TIMER_H__ |
| 22 | +#define MBED_LORAWAN_SYS_TIMER_H__ |
| 23 | +#include "drivers/Timer.h" |
| 24 | +#include "drivers/Ticker.h" |
| 25 | +#include "lorawan/system/lorawan_data_structures.h" |
| 26 | + |
| 27 | +/*! |
| 28 | + * \brief Timer object description |
| 29 | + */ |
| 30 | +typedef struct TimerEvent_s |
| 31 | +{ |
| 32 | + uint32_t value; |
| 33 | + void ( *Callback )( void ); |
| 34 | + mbed::Ticker Timer; |
| 35 | +}TimerEvent_t; |
| 36 | + |
| 37 | +/*! |
| 38 | + * \brief Initializes the timer used to get the current time. |
| 39 | + * |
| 40 | + * \remark The current time corresponds to the time since system startup. |
| 41 | + */ |
| 42 | +void TimerTimeCounterInit( void ); |
| 43 | + |
| 44 | +/*! |
| 45 | + * \brief Initializes the timer object. |
| 46 | + * |
| 47 | + * \remark The TimerSetValue function must be called before starting the timer. |
| 48 | + * This function initializes the timestamp and reloads the value at 0. |
| 49 | + * |
| 50 | + * \param [in] obj The structure containing the timer object parameters. |
| 51 | + * \param [in] callback The function callback called at the end of the timeout. |
| 52 | + */ |
| 53 | +void TimerInit( TimerEvent_t *obj, void ( *callback )( void ) ); |
| 54 | + |
| 55 | +/*! |
| 56 | + * \brief Starts and adds the timer object to the list of timer events. |
| 57 | + * |
| 58 | + * \param [in] obj The structure containing the timer object parameters. |
| 59 | + */ |
| 60 | +void TimerStart( TimerEvent_t *obj ); |
| 61 | + |
| 62 | +/*! |
| 63 | + * \brief Stops and removes the timer object from the list of timer events. |
| 64 | + * |
| 65 | + * \param [in] obj The structure containing the timer object parameters. |
| 66 | + */ |
| 67 | +void TimerStop( TimerEvent_t *obj ); |
| 68 | + |
| 69 | +/*! |
| 70 | + * \brief Resets the timer object. |
| 71 | + * |
| 72 | + * \param [in] obj The structure containing the timer object parameters. |
| 73 | + */ |
| 74 | +void TimerReset( TimerEvent_t *obj ); |
| 75 | + |
| 76 | +/*! |
| 77 | + * \brief Set a new timeout value. |
| 78 | + * |
| 79 | + * \param [in] obj The structure containing the timer object parameters. |
| 80 | + * \param [in] value The new timeout value. |
| 81 | + */ |
| 82 | +void TimerSetValue( TimerEvent_t *obj, uint32_t value ); |
| 83 | + |
| 84 | +/*! |
| 85 | + * \brief Read the current time. |
| 86 | + * |
| 87 | + * \retval time The current time. |
| 88 | + */ |
| 89 | +TimerTime_t TimerGetCurrentTime( void ); |
| 90 | + |
| 91 | +/*! |
| 92 | + * \brief Return the time elapsed since a fixed moment in time. |
| 93 | + * |
| 94 | + * \param [in] savedTime The fixed moment in time. |
| 95 | + * \retval time The elapsed time. |
| 96 | + */ |
| 97 | +TimerTime_t TimerGetElapsedTime( TimerTime_t savedTime ); |
| 98 | + |
| 99 | +/*! |
| 100 | + * \brief Return the time elapsed since a fixed moment in time. |
| 101 | + * |
| 102 | + * \param [in] eventInFuture The fixed moment in the future. |
| 103 | + * \retval time The difference between now and a future event. |
| 104 | + */ |
| 105 | +TimerTime_t TimerGetFutureTime( TimerTime_t eventInFuture ); |
| 106 | + |
| 107 | +#endif // MBED_LORAWAN_SYS_TIMER_H__ |
0 commit comments