Пример #1
0
void KeyScan_PowerDelay(void)
{
    if (timer_open((UINT *)&guiKeyscanPowerDelayTimerID, KeyScan_PowerDelayTimerHdl) != E_OK)
        return;
    debug_err(("*********KeyScan_PowerDelay ----- \r\n"));	
    timer_set(guiKeyscanPowerDelayTimerID, 800, _TIMER_CTRL_ONE_SHOT | _TIMER_CTRL_INT_ENABLE, _TIMER_PLAY);
}
Пример #2
0
void timer_query_driven_test( uint8 id )
{
	TiTimerAdapter *timer;
	timer = timer_construct( (void *)&g_timer, sizeof(g_timer) );
    timer_open( timer, id, NULL, NULL, 0x00 ); 
	timer_setinterval( timer,5, 1 );  //(timer,interval,repeat)  the range of the interval  1~8
	timer_start( timer );
//next is the function for the query model
	int i;

	while (1)
	{

        i=0;
        while(i<100)
        {
            // todo: maybe mistake here. shall we restart the timer manualy here?
		    if(timer_expired(timer))
		        i++;
		}
		led_toggle( LED_RED );
		led_toggle(LED_GREEN);
	}

  //  timer_close( timer );
}
Пример #3
0
int
ipe_init(void)
{
	spinlock_acquire(&ipe_init_alloc_lock);
	local_recv_buffer = remote_recv_buffer[lapic_id] =
		(ipe_packet_t *)KADDR_DIRECT(kalloc_pages(RBUF_PAGES));
	spinlock_release(&ipe_init_alloc_lock);
	
	eproc_open(&ipe_eproc, "ipe", (void(*)(void))proc_wait_try, NULL, 8192);
	event_open(ipe_event, &ipe_eproc.event_pool, do_ipe, NULL);
	event_open(&ipe_timer.event, &ipe_eproc.event_pool, do_ipe, NULL);
	timer_open(&ipe_timer, timer_tick + IPE_REFRESH_INV * timer_freq);

	/* ALL CPU BARRIER {{{ */	
	/* XXX: use naive CAS here =_= for atomic inc */
	while (1)
	{
		int old = ipe_ready;
		if (cmpxchg32(&ipe_ready, old, old + 1) == old) break;
	}
	
	while (ipe_ready != lcpu_count) ;
	/* }}} */
	
	return 0;
}
Пример #4
0
int kthread_init(const struct stack_struct *ss) {

  const int idle_task=0;
  const int boot_task=1;

  if((run_queue = kmalloc(sizeof *run_queue, GFP_KERNEL | GFP_ZERO))) {

    DEBUG_TRACE("%d = stack_check %x %x", stack_check(ss), ss->stack_base, ss->stack_size);
    spinlock_init(&run_queue->spinlock);
    run_queue->running = boot_task; 
		
    // create an empty kthread for the boot-task! UGLY!
    run_queue->kthreads[boot_task] = _kmalloc_kthread();
		
    if(run_queue->kthreads[boot_task]) {

      DEBUG_TRACE("%d = stack_check", stack_check(ss));

      // store boot_stack info.
      run_queue->kthreads[boot_task]->stack = *ss;
      
      irq_itf irq;
      if(timer_open(&run_queue->timer, &irq, 0)==0) {

	DEBUG_TRACE("");

        interrupt_controller_itf intc;
        if(interrupt_controller(&intc) == 0) {

	  DEBUG_TRACE("");

          INVOKE(intc, register_handler, irq);
          INVOKE(intc, unmask, irq);
	  
          goto success;
        }
      }
    }
  }

  goto err;

success:
  // start idle-task.
  if(_kthread_create(&run_queue->kthreads[idle_task], GFP_KERNEL, &_asm_idle_task, 0)==0)
  {
    DEBUG_TRACE("");
    _BUG_ON(!run_queue->kthreads[idle_task]);

    // UGLY - yield to self! current task is first, and only runnable thread right now.
    // we NEED to do this to populate the empty kthread we allocated for ourselves earier
    kthread_yield();

    return _sched_next_task(NULL);
  }
err:
  _BUG();
  return -1;
}
Пример #5
0
void SysInit_ResetShutDownTimer(void)
{
  // reset shutdown timer first
  rtc_resetShutdownTimer();

  if (timer_open((UINT *)&guiResetShutDownTimerID, SysInit_ResetShutDownTimerHdl) != E_OK)
     return;

  timer_cfg(guiResetShutDownTimerID, RESET_SHUTDOWN_TIMER_INTERVAL*1000, TIMER_MODE_FREE_RUN | TIMER_MODE_ENABLE_INT, TIMER_STATE_PLAY);
}
Пример #6
0
void GPIOMap_SoundPlayPWMIOSim(void)
{
    if (timer_open((UINT *)&g_uiSoundPlayTimerID, GPIOMap_SoundTimerHdl) != E_OK)
    {
        debug_err(("GPIOMap_SoundPlayPWMIOSim: Open timer failed\r\n"));
        return;
    }

    g_uiSoundPlayCnt = 400;
    timer_set_us(g_uiSoundPlayTimerID, 125, _TIMER_CTRL_FREE_RUN | _TIMER_CTRL_INT_ENABLE, _TIMER_PLAY);
}
Пример #7
0
void timer_interrupt_driven_test( uint8 id )
{ 
	TiTimerAdapter *timer;

	hal_enable_interrupts();
    timer = timer_construct( (void *)&g_timer, sizeof(g_timer) );
    timer_open( timer, id, on_timer_expired, NULL, 0x01 ); 
    timer_setinterval( timer, 1, 0 );  //(timer,interval,repeat)  the range of the interval  1~8
	timer_start( timer );
	
    while (1) {};
}
Пример #8
0
void timer_query_driven_test( uint8 id )
{
	TiTimerAdapter *timer;
	timer = timer_construct( (void *)&g_timer, sizeof(g_timer) );
    timer_open( timer, id, NULL, NULL, 0x00 ); 
	timer_setinterval( timer,5, 1 );  //(timer,interval,repeat)  the range of the interval  1~8
	timer_start( timer );
//next is the function for the query model
	int i;

	while (1)
	{

/*  		for(i=0;i<100;i++)              //
		{
//		   loop_until_bit_is_set(TIFR,OCF0);   
//		   TIFR=TIFR|0x02;  
		  // be caution: the flag should be clear after it is queried by set the OCF0 bit to be 1


		  //   loop_until_bit_is_set(TIFR,OCF2);		    
		  //	 TIFR=TIFR|0x80; 
		  	
		//	dbo_putchar(OCR1AH);
		//	dbo_putchar(OCR1AL);
			
		//	loop_until_bit_is_set(TIFR,OCF1A);
		//	TIFR =TIFR| (1 << OCF1A); 
		   // led_toggle(LED_GREEN);

		//	loop_until_bit_is_set(ETIFR,OCF3A);
		//	ETIFR =ETIFR| (1 << OCF3A); 
			}
*/
			i=0;
			while(i<100){
				if(timer_expired(timer))
							i++;

			}
		led_toggle( LED_RED );
		led_toggle(LED_GREEN);

	}

  //  timer_close( timer );
}
Пример #9
0
int Epoll_Watcher::open(void) {
	pending_io_map_.resize(max_fd(), (Event_Handler *)0);

	Heart_Map heart_map0(max_fd()), heart_map1(max_fd());
	io_heart_map_[0].swap(heart_map0);
	io_heart_map_[1].swap(heart_map1);

	if ((this->epfd_ = ::epoll_create(1)) == -1) {
		LOG_SYS("epoll_create");
		return -1;
	}

	timer_open();
	io_open();

	return 0;
}
Пример #10
0
void _ledremote(void)
{
    TiCc2420Adapter * cc;
	TiUartAdapter * uart;
	TiOpenFrame * opf;
	TiTimerAdapter *timer;

	char * msg = "welcome to _ledremote...";

	target_init();
	HAL_SET_PIN_DIRECTIONS();
	wdt_disable();

	led_open();
	led_off( LED_ALL );
	hal_delay( 500 );
	//led_on( LED_RED );

    timer = timer_construct( (void *)&g_timer, sizeof(g_timer) );
    timer_open( timer, 0, on_timer_expired, NULL, 0x01 ); 
    timer_setinterval( timer, 8, 1 );
	timer_start( timer );

	dbo_open(38400);


	uart = uart_construct( (void *)(&g_uart), sizeof(TiUartAdapter) );
	uart_open( uart, 0, 38400, 8, 1, 0x00 );
	uart_write( uart, msg, strlen(msg), 0x00 );

	cc = cc2420_construct( (void *)(&g_cc), sizeof(TiCc2420Adapter) );
	cc2420_open( cc, 0, _cc2420_listener, cc, 0x00 );
	cc2420_setchannel( cc, DEFAULT_CHANNEL );
	cc2420_enable_addrdecode( cc );				    //使能地址译码
	cc2420_setpanid( cc, PANID );				    //网络标识
	cc2420_setshortaddress( cc, LOCAL_ADDRESS );    //网内标识
	cc2420_enable_autoack(cc);

	opf = opf_open( (void *)(&g_opfmem), sizeof(g_opfmem), OPF_FRAMECONTROL_UNKNOWN, OPF_DEF_OPTION );

	hal_enable_interrupts();
 
	while(1) {};
}
Пример #11
0
/***********************************************************************
 *
 * Function: time_init
 *
 * Purpose: Initializes time system
 *
 * Processing: Initializes the system timer.
 *
 * Parameters: None
 *
 * Outputs: None
 *
 * Returns: 0 if the init failed, otherwise non-zero
 *
 * Notes: None
 *
 **********************************************************************/
