the difference of two sets of timer API

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
mawu_4270096
Level 5
Level 5
50 replies posted 25 replies posted 10 replies posted

Hi:

  I find there are two sets of  timer API supported by the SDK,but I don't know which  one is more accurate for timing

one  set timer API is located at the wiced_timer.h:

wiced_result_t wiced_init_timer( wiced_timer_t* p_timer, wiced_timer_callback_t TimerCb,

                                 TIMER_PARAM_TYPE cBackparam, wiced_timer_type_t type);

wiced_result_t wiced_start_timer(wiced_timer_t* p_timer, uint32_t timeout);

/** Stops the timer
*
* @param[in]    wiced_timer_t           :Pointer to the timer structure
*
* @return       wiced_result_t
*/

wiced_result_t wiced_stop_timer(wiced_timer_t* p_timer);

/**  Checks if the timer is in use
*
* @param[in]    p_timer             :Pointer to the timer structure
*
* @return   TRUE if the timer is in use and FALSE if the timer is not in use
*/
wiced_bool_t wiced_is_timer_in_use(wiced_timer_t* p_timer);

/** Deinitialize the timer instance and stops the timer if it is running
*
* * @param[in]    p_timer           :Pointer to the timer
*
* @return   wiced_result_t
*/
wiced_result_t wiced_deinit_timer(wiced_timer_t* p_timer);

another is located at clock_timer.h:

extern void osapi_createPeriodicTimer(OSAPI_TIMER *timer,
                  void (*timerCallback)(INT32 arg, UINT32 overTimeInUs),
                  INT32  arg,
                  UINT32  interval);

//! Create a timer.
           void osapi_createTimer(OSAPI_TIMER *timer, void (*timerCallback)(INT32 arg, UINT32 overTimeInUs), INT32 arg);

//! Activates an OSAPI timer.
//! If this timer can be a wakeup source, we should call
//! osapi_setTimerWakeupSource after osapi_createTimer and before
//! osapi_activateTimer. Interval here is in micro seconds.
              extern void osapi_activateTimer(OSAPI_TIMER* timer, UINT32 interval);

//! Reports if timer is running/pending or not.
#define osapi_is_timer_running(timer) ((timer)->flags&OSAPI_TIMER_ACTIVE)

//! Marks the timer as being a wake up source.
//! This may be called before the call to osapi_activateTimer() to mark
//! the timer as a wake up source.
        extern void osapi_setTimerWakeupSource( OSAPI_TIMER* timer, UINT32 can_be_wakeup_source);

//! Remove the timer from timer list.
//! It will return 0 if successful
//! It will return 1 if timeout callback already called.
//! It will return 2 otherwise.
         extern UINT32 osapi_deactivateTimer(OSAPI_TIMER* timer);

//! Query timer for remain time until timeout.
//! This function will query current timer, return microseconds from now until it timeout
           extern UINT32 osapi_getTimerRemain(OSAPI_TIMER* timer);

//! See if certain timer is still linked to notifyTimerlist.
//! This will return TRUE, if timer is linked to the list.
       extern BOOL32 osapi_timerLinkedToNotifyTimeList(OSAPI_TIMER *timer);

who can tell me the function difference beteen the two sets of API ? whice one is more  accurate for timing application?

Looking forward to your reply!

thanks

0 Likes
1 Solution
AnjanaM_61
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 5 questions asked

Hello,

wiced_init_timer uses osapi timers internally but with some safety checks.

Its recommended to use APIs from wiced_timer.h for customer applications.

Thanks,

Anjana

View solution in original post

0 Likes
1 Reply
AnjanaM_61
Moderator
Moderator
Moderator
5 comments on KBA First comment on KBA 5 questions asked

Hello,

wiced_init_timer uses osapi timers internally but with some safety checks.

Its recommended to use APIs from wiced_timer.h for customer applications.

Thanks,

Anjana

0 Likes