#ifndef _TIMER_H_
#define _TIMER_H_

#include "platform.h"

typedef uint32_t TimerTime_t;
typedef struct TimerEvent_s
{
    uint32_t Timestamp;                  //! Current timer value
    uint32_t ReloadValue;                //! Timer delay value
    bool IsStarted;                      //! Is the timer currently running
    bool IsNext2Expire;                  //! Is the next timer to expire
    void ( *Callback )( void* context ); //! Timer IRQ callback function
    void *Context;                       //! User defined data object pointer to pass back
    struct TimerEvent_s *Next;           //! Pointer to the next Timer object.
}TimerEvent_t;

void DelayMs( uint32_t ms );
void TimerInit( TimerEvent_t *obj, void ( *callback )( void *context ) );
void TimerSetValue( TimerEvent_t *obj, uint32_t value );
void TimerStart( TimerEvent_t *obj );
void TimerStop( TimerEvent_t *obj );
TimerTime_t TimerGetCurrentTime( void );
TimerTime_t TimerGetElapsedTime( TimerTime_t past );
void TimerService( void );

#endif