INT_32 time_init(void)
{
	TMR_PSCALE_SETUP_T pscale;

	/* Open timer driver */
	if (tdev == 0)
	{
		tdev = timer_open((void *) TIMER_CNTR0, 0);
		if (tdev != 0)
		{
			/* Use a prescale count to 100000 */
			pscale.ps_tick_val = 100000;
			pscale.ps_us_val = 0; /* Not needed when ps_tick_val != 0 */
			timer_ioctl(tdev, TMR_SETUP_PSCALE, (INT_32) &pscale);

			/* Get timer clock rate */
			base_rate = (UNS_64) timer_ioctl(tdev, TMR_GET_STATUS,
				TMR_GET_CLOCK);
		}
	}

	return tdev;
}
Пример #12
0
static void
do_ipe(event_t e)
{
	int i;
	for (i = 0; i != RBUF_COUNT; ++ i)
	{
		if (local_recv_buffer[i])
		{
			ipe_packet_t packet = local_recv_buffer[i];
			if (packet->from_lapic == lapic_id)
			{
				ipe_packet_back_handle(packet);
			}
			else
			{
				if (packet->processed == 0)
				{
					packet->processed = 1;
					ipe_packet_handle(packet);
				}

				if (ipe_packet_send(packet->from_lapic, packet))
				{
					/* SEND ACK FAILED */
					continue;
				}
			}
			
			local_recv_buffer[i] = NULL;
		}
	}

	if (e == &ipe_timer.event)
	{
		timer_open(&ipe_timer, timer_tick + IPE_REFRESH_INV * timer_freq);
	}
}
Пример #13
0
int
main(int argc, char **argv)
{
    AVFormatContext *afc;
    AVStream *st;
    AVPacket pk;
    struct frame_format frame_fmt = { 0 };
    const struct pixconv *pixconv = NULL;
    const struct memman *memman = NULL;
    const struct codec *codec = NULL;
    struct frame_format dp;
    int bufsize = BUFFER_SIZE;
    pthread_t dispt;
    unsigned flags = OFBP_DOUBLE_BUF;
    char *test_param = NULL;
    char *dispdrv = NULL;
    char *timer_drv = NULL;
    char *memman_drv = NULL;
    char *pixconv_drv = NULL;
    char *codec_drv = NULL;
    int opt;
    int ret = 0;

#define error(n) do { ret = n; goto out; } while (0)

    while ((opt = getopt(argc, argv, "b:d:fFM:P:st:T:v:")) != -1) {
        switch (opt) {
        case 'b':
            bufsize = strtol(optarg, NULL, 0) * 1048576;
            break;
        case 'd':
            dispdrv = optarg;
            break;
        case 'F':
            noaspect = 1;
        case 'f':
            flags |= OFBP_FULLSCREEN;
            break;
        case 'M':
            memman_drv = optarg;
            break;
        case 'P':
            pixconv_drv = optarg;
            break;
        case 's':
            flags &= ~OFBP_DOUBLE_BUF;
            break;
        case 't':
            test_param = optarg;
            break;
        case 'T':
            timer_drv = optarg;
            break;
        case 'v':
            codec_drv = optarg;
            break;
        }
    }

    argc -= optind;
    argv += optind;

    if (test_param)
        return speed_test(dispdrv, memman_drv, pixconv_drv, test_param, flags);

    if (argc < 1)
        return 1;

    av_register_all();
    avcodec_register_all();

    afc = open_file(argv[0]);

    st = find_stream(afc);
    if (!st) {
        fprintf(stderr, "No video streams found.\n");
        exit(1);
    }

    codec = find_driver(codec_drv, NULL, ofbp_codec_start);
    if (!codec) {
        fprintf(stderr, "Decoder '%s' not found\n", codec_drv);
        error(1);
    }

    if (codec->open(NULL, st->codec, &frame_fmt)) {
        fprintf(stderr, "Error opening decoder\n");
        error(1);
    }

    if (!frame_fmt.width) {
        fprintf(stderr, "Decoder error: frame size not specified\n");
        error(1);
    }

    dp.pixfmt = frame_fmt.pixfmt;
    display = display_open(dispdrv, &dp, &frame_fmt);
    if (!display)
        error(1);

    set_scale(&dp, &frame_fmt, flags);

    if (display->memman) {
        if (dp.pixfmt == frame_fmt.pixfmt) {
            memman = display->memman;
        } else if (display->flags & OFBP_PRIV_MEM) {
            fprintf(stderr, "Decoder/display pixel format mismatch\n");
            error(1);
        }
    }

    if (!memman)
        memman = find_driver(memman_drv, NULL, ofbp_memman_start);
    if (!memman)
        error(1);

    if ((codec->flags & OFBP_PHYS_MEM) && !(memman->flags & OFBP_PHYS_MEM)) {
        fprintf(stderr, "Incompatible decoder/memman\n");
        error(1);
    }

    if (memman->alloc_frames(&frame_fmt, bufsize, &frames, &num_frames))
        error(1);

    if (memman != display->memman) {
        pixconv = pixconv_open(pixconv_drv, &frame_fmt, &dp);
        if (!pixconv)
            error(1);
        if ((pixconv->flags & OFBP_PHYS_MEM) &&
            !(memman->flags & display->flags & OFBP_PHYS_MEM)) {
            fprintf(stderr, "Incompatible display/memman/pixconv\n");
            error(1);
        }
    }

    timer = timer_open(timer_drv);
    if (!timer)
        error(1);

    init_frames(&frame_fmt);

    if (display->enable(&frame_fmt, flags, pixconv, &dp))
        error(1);

    pthread_mutex_init(&disp_lock, NULL);
    sem_init(&disp_sem, 0, 0);

    signal(SIGINT, sigint);

    pthread_create(&dispt, NULL, disp_thread, st);

    while (!stop && !av_read_frame(afc, &pk)) {
        if (pk.stream_index == st->index)
            if (codec->decode(&pk))
                stop = 1;
        av_free_packet(&pk);
    }

    if (!stop) {
        sem_post(&disp_sem);
        while (disp_tail != -1)
            usleep(100000);
    }

    stop = 1;
    sem_post(&disp_sem);
    pthread_join(dispt, NULL);

out:
    if (afc) av_close_input_file(afc);

    if (codec)   codec->close();
    if (timer)   timer->close();
    if (memman)  memman->free_frames(frames, num_frames);
    if (display) display->close();
    if (pixconv) pixconv->close();

    return ret;
}
Пример #14
0
/**
  KeyScan task

  KeyScan task

  @param void
  @return void
*/
void KeyScanTsk(void)
{
    UINT32 uiKeyScanTimerCnt;
    UINT32 uiKeyScanQSecCnt;

    #if (_TouchPanel_ != DISABLE)
    GESTURE_GESTURE_STRUCT  TempGesture;
    #endif

    // Initial Message Queue
    // KeyScan may send commands in the boot stage before UIFrameworkTsk starts.
    // MessageQueue has to be initialized before KeyScan running.
    Ux_InitMessage(MBXID_SYS_EVENT, MBXID_BKG_EVENT);

    // Init the callback function of Primary task for file system initialization
    Primary_SetFSInitCB(KeyScan_StorageCB);

    // Set LED toggle speed
    KeyScan_SetLEDToggleSpeed(KEYSCAN_LED_GREEN,  KEYSCAN_LED_TSPEED_SLOW);
    KeyScan_SetLEDToggleSpeed(KEYSCAN_LED_RED,    KEYSCAN_LED_TSPEED_SLOW);
    KeyScan_SetLEDToggleSpeed(KEYSCAN_LED_FCS,    KEYSCAN_LED_TSPEED_NORMAL);

    KeyScan_initTimer();

    if (timer_open((UINT *)&g_uiKeyScanTimerID, NULL) != E_OK)
    {
        debug_err(("KEYSCAN ERR: Error open keyscan timer\r\n"));
        while (1)
        {
            ;
        }
    }

    // Turn on green LED and turn off red LED
    KeyScan_TurnOnLED(KEYSCAN_LED_GREEN);
    KeyScan_TurnOffLED(KEYSCAN_LED_RED);
    KeyScan_TurnOffLED(KEYSCAN_LED_FCS);

    //Already clr_flg during timer_open procedure
    //clr_flg(FLG_ID_INT2, FLGINT2_TIMER0 << g_uiKeyScanTimerID);
    timer_set(g_uiKeyScanTimerID, KEYSCAN_TIMER_INTERVAL, _TIMER_CTRL_FREE_RUN | _TIMER_CTRL_INT_ENABLE, _TIMER_PLAY);

    // Init variables
    uiKeyScanTimerCnt   = 0;
    uiKeyScanQSecCnt    = 0;

    // Init Card and File System
    KeyScan_DetStrgCard();
    KeyScan_DetStrgCard();
    //
    KeyScanACCDet();               

    #if (KEYSCAN_BATTERY_DET == ENABLE)
    if (!KeyScan_CheckUSBInSysInit())
    {
        KeyScan_DetBatteryInSysInit();
    }
    #endif

#if (_DATETIME_SETTING_ == ENABLE)
    //KeyScan_SetTime();
#endif
    #if (KEYSCAN_KEY_DET == ENABLE)
    KeyScan_DetKey();

    if (!KeyScan_CheckEngMode() && !KeyScan_CheckUSBInSysInit())
    {
        Primary_ChangeMode(PRIMARY_MODE_MOVIE);
        //Primary_ChangeMode(PRIMARY_MODE_PHOTO);
        //Primary_ChangeMode(PRIMARY_MODE_PLAYBACK);
        Primary_Wait4ChangeModeDone();
    }
    #endif

    // Init UI USB detection
    //KeyScan_DetUSB();
    //KeyScan_DetUSB();

    // Init UI battery level
    //KeyScan_DetBattery();
    //KeyScan_DetBattery();         
    //get the acc 
    if((GPIOMap_GetAcc12V() == FALSE)&&(gbACCStatus != ACCON2OFF))
    {
        debug_err(("PowerOnMau TRUE and turn to half an hour mode-----\r\n"));
	  PowerOnMau=TRUE;
    }
    //---------------------------------------------------------------------------------------------------
    // KeyScan Main Loop
    //---------------------------------------------------------------------------------------------------
    while (1)
    {
        //wai_flg((UINT *)&uiFlag, FLG_ID_INT2, FLGINT2_TIMER0 << g_uiKeyScanTimerID, TWF_ORW | TWF_CLR);
        timer_waitTimeup(g_uiKeyScanTimerID);
        uiKeyScanTimerCnt++;

        g_uiKeyScanFlags = 0;

        //-----------------------------------------------------------------------------------------------
        // Do the following task every 20ms
        //-----------------------------------------------------------------------------------------------
        // Detect key
        #if (KEYSCAN_KEY_DET == ENABLE)
        if (g_bKeyScanKeyDetEn == TRUE)
        {
            KeyScan_DetKey();
        }
        #endif
        #if (KEYSCAN_POWEROFF_DET == ENABLE)
        // Detect power off key
            KeyScan_DetPoweroff();
        #endif		
        KeyScanACCDet();               

        // Detect IR Remote key
        #if (_IR_REMOTE_ != _IR_REMOTE_NONE_)
        // Check IR data expiration, frequency value must be smaller than 100ms
        KeyScan_CheckIrRxExp();
        // Detect IR remote control receiver detected key, frequency value must be smaller than 50ms
        KeyScan_DetIrRxKey();
        #endif
        if(Ux_GetBackgroundTskBusy() == TRUE)
        {
            // Detect storage card,prevent card unplug
            KeyScan_DetStrgCard();
        }

        KeyScan_countTimer();

        //-----------------------------------------------------------------------------------------------
        // Do the following task every 80ms
        //-----------------------------------------------------------------------------------------------
        if ((uiKeyScanTimerCnt & 3) == 0)
        {
            // Detect touch panel
            #if (_TouchPanel_ != DISABLE)
            if(g_bKeyScanTP)
            {
                Gesture_DetGesture(&TempGesture);
                if(TempGesture.Event != GESTURE_EVENT_IDLE)
                {
                    KeyScan_PostNvtTPEvent(&TempGesture);
                }
            }
            #endif

            // Toggle LED
            KeyScan_ToggleLED();
            // Detect flash light
            #if (_FLASHLIGHT_ != _FLASHLIGHT_NONE_)
            KeyScan_DetFlash();
            #endif
        }

        //-----------------------------------------------------------------------------------------------
        // Do the following task every 100ms
        //-----------------------------------------------------------------------------------------------
        if ((uiKeyScanTimerCnt % 5) == 0)
        {
        
            //#if (KEYSCAN_POWEROFF_DET == ENABLE)
            // Detect power off key
               // KeyScan_DetPoweroff();
           // #endif

            //-------------------------------------------------------------------------------------------
            // Do the following task every 1s
            //-------------------------------------------------------------------------------------------
            if ((uiKeyScanTimerCnt % 50) == 0)
            {
                #if (KEYSCAN_AUTOPOWEROFF_DET == ENABLE)
                // Detect auto poweroff
                if ((KeyScan_GetAutoPoweroffTime() != KEYSCAN_AUTOPOWEROFF_DISABLED) && (g_bKeyScanAutoPoweroffEn == TRUE))
                {
                    KeyScan_DetAutoPoweroff();
                }
                #endif

                #if (_WDT_CONTROL_ == ENABLE)
                wdt_setTrig();
                #endif
            }
        }

        //-----------------------------------------------------------------------------------------------
        // Do the following task every 250ms
        //-----------------------------------------------------------------------------------------------
        if ((uiKeyScanTimerCnt % 12) == 0)
        {
            uiKeyScanQSecCnt++;

            #if (KEYSCAN_KEY_DET == ENABLE)
            // Detect modedial
            //if (g_bKeyScanMDDetEn == TRUE)
            //{
            //    KeyScan_DetModedial(FALSE);
            //}
            #endif

            // Detect flash light
            //KeyScan_DetFlash();

            // Detect USB
            //KeyScan_DetUSB();

            //Detect macro mode
            KeyScan_DetMacro();

	      //Detect Gsensor
	     KeyScan_DetGsensor();
            //-------------------------------------------------------------------------------------------
            // Do the following task every 500ms
            //-------------------------------------------------------------------------------------------
            if (uiKeyScanQSecCnt & 1)
            {
                #if (KEYSCAN_CARDDET_INT == DISABLE)
                // Detect storage card
                KeyScan_DetStrgCard();
                #endif

                // Detect HDMI
                KeyScan_DetHDMI();

                // Detect TV
                KeyScan_DetTV();

                // Detect External Audio (headphone...)
                //KeyScan_DetAudio();

                // Detect LCD rotate
                //KeyScan_DetLCDRotate();

                // Detect system is busy or not
                KeyScan_DetBusy();

            }

            //-------------------------------------------------------------------------------------------
            // Do the following task every 1s
            //-------------------------------------------------------------------------------------------
            if ((uiKeyScanQSecCnt % 4) == 0)
            {
                #if (KEYSCAN_BATTERY_DET == ENABLE)
                //if (!KeyScan_IsUSBPlug()) {
                    //KeyScan_DetBattery();
               // }
                #endif
			
//--------------------------------jack lan begin-------------------------------	
                if ((KeyScan_GetAutoLCDoffTime() != 0))
                {
		  		KeyScan_DeLcdOff();
                }					

               //KeyScan_DetAC();		
		if(gBKeyscanDetGSPNAVIEn == TRUE)
		{
		   KeyScan_DetGSPNAVI();		
		}
#if 0				   
		  if(KeyScan_GetLedLightSta()== LED_AUTO)
		  {
                if (AE__GetLV()>50)
                {
                		if(GPIOMap_IsWhiteLightOn())
                			{
				GPIOMap_TurnOffWhiteLight();
                			}
                } 
		   else 
                {                
                		if(!GPIOMap_IsWhiteLightOn())
                			{
				GPIOMap_TurnOnWhiteLight();	        
                			}
                }				
		  }
#endif		  
//--------------------------------jack lan end-------------------------------	

            }
			
            //-------------------------------------------------------------------------------------------
            // Do the following task every 5s
            //-------------------------------------------------------------------------------------------			
            if ((uiKeyScanQSecCnt % 20) == 0)			
		{
			KeyScan_NAVIComunicate();
		}
        }
        //-----------------------------------------------------------------------------------------------
        // End of KeyScanTimer divider
        //-----------------------------------------------------------------------------------------------

        //-----------------------------------------------------------------------------------------------
        // Start to set key flag
        //-----------------------------------------------------------------------------------------------
        if (g_uiKeyScanFlags != 0)
        {
#if (_CALIBRATION_MODE_ == ENABLE)
            set_flg(FLG_ID_KEY, g_uiKeyScanFlags);
#endif
            switch(g_uiKeyScanFlags & FLGKEY_ACT_MASK)
            {
                case FLGKEY_PRESSED:
                    Ux_PostEvent(Get_NVTCMD(g_uiKeyScanFlags), 2, NVTEVT_KEY_PRESS, FLGKEY_PRESSED);
                break;

                case FLGKEY_RELEASED:
                    Ux_PostEvent(Get_NVTCMD(g_uiKeyScanFlags), 1, NVTEVT_KEY_RELEASE);
                break;

                case FLGKEY_HOLD:
                    Ux_PostEvent(Get_NVTCMD(g_uiKeyScanFlags), 2, NVTEVT_KEY_PRESS, FLGKEY_HOLD);
                break;

                case FLGKEY_LONGHOLD:
                    Ux_PostEvent(Get_NVTCMD(g_uiKeyScanFlags), 2, NVTEVT_KEY_PRESS, FLGKEY_LONGHOLD);
                break;

                default:
                    debug_err(("KeyScanTsk: Unknown key action (0x%.8X)\r\n", (g_uiKeyScanFlags & FLGKEY_ACT_MASK)));
                break;
            }
            g_uiKeyScanFlags = 0;
        }
    }
}
//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]);
}
Пример #16
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;
}
Пример #17
0
void recvnode(void)
{
    TiCc2420Adapter * cc;
    TiFrameRxTxInterface * rxtx;
	TiNioAcceptor * nac;
    TiAloha * mac;
	TiTimerAdapter   *timer;
	TiTimerManager * vtm;
	TiTimer * mac_timer;
	TiFrame * rxbuf;
	char * msg = "welcome to aloha recv test...";
	int len=0;
	target_init();

    // flash the led to indicate the software is successfully running now.
    //
	led_open();
	led_on( LED_ALL );
	hal_delay( 500 );
	led_off( LED_ALL );
	//led_on( LED_RED );

    // initialize the runtime library for debugging input/output and assertion
    // hal_assert_report is defined in module "hal_assert"
    //
	//dbo_open( 38400 );
    rtl_init( (void *)dbio_open(38400), (TiFunDebugIoPutChar)dbio_putchar, (TiFunDebugIoGetChar)dbio_getchar, hal_assert_report );
    dbc_putchar( 0xF0 );
    dbc_mem( msg, strlen(msg) );

	cc = cc2420_construct( (void *)(&m_cc), sizeof(TiCc2420Adapter) );
	nac = nac_construct( &m_nacmem[0], NAC_SIZE );
    mac = aloha_construct( (char *)(&m_aloha), sizeof(TiAloha) );
    timer= timer_construct(( char *)(&m_timer),sizeof(TiTimerAdapter));
	vtm = vtm_construct( (void*)&m_vtm, sizeof(m_vtm) );
    timer = timer_open( timer, 2, NULL, NULL, 0x00 ); 
	vtm = vtm_open( vtm, timer, VTM_RESOLUTION );
	mac_timer = vtm_apply( vtm );
	vti_open( mac_timer, NULL, NULL );

	#ifdef CONFIG_TSET_LISTENER
	// cc = cc2420_open( cc, 0, _aloha_listener, NULL, 0x00 );
    cc = cc2420_open( cc, 0, aloha_evolve, mac, 0x00 );
    rxtx = cc2420_interface( cc, &m_rxtx );
	mac = aloha_open( mac, rxtx, CONFIG_ALOHA_CHANNEL, CONFIG_ALOHA_PANID, CONFIG_ALOHA_LOCAL_ADDRESS, 
        mac_timer, _aloha_listener, NULL,0x00 );
	#endif

    #ifndef CONFIG_TSET_LISTENER
    cc = cc2420_open( cc, 0, NULL, NULL, 0x00 );
    rxtx = cc2420_interface( cc, &m_rxtx );
	nac_open( nac, rxtx, CONFIG_NIOACCEPTOR_RXQUE_CAPACITY, CONFIG_NIOACCEPTOR_TXQUE_CAPACITY);
	mac = aloha_open( mac, rxtx, nac,CONFIG_ALOHA_CHANNEL, CONFIG_ALOHA_PANID, CONFIG_ALOHA_LOCAL_ADDRESS, 
        mac_timer, NULL, NULL,0x00 );
	#endif
 
	cc2420_setchannel( cc, CONFIG_ALOHA_CHANNEL );
	cc2420_setrxmode( cc );							            // enable RX mode
	cc2420_setpanid( cc, CONFIG_ALOHA_PANID );					// network identifier, seems no use in sniffer mode
	cc2420_setshortaddress( cc, CONFIG_ALOHA_LOCAL_ADDRESS );	// in network address, seems no use in sniffer mode
	cc2420_enable_autoack( cc );
	cc2420_settxpower( cc, CC2420_POWER_1);//cc2420_settxpower( cc, CC2420_POWER_2);CC2420_POWER_1

	#ifdef CONFIG_TEST_ADDRESSRECOGNITION
	cc2420_enable_addrdecode( cc );
	#else	
	cc2420_disable_addrdecode( cc );
	#endif

	#ifdef CONFIG_TEST_ACK
	cc2420_enable_autoack( cc );
	#endif
 
    rxbuf = frame_open( (char*)(&m_rxbufmem), FRAME_HOPESIZE(MAX_IEEE802FRAME154_SIZE), 3, 20, 0 );
    dbc_putchar(0x11);

    #ifdef CONFIG_TEST_ACK
    //fcf = OPF_DEF_FRAMECONTROL_DATA_ACK; 
	#else
    //fcf = OPF_DEF_FRAMECONTROL_DATA_NOACK; 
	#endif


    hal_enable_interrupts();

	/* Wait for listener action. The listener function will be called by the TiCc2420Adapter
	 * object when a frame arrives */
	#ifdef CONFIG_TEST_LISTENER	
	while (1) {}
	#endif
    
	/* Query the TiCc2420Adapter object if there's no listener */
	#ifndef CONFIG_TEST_LISTENER
	while(1) 
	{	
		char * ptr;//todo for testing
        frame_reset( rxbuf, 3, 20, 0 );
		len = aloha_recv( mac, rxbuf, 0x00 );        
		if (len > 0)
		{   
            frame_moveouter( rxbuf );
            _output_frame( rxbuf, NULL );
           frame_moveinner( rxbuf );
			/*
			dbc_write( frame_startptr( rxbuf),frame_length( rxbuf));//todo for testing
            ptr = frame_startptr( rxbuf);//todo for testing
			dbc_putchar( 0xff);//todo for testing
			dbc_uint8( ptr[ (frame_length( rxbuf)-2)]);//todo for testing
			dbc_putchar( 0xff);//todo for testing
            frame_moveinner( rxbuf );//todo for testing*/
			//led_off( LED_RED );

			/* warning: You shouldn't wait too long in the while loop, or else 
			 * you may encounter frame loss. However, the program should still 
			 * work properly even the delay time is an arbitrary value. No error 
			 * are allowed in this case. 
			 */
			//hal_delay( 500 );
			led_toggle( LED_RED );
		
        }

		aloha_evolve(mac, NULL );
	}
	#endif

    frame_close( rxbuf );
    aloha_close( mac );
    cc2420_close( cc );
}
Пример #18
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);
    }
    */
}