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