Exemple #1
0
void SysInit_ResetShutDownTimerHdl(UINT32 uiEvent)
{
   // checking whether power butter pressing or not
   if (rtc_getPWRStatus()==FALSE)
   {
       if(SysGetFlag(FL_MOVIE_PARKING) == MOVIE_PARKING_ON)
        {
              Gsensor_ClearCrashMode();			
		GSensor_ParkingMode();
		//Delay_DelayMs(100);
              debug_msg(">>----turn on Parking movie--------\r\n");		
	 }	   
      rtc_poweroffPWR();  
      while (1)
      {
          debug_err(("*"));
      }
   } else {
       if (guiResetSDTimerCount > RESET_SHUTDOWN_TIMER_COUNT)
       {
         // over 2 sec
         timer_close(guiResetShutDownTimerID);
       } else {
         guiResetSDTimerCount++;
         // reset shutdown timer once
         rtc_resetShutdownTimer();
       }
   }
}
void test::FSTestFixture::TearDown() {
	if (_initFlags & INIT_SHIPS) {
		ship_close();
	}

	if (_initFlags & INIT_GRAPHICS) {
		io::mouse::CursorManager::shutdown();

		bm_unload_all();

		gr_close(nullptr);
	}

	cfile_close();

	timer_close();

	lcl_close();

	os_cleanup();

#ifndef NDEBUG
	outwnd_close();
#endif

	// although the comment in cmdline.cpp said this isn't needed,
	// Valgrind disagrees (quite possibly incorrectly), but this is just cleaner
	if (Cmdline_mod != NULL) {
		delete[] Cmdline_mod;
		Cmdline_mod = NULL;
	}
}
Exemple #3
0
void* timerfd_timer_run_thread(rtdal_timer_t* obj) {
    int s;

    assert(obj->period_function);

    if (timer_setup(obj)) {
        aerror("Setting up timer");
        goto timer_destroy;
    }

    if (obj->wait_futex) {
        futex_wait(obj->wait_futex);
    }
    if (timer_start(obj)) {
        aerror("timer_start");
        goto timer_destroy;
    }

    obj->stop = 0;
    while(!obj->stop) {
        if (timer_wait_period(obj)) {
            aerror("waiting for timer");
            goto timer_destroy;
        }
        obj->period_function(obj->arg, NULL);
    }

    s = 0;

timer_destroy:
    timer_close(obj);
    pthread_exit(&s);
    return NULL;
}
Exemple #4
0
static int ntpd_stop(struct ntpd_param *param) {
	assert(param != NULL);

	if (param->running) {
		timer_close(param->tmr);
		close(param->sock);
		param->running = 0;
	}

	return 0;
}
Exemple #5
0
inline void handle_close (evHandle *h){
    if ((h->flags & HANDLE_CLOSING) != 0) return;
    h->flags |= HANDLE_CLOSING;
    if (h->type == EV_IO){
        io_close(h);
    } else if (h->type == EV_TIMER){
        timer_close(h);
    } else {
        assert(0 && "CLOSING UNKNOWN HANDLE\n");
    }
}
Exemple #6
0
/*
 * \brief Stop the timer.
 */
