void usbc_set_wk_notify_timer(kal_uint8 class_device_id) { eventid eid; kal_uint8 nInterface; usbc_core_t* pUsbCore = usbc_core_get_instance(); /* * To prevent race condition of event cancelling and set, * there shall be only one such event for simplicity. */ ASSERT(NULL != pUsbCore->usbc_es_wk_notify_g); usbc_trace_info(USBCORE_REMOTE_WK_SET_NOTIFY_TIMER, class_device_id); USBC_CLASS_REMOTE_WK_LOCK(pUsbCore->usbc_class_renotify_mutex); // usb a bitmap to maintain the list of function wakeup notification pUsbCore->func_notify_list[class_device_id] = KAL_TRUE; // get the firtst interface ot the function nInterface = usbc_class_device_get_1st_interface(class_device_id); // send function remote wakeup notification via HIF driver usbc_normal_hif_ss_wk_notify(nInterface); if (NULL == pUsbCore->wk_eventid) { eid = evshed_set_event( pUsbCore->usbc_es_wk_notify_g, usbc_wk_notify_timeout, // timeout handler NULL, /* event_hf_param */ USBC_WK_NOTIFY_CHECK_TICKS); /* elapse_time */ ASSERT(eid); } USBC_CLASS_REMOTE_WK_UNLOCK(pUsbCore->usbc_class_renotify_mutex); }
void bmt_set_timer(bmt_timer_enum timer_id, kal_uint32 tick) { #if !defined(BMT_CHARGING_DISABLE) kal_uint32 max_total_charge_time; if(BMT_CHARGE_TIMEOUT_TIMER == timer_id) { max_total_charge_time = bmt_get_max_total_charge_time(); if(bmt_charging_para.bmt_total_charge_time > max_total_charge_time) //if the custom total charge time large than the max value, set the max vlaue tick = max_total_charge_time; } #endif bmt_event_scheduler_id[timer_id] = evshed_set_event(bmt_event_scheduler_ptr,(kal_timer_func_ptr)bmt_timer_callback[timer_id], NULL, tick); }
void bt_simap_start_timer(eventid *timer_id_p, kal_uint32 timer_duration, kal_timer_func_ptr funct_ptr) { eventid timer_evt_id = *timer_id_p; kal_trace(TRACE_GROUP_1, BT_SIMAP_START_TIMER, timer_duration); if (bt_p->os_init == TRUE) { if (timer_evt_id != 0) { evshed_cancel_event(bt_p->evsh_sched, timer_id_p); *timer_id_p = 0; } *timer_id_p = evshed_set_event(bt_p->evsh_sched, funct_ptr, NULL, MS_TO_TICKS(timer_duration)); } }
/***************************************************************************** * FUNCTION * jpush_alarm_set * DESCRIPTION * set the alarm registrations to event schedule * PARAMETERS * entry_ptr [?] * alarmtime [IN] * RETURNS * void *****************************************************************************/ eventid jpush_alarm_set(alarmentry_struct *entry_ptr, kal_uint32 alarmtime) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ eventid event_id; /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ kal_trace(TRACE_FUNC, JPUSH_ALARM_SET); jpush_timer_mutex_lock(); event_id = evshed_set_event( j2me_alarm_es_ptr, (kal_timer_func_ptr) j2me_alarm_timeout_handler, entry_ptr, alarmtime); jpush_timer_mutex_unlock(); return event_id; }
void tcm_start_timer( kal_uint8 context_id ) { kal_uint8 index; tcm_event_info_struct *event_ptr ; kal_trace(TRACE_FUNC, FUNC_TCM_START_TIMER); index = tcm_get_sib_id( GET_FROM_CONTEXTID, context_id ); ASSERT(index < TCM_TOT_CONTEXT); event_ptr = &(tcm_ptr_g->t3333timer[index]) ; kal_brief_trace(TRACE_INFO, TCM_START_EVENT_TIMER, context_id) ; event_ptr->context_id = context_id ; event_ptr->event_id = evshed_set_event( tcm_ptr_g->tcm_event_scheduler_ptr, tcm_timer_expiry_hdlr, event_ptr, TCM_T3333_TIMEOUT_MILLI_SECS ) ; return; }
/***************************************************************************** * FUNCTION * avk_mytimer_start_timer * DESCRIPTION * start a mytimer * PARAMETERS * expiry_proc : [IN] proc for mytimer expiry * milli_secs : [IN] milliseconds for expiry * param : [IN] user data * RETURNS * NULL : fail to start timer * avk_mytimer_id : mytimer id *****************************************************************************/ avk_mytimer_id avk_mytimer_start_timer(avk_mytimer_proc expiry_proc, U32 milli_secs, void *param) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ kal_uint32 ticks; /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ if (expiry_proc == NULL) { return NULL; } ticks = kal_milli_secs_to_ticks(milli_secs); if (ticks == 0) { ticks = 1; } return (avk_mytimer_id)evshed_set_event((event_scheduler *)g_mytimer_base_cntx, (kal_timer_func_ptr)expiry_proc, param, ticks); }
/***************************************************************************** * FUNCTION * applib_async_file_task_internal_read * DESCRIPTION * * PARAMETERS * op [?] * RETURNS * void *****************************************************************************/ static void applib_async_file_task_internal_read(applib_async_file_task_struct *op) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ kal_int32 ret; kal_uint32 rd_no; kal_uint32 length; /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ if (op == NULL) { ASSERT(0); } length = op->buffer + op->dataLen - op->pos; while (1) { if (length == 0) { op->callback(APPLIB_ASYNC_FILE_OK, op->totalLen, op->arg_in_callback); return; } rd_no = 0; #ifndef __MTK_TARGET__ if (length > 512) { ret = FS_Read(op->fileHandle, op->pos, 512, &rd_no); ret = FS_FLASH_ERASE_BUSY; } else { ret = FS_Read(op->fileHandle, op->pos, length, &rd_no); } #else /* __MTK_TARGET__ */ ret = FS_Read(op->fileHandle, op->pos, length, &rd_no); #endif /* __MTK_TARGET__ */ if (rd_no > 0) { op->totalLen += (unsigned long)rd_no; op->pos += rd_no; length -= rd_no; } switch (transferFsError(ret)) { /* File system busy */ case APPLIB_ASYNC_FILE_ERROR_DELAYED: { if (applib_callout_active(op->fs_timer)) { ASSERT(0); } op->fs_timer.c_flags |= APPLIB_CALLOUT_ACTIVE; op->fs_timer.event_id = evshed_set_event( op->es, (kal_timer_func_ptr) applib_async_file_task_read_continue, op, APPLIB_FILE_TIMEOUT); return; } default: if (ret < 0) { op->callback(transferFsError(ret), op->totalLen, op->arg_in_callback); return; } } } }