![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
firstTest
Dependencies: mbed lib_sx9500 SX127x lib_mpl3115a2 lib_mma8451q lib_gps libscpi
timer.h@0:1aa6d4a96bf1, 2020-04-14 (annotated)
- Committer:
- bongkwan
- Date:
- Tue Apr 14 02:53:27 2020 +0000
- Revision:
- 0:1aa6d4a96bf1
first comment
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bongkwan | 0:1aa6d4a96bf1 | 1 | /* |
bongkwan | 0:1aa6d4a96bf1 | 2 | / _____) _ | | |
bongkwan | 0:1aa6d4a96bf1 | 3 | ( (____ _____ ____ _| |_ _____ ____| |__ |
bongkwan | 0:1aa6d4a96bf1 | 4 | \____ \| ___ | (_ _) ___ |/ ___) _ \ |
bongkwan | 0:1aa6d4a96bf1 | 5 | _____) ) ____| | | || |_| ____( (___| | | | |
bongkwan | 0:1aa6d4a96bf1 | 6 | (______/|_____)_|_|_| \__)_____)\____)_| |_| |
bongkwan | 0:1aa6d4a96bf1 | 7 | (C)2013 Semtech |
bongkwan | 0:1aa6d4a96bf1 | 8 | |
bongkwan | 0:1aa6d4a96bf1 | 9 | Description: Timer objects and scheduling management |
bongkwan | 0:1aa6d4a96bf1 | 10 | |
bongkwan | 0:1aa6d4a96bf1 | 11 | License: Revised BSD License, see LICENSE.TXT file include in the project |
bongkwan | 0:1aa6d4a96bf1 | 12 | |
bongkwan | 0:1aa6d4a96bf1 | 13 | Maintainer: Miguel Luis and Gregory Cristian |
bongkwan | 0:1aa6d4a96bf1 | 14 | */ |
bongkwan | 0:1aa6d4a96bf1 | 15 | #ifndef __TIMER_H__ |
bongkwan | 0:1aa6d4a96bf1 | 16 | #define __TIMER_H__ |
bongkwan | 0:1aa6d4a96bf1 | 17 | |
bongkwan | 0:1aa6d4a96bf1 | 18 | #include "mbed.h" |
bongkwan | 0:1aa6d4a96bf1 | 19 | |
bongkwan | 0:1aa6d4a96bf1 | 20 | /*! |
bongkwan | 0:1aa6d4a96bf1 | 21 | * \brief Timer object description |
bongkwan | 0:1aa6d4a96bf1 | 22 | */ |
bongkwan | 0:1aa6d4a96bf1 | 23 | typedef struct TimerEvent_s |
bongkwan | 0:1aa6d4a96bf1 | 24 | { |
bongkwan | 0:1aa6d4a96bf1 | 25 | uint32_t value; |
bongkwan | 0:1aa6d4a96bf1 | 26 | void ( *Callback )( void ); |
bongkwan | 0:1aa6d4a96bf1 | 27 | Ticker Timer; |
bongkwan | 0:1aa6d4a96bf1 | 28 | }TimerEvent_t; |
bongkwan | 0:1aa6d4a96bf1 | 29 | |
bongkwan | 0:1aa6d4a96bf1 | 30 | /*! |
bongkwan | 0:1aa6d4a96bf1 | 31 | * \brief Timer time variable definition |
bongkwan | 0:1aa6d4a96bf1 | 32 | */ |
bongkwan | 0:1aa6d4a96bf1 | 33 | #ifndef TimerTime_t |
bongkwan | 0:1aa6d4a96bf1 | 34 | typedef uint32_t TimerTime_t; |
bongkwan | 0:1aa6d4a96bf1 | 35 | #endif |
bongkwan | 0:1aa6d4a96bf1 | 36 | |
bongkwan | 0:1aa6d4a96bf1 | 37 | /*! |
bongkwan | 0:1aa6d4a96bf1 | 38 | * \brief Inializes the timer used to get current time. |
bongkwan | 0:1aa6d4a96bf1 | 39 | * |
bongkwan | 0:1aa6d4a96bf1 | 40 | * \remark Current time corresponds to the time since system startup |
bongkwan | 0:1aa6d4a96bf1 | 41 | */ |
bongkwan | 0:1aa6d4a96bf1 | 42 | void TimerTimeCounterInit( void ); |
bongkwan | 0:1aa6d4a96bf1 | 43 | |
bongkwan | 0:1aa6d4a96bf1 | 44 | /*! |
bongkwan | 0:1aa6d4a96bf1 | 45 | * \brief Initializes the timer object |
bongkwan | 0:1aa6d4a96bf1 | 46 | * |
bongkwan | 0:1aa6d4a96bf1 | 47 | * \remark TimerSetValue function must be called before starting the timer. |
bongkwan | 0:1aa6d4a96bf1 | 48 | * this function initializes timestamp and reload value at 0. |
bongkwan | 0:1aa6d4a96bf1 | 49 | * |
bongkwan | 0:1aa6d4a96bf1 | 50 | * \param [IN] obj Structure containing the timer object parameters |
bongkwan | 0:1aa6d4a96bf1 | 51 | * \param [IN] callback Function callback called at the end of the timeout |
bongkwan | 0:1aa6d4a96bf1 | 52 | */ |
bongkwan | 0:1aa6d4a96bf1 | 53 | void TimerInit( TimerEvent_t *obj, void ( *callback )( void ) ); |
bongkwan | 0:1aa6d4a96bf1 | 54 | |
bongkwan | 0:1aa6d4a96bf1 | 55 | /*! |
bongkwan | 0:1aa6d4a96bf1 | 56 | * \brief Starts and adds the timer object to the list of timer events |
bongkwan | 0:1aa6d4a96bf1 | 57 | * |
bongkwan | 0:1aa6d4a96bf1 | 58 | * \param [IN] obj Structure containing the timer object parameters |
bongkwan | 0:1aa6d4a96bf1 | 59 | */ |
bongkwan | 0:1aa6d4a96bf1 | 60 | void TimerStart( TimerEvent_t *obj ); |
bongkwan | 0:1aa6d4a96bf1 | 61 | |
bongkwan | 0:1aa6d4a96bf1 | 62 | /*! |
bongkwan | 0:1aa6d4a96bf1 | 63 | * \brief Stops and removes the timer object from the list of timer events |
bongkwan | 0:1aa6d4a96bf1 | 64 | * |
bongkwan | 0:1aa6d4a96bf1 | 65 | * \param [IN] obj Structure containing the timer object parameters |
bongkwan | 0:1aa6d4a96bf1 | 66 | */ |
bongkwan | 0:1aa6d4a96bf1 | 67 | void TimerStop( TimerEvent_t *obj ); |
bongkwan | 0:1aa6d4a96bf1 | 68 | |
bongkwan | 0:1aa6d4a96bf1 | 69 | /*! |
bongkwan | 0:1aa6d4a96bf1 | 70 | * \brief Resets the timer object |
bongkwan | 0:1aa6d4a96bf1 | 71 | * |
bongkwan | 0:1aa6d4a96bf1 | 72 | * \param [IN] obj Structure containing the timer object parameters |
bongkwan | 0:1aa6d4a96bf1 | 73 | */ |
bongkwan | 0:1aa6d4a96bf1 | 74 | void TimerReset( TimerEvent_t *obj ); |
bongkwan | 0:1aa6d4a96bf1 | 75 | |
bongkwan | 0:1aa6d4a96bf1 | 76 | /*! |
bongkwan | 0:1aa6d4a96bf1 | 77 | * \brief Set timer new timeout value |
bongkwan | 0:1aa6d4a96bf1 | 78 | * |
bongkwan | 0:1aa6d4a96bf1 | 79 | * \param [IN] obj Structure containing the timer object parameters |
bongkwan | 0:1aa6d4a96bf1 | 80 | * \param [IN] value New timer timeout value |
bongkwan | 0:1aa6d4a96bf1 | 81 | */ |
bongkwan | 0:1aa6d4a96bf1 | 82 | void TimerSetValue( TimerEvent_t *obj, uint32_t value ); |
bongkwan | 0:1aa6d4a96bf1 | 83 | |
bongkwan | 0:1aa6d4a96bf1 | 84 | /*! |
bongkwan | 0:1aa6d4a96bf1 | 85 | * \brief Read the current time |
bongkwan | 0:1aa6d4a96bf1 | 86 | * |
bongkwan | 0:1aa6d4a96bf1 | 87 | * \retval time returns current time |
bongkwan | 0:1aa6d4a96bf1 | 88 | */ |
bongkwan | 0:1aa6d4a96bf1 | 89 | TimerTime_t TimerGetCurrentTime( void ); |
bongkwan | 0:1aa6d4a96bf1 | 90 | |
bongkwan | 0:1aa6d4a96bf1 | 91 | |
bongkwan | 0:1aa6d4a96bf1 | 92 | #endif // __TIMER_H__ |