void timer_dly_ms(int tmr_id, u32 dly_tim) { u32 cur_tim; u32 s_tck, e_tck; timer_disable(tmr_id); timer_enable(tmr_id); s_tck = timer_get_tick(tmr_id); while (1) { e_tck = timer_get_tick(tmr_id); cur_tim = timer_tick2ms(s_tck, e_tck); if (cur_tim >= dly_tim) break; } }
static void _playback_stop(void) { uint32_t elapsed = timer_get_interval(start_tick, timer_get_tick()); printf("<Playback Stop (%ums elapsed)>\r\n", (unsigned)elapsed); classd_volume_mute(true, true); }
void chrono_start (void) { chrono_started_ = 1; chrono_tick_left_ = CHRONO_MATCH_TICK_COUNT; chrono_last_tick_ = timer_get_tick (); }
void chrono_update (void) { if (chrono_started_) { uint16_t new_tick = timer_get_tick (); uint16_t diff = new_tick - chrono_last_tick_; chrono_last_tick_ = new_tick; if (diff > chrono_tick_left_) chrono_tick_left_ = 0; else chrono_tick_left_ -= diff; } }
/*bltRandom模块函数*/ ZL_EXP_VOID main_builtin_random(ZL_EXP_VOID * VM_ARG,ZL_EXP_INT argcount) { UNUSED(argcount); if(random_seed == 0) //第一次使用时间作为随机种子。 { srand((unsigned) timer_get_tick()); random_seed = rand(); } else //其他时候使用上一次生成的随机数作为随机种子 { srand(random_seed); random_seed = rand(); } zenglApi_SetRetVal(VM_ARG,ZL_EXP_FAT_INT,ZL_EXP_NULL,(long)random_seed,0); }
/* This one get's called from the architecture-specific interrupt * handlers, which do fiddling like EOIs (i386). */ isf_t* __attribute__((fastcall)) interrupts_callback(uint32_t intr, isf_t* regs) { struct interrupt_reg reg = interrupt_handlers[intr]; task_t* task = scheduler_get_current(); #ifdef INTERRUPTS_DEBUG debug("state before:\n"); dump_isf(LOG_DEBUG, regs); #endif if(reg.handler) { if(reg.can_reent) { interrupts_enable(); } reg.handler(regs); } #ifdef ENABLE_PICOTCP if(intr == IRQ(0)) { net_tick(); } #endif // Run scheduler every 100th tick, or when task yields if((intr == IRQ(0) && !(timer_get_tick() % 100)) || (task && task->interrupt_yield)) { if((task && task->interrupt_yield)) { task->interrupt_yield = false; } task_t* new_task = scheduler_select(regs); if(new_task && new_task->state) { #ifdef INTERRUPTS_DEBUG debug("state after (task selection):\n"); dump_isf(LOG_DEBUG, new_task->state); #endif gdt_set_tss(new_task->kernel_stack + PAGE_SIZE); return new_task->state; } } #ifdef INTERRUPTS_DEBUG debug("state after:\n"); dump_isf(LOG_DEBUG, regs); #endif return regs; }
static void _playback_start(void) { classd_volume_unmute(true, true); printf("<Playback Start>\r\n"); start_tick = timer_get_tick(); }