PROCESS_THREAD(oled_temp_process, ev, data) { static struct etimer sensors_timer; PROCESS_BEGIN(); draw_init(); draw_clear(); onewire_init(); etimer_set(&sensors_timer, READ_INTERVAL); timer_callback(); while(1) { PROCESS_YIELD(); if(etimer_expired(&sensors_timer)) { timer_callback(); etimer_set(&sensors_timer, READ_INTERVAL); } } PROCESS_END(); }
static cyg_uint32 sys_timer_isr(cyg_vector_t vector, cyg_addrword_t data) { ++sys_timer_ticks; #ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF HAL_CLOCK_RESET(CYGNUM_HAL_INTERRUPT_RTC, set_period); #else HAL_CLOCK_RESET(CYGNUM_HAL_INTERRUPT_RTC, CYGNUM_HAL_RTC_PERIOD); #endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF cyg_drv_interrupt_acknowledge(CYGNUM_HAL_INTERRUPT_RTC); #ifdef CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF if ( timer_callback ) { char *intrpc = (char *)0; char *intrsp = (char *)0; // There may be a number of ways to get the PC and (optional) SP // information out of the HAL. Hence this is conditioned. In some // configurations, a register-set pointer is available as // (invisible) argument 3 to this ISR call. #ifdef HAL_GET_PROFILE_INFO HAL_GET_PROFILE_INFO( intrpc, intrsp ); #endif // HAL_GET_PROFILE_INFO available CYGARC_HAL_SAVE_GP(); timer_callback( intrpc, intrsp ); CYGARC_HAL_RESTORE_GP(); } #endif // CYGSEM_REDBOOT_BSP_SYSCALLS_GPROF return CYG_ISR_HANDLED; }
int timer__cancel_impl(CORBA_Object _caller, objref_t timer_obj, idl4_server_environment * _env) { struct timer *timer = (struct timer *)timer_obj; struct driver *device = timer->timer_service->device; int is_start = (timer->prev == NULL); struct timer *next_timer = timer->next; if (timer->state == timer_cancelled_e) return 1; assert(is_start ? timer->timer_service->active == timer : 1); assert(next_timer == NULL ? timer->timer_service->active_end == timer : 1); /* Inactivate timer */ deactivate_timer(timer); if (is_start) { if (next_timer) { /* Timeout at next registered time */ if (timer_timeout (device, next_timer->timeout, timer_callback, 0, (uintptr_t)next_timer)) { timer_callback(0, 0, NULL, (uintptr_t)timer); } } else { /* Never timeout -- nothing left in list */ timer_timeout(device, -1, NULL, 0, (uintptr_t)0); } } return 0; }
/* Prepares the first frame of animation */ static void draw_first_frame(void) { VMUINT8* img_data; VMUINT32 img_size; vm_graphic_color_argb_t color; /* draw background image */ //img_data = vm_res_get_image(IMG_ID_BG, &img_size); //vm_graphic_draw_image_memory(g_frame_group[0], 0, 0, img_data, img_size, 0); /* draw a purple horizontal blue line from center of screen */ color.a = 255; color.r = 0; color.g = 0; color.b = 255; vm_graphic_set_color(color); vm_graphic_draw_solid_rectangle(&g_temp_frame, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); color.r = 255; vm_graphic_set_color(color); vm_graphic_draw_line(&g_temp_frame, SCREEN_WIDTH / 2, SCREEN_HEIGHT / 2, SCREEN_WIDTH / 2 + LINE_LENGTH - 1, SCREEN_HEIGHT / 2); /* create animation timer */ g_timer_id = vm_timer_create_precise(100, timer_callback, NULL); theta = 0; /* explicitly trigger 1st frame */ timer_callback(g_timer_id, NULL); }
void xadapter_timer_handler(void *p) { timer_callback(); XTime_TSRClearStatusBits(XREG_TSR_CLEAR_ALL); }
void z80ctc_device::ctc_channel::trigger(uint8_t data) { // normalize data data = data ? 1 : 0; // see if the trigger value has changed if (data != m_extclk) { m_extclk = data; // see if this is the active edge of the trigger if (((m_mode & EDGE) == EDGE_RISING && data) || ((m_mode & EDGE) == EDGE_FALLING && !data)) { // if we're waiting for a trigger, start the timer if ((m_mode & WAITING_FOR_TRIG) && (m_mode & MODE) == MODE_TIMER) { attotime curperiod = period(); VPRINTF_CHANNEL(("CTC period %s\n", curperiod.as_string())); m_timer->adjust(curperiod, m_index, curperiod); } // we're no longer waiting m_mode &= ~WAITING_FOR_TRIG; // if we're clocking externally, decrement the count if ((m_mode & MODE) == MODE_COUNTER) { // if we hit zero, do the same thing as for a timer interrupt if (--m_down == 0) timer_callback(nullptr,0); } } } }
/** * \brief Main function. * * Initializes the board, and runs the application in an infinite loop. */ int main(void) { /* hardware initialization */ sysclk_init(); board_init(); pmic_init(); timer_init(); rs485_init(); led_init(); adc_init(); #ifdef CONF_BOARD_ENABLE_RS485_XPLAINED // Enable display backlight gpio_set_pin_high(NHD_C12832A1Z_BACKLIGHT); #endif // Workaround for known issue: Enable RTC32 sysclk sysclk_enable_module(SYSCLK_PORT_GEN, SYSCLK_RTC); while (RTC32.SYNCCTRL & RTC32_SYNCBUSY_bm) { // Wait for RTC32 sysclk to become stable } cpu_irq_enable(); /* application initialization */ rs485_baud_rate_set(38400); bacnet_init(); /* run forever - timed tasks */ timer_callback(bacnet_task_timed, 5); for (;;) { bacnet_task(); led_task(); } }
void dispatch_once(struct event_base* base) { dns = NULL; /* Using a blocking dns here else it'll never quit :/ FIXME */ struct server* node = global_config.servers; while (node) { timer_callback(-1, 1, node); node = node->next; }; };
int run(void) { seL4_CPtr aep = timeout_aep(); while(1) { seL4_Wait(aep, NULL); timer_callback(NULL); } return 0; }
GUI::GUI( QWidget * parent ) : QGLWidget( parent ), timer() { setMinimumSize( 600, 600 ); timer = new QTimer( this ); connect( timer, SIGNAL( timeout() ), this, SLOT( timer_callback() ) ); timer->start( 100 ); // call timer_callback at 0.1 Hz (period is 100 ms) GUI::quaternion.resize(4); //ector<float> quaternion(4); }
acl_int64 event_timer::trigger(void) { // sanity check if (tasks_.empty()) return TIMER_EMPTY; acl_assert(length_ > 0); set_time(); std::list<event_task*> tasks; // 从定时器中取出到达的定时任务 for (std::list<event_task*>::iterator it = tasks_.begin(); it != tasks_.end();) { if ((*it)->when > present_) break; tasks.push_back(*it); it = tasks_.erase(it); length_--; } if (tasks.empty()) { acl_assert(!tasks_.empty()); event_task* first = tasks_.front(); acl_int64 delay = first->when - present_; return delay < 0 ? 0 : delay; } for (std::list<event_task*>::iterator it = tasks.begin(); it != tasks.end(); ++it) { set_task(*it); // 调用子类虚函数,触发定时器任务过程 timer_callback((*it)->id); } tasks.clear(); // 子类有可能会在 timer_callback 中删除了所有的定时任务 if (tasks_.empty()) return TIMER_EMPTY; event_task* first = tasks_.front(); acl_int64 delay = first->when - present_; if (delay < 0) return 0; else if (delay > first->delay) /* xxx */ return first->delay; else return delay; }
static void main_window_load(Window *window) { Layer *window_layer = window_get_root_layer(window); graphics_layer = layer_create(layer_get_frame(window_layer)); layer_set_update_proc(graphics_layer, graphics_layer_update); layer_add_child(window_layer, graphics_layer); max_width = layer_get_bounds(graphics_layer).size.w - 1; max_height = layer_get_bounds(graphics_layer).size.h - 1; timer_callback(NULL); // Start the main loop! }
/** * Resets / Initializes all the Game Variables */ void window_appear(Window *window) { if (!status.first) do_some_cleanup(); status.pos = 0; status.size = 3; status.points = 0; status.speed = TIME_INTERVAL; status.level = ROWS; status.left = true; status.first = false; status.end = false; status.zigzag = false; status.lastLeft = false; status.boxes = malloc(sizeof(GPoint) * 3); status.boxes[0] = GPoint(status.level, (status.pos - 1)); status.boxes[1] = GPoint(status.level, status.pos); status.boxes[2] = GPoint(status.level, (status.pos + 1)); int i; status.sizes[0] = status.size; for (i=1;i<ROWS;i++) { status.sizes[i] = 0; } int r; for (r=0;r<ROWS;r++) { status.storage[r] = NULL; } if (status.difficulty == HARD) { status.speeds[0] = 10; status.speeds[1] = 20; status.speeds[2] = 30; status.speeds[3] = 40; status.speeds[4] = 50; status.speeds[5] = 60; } else if (status.difficulty == NORMAL) { status.speeds[0] = 30; status.speeds[1] = 40; status.speeds[2] = 50; status.speeds[3] = 60; status.speeds[4] = 70; status.speeds[5] = 80; } else if (status.difficulty == EASY) { status.speeds[0] = 50; status.speeds[1] = 60; status.speeds[2] = 70; status.speeds[3] = 80; status.speeds[4] = 90; status.speeds[5] = 100; } // Initializates the Timer timer_callback(NULL); }
void xadapter_fasttimer_handler(void) { timer_callback(); /* Load timer, clear interrupt bit */ XTmrCtr_SetControlStatusReg(PLATFORM_TIMER_BASEADDR, 0, XTC_CSR_INT_OCCURED_MASK | XTC_CSR_LOAD_MASK); XTmrCtr_SetControlStatusReg(PLATFORM_TIMER_BASEADDR, 0, XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK | XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK); }
acl_int64 event_timer::trigger(void) { // sanity check if (tasks_.empty()) return TIMER_EMPTY; acl_assert(length_ > 0); set_time(); std::list<event_task*>::iterator it, next; std::list<event_task*> tasks; event_task* task; // 从定时器中取出到达的定时任务 for (it = tasks_.begin(); it != tasks_.end(); it = next) { if ((*it)->when > present_) break; next = it; ++next; task = *it; tasks_.erase(it); length_--; tasks.push_back(task); } // 有可能这些到达的定时任务已经被用户提前删除了 if (tasks.empty()) { acl_assert(!tasks_.empty()); event_task* first = tasks_.front(); acl_int64 delay = first->when - present_; return delay < 0 ? 0 : delay; } for (it = tasks.begin(); it != tasks.end(); ++it) { set_task(*it); // 调用子类虚函数,触发定时器任务过程 timer_callback((*it)->id); } tasks.clear(); // 子类有可能会在 timer_callback 中删除了所有的定时任务 if (tasks_.empty()) return TIMER_EMPTY; event_task* first = tasks_.front(); acl_int64 delay = first->when - present_; return delay < 0 ? 0 : delay; }
void nb1413m3_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) { switch (id) { case TIMER_CB: timer_callback(ptr, param); break; default: assert_always(false, "Unknown id in nb1413m3_device::device_timer"); } }
int timer_obj_tick(timer_obj_t t) { if (t->m_cycl_tick > 0) { t->m_current_tick--; } if (t->m_current_tick == 0) { timer_callback(t->mTimer_callback); return 1; } else { return 0; } }
/* Return true if we waited */ bool gps_wait_fix(uint16_t timeout) { Timer ttimer; if (is_fixed) return false; if (timeout > 0) { timer_set(&ttimer, timeout); timer_callback(&ttimer, (CBfunc) notifyAll, &wait_gps); } wait(&wait_gps); timer_cancel(&ttimer); return true; }
void xadapter_timer_handler(void *p) { //unsigned *timer_base = (unsigned *)PLATFORM_TIMER_BASEADDR; //unsigned tcsr = 0; timer_callback(); /* Load timer, clear interrupt bit */ XTmrCtr_SetControlStatusReg(PLATFORM_TIMER_BASEADDR, 0, XTC_CSR_INT_OCCURED_MASK | XTC_CSR_LOAD_MASK); XTmrCtr_SetControlStatusReg(PLATFORM_TIMER_BASEADDR, 0, XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK | XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK); XIntc_AckIntr(XPAR_INTC_0_BASEADDR, PLATFORM_TIMER_INTERRUPT_MASK); }
uint64_t timer__request_impl(CORBA_Object _caller, objref_t timer_obj, uint64_t time, int flags, idl4_server_environment * _env) { struct timer *timer = (struct timer *)timer_obj; struct driver *device = timer->timer_service->device; uint64_t abs_time; int is_earliest; if (timer->state != timer_cancelled_e) { /* We need to cancel the timer first */ timer__cancel_impl(_caller, timer_obj, _env); } abs_time = time; if (!(flags & TIMER_ABSOLUTE)) { abs_time += timer_current_time(device); } if (flags & TIMER_PERIODIC) { if (flags & TIMER_ABSOLUTE) { return -1; } timer->state = timer_periodic_e; timer->period = time; } else { timer->state = timer_oneshot_e; } timer->timeout = abs_time; is_earliest = make_active(timer); // debug_active(timer); /* Set a request for that point in time */ if (is_earliest) { if (timer_timeout (device, abs_time, timer_callback, 0, (uintptr_t)timer)) { timer_callback(0, 0, NULL, (uintptr_t)timer); } } return abs_time; }
static gboolean start_callback (GkmTransaction *transaction, GObject *obj, gpointer user_data) { GkmObject *self = GKM_OBJECT (obj); GkmObjectTransient *transient; GTimeVal tv; g_return_val_if_fail (GKM_IS_OBJECT (self), FALSE); g_return_val_if_fail (self->pv->transient, FALSE); transient = self->pv->transient; g_return_val_if_fail (!transient->timer, FALSE); g_get_current_time (&tv); transient->stamp_created = tv.tv_sec; transient->stamp_used = tv.tv_sec; /* Start the timer going */ timer_callback (NULL, self); return TRUE; }
acl_int64 aio_timer_callback::trigger(void) { // sanity check if (tasks_.empty()) return TIMER_EMPTY; acl_assert(length_ > 0); set_time(); std::list<aio_timer_task*>::iterator it, next; std::list<aio_timer_task*> tasks; aio_timer_task* task; // 从定时器中取出到达的定时任务 for (it = tasks_.begin(); it != tasks_.end(); it = next) { if ((*it)->when > present_) break; next = it; ++next; task = *it; tasks_.erase(it); length_--; tasks.push_back(task); } // 有可能这些到达的定时任务已经被用户提前删除了 if (tasks.empty()) { acl_assert(!tasks_.empty()); aio_timer_task* first = tasks_.front(); acl_int64 delay = first->when - present_; return delay < 0 ? 0 : delay; } // 将到达的定时任务重新放回至定时器的任务列表中, // 并开始触发所有的到达的定时任务 // 必须先设置触发器的忙状态,以防止子类在回调过程 // 中调用了该类对象的析构过程 set_locked(); // 设置解锁后销毁标志为 false,因为当前该定时器处于 // 锁定状态,所以其它类对象不能直接在锁定时销毁本类 // 对象,当解锁后,如果该标识被置为 true,则本类对象 // 应该自动销毁 destroy_on_unlock_ = false; for (it = tasks.begin(); it != tasks.end(); ++it) { set_task(*it); timer_callback((*it)->id); } tasks.clear(); // 允许之后的操作中被子类调用析构过程 unset_locked(); // 子类有可能会在 timer_callback 中删除了所有的定时任务 if (tasks_.empty()) return TIMER_EMPTY; aio_timer_task* first = tasks_.front(); acl_int64 delay = first->when - present_; // 如果在加锁期间外部程序要求释放该对象,则在此处释放 if (destroy_on_unlock_) { destroy(); return -1; } return delay < 0 ? 0 : delay; }
void *thread_callback(void *session) { sleep(5); timer_callback(session); pthread_exit(NULL); }
void* timer_thread(void* arg) { while(1) { sleep(key_poll_period); timer_callback(); } }