Loading gki/common/gki.h +9 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,7 @@ typedef struct _tle struct _tle *p_prev; TIMER_CBACK *p_cback; INT32 ticks; INT32 ticks_initial; TIMER_PARAM_TYPE param; UINT16 event; UINT8 in_use; Loading Loading @@ -205,6 +206,14 @@ GKI_API extern void GKI_timer_update(INT32); GKI_API extern UINT16 GKI_update_timer_list (TIMER_LIST_Q *, INT32); GKI_API extern UINT32 GKI_get_remaining_ticks (TIMER_LIST_Q *, TIMER_LIST_ENT *); GKI_API extern UINT16 GKI_wait(UINT16, UINT32); GKI_API extern BOOLEAN GKI_timer_queue_is_empty(const TIMER_LIST_Q *timer_q); GKI_API extern TIMER_LIST_ENT *GKI_timer_getfirst(const TIMER_LIST_Q *timer_q); GKI_API extern TIMER_LIST_ENT *GKI_timer_getlast(const TIMER_LIST_Q *timer_q); GKI_API extern INT32 GKI_timer_ticks_getlast(const TIMER_LIST_Q *timer_q); GKI_API extern TIMER_LIST_ENT *GKI_timer_entry_next(const TIMER_LIST_ENT *tle); GKI_API extern INT32 GKI_timer_ticks_getcurrent(const TIMER_LIST_ENT *tle); GKI_API extern INT32 GKI_timer_ticks_getinitial(const TIMER_LIST_ENT *tle); GKI_API extern BOOLEAN GKI_timer_in_use(const TIMER_LIST_ENT *tle); /* Start and Stop system time tick callback * true for start system tick if time queue is not empty Loading gki/common/gki_time.c +53 −12 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ * ******************************************************************************/ #include <assert.h> #include <utils/Log.h> #include "gki_int.h" Loading Loading @@ -651,13 +652,31 @@ void GKI_timer_queue_register_callback (SYSTEM_TICK_CBACK *p_callback) ** Returns void ** *******************************************************************************/ void GKI_init_timer_list (TIMER_LIST_Q *p_timer_listq) { p_timer_listq->p_first = NULL; p_timer_listq->p_last = NULL; p_timer_listq->last_ticks = 0; void GKI_init_timer_list(TIMER_LIST_Q *timer_q) { timer_q->p_first = NULL; timer_q->p_last = NULL; timer_q->last_ticks = 0; } return; bool GKI_timer_queue_is_empty(const TIMER_LIST_Q *timer_q) { assert(timer_q != NULL); return (timer_q->p_first == NULL); } TIMER_LIST_ENT *GKI_timer_getfirst(const TIMER_LIST_Q *timer_q) { assert(timer_q != NULL); return timer_q->p_first; } TIMER_LIST_ENT *GKI_timer_getlast(const TIMER_LIST_Q *timer_q) { assert(timer_q != NULL); return timer_q->p_last; } /* Returns the number of ticks of the last entry in the queue. */ INT32 GKI_timer_ticks_getlast(const TIMER_LIST_Q *timer_q) { assert(timer_q != NULL); return timer_q->last_ticks; } /******************************************************************************* Loading @@ -673,14 +692,36 @@ void GKI_init_timer_list (TIMER_LIST_Q *p_timer_listq) ** Returns void ** *******************************************************************************/ void GKI_init_timer_list_entry (TIMER_LIST_ENT *p_tle) { p_tle->p_next = NULL; p_tle->p_prev = NULL; p_tle->ticks = GKI_UNUSED_LIST_ENTRY; p_tle->in_use = FALSE; void GKI_init_timer_list_entry(TIMER_LIST_ENT *tle) { tle->p_next = NULL; tle->p_prev = NULL; tle->ticks = GKI_UNUSED_LIST_ENTRY; tle->ticks_initial = 0; tle->in_use = FALSE; } /* Returns the next linked entry from this tle or NULL. */ TIMER_LIST_ENT *GKI_timer_entry_next(const TIMER_LIST_ENT *tle) { assert(tle != NULL); return tle->p_next; } /* Returns the current number of ticks for this timer entry. */ INT32 GKI_timer_ticks_getcurrent(const TIMER_LIST_ENT *tle) { assert(tle != NULL); return tle->ticks; } /* Returns the initial number of ticks for this timer entry. */ INT32 GKI_timer_ticks_getinitial(const TIMER_LIST_ENT *tle) { assert(tle != NULL); return tle->ticks_initial; } BOOLEAN GKI_timer_in_use(const TIMER_LIST_ENT *tle) { assert(tle != NULL); return tle->in_use; } /******************************************************************************* ** Loading system/bta/sys/ptim.c +1 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,7 @@ void ptim_start_timer(tPTIM_CB *p_cb, TIMER_LIST_ENT *p_tle, UINT16 type, INT32 p_tle->event = type; p_tle->ticks = timeout; p_tle->ticks_initial = timeout; GKI_add_to_timer_list(&p_cb->timer_queue, p_tle); } Loading system/stack/btu/btu_task.c +9 −12 Original line number Diff line number Diff line Loading @@ -331,8 +331,7 @@ BTU_API UINT32 btu_task (UINT32 param) break; case BT_EVT_TO_STOP_TIMER: if (btu_cb.timer_queue.p_first == NULL) { if (GKI_timer_queue_is_empty(&btu_cb.timer_queue)) { GKI_stop_timer(TIMER_0); } GKI_freebuf (p_msg); Loading Loading @@ -374,19 +373,17 @@ BTU_API UINT32 btu_task (UINT32 param) } if (event & TIMER_0_EVT_MASK) { TIMER_LIST_ENT *p_tle; if (event & TIMER_0_EVT_MASK) { GKI_update_timer_list (&btu_cb.timer_queue, 1); while ((btu_cb.timer_queue.p_first) && (!btu_cb.timer_queue.p_first->ticks)) { p_tle = btu_cb.timer_queue.p_first; while (!GKI_timer_queue_is_empty(&btu_cb.timer_queue)) { TIMER_LIST_ENT *p_tle = GKI_timer_getfirst(&btu_cb.timer_queue); if (p_tle->ticks != 0) break; GKI_remove_from_timer_list(&btu_cb.timer_queue, p_tle); switch (p_tle->event) { switch (p_tle->event) { case BTU_TTYPE_BTM_DEV_CTL: btm_dev_timeout(p_tle); break; Loading Loading
gki/common/gki.h +9 −0 Original line number Diff line number Diff line Loading @@ -97,6 +97,7 @@ typedef struct _tle struct _tle *p_prev; TIMER_CBACK *p_cback; INT32 ticks; INT32 ticks_initial; TIMER_PARAM_TYPE param; UINT16 event; UINT8 in_use; Loading Loading @@ -205,6 +206,14 @@ GKI_API extern void GKI_timer_update(INT32); GKI_API extern UINT16 GKI_update_timer_list (TIMER_LIST_Q *, INT32); GKI_API extern UINT32 GKI_get_remaining_ticks (TIMER_LIST_Q *, TIMER_LIST_ENT *); GKI_API extern UINT16 GKI_wait(UINT16, UINT32); GKI_API extern BOOLEAN GKI_timer_queue_is_empty(const TIMER_LIST_Q *timer_q); GKI_API extern TIMER_LIST_ENT *GKI_timer_getfirst(const TIMER_LIST_Q *timer_q); GKI_API extern TIMER_LIST_ENT *GKI_timer_getlast(const TIMER_LIST_Q *timer_q); GKI_API extern INT32 GKI_timer_ticks_getlast(const TIMER_LIST_Q *timer_q); GKI_API extern TIMER_LIST_ENT *GKI_timer_entry_next(const TIMER_LIST_ENT *tle); GKI_API extern INT32 GKI_timer_ticks_getcurrent(const TIMER_LIST_ENT *tle); GKI_API extern INT32 GKI_timer_ticks_getinitial(const TIMER_LIST_ENT *tle); GKI_API extern BOOLEAN GKI_timer_in_use(const TIMER_LIST_ENT *tle); /* Start and Stop system time tick callback * true for start system tick if time queue is not empty Loading
gki/common/gki_time.c +53 −12 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ * ******************************************************************************/ #include <assert.h> #include <utils/Log.h> #include "gki_int.h" Loading Loading @@ -651,13 +652,31 @@ void GKI_timer_queue_register_callback (SYSTEM_TICK_CBACK *p_callback) ** Returns void ** *******************************************************************************/ void GKI_init_timer_list (TIMER_LIST_Q *p_timer_listq) { p_timer_listq->p_first = NULL; p_timer_listq->p_last = NULL; p_timer_listq->last_ticks = 0; void GKI_init_timer_list(TIMER_LIST_Q *timer_q) { timer_q->p_first = NULL; timer_q->p_last = NULL; timer_q->last_ticks = 0; } return; bool GKI_timer_queue_is_empty(const TIMER_LIST_Q *timer_q) { assert(timer_q != NULL); return (timer_q->p_first == NULL); } TIMER_LIST_ENT *GKI_timer_getfirst(const TIMER_LIST_Q *timer_q) { assert(timer_q != NULL); return timer_q->p_first; } TIMER_LIST_ENT *GKI_timer_getlast(const TIMER_LIST_Q *timer_q) { assert(timer_q != NULL); return timer_q->p_last; } /* Returns the number of ticks of the last entry in the queue. */ INT32 GKI_timer_ticks_getlast(const TIMER_LIST_Q *timer_q) { assert(timer_q != NULL); return timer_q->last_ticks; } /******************************************************************************* Loading @@ -673,14 +692,36 @@ void GKI_init_timer_list (TIMER_LIST_Q *p_timer_listq) ** Returns void ** *******************************************************************************/ void GKI_init_timer_list_entry (TIMER_LIST_ENT *p_tle) { p_tle->p_next = NULL; p_tle->p_prev = NULL; p_tle->ticks = GKI_UNUSED_LIST_ENTRY; p_tle->in_use = FALSE; void GKI_init_timer_list_entry(TIMER_LIST_ENT *tle) { tle->p_next = NULL; tle->p_prev = NULL; tle->ticks = GKI_UNUSED_LIST_ENTRY; tle->ticks_initial = 0; tle->in_use = FALSE; } /* Returns the next linked entry from this tle or NULL. */ TIMER_LIST_ENT *GKI_timer_entry_next(const TIMER_LIST_ENT *tle) { assert(tle != NULL); return tle->p_next; } /* Returns the current number of ticks for this timer entry. */ INT32 GKI_timer_ticks_getcurrent(const TIMER_LIST_ENT *tle) { assert(tle != NULL); return tle->ticks; } /* Returns the initial number of ticks for this timer entry. */ INT32 GKI_timer_ticks_getinitial(const TIMER_LIST_ENT *tle) { assert(tle != NULL); return tle->ticks_initial; } BOOLEAN GKI_timer_in_use(const TIMER_LIST_ENT *tle) { assert(tle != NULL); return tle->in_use; } /******************************************************************************* ** Loading
system/bta/sys/ptim.c +1 −0 Original line number Diff line number Diff line Loading @@ -137,6 +137,7 @@ void ptim_start_timer(tPTIM_CB *p_cb, TIMER_LIST_ENT *p_tle, UINT16 type, INT32 p_tle->event = type; p_tle->ticks = timeout; p_tle->ticks_initial = timeout; GKI_add_to_timer_list(&p_cb->timer_queue, p_tle); } Loading
system/stack/btu/btu_task.c +9 −12 Original line number Diff line number Diff line Loading @@ -331,8 +331,7 @@ BTU_API UINT32 btu_task (UINT32 param) break; case BT_EVT_TO_STOP_TIMER: if (btu_cb.timer_queue.p_first == NULL) { if (GKI_timer_queue_is_empty(&btu_cb.timer_queue)) { GKI_stop_timer(TIMER_0); } GKI_freebuf (p_msg); Loading Loading @@ -374,19 +373,17 @@ BTU_API UINT32 btu_task (UINT32 param) } if (event & TIMER_0_EVT_MASK) { TIMER_LIST_ENT *p_tle; if (event & TIMER_0_EVT_MASK) { GKI_update_timer_list (&btu_cb.timer_queue, 1); while ((btu_cb.timer_queue.p_first) && (!btu_cb.timer_queue.p_first->ticks)) { p_tle = btu_cb.timer_queue.p_first; while (!GKI_timer_queue_is_empty(&btu_cb.timer_queue)) { TIMER_LIST_ENT *p_tle = GKI_timer_getfirst(&btu_cb.timer_queue); if (p_tle->ticks != 0) break; GKI_remove_from_timer_list(&btu_cb.timer_queue, p_tle); switch (p_tle->event) { switch (p_tle->event) { case BTU_TTYPE_BTM_DEV_CTL: btm_dev_timeout(p_tle); break; Loading