LoRaWAN demo 76 bootcamp
Dependencies: mbed DigitDisplay Chainable_RGB_LED LoRaWAN-lib SX1276Lib
system/timer.h@5:d87bb1eabccd, 2017-04-24 (annotated)
- Committer:
- mluis
- Date:
- Mon Apr 24 13:40:32 2017 +0000
- Revision:
- 5:d87bb1eabccd
- Parent:
- 3:de1dcfbe175a
WARNING: Radio API timings changed from micro-seconds to milliseconds; ; Synchronized with https://github.com/Lora-net/LoRaMac-node git revision e506c246652fa44c3f24cecb89d0707b49ece739; Updated all libraries to the latest versions
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mluis | 0:cb80564f40e1 | 1 | /* |
mluis | 0:cb80564f40e1 | 2 | / _____) _ | | |
mluis | 0:cb80564f40e1 | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ |
mluis | 0:cb80564f40e1 | 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ |
mluis | 0:cb80564f40e1 | 5 | _____) ) ____| | | || |_| ____( (___| | | | |
mluis | 0:cb80564f40e1 | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| |
mluis | 0:cb80564f40e1 | 7 | (C)2013 Semtech |
mluis | 0:cb80564f40e1 | 8 | |
mluis | 0:cb80564f40e1 | 9 | Description: Timer objects and scheduling management |
mluis | 0:cb80564f40e1 | 10 | |
mluis | 0:cb80564f40e1 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project |
mluis | 0:cb80564f40e1 | 12 | |
mluis | 0:cb80564f40e1 | 13 | Maintainer: Miguel Luis and Gregory Cristian |
mluis | 0:cb80564f40e1 | 14 | */ |
mluis | 0:cb80564f40e1 | 15 | #ifndef __TIMER_H__ |
mluis | 0:cb80564f40e1 | 16 | #define __TIMER_H__ |
mluis | 0:cb80564f40e1 | 17 | |
mluis | 0:cb80564f40e1 | 18 | #include "mbed.h" |
mluis | 0:cb80564f40e1 | 19 | |
mluis | 0:cb80564f40e1 | 20 | /*! |
mluis | 0:cb80564f40e1 | 21 | * \brief Timer object description |
mluis | 0:cb80564f40e1 | 22 | */ |
mluis | 0:cb80564f40e1 | 23 | typedef struct TimerEvent_s |
mluis | 0:cb80564f40e1 | 24 | { |
mluis | 5:d87bb1eabccd | 25 | uint32_t value; |
mluis | 0:cb80564f40e1 | 26 | void ( *Callback )( void ); |
mluis | 0:cb80564f40e1 | 27 | Ticker Timer; |
mluis | 0:cb80564f40e1 | 28 | }TimerEvent_t; |
mluis | 0:cb80564f40e1 | 29 | |
mluis | 0:cb80564f40e1 | 30 | /*! |
mluis | 0:cb80564f40e1 | 31 | * \brief Timer time variable definition |
mluis | 0:cb80564f40e1 | 32 | */ |
mluis | 0:cb80564f40e1 | 33 | #ifndef TimerTime_t |
mluis | 5:d87bb1eabccd | 34 | typedef uint32_t TimerTime_t; |
mluis | 0:cb80564f40e1 | 35 | #endif |
mluis | 0:cb80564f40e1 | 36 | |
mluis | 0:cb80564f40e1 | 37 | /*! |
mluis | 0:cb80564f40e1 | 38 | * \brief Inializes the timer used to get current time. |
mluis | 0:cb80564f40e1 | 39 | * |
mluis | 0:cb80564f40e1 | 40 | * \remark Current time corresponds to the time since system startup |
mluis | 0:cb80564f40e1 | 41 | */ |
mluis | 0:cb80564f40e1 | 42 | void TimerTimeCounterInit( void ); |
mluis | 0:cb80564f40e1 | 43 | |
mluis | 0:cb80564f40e1 | 44 | /*! |
mluis | 0:cb80564f40e1 | 45 | * \brief Initializes the timer object |
mluis | 0:cb80564f40e1 | 46 | * |
mluis | 0:cb80564f40e1 | 47 | * \remark TimerSetValue function must be called before starting the timer. |
mluis | 0:cb80564f40e1 | 48 | * this function initializes timestamp and reload value at 0. |
mluis | 0:cb80564f40e1 | 49 | * |
mluis | 0:cb80564f40e1 | 50 | * \param [IN] obj Structure containing the timer object parameters |
mluis | 0:cb80564f40e1 | 51 | * \param [IN] callback Function callback called at the end of the timeout |
mluis | 0:cb80564f40e1 | 52 | */ |
mluis | 0:cb80564f40e1 | 53 | void TimerInit( TimerEvent_t *obj, void ( *callback )( void ) ); |
mluis | 0:cb80564f40e1 | 54 | |
mluis | 0:cb80564f40e1 | 55 | /*! |
mluis | 0:cb80564f40e1 | 56 | * \brief Starts and adds the timer object to the list of timer events |
mluis | 0:cb80564f40e1 | 57 | * |
mluis | 0:cb80564f40e1 | 58 | * \param [IN] obj Structure containing the timer object parameters |
mluis | 0:cb80564f40e1 | 59 | */ |
mluis | 0:cb80564f40e1 | 60 | void TimerStart( TimerEvent_t *obj ); |
mluis | 0:cb80564f40e1 | 61 | |
mluis | 0:cb80564f40e1 | 62 | /*! |
mluis | 0:cb80564f40e1 | 63 | * \brief Stops and removes the timer object from the list of timer events |
mluis | 0:cb80564f40e1 | 64 | * |
mluis | 0:cb80564f40e1 | 65 | * \param [IN] obj Structure containing the timer object parameters |
mluis | 0:cb80564f40e1 | 66 | */ |
mluis | 0:cb80564f40e1 | 67 | void TimerStop( TimerEvent_t *obj ); |
mluis | 0:cb80564f40e1 | 68 | |
mluis | 0:cb80564f40e1 | 69 | /*! |
mluis | 0:cb80564f40e1 | 70 | * \brief Resets the timer object |
mluis | 0:cb80564f40e1 | 71 | * |
mluis | 0:cb80564f40e1 | 72 | * \param [IN] obj Structure containing the timer object parameters |
mluis | 0:cb80564f40e1 | 73 | */ |
mluis | 0:cb80564f40e1 | 74 | void TimerReset( TimerEvent_t *obj ); |
mluis | 0:cb80564f40e1 | 75 | |
mluis | 0:cb80564f40e1 | 76 | /*! |
mluis | 0:cb80564f40e1 | 77 | * \brief Set timer new timeout value |
mluis | 0:cb80564f40e1 | 78 | * |
mluis | 0:cb80564f40e1 | 79 | * \param [IN] obj Structure containing the timer object parameters |
mluis | 0:cb80564f40e1 | 80 | * \param [IN] value New timer timeout value |
mluis | 0:cb80564f40e1 | 81 | */ |
mluis | 0:cb80564f40e1 | 82 | void TimerSetValue( TimerEvent_t *obj, uint32_t value ); |
mluis | 0:cb80564f40e1 | 83 | |
mluis | 0:cb80564f40e1 | 84 | /*! |
mluis | 0:cb80564f40e1 | 85 | * \brief Read the current time |
mluis | 0:cb80564f40e1 | 86 | * |
mluis | 0:cb80564f40e1 | 87 | * \retval time returns current time |
mluis | 0:cb80564f40e1 | 88 | */ |
mluis | 0:cb80564f40e1 | 89 | TimerTime_t TimerGetCurrentTime( void ); |
mluis | 0:cb80564f40e1 | 90 | |
mluis | 1:21e3eef8200f | 91 | /*! |
mluis | 1:21e3eef8200f | 92 | * \brief Return the Time elapsed since a fix moment in Time |
mluis | 1:21e3eef8200f | 93 | * |
mluis | 1:21e3eef8200f | 94 | * \param [IN] savedTime fix moment in Time |
mluis | 1:21e3eef8200f | 95 | * \retval time returns elapsed time |
mluis | 1:21e3eef8200f | 96 | */ |
mluis | 1:21e3eef8200f | 97 | TimerTime_t TimerGetElapsedTime( TimerTime_t savedTime ); |
mluis | 1:21e3eef8200f | 98 | |
mluis | 1:21e3eef8200f | 99 | /*! |
mluis | 1:21e3eef8200f | 100 | * \brief Return the Time elapsed since a fix moment in Time |
mluis | 1:21e3eef8200f | 101 | * |
mluis | 1:21e3eef8200f | 102 | * \param [IN] eventInFuture fix moment in the future |
mluis | 1:21e3eef8200f | 103 | * \retval time returns difference between now and future event |
mluis | 1:21e3eef8200f | 104 | */ |
mluis | 1:21e3eef8200f | 105 | TimerTime_t TimerGetFutureTime( TimerTime_t eventInFuture ); |
mluis | 0:cb80564f40e1 | 106 | |
mluis | 0:cb80564f40e1 | 107 | #endif // __TIMER_H__ |