void GE_TimerClose()
{
#ifndef WIN32
  int tfd = timer_get();

  if(tfd >= 0)
  {
    ev_remove_source(tfd);
  }
#endif
  timer_close(0);
}
Exemple #7
0
int main()
{
	int ret = -1;
	u8 id, mode;


	//环境初始化
	inittest();

	//测试用例1
	id = 2;
	mode = TIMER_MODE_HEART;
	timer_init(id, mode);
	ret = timer_close(id);
	assert(ret == 0,"timer_close 1 error");

	//测试用例2
	id = 0;
	mode = TIMER_MODE_HEART;
	timer_init(id, mode);
	ret = timer_close(id);
	assert(ret == 0,"timer_close 2 error");

	//测试用例3
	id = 5;
	mode = TIMER_MODE_HEART;
	timer_init(id, mode);
	ret = timer_close(id);
	assert(ret == 0,"timer_close 3 error");

	//测试用例4
	id = 2;
	ret = timer_close(id);
	assert(ret == -ERR_NOINIT,"timer_close 4 error");

	finaltest();
	return 0;
}
Exemple #8
0
void handle_close (evHandle *h){
	if ((h->flags & HANDLE_CLOSING) != 0) return;
	if (h->type == EV_IO){
		io_close(h);
	} else if (h->type == EV_TIMER){
		timer_close(h);
	} else {
		handle_stop(h);
		h->flags |= HANDLE_CLOSING;
		QUEUE_REMOVE(&h->queue);
		QUEUE_INSERT_TAIL(&h->loop->closing_queue,
						  &h->queue);

		//closing un initaited handle
		//assert(0 && "CLOSING UNKNOWN HANDLE\n");
	}
}
int ksleep(useconds_t msec) {
	volatile int wait_flag; // for sleep func
	sys_timer_t timer;

	if(0 == msec) {
		return 0;
	}

	wait_flag = 1;

	if (timer_init_start_msec(&timer, TIMER_ONESHOT, msec , &wake_up, (void *) &wait_flag)) {
		return 1;
	}
	while (wait_flag) {
		arch_idle();
	}
	timer_close(&timer);
	return 0;
}
/**
  Play sound (beep) by using IO simulated PWM

  Play sound (beep) by using IO simulated PWM.
  Need timer function support.

  @param void
  @return void
*/
void GPIOMap_SoundTimerHdl(void)
{
    if (g_uiSoundPlayCnt%2)
    {
        gpio_setPin(GPIO_BEEP_PWMIOSIM);
    }
    else
    {
        gpio_clearPin(GPIO_BEEP_PWMIOSIM);
    }

    if (g_uiSoundPlayCnt == 0)
    {
        // Pause sound play timer
        timer_close(g_uiSoundPlayTimerID);
        return;
    }
    g_uiSoundPlayCnt --;
}
void test::FSTestFixture::TearDown() {
	if (_initFlags & INIT_CFILE) {
		if (_initFlags & INIT_SHIPS) {
			ship_close();
		}

		if (_initFlags & INIT_GRAPHICS) {
			if (_initFlags & INIT_FONTS) {
				font::close();
			}

			io::mouse::CursorManager::shutdown();

			bm_unload_all();

			gr_close();
		}

		if (_initFlags & INIT_MOD_TABLE) {
			// Reset mod settings again so that subsequent tests don't get broken
			mod_table_reset();
		}

		cfile_close();
	}

	timer_close();

	lcl_close();

	os_cleanup();

#ifndef NDEBUG
	outwnd_close();
#endif

	// although the comment in cmdline.cpp said this isn't needed,
	// Valgrind disagrees (quite possibly incorrectly), but this is just cleaner
	if (Cmdline_mod != NULL) {
		delete[] Cmdline_mod;
		Cmdline_mod = NULL;
	}
}
Exemple #12
0
Fichier : rbtest.c Projet : btb/d2x
int main()
{
	fix fsecs;
	int oldmin=-1, oldsec=-1;

	error_init(NULL, NULL);
	dpmi_init(0);
	timer_init();
	key_init();
	RBAInit();
	RBARegisterCD();
	RBAPlayTrack(2);

	fsecs = timer_get_fixed_seconds();
	do
	{
		int min, sec, frame;
		long headloc;

		if ((timer_get_fixed_seconds() - fsecs) >= F2_0) {
			headloc = RBAGetHeadLoc(&min, &sec, &frame);
			printf("Head loc: %d (%d:%d:%d)\n", headloc, min, sec, frame);
			if (min==oldmin && sec==oldsec) {
				printf("\nRepeating track..\n");
				RBAPlayTrack(2);
			}
			oldmin = min; oldsec = sec;
			fsecs = timer_get_fixed_seconds();
		}
		if (key_inkey()) {
			RBAStop();
			printf("\nCD stopped.\n");
			break;
		}
	}
	while (1); 

	key_close();
	timer_close();

	return 0;
}
Exemple #13
0
static void loop_run_timers(evLoop *loop) {
    struct heap_node *heap_node;
    evTimer *timer;
    for (;;) {
        loop_run_immediate(loop);
        heap_node = heap_min((struct heap*) &loop->timer_heap);
        if (heap_node == NULL) break;
        
        timer = container_of(heap_node, evTimer, heap_node);
        if (timer->timeout > loop->time) {
            break;
        }
        
        timer_again(timer->handle);
        timer->handle->cb(timer->handle);
        if (!timer->repeat || timer->repeat == 0) {
            timer_close(timer->handle);
        }
    }
}
Exemple #14
0
void SysInit_ResetShutDownTimerHdl(UINT32 uiEvent)
{
   // checking whether power butter pressing or not
   if (rtc_getPWRStatus()==FALSE)
   {
      rtc_poweroffPWR();
      while (1)
      {
          debug_err(("*"));
      }
   } else {
       if (guiResetSDTimerCount > RESET_SHUTDOWN_TIMER_COUNT)
       {
         // over 2 sec
         timer_close(guiResetShutDownTimerID);
       } else {
         guiResetSDTimerCount++;
         // reset shutdown timer once
         rtc_resetShutdownTimer();
       }
   }
}
Exemple #15
0
void main (void)
{
	unsigned int MyTimer, t,t1, t2, ot, myc;
	int i,s, b;

	key_init();

	//timer_init( 4661, NULL );
	timer_init( 0, NULL );

	s = TICKER;
	MyTimer = timer_get_microseconds();

	while(!keyd_pressed[KEY_ESC])
	{
		delay(1);
		ot =t;
		t = timer_get_milliseconds();
		t1 = (TICKER - s)*10000/182;
		//printf( "%d\t%d\t%u\t%d\t%u\t%u\t%u\n", (TICKER-s)*10000/182, myc, t, (int)t-(int)ot, key_down_time(KEY_G), key_down_count(KEY_G), key_up_count(KEY_G) );
		printf( "%u\t%u\t%d\n", t1, t, (int)t - (int)t1 );
	}

	t1 = timer_get_microseconds();
	delay(100);
	t2 = timer_get_microseconds();

	printf( "This number should be about 100000:  %d\n", t2-t1 );

	t1 = timer_get_microseconds();
	t2 = timer_get_microseconds();

	printf( "Overhead for 'timer_get_microseconds' call:  %d æSeconds\n", t2-t1 );


	timer_close();

}
Exemple #16
0
static void timer_handler(struct sys_timer *timer, void *param) {
	int ret;
	struct ntpd_param *param_;

	assert(timer != NULL);
	assert(param != NULL);

	param_ = param;

	if (!param_->replied && param_->poll < NTP_POLL_MAX) {
		++param_->poll;
		timer_close(param_->tmr);
		timer_set(&param_->tmr, TIMER_PERIODIC,
				(1 << param_->poll) * MSEC_PER_SEC,
				timer_handler, param);
	}

	param_->replied = 0;
	ret = send_request(param_);
	if (ret != 0) {
		printf("timer_handler: error: send_request return %d\n", ret);
	}
}
void sched_ticker_fini(void) {
	timer_close(sched_tick_timer);  // TODO err check?
}
Exemple #18
0
/***********************************************************************
 *
 * Function: c_entry
 *
 * Purpose: Application entry point from the startup code
 *
 * Processing:
 *     See function.
 *
 * Parameters: None
 *
 * Outputs: None
 *
 * Returns: Always returns 1
 *
 * Notes: None
 *
 **********************************************************************/
int c_entry(void)
{
  TMR_PSCALE_SETUP_T pscale;
  TMR_MATCH_SETUP_T msetup;

  /* Disable interrupts in ARM core */
  disable_irq_fiq();

  /* Set virtual address of MMU table */
  cp15_set_vmmu_addr((void *)
                     (IRAM_BASE + (256 * 1024) - (16 * 1024)));

  /* Initialize interrupt system */
  int_initialize(0xFFFFFFFF);

  /* Install standard IRQ dispatcher at ARM IRQ vector */
  int_install_arm_vec_handler(IRQ_VEC, (PFV) lpc32xx_irq_handler);

  /* Install timer interrupts handlers as a IRQ interrupts */
  int_install_irq_handler(IRQ_TIMER0, (PFV) timer0_user_interrupt);
  int_install_irq_handler(IRQ_TIMER1, (PFV) timer1_user_interrupt);

  /* Open timers - this will enable the clocks for all timers when
     match control, match output, and capture control functions
     disabled. Default clock will be internal. */
  timer0dev = timer_open(TIMER_CNTR0, 0);
  timer1dev = timer_open(TIMER_CNTR1, 0);

  /******************************************************************/
  /* Setup timer 0 for a 10Hz match rate                            */

  /* Use a prescale count time of 100uS                             */
  pscale.ps_tick_val = 0; /* Use ps_us_val value */
  pscale.ps_us_val = 100; /* 100uS */
  timer_ioctl(timer0dev, TMR_SETUP_PSCALE, (INT_32) &pscale);

  /* Use a match count value of 1000 (1000 * 100uS = 100mS (10Hz))  */
  msetup.timer_num = 0; /* Use match register set 0 (of 0..3) */
  msetup.use_match_int = TRUE; /* Generate match interrupt on match */
  msetup.stop_on_match = FALSE; /* Do not stop timer on match */
  msetup.reset_on_match = TRUE; /* Reset timer counter on match */
  msetup.match_tick_val = 999; /* Match is when timer count is 1000 */
  timer_ioctl(timer0dev, TMR_SETUP_MATCH, (INT_32) &msetup);

  /* Clear any latched timer 0 interrupts and enable match
   interrupt */
  timer_ioctl(timer0dev, TMR_CLEAR_INTS,
              (TIMER_CNTR_MTCH_BIT(0) | TIMER_CNTR_MTCH_BIT(1) |
               TIMER_CNTR_MTCH_BIT(2) | TIMER_CNTR_MTCH_BIT(3) |
               TIMER_CNTR_CAPT_BIT(0) | TIMER_CNTR_CAPT_BIT(1) |
               TIMER_CNTR_CAPT_BIT(2) | TIMER_CNTR_CAPT_BIT(3)));
  /******************************************************************/

  /******************************************************************/
  /* Setup timer 1 for a 4.9Hz match rate                           */

  /* Use a prescale count time of 100uS                             */
  pscale.ps_tick_val = 0; /* Use ps_us_val value */
  pscale.ps_us_val = 10; /* 100uS */
  timer_ioctl(timer1dev, TMR_SETUP_PSCALE, (INT_32) &pscale);

  /* Use a match value of 490 (490 * 100uS)                         */
  msetup.timer_num = 0; /* Use match register set 0 (of 0..3) */
  msetup.use_match_int = TRUE; /* Generate match interrupt on match */
  msetup.stop_on_match = FALSE; /* Do not stop timer on match */
  msetup.reset_on_match = TRUE; /* Reset timer counter on match */
  msetup.match_tick_val = 489;
  timer_ioctl(timer1dev, TMR_SETUP_MATCH, (INT_32) &msetup);

  /* Clear any latched timer 1 interrupts and enable match
   interrupt */
  timer_ioctl(timer1dev, TMR_CLEAR_INTS,
              (TIMER_CNTR_MTCH_BIT(0) | TIMER_CNTR_MTCH_BIT(1) |
               TIMER_CNTR_MTCH_BIT(2) | TIMER_CNTR_MTCH_BIT(3) |
               TIMER_CNTR_CAPT_BIT(0) | TIMER_CNTR_CAPT_BIT(1) |
               TIMER_CNTR_CAPT_BIT(2) | TIMER_CNTR_CAPT_BIT(3)));
  /******************************************************************/

  /* Enable timers (starts counting) */
  msecs = 0;
  timer_ioctl(timer0dev, TMR_ENABLE, 1);
  timer_ioctl(timer1dev, TMR_ENABLE, 1);

  /* Enable timer interrupts in the interrupt controller */
  int_enable(IRQ_TIMER0);
  int_enable(IRQ_TIMER1);

  /* Enable IRQ interrupts in the ARM core */
  enable_irq();

  /* Loop for 20 seconds and let interrupts toggle the LEDs */
  while (msecs < (10 * 1000));

  /* Disable timer interrupts in the interrupt controller */
  int_disable(IRQ_TIMER0);
  int_disable(IRQ_TIMER1);

  /* Disable interrupts in ARM core */
  disable_irq_fiq();

  /* Close timers */
  timer_close(timer0dev);
  timer_close(timer1dev);

  return 1;
}
Exemple #19
0
int stop_profiler(void) {
	is_running = false;
	timer_close(sampling_timer);
	return ENOERR;
}
//UINT32 PerfData[20];
void IPL_FCB_GetCapRawNormal(IPL_PROC_ID Id, IPC_SIE_Info *Info, IPLCTRL_CAP_EXT_INFO *ExtInfo)
{
    EXPOSURE_SETTING ExpTSetting;
    GAIN_SETTING Gain;
    SENSOR_MODE Mode;
    UINT32 Ratio;
    UINT32 capiso,capext,iris,Iris_Step;
#if MS_CTRLBY_TIMER
    TIMER_ID    TimerID_MS;
    ER  TimerState;

    TimerState = timer_open(&TimerID_MS, IPL_FCB_MshutterClose);
    if(TimerState != E_OK)
    {
        GRS_Mode = 0;
        DBG_ERR("Timer oper fail, use rolling shutter!");
    }
    else
    {
        GRS_Mode = 1;
    }
#endif
    //Perf_Open();

    SENSOR_ID SenId;
    SenId = IPL_UTI_CONV2_SEN_ID(Id);

    //change sensor mode to capture
    //IPC_WaitVD(FALSE,IPL_ID_1);
    AE_GetCapAEArg(&capiso, &capext, &iris);
    if (MainFlashInfo.TriggerEnable == ENABLE)
    {
        capiso = MainFlashInfo.Flash_Cap_ISO;
        capext = MainFlashInfo.Flash_Cap_ExpoTime;
    }

    switch(iris)
    {
        case AEALG_IRIS_0:
        default:
            Iris_Step = IRIS_POS_F1_8;
            break;
        case AEALG_IRIS_1:
            Iris_Step = IRIS_POS_F2_8;
            break;
        case AEALG_IRIS_2:
            Iris_Step = IRIS_POS_F4_0;
            break;
        case AEALG_IRIS_3:
            Iris_Step = IRIS_POS_F5_6;
            break;
        case AEALG_IRIS_4:
            Iris_Step = IRIS_POS_F8_0;
            break;
    }
    Lens_Aperture_Move(Iris_Step);
    Lens_Shutter_Move(MOTOR_SHUTTER_CAP, ENABLE);

    //IPC_WaitVD(TRUE,IPL_ID_1);
    //PerfData[0] = Perf_Mark();

    Sensor_ChgMode(SenId, IPL_AlgGetUIInfo(IPL_SEL_CAPSENMODE));
    //PerfData[1] = Perf_Mark();
    Sensor_GetCurMode(SenId, &Mode);
    Ratio = Sensor_GetExpoSetting(SenId, capext, Mode, &ExpTSetting);
    Sensor_GetGainSetting(SenId, (capiso * Ratio / 100), &Gain);
    Sensor_SetExpTime(SenId, &ExpTSetting);
    Sensor_SetGain(SenId, &Gain);
    //IPC_WaitVD(FALSE,Id);
    if(GRS_Mode)
    {
        IPL_FCB_MshutterConfig();
        if (MainFlashInfo.TriggerEnable == ENABLE)
            IPL_FCB_FlashCfg_Main(&MainFlashInfo);
        //IPC_WaitVD(FALSE);
        //PerfData[2] = Perf_Mark();
        Sensor_SetGRS(SenId);
        IPC_WaitVD(TRUE,Id);
        //IPH_ENG_WaitSignal(IPL_HAL_SIE,SIE_FLDEND,FALSE);
        //PerfData[3] = Perf_Mark();
#if MS_CTRLBY_TIMER
        timer_cfg(TimerID_MS, 51000, TIMER_MODE_ONE_SHOT | TIMER_MODE_ENABLE_INT, TIMER_STATE_PLAY);
#endif
        IPL_CTRLRunTimeChg(IPC_SIE_, (void*)Info);
        IPL_CTRLStop(IPC_RESUME_SIE);
#if (MS_CTRLBY_TIMER == 0)
    /*** need to calibrate the delay time and modify the control methold ***/
        if(SENSOR_MODE_2 == Mode)
            Delay_DelayUs(51000);
        else
            Delay_DelayUs(32000);

        IPL_FCB_MshutterClose(0);
    /***********************************************************/
#endif
    }
    else// ERS mode
    {
        IPL_CTRLRunTimeChg(IPC_SIE_, (void*)Info);
        if (MainFlashInfo.TriggerEnable == ENABLE)
        {
            IPL_FCB_FlashTrig(&MainFlashInfo);
        }
        IPC_WaitVD(FALSE,Id);
        IPL_CTRLStop(IPC_RESUME_SIE);
    }
    IPC_WaitVD(FALSE,Id);
    //IPH_ENG_WaitSignal(IPL_HAL_SIE,SIE_FLDEND,FALSE);
    //PerfData[4] = Perf_Mark();
    IPL_CTRLStop(IPC_PAUSE_SIE);
    IPC_WaitVD(FALSE,Id);
    //IPH_ENG_WaitSignal(IPL_HAL_SIE,SIE_FLDEND,FALSE);
    //PerfData[5] = Perf_Mark();
    if(GRS_Mode)
    {
        IPL_FCB_MshutterOpen();
        Delay_DelayMs(15);
        Lens_Shutter_Move(MOTOR_SHUTTER_CAP, DISABLE);
#if MS_CTRLBY_TIMER
        timer_close(TimerID_MS);
#endif
    }
    //DBG_ERR("Perf1: %d\r\n", PerfData[1]-PerfData[0]);
    //DBG_ERR("Perf2: %d\r\n", PerfData[2]-PerfData[1]);
    //DBG_ERR("Perf3: %d\r\n", PerfData[3]-PerfData[2]);
    //DBG_ERR("Perf4: %d\r\n", PerfData[4]-PerfData[3]);
    //DBG_ERR("Perf5: %d\r\n", PerfData[5]-PerfData[4]);
}
Exemple #21
0
/**
  Power off

  Power off. Add any code here that you want to do during power off flow.
  [KeyScan internal API]

  @param void
  @return void
*/
void KeyScan_PowerDelayTimerHdl(void)
{
    timer_close(guiKeyscanPowerDelayTimerID);
    guiKeyscanPowerDelay=FALSE;
}
Exemple #22
0
Fichier : testj.c Projet : btb/d2x
void main (void)
{
	unsigned int t1, t2;
	int i, start, stop, frames;
	short bd1, bd2, bu1, bu2, b, x, y, bt1, bt2;

	key_init();

	if (!joy_init())   {
		printf( "No joystick detected.\n" );
		key_close();
		exit(1);
	}

	timer_init( 0, NULL );

	printf( "Displaying joystick button transitions and time...any key leaves.\n" );

	i = 0;
	while( !key_inkey() )
	{
		i++;
		if (i>500000)    {
			i = 0;
			joy_get_btn_down_cnt( &bd1, &bd2 );
			joy_get_btn_up_cnt( &bu1, &bu2 );
			joy_get_btn_time( &bt1, &bt2 );
			printf( "%d  %d   %d   %d      T1:%d   T2:%d\n",bd1, bu1, bd2, bu2, bt1, bt2 );
		}
	}

	printf( "\nPress c to do a deluxe-full-fledged calibration.\n" );
	printf( "or any other key to just use the cheap method.\n" );

	if (key_getch() == 'c')    {
		printf( "Move stick to center and press any key.\n" );
		wait();
		joy_set_cen();

		printf( "Move stick to Upper Left corner and press any key.\n" );
		wait();
		joy_set_ul();

		printf( "Move stick to Lower Right corner and press any key.\n" );
		wait();
		joy_set_lr();
	}


	while( !keyd_pressed[KEY_ESC])
	{
		frames++;

		joy_get_pos( &x, &y );
		b = joy_get_btns();

		printf( "%d, %d   (%d %d)\n", x, y, b & 1, b & 2);

	}


	printf( "Testing joystick reading speed...\n" );
	t1 = timer_get_microseconds();
	joy_get_pos( &x, &y );
	t2 = timer_get_microseconds();

	printf( "~ %u æsec per reading using Timer Timing\n", t2 - t1 );

	joy_close();
	key_close();
	timer_close();

	frames = 1000;
	start = TICKER;
	for (i=0; i<frames; i++ )
		joy_get_pos( &x, &y );

	stop = TICKER;

	printf( "~ %d æsec per reading using BIOS ticker as a stopwatch.\n", USECS_PER_READING( start, stop, frames ) );


}
Exemple #23
0
main()
{
	unsigned int t1, t2, fastest;
	unsigned int timeb1v, timeb2v, timeb4v, timeb1s, timeb2s, timeb4s;
	unsigned int timew1v, timew2v, timew4v, timew1s, timew2s, timew4s;
	unsigned int timed1v, timed2v, timed4v, timed1s, timed2s, timed4s;

	gr_init( 0 );

	timer_init( 0, NULL );


	TempBuffer1 = (unsigned char *)(((unsigned int)TempBufferX+0xF) & 0xFFFFFFF0);

	System4  = (unsigned char *)(((unsigned int)TempBuffer2+0xF) & 0xFFFFFFF0);
	System2  = (unsigned char *)((unsigned int)System4 + 2);
	System1  = (unsigned char *)((unsigned int)System4 + 1);



	Video4 = (unsigned char *)0xA0000;
	Video2 = (unsigned char *)0xA0002;
	Video1 = (unsigned char *)0xA0001;


	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, Video1, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, Video1, 320*200);
	t2 = timer_get_microseconds();
	fastest = t2-t1;
	if ((t2-t1) < fastest) fastest = t2-t1;
	timeb1v = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, Video2, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, Video2, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timeb2v = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, Video4, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, Video4, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timeb4v = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, System1, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, System1, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timeb1s = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, System2, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, System2, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timeb2s = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, System4, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsb(TempBuffer1, System4, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timeb4s = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, Video1, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, Video1, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timew1v = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, Video2, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, Video2, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timew2v = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, Video4, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, Video4, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timew4v = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, System1, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, System1, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timew1s = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, System2, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, System2, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timew2s = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, System4, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsw(TempBuffer1, System4, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timew4s = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, Video1, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, Video1, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timed1v = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, Video2, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, Video2, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timed2v = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, Video4, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, Video4, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timed4v = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, System1, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, System1, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timed1s = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, System2, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, System2, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timed2s = t2 - t1;

	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, System4, 320*200);
	t2 = timer_get_microseconds();
	t1 = timer_get_microseconds();
	gr_linear_movsd(TempBuffer1, System4, 320*200);
	t2 = timer_get_microseconds();
	if ((t2-t1) < fastest) fastest = t2-t1;
	timed4s = t2 - t1;

	timer_close();
	gr_close();

	printf( "Relative memory move speeds: \n\n" );
	printf( "           Vid1  Vid2  Vid4  Sys1  Sys2  Sys4\n" );
	printf( "REP MOVSB: %#2.2f  %#2.2f  %#2.2f  %#2.2f  %#2.2f  %#2.2f\n", RelTime(timeb1v),RelTime(timeb2v),RelTime(timeb4v), RelTime(timeb1s),RelTime(timeb2s),RelTime(timeb4s) );
	printf( "REP MOVSW: %#2.2f  %#2.2f  %#2.2f  %#2.2f  %#2.2f  %#2.2f\n", RelTime(timew1v),RelTime(timew2v),RelTime(timew4v), RelTime(timew1s),RelTime(timew2s),RelTime(timew4s) );
	printf( "REP MOVSD: %#2.2f  %#2.2f  %#2.2f  %#2.2f  %#2.2f  %#2.2f\n", RelTime(timed1v),RelTime(timed2v),RelTime(timed4v), RelTime(timed1s),RelTime(timed2s),RelTime(timed4s) );

	printf( "\nA 1.00 corresponds to %d microseconds to move 320x200 unsigned chars.\n", fastest );

	return;
}
Exemple #24
0
/**
  BurnIn main loop

  BurnIn main loop
  [CalBurnIn internal API]

  @param UINT32 uiOperation: Which operation you want to run
    BURNIN_OP_BURNIN            (Burn In)
    BURNIN_OP_ZOOMAF            (ZoomAF Lasting)
    BURNIN_OP_FLASH             (Flash Lasting)
    BURNIN_OP_168H              (168H)
  @return void
*/
static void Cal_BurnIn(UINT32 uiOperation)
{
    //#NT#2009/09/01#KS Hung -begin
    FLGPTN      uiFlag;
    UINT32      uiTimerID;
    //#NT#2009/09/01#KS Hung -end
    UINT32      uiKeyFlagID, uiKeyEvent;
//    UINT32      uiOldPressConfig, uiOldReleaseConfig;
    UINT32      uiTotalIteration;
    UINT32      uiInterval;
    UINT32      uiEventCnt;
    PSIM_EVENT  pSimEvent, pStartEvent;
    UINT8       uiKeyStatus, uiRepeatCnt;


    // Disable scan key function of KeySacn task
    /*
    uiOldPressConfig = get_scankey_press_config();
    uiOldReleaseConfig = get_scankey_release_config();
    set_scankey_press_config(0x00);
    set_scankey_release_config(0x00);
    */

    // Open timer
    if (timer_open((UINT *)&uiTimerID, Cal_BurnInTimerISR) != E_OK)
    {
        /*
        set_scankey_press_config(uiOldPressConfig);
        set_scankey_release_config(uiOldReleaseConfig);
        */
        return;
    }

    // Set image size to VGA, quality to economy and Drive mode to single;
    /*
    gMenuPhotoInfo.uiIMGSize        = IMGSIZE_VGA;
    gMenuPhotoInfo.uiQuality        = IMGQUAL_ECONOMY;
    gMenuPhotoInfo.uiDriveMode      = IMGDRIVE_SINGLE;
    gMenuSetupInfo.uiAutoPowerOff   = AUTOPOWEROFF_OFF;

    Set_ImageInfo_IMGSize(gMenuPhotoInfo.uiIMGSize);
    Set_ImageInfo_Quality(gMenuPhotoInfo.uiQuality);
    Set_ImageInfo_DriveMoce(gMenuPhotoInfo.uiDriveMode);
    */

    switch (uiOperation)
    {
    case BURNIN_OP_BURNIN:
        uiTotalIteration    = 30;
        pStartEvent         = (PSIM_EVENT)&BurnInEvent;
        break;

    case BURNIN_OP_ZOOMAF:
        uiTotalIteration    = 1000;
        pStartEvent         = (PSIM_EVENT)&ZoomAFEvent;
        Primary_ChangeMode(PRIMARY_MODE_PHOTO);
        break;

    case BURNIN_OP_FLASH:
        uiTotalIteration    = 500;
        pStartEvent         = (PSIM_EVENT)&FlashEvent;
        Primary_ChangeMode(PRIMARY_MODE_PHOTO);
        break;

    case BURNIN_OP_168H:
        uiTotalIteration    = 0xFFFFFFFF;
        pStartEvent         = (PSIM_EVENT)&BurnInEvent;
        break;
    }

    // Init variable
    uiTimeoutValue  = 0;

    // Enable timer and clear all flags
    clr_flg(FLG_ID_BURNIN, FLGBURNIN_ALL);
    timer_set(uiTimerID, TIMER_INTERVAL, _TIMER_CTRL_FREE_RUN | _TIMER_CTRL_INT_ENABLE, _TIMER_PLAY);

    for (uiIteration=1; uiIteration<=uiTotalIteration; uiIteration++)
    {
        Cal_BurnInShowLoop(uiIteration, uiEventCnt);
        debug_ind(("\n\r ***Loop = %ld,Event= %ld ***\r\n", uiIteration, uiEventCnt));
        pSimEvent   = pStartEvent;
        uiRepeatCnt = 0;
        uiInterval  = 0;
        uiEventCnt  = 0;
        while (1)
        {
            if (pSimEvent == pStartEvent)
            {
                switch (uiOperation)
                {
                case BURNIN_OP_BURNIN:
                    // Set Flash Auto, disable Ditital Zoom and set AV F2.8
                    /*
                    gMenuPhotoInfo.uiFlashMode      = IMGFLASH_AUTO;
                    gMenuPhotoInfo.uiISDigitalZoom  = IMGDZ_OFF;
                    gMenuPhotoInfo.uiFValue         = 0;

                    Set_ImageInfo_FlashMode(gMenuPhotoInfo.uiFlashMode);
                    MenuOff_ShowFlash(gMenuPhotoInfo.uiFlashMode);

                    Set_ImageInfo_FValue(gMenuPhotoInfo.uiFValue);
                    */
                    break;

                case BURNIN_OP_ZOOMAF:
                    // Disable Flash and Ditital Zoom
                    /*
                    gMenuPhotoInfo.uiFlashMode      = IMGFLASH_FORCEOFF;
                    gMenuPhotoInfo.uiISDigitalZoom  = IMGDZ_OFF;

                    Set_ImageInfo_FlashMode(gMenuPhotoInfo.uiFlashMode);
                    MenuOff_ShowFlash(gMenuPhotoInfo.uiFlashMode);
                    */
                    break;

                case BURNIN_OP_FLASH:
                    // Enable Flash and disable Ditital Zoom
                    /*
                    gMenuPhotoInfo.uiFlashMode      = IMGFLASH_FORCEON;
                    gMenuPhotoInfo.uiISDigitalZoom  = IMGDZ_OFF;

                    Set_ImageInfo_FlashMode(gMenuPhotoInfo.uiFlashMode);
                    MenuOff_ShowFlash(gMenuPhotoInfo.uiFlashMode);
                    */
                    break;

                default:
                    break;
                }
            }

            wai_flg((FLGPTN *)&uiFlag, FLG_ID_BURNIN, FLGBURNIN_TIMER, TWF_ORW | TWF_CLR);

            uiInterval += TIMER_INTERVAL;
            if (uiInterval >= pSimEvent->uiInterval)
            {
                /*
                if (pSimEvent->uiKeyEvent == FLGKEY_SHUTTER2 &&
                    gMenuPhotoInfo.uiFlashMode != IMGFLASH_FORCEOFF &&
                    gucLastDialMode != FLGOPMODE_MOVIE &&
                    gucLastDialMode != FLG_BURNIN_SETUP &&
                    VolDetGetFlashLevel() == FLASH_LEVEL_EMPTY)
                {
                    if (uiInterval < ((TIMER_INTERVAL << 1) + pSimEvent->uiInterval))
                    {
                        debug_wrn(("Wait for flash voltage to be full\r\n"));
                    }

                    // Check timeout
                    if (uiInterval >= (FLASH_TIMEOUT + pSimEvent->uiInterval))
                    {
                        debug_err(("Wait for flash voltage to be full timeout\r\n"));
                    }
                    else
                    {
                        continue;
                    }
                }
                */

                uiInterval = 0;

                // Wait for specific flag, or change mode
                if (pSimEvent->uiKeyFlagID == FLG_ID_BURNIN)
                {
                    if (pSimEvent->uiKeyEvent == FLGBURNIN_WAITING)
                    {
                        // Enable timeout
                        uiTimeoutValue  = WAITING_TIMEOUT;
                        uiTimerCnt      = 0;
                        clr_flg(FLG_ID_BURNIN, FLGBURNIN_TIMEOUT);

                        wai_flg((FLGPTN *)&uiFlag, FLG_ID_BURNIN, pSimEvent->uiKeyEvent | FLGBURNIN_TIMEOUT, TWF_ORW | TWF_CLR);

                        if (uiFlag & FLGBURNIN_TIMEOUT)
                        {
                            debug_err(("Wait for specific flag timeout\r\n"));
                        }

                        // Disable timeout
                        uiTimeoutValue = 0;

                        // Clear timer flag
                        clr_flg(FLG_ID_BURNIN, FLGBURNIN_TIMER);

                        uiRepeatCnt = 0;
                        pSimEvent++;
                        uiEventCnt++;
                        debug_ind(("\n\r ***Loop = %ld,Event= %ld ***\r\n", uiIteration, uiEventCnt));
                        continue;
                    }
                    else
                    {
                        switch (pSimEvent->uiKeyEvent)
                        {
                        case FLGBURNIN_MODE_PHOTO:
                            Primary_ChangeMode(PRIMARY_MODE_PHOTO);
                            break;

                        case FLGBURNIN_MODE_ASF:
                            Primary_ChangeMode(PRIMARY_MODE_MOVIE);// ther is no PRIMARY_MODE_ASF);
                            break;
                        case FLGBURNIN_MODE_PLAYBACK:
                            Primary_ChangeMode(PRIMARY_MODE_PLAYBACK);
                            break;
                        case FLGBURNIN_MODE_SETUP:
                            Primary_ChangeMode(PRIMARY_MODE_SETUP);
                            break;
                        }
                    }
                }

                // End of event
                if (pSimEvent->uiKeyFlagID == SIM_END)
                    break;

                uiKeyFlagID = pSimEvent->uiKeyFlagID;
                uiKeyEvent  = pSimEvent->uiKeyEvent;
                uiKeyStatus = pSimEvent->uiKeyStatus;
                uiRepeatCnt++;

                // Move to next event
                if (uiRepeatCnt == pSimEvent->uiRepeatCnt)
                {
                    uiRepeatCnt = 0;
                    pSimEvent++;
                    uiEventCnt++;
                    debug_ind(("******************Loop = %ld,Event= %ld ***************\r\n", uiIteration, uiEventCnt));
                }

                // Set key event
                /*
                if (uiKeyFlagID != NULL && uiKeyEvent != NULL)
                {
                    if (uiKeyStatus == KEY_STATUS_PRESS)
                    {
                        set_key_status(uiKeyEvent);
                    }
                    else
                    {
                        set_key_status(~uiKeyEvent);
                    }
                    set_flg(uiKeyFlagID, uiKeyEvent);
                }
                */
            }
            Cal_BurnInShowLoop(uiIteration, uiEventCnt);

        }
    }

    timer_close(uiTimerID);
    /*
    set_scankey_press_config(uiOldPressConfig);
    set_scankey_release_config(uiOldReleaseConfig);
    */

    // Power off DSC after burn in done
    // Premier don't want to power off now (2005.10.16)
    /*
    if (uiOperation == BURNIN_OP_BURNIN)
    {
        PowerOffFlow(TRUE, FALSE);
    }
    */
}