app_timer.c 16.3 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863
/*
** Copyright (C) 2001 Optek. All rights reserved.
**
** The information and source code contained herein is the exclusive
** property of Mediamatics and may  not be disclosed, examined or
** reproduced in whole or in part without explicit written authorization
** from the company.
*/

/*
** Author:
**
** Date: 1/15/2001
**
** Description: 
** 
*/
#include "os_config.h"

#include "c_def.h"
#include "debug.h"
#include "oem.h"

#include "regmap.h"

#include "mem_reloc.h"


#include "message.h"

#include "app_timer.h"
#include "remote.h"
#include "key_scan.h"
#include "app_cmd.h"
#include "app_main.h"

#include "flash_boot.h"
#include "app_ver.h"


#define	TIMER1_DIV			0
#define	TIMER1_COUNT		4

#define LCD_REFRESH_TIMER	100				/*500ms*/

TIMER_DATA timer_data;

#define IDLE_MAX_TIME1      (900000/CD_TIMER_TIME)         //15 minutes
#define IDLE_MAX_TIME2      (600000/CD_TIMER_TIME)         //10 minutes
#define IDLE_MAX_TIME3      ((900000-30000)/CD_TIMER_TIME) //14.5 minutes


void app_timer_handler(void *param);// __INTERNAL_RAM_TEXT;
//void app_timer_idle_time_reset (void) __INTERNAL_RAM_TEXT;


#if 1
//Pioneer(there is a problem for alalrm timer on)
#define ALARM_TIMER_TICKS		(5000/CD_TIMER_TIME)
#else
#define ALARM_TIMER_TICKS		(2000/CD_TIMER_TIME)
#endif

#define VOLUME_AUTO_MINUS_START  ((60*1000)/CD_TIMER_TIME)  //1 minute

#if 0
#define BT_NFC_TIMER_TICKS       ((1*60*1000)/CD_TIMER_TIME) //1 minute
#else
#define BT_NFC_TIMER_TICKS       ((1*10*1000)/CD_TIMER_TIME) //10 seconds
//#define BT_NFC_TIMER_TICKS       ((1*5*1000)/CD_TIMER_TIME) //5 seconds
#endif

#if defined(REMOTE_ENABLE) && defined(REMOTE_PHILIPS_FORMAT)
U8 remote_time_tick;
#endif

extern U8 usbmsc_USBhostOpen(void);
extern U8 usbmsc_USBhostClose(void);
extern U8 rec_search_fspace_keylock;

U8 decode_block_process_timer;

void app_timer_init (void)
{
	int xTimer;
	void *xTimer0;
	void *xTimer1;
	void *xTimer2;
	void *xAutoReloadTimers[ configTIMER_QUEUE_LENGTH + 1 ] = { 0 };
	//U8 ucAutoReloadTimerCounters[ configTIMER_QUEUE_LENGTH + 1 ] = { 0 };

	memset( &timer_data, 0, sizeof( timer_data ) );

	#define xTimerID0   0
	#define xTimerID1   1
	#define xTimerID2   2


	xTimer0 = xTimerCreate( "FR Timer",                     /* Text name to facilitate debugging.  The kernel does not use this itself. */
						//( 1000 ),                           /* The period for the timer.  The plus 1 ensures a period of zero is not specified. */
						( TIMER_25MS/OS_MSEC_PER_TICK ),            /* The period for the timer.  The plus 1 ensures a period of zero is not specified. */
						pdTRUE,                             /* Auto-reload is set to true. */
						( void * ) xTimerID0,               /* An identifier for the timer as all the auto reload timers use the same callback. */
						app_timer_handler );		/* The callback to be called when the timer expires. */

	//xAutoReloadTimers[ xTimerID0 ] = xTimer0;

	if (xTimer0 == NULL)
	{
		configASSERT( pdFAIL );
	}
	else
	{
		/* The scheduler has not yet started, so the block period of
		portMAX_DELAY should just get set to zero in xTimerStart().  Also,
		the timer queue is not yet full so xTimerStart() should return
		pdPASS. */
		//if( xTimerStart( xTimer0, portMAX_DELAY ) != pdPASS )
		//if( xTimerStart( xTimer0, 2000/OS_MSEC_PER_TICK ) != pdPASS )
		if( xTimerStart( xTimer0, 2000/OS_MSEC_PER_TICK ) != pdPASS )
		{
 			configASSERT( pdFAIL );
		}
	}
}



void app_timer_open (void)
{
}

void app_timer_close (void)
{
}

void app_timer_fini (void)
{
}

void app_timer_reset_standby_tick (void)
{
}


void app_timer_handler (void *param)
{
#if 0
	static unsigned char state = FALSE;

	if (state)
	{
		state = FALSE;
		DBG_PIN_HIGH;
	}
	else
	{
		state = TRUE;
		DBG_PIN_LOW;
	}
#endif


	timer_data.ticks++;

//------------------------key hold
	if (timer_data.key_hold_timer)
	{
		if (--timer_data.key_hold_timer == 0)
		{
				uMsgSend ((U16)UI_MAIN_BOARD_KEY, KEY_HOLD, NULL);
		}
	}
	
	if (timer_data.window_time)
	{
		if (--timer_data.window_time == 0)
		{
			ukParmSend (app_window_timer_expired,app_main_data.window);
		}
	}		

	if (timer_data.saveDataTimer)
	{
		if (-- timer_data.saveDataTimer == 0)
		{
			//ukMsgSend(app_nav_save_data_handle);
		}
	}

	if (timer_data.mute_Timer)
	{
		//mute off
		if(--timer_data.mute_Timer == 0)
		{
			//ukMsgSend(app_nav_mute_off);
		}
	}

	if (timer_data.mute_on_Timer)
	{
		if(--timer_data.mute_on_Timer == 0)
		{
			//ukMsgSend(app_nav_mute_on);
		}
	}


#ifdef VOLUME_AUTO_PLUS
	if (timer_data.VolAutoPlus_Timer)
	{
		if (--timer_data.VolAutoPlus_Timer == 0)
		{
#ifdef SHARP_KP82
			if (timer_alarm_power_on_num)
			{
				ukMsgSend(app_nav_volume_auto_plus_for_timer_alarm);
			}
			else
			{
				ukMsgSend(app_nav_volume_auto_plus);
			}
#else
			ukMsgSend(app_nav_volume_auto_plus_for_timer_alarm);
#endif
		}
	}
#endif

#ifdef VOLUME_AUTO_MINUS
	if (timer_data.VolAutoMinus_Timer)
	{
		if (--timer_data.VolAutoMinus_Timer == 0)
		{
			ukMsgSend(app_nav_volume_auto_minus);
		}
	}
#endif

#if 1
//------------------------process poll timer
	#define PROCESS_POLL_TIME    (50/CD_TIMER_TIME)
	//#define PROCESS_POLL_TIME    (100/CD_TIMER_TIME)
	if(++timer_data.process_Timer >= PROCESS_POLL_TIME)
	{
		timer_data.process_Timer = 0;
		if (decode_block_process_timer == FALSE)
		{
			uMsgSend (UI_TIMER, UI_FIT_TIMER, 0);
		}
	}
#endif

#ifdef DSPEQ_TUNING_ENABLE
	#define SET_EQ_PROCESS_POLL_TIME    (150/CD_TIMER_TIME)
	if (++timer_data.set_eq_process_timer >= SET_EQ_PROCESS_POLL_TIME)
	{
		timer_data.set_eq_process_timer = 0;
		if (decode_block_process_timer == FALSE)
		{
			uiMsgSend (UI_SET_EQ, UI_FIT_SET_EQ, 0);
		}
	}
#endif

#ifdef REMOTE_ENABLE
	if (timer_data.remoteKeyUpTimer )
	{
		if (--timer_data.remoteKeyUpTimer == 0)
		{
			remote_repeat_valid = FALSE;

			if (remote_key_state == KEY_DOWN)
			{
				remote_key_state = KEY_UP;
				uMsgSend (UI_REMOTE_KEY, KEY_UP, remote_key);
				//DBG_RMTPrintf("RMT:key up 0x%x\n\r", remote_key);
			}
		}
	}
#endif

#ifdef KEY_UP_TIMER_ENABLE
	if (timer_data.keyUpTimer)
	{
		timer_data.keyUpTimer--;
	}
#endif

#ifdef FOR_ESD_PROTECT
	if (timer_data.esdProtectTimer)
	{
		timer_data.esdProtectTimer--;
	}
#endif

#ifdef USB_DEV_ENABLE
	if (timer_data.usbdev_upstream_timeout_timer)
	{
		timer_data.usbdev_upstream_timeout_timer--;
		if (timer_data.usbdev_upstream_timeout_timer == 0)
		{
			void usbdev_upstream_timeout_handle(void);
			ukMsgSend(usbdev_upstream_timeout_handle);
		}
	}
#endif
#ifdef BT_HCI_ENABLE
	if (timer_data.bt_reLink_timer)
	{
		timer_data.bt_reLink_timer--;
		if (timer_data.bt_reLink_timer == 0)
		{
			ukMsgSend(app_nav_bt_relink);
		}
	}
#endif
//------------------------string scroll
	if (timer_data.nav_lcd_roll_timer)
	{
		if (--timer_data.nav_lcd_roll_timer == 0)
		{
			//ukMsgSend (app_lcd_disp_scroll);
		}
	}


#if 1//
	timer_data.idle_time++;
	if (timer_data.idle_time > IDLE_MAX_TIME1)
	{
		timer_data.idle_time = 0;
		//if (app_main_data.media != MEDIA_AUX && app_main_data.media != MEDIA_TUNER)
		//if (app_main_data.media != MEDIA_TUNER)
		{
#ifdef SLEEP_TIMER
			if (timer_data.sleep_timer == 0)
#endif
			{
#ifdef BOOT_FROM_FLASH
				if (!app_main_data.standby_status)
				{
#ifdef LCD_DISP_DEMO_FUN
					//demo_func_disp = FALSE;
#endif

					//if (app_main_data.window == (const WINDOW *) &standby_window)
					//{
					//	ukMsgSend(app_nav_ECO_standby_enter);
					//}
					//else
					{
#if defined APS_MODE_ENABLE
						if (aps_mode_flag)
#endif
						{
							//ukMsgSend(app_nav_standby);
						}
					}
				}
#endif
			}
		}
	}
	else
	{
		
		if (timer_data.idle_time > IDLE_MAX_TIME3 && (!app_main_data.standby_status))// && (app_main_data.media != MEDIA_TUNER))
		{
			if (timer_data.sleep_timer == 0)
			{
#if defined APS_MODE_ENABLE
				if (aps_mode_flag)
#endif
				{
					//ukMsgSend(app_nav_aps_mode_enter);
				}
			}
		}
	}


#ifdef ROTARY_ENABLE
	if (timer_data.rotary0_timer > 0) 
	{
		timer_data.rotary0_timer--;
		if (timer_data.rotary0_timer == 0) 
		{
			rotary0_KeyScan_act (timer_data.rotary0_dir);
		}
	}

	if (timer_data.rotary1_timer > 0) 
	{
		if(ad_data[1] < ADC_INVALID_VAL)
		{
			timer_data.rotary1_timer = 0;
		}
		else 
		{
			timer_data.rotary1_timer--;
			if (timer_data.rotary1_timer == 0) 
			{
				rotary1_KeyScan_act (timer_data.rotary1_dir);
			}
		}
	}
#endif


#ifdef CD_DOOR_LOCK_ENABLE
	if (timer_data.cd_door_lock_timer)
	{
		timer_data.cd_door_lock_timer--;
		//if (timer_data.cd_door_lock_timer == 0)
		//{
		//	ukMsgSend(app_nav_cd_door_lock_enter);
		//}
	}
#endif

#endif


#ifdef USB_HOST_ENABLE
	if (mscClass_isOpend())
	{
		usbLUNtimerTick();
	}
#endif //USB_HOST_ENABLE


	KeyScan(timer_data.ticks);
}



/****************************************************************************************
 *								KEY HOLD TIMER											*
 ****************************************************************************************/

void app_timer_key_hold_set_timer (U16 time)
{
	timer_data.key_hold_timer = (time + CD_TIMER_TIME - 1) / CD_TIMER_TIME;
}

void app_timer_key_hold_reset (void)
{
	timer_data.key_hold_timer = 0;
}

void app_timer_window_time_set (U32 time)
{
	timer_data.window_time = (time + CD_TIMER_TIME - 1) / CD_TIMER_TIME;
}

void app_timer_window_time_reset (void)
{
	timer_data.window_time = 0;
}

void app_timer_scroll_set (U16 time)
{
	timer_data.nav_lcd_roll_timer = (time + CD_TIMER_TIME - 1) / CD_TIMER_TIME;
}

void app_timer_idle_time_reset (void)
{
	timer_data.idle_time = 0;
}

void app_timer_delete_time_set(U32 time)
{
//	timer_data.delete_timer = (U8) ( (time + CD_TIMER_TIME - 1) / CD_TIMER_TIME );
}


void app_timer_mute_off_time_set(U32 time)
{
	timer_data.mute_Timer = (U16) ( (time + CD_TIMER_TIME - 1) / CD_TIMER_TIME );
}

void app_timer_mute_off_time_clr(void)
{
	timer_data.mute_Timer = 0;
}

long app_timer_mute_off_time_get(void)
{
	return  timer_data.mute_Timer;
}

void app_timer_mute_on_time_set(U32 time)
{
	timer_data.mute_on_Timer = (U16) ( (time + CD_TIMER_TIME - 1) / CD_TIMER_TIME );
}

void app_timer_mute_on_time_clr(void)
{
	timer_data.mute_on_Timer = 0;
}

#ifdef VOLUME_AUTO_PLUS
void app_timer_vol_auto_plus_time_set(U32 time)
{
	timer_data.VolAutoPlus_Timer = (U16) ( (time + CD_TIMER_TIME - 1) / CD_TIMER_TIME );
}

void app_timer_vol_auto_plus_time_clr(void)
{
	timer_data.VolAutoPlus_Timer = 0;
}
#endif

#ifdef VOLUME_AUTO_MINUS
void app_timer_vol_auto_minus_time_set(U32 time)
{
	timer_data.VolAutoMinus_Timer = (U16) ( (time + CD_TIMER_TIME - 1) / CD_TIMER_TIME );
}

void app_timer_vol_auto_minus_time_clr(void)
{
	timer_data.VolAutoMinus_Timer = 0;
}
#endif

void app_timer_sleep_time_set (U32 time)
{
	timer_data.sleep_timer = (time + CD_TIMER_TIME - 1) / CD_TIMER_TIME;
}

U32 app_timer_sleep_time_get (void)
{
	U32 temp;
	
	temp = (timer_data.sleep_timer * CD_TIMER_TIME)/1000;
	return temp;
}

U32 app_timer_sleep_minute_get (void)
{
	U32 temp;

	temp = (timer_data.sleep_timer * CD_TIMER_TIME)/1000;

	if (temp%60 == 0)
	{
		temp = temp/60;
	}
	else
	{
		temp = temp/60 + 1;
	}
	return temp;
}

void app_timer_save_data_time_set(U16 ms)
{
	timer_data.saveDataTimer = ( (ms + CD_TIMER_TIME - 1) / CD_TIMER_TIME );
}

void app_timer_save_data_time_clr(void)
{
	timer_data.saveDataTimer = 0;
}

U16 app_timer_save_data_time_get(void)
{
	return timer_data.saveDataTimer;
}


#ifdef KEY_UP_TIMER_ENABLE
void app_timer_keyUpTimer_time_set (U16 time)
{
	timer_data.keyUpTimer = ( (time + CD_TIMER_TIME - 1) / CD_TIMER_TIME );
}

U16 app_timer_keyUpTimer_time_get (void)
{
	return (timer_data.keyUpTimer);
}
#endif

#ifdef BT_HCI_ENABLE
void app_timer_bt_reLinktTimer_time_set (U16 time)
{
	timer_data.bt_reLink_timer = ( (time + CD_TIMER_TIME - 1) / CD_TIMER_TIME );
}

void app_timer_bt_reLinktTimer_time_clr (void)
{
	timer_data.bt_reLink_timer = 0;
}

U16 app_timer_bt_reLinktTimer_time_get (void)
{
	return (timer_data.bt_reLink_timer);
}

#endif

U32 app_timer_get_idle_time (void)
{
	return (timer_data.idle_time * CD_TIMER_TIME);
}

void app_timer_waiting_play_time (U16 time)
{
	timer_data.waiting_play_time = time;
}

#ifdef REMOTE_ENABLE
void app_timer_remoteKeyUpTimer_set(U16 ms)
{
	timer_data.remoteKeyUpTimer = (U16) ( (ms + CD_TIMER_TIME - 1) / CD_TIMER_TIME);
}

U16 app_timer_remoteKeyUpTimer_clr(void)
{
	timer_data.remoteKeyUpTimer = 0;;
}
#endif



/**************************usb*****************************/

void timer_usbTimeSet( U16 ms )
{
}
void timer_usbTimeStart( void )
{
}
void timer_usbTimeStop( void )
{
}

void timer_usbRHtimeSet( U16 ms )
{
}

void timer_usbRHtimerStart( void )
{
}

void timer_usbRHtimerStop( void )
{
}

void timer_usbLUNtimerSet( U16 ms, U8 maxlun )
{
#if 1	
	timer_data.usbLUNtimerRun	=	0x00;
	timer_data.usbLUNtime		=	ms/CD_TIMER_TIME + 1;
	timer_data.usbMaxluns		=	maxlun;
	memset( timer_data.usbLUNtimer, 0, sizeof(timer_data.usbLUNtimer) );
#endif	
}

void timer_usbLUNtimerStart( U16 tno )
{
#if 1	
	U16	tmp	=	0x01;

	DBG_assert( tno < USB_MSC_MAX_TIMER );
	
	tmp <<= tno;
	
	timer_data.usbLUNtimer[ tno ]	=	timer_data.usbLUNtime;
	timer_data.usbLUNtimerRun	|=	tmp;
#endif	
}

void timer_usbLUNtimerStartAll( void )
{
#if 1	
	U16	i;

	for( i = 0; i < timer_data.usbMaxluns; i ++ ) {
		timer_usbLUNtimerStart( i );
	}
#endif	
}

void timer_usbLUNtimerRestart( U16 tno )
{
#if 1	
	DBG_assert( tno < USB_MSC_MAX_TIMER );
	timer_data.usbLUNtimer[ tno ]	=	timer_data.usbLUNtime;
#endif	
}

void timer_usbLUNtimerRestartAll( void )
{
#if 1	
	U16	i;

	for( i = 0; i < timer_data.usbMaxluns; i ++ ) {
		timer_data.usbLUNtimer[ i ]	=	timer_data.usbLUNtime;
	}
#endif	
}

void timer_usbLUNtimerPause( U16 tno )
{
#if 1	
	DBG_assert( tno < USB_MSC_MAX_TIMER );	
	timer_data.usbLUNtimer[ tno ]	=	0;
#endif	
}

void timer_usbLUNtimerPauseAll( void )
{
#if 1	
	U16	i;

	for( i = 0; i < timer_data.usbMaxluns; i ++ ) {
		timer_data.usbLUNtimer[ i ]	=	0;
	}
#endif	
}

void timer_usbLUNtimerStop( U16 tno )
{
#if 1	
	U16	tmp	=	0x01;

	DBG_assert( tno < USB_MSC_MAX_TIMER );
	
	tmp <<= tno;
	
	timer_data.usbLUNtimerRun	&=	~tmp;	
	timer_data.usbLUNtimer[ tno ]	=	0x0;
#endif	
}

void timer_usbLUNtimerStopAll( void )
{
#if 1	
	timer_data.usbLUNtimerRun	=	0x00;
	memset( timer_data.usbLUNtimer, 0, sizeof(timer_data.usbLUNtimer) );
#endif	
}

void timer_usbLUNdetTimerSet( U16 ms )
{
#if 1	
	timer_data.usbLunDetTimer = ms/CD_TIMER_TIME + 1;
#endif	
}

void timer_usbLUNdetTimerStop( void )
{
#if 0
	OS_DisableInterrupts ();
	timer_data.usbLunDetTimer	=	0;
	OS_EnableInterrupts ();
#endif
}

#ifdef USB_HOST_ENABLE
void mscClass_isendLUNpollTimeOutIRP( U32 luns );
void mscClass_sendLUNpollTimeOutIRP( U32 luns );
void usbLUNtimerTick( void )
{
#if 1	
	U16	i;
	U32	tmp = 0x01;
	U32	luns = 0;
	U8	timeout = FALSE;

	for( i = 0; i < timer_data.usbMaxluns; i ++ ) {
		if( (timer_data.usbLUNtimerRun & tmp) && (timer_data.usbLUNtimer[ i ] > 0) ) {
			if( -- timer_data.usbLUNtimer[ i ] == 0 ) {
				timeout	=	TRUE;
				luns	|=	tmp;
				timer_data.usbLUNtimer[ i ]	=	timer_data.usbLUNtime;
			}
		}
		
		tmp <<= 1;
	}

	//if( timeout )	mscClass_isendLUNpollTimeOutIRP( luns );
	if( timeout )	mscClass_sendLUNpollTimeOutIRP( luns );
#endif	
}
#endif

#if 1//def FOR_ESD_PROTECT
void app_timer_esdProtectTimer_time_set (U16 time)
{
	timer_data.esdProtectTimer = ( (time + CD_TIMER_TIME - 1) / CD_TIMER_TIME );
}

U16 app_timer_esdProtectTimer_time_get (void)
{
	return (timer_data.esdProtectTimer);
}
#endif

#if 1
#if 1//def USBHOST_OPEN_TIMER_ENABLE
void app_timer_usb_open_time_set(U16 time)
{
#if 0	
	timer_data.usbOpenTimer = (U8) ( (time + CD_TIMER_TIME - 1) / CD_TIMER_TIME );

#ifdef USBHOST_CLOSE_TIMER_ENABLE
	timer_data.usbCloseTimer = 0;
#endif
#endif
}

void app_timer_usb_open_time_clr(void)
{
	//timer_data.usbOpenTimer = 0;
}
#endif

#if 1//def USBHOST_CLOSE_TIMER_ENABLE
void app_timer_usb_close_time_set(U16 time)
{
#if 0	
	timer_data.usbCloseTimer = (U8) ( (time + CD_TIMER_TIME - 1) / CD_TIMER_TIME );

#ifdef USBHOST_OPEN_TIMER_ENABLE
	timer_data.usbOpenTimer = 0;
#endif
#endif
}

void app_timer_usb_close_time_clr(void)
{
//	timer_data.usbCloseTimer = 0;
}
#endif

#if 1//def USBHOST_PWR_ON_TIMER_ENABLE
void app_timer_usb_pwr_on_time_set(U16 time)
{
	//timer_data.usbPwrOnTimer = (U8) ( (time + CD_TIMER_TIME - 1) / CD_TIMER_TIME ); 
}

void app_timer_usb_pwr_on_time_clr(void)
{
	//timer_data.usbPwrOnTimer = 0;
}
#endif

void app_timer_usbdev_upstream_timeout_time_set (U16 time)
{
	timer_data.usbdev_upstream_timeout_timer = ( (time + CD_TIMER_TIME - 1) / CD_TIMER_TIME );
}

void app_timer_usbdev_upstream_timeout_time_clr (void)
{
	timer_data.usbdev_upstream_timeout_timer = 0;
}

#endif
/************************usb end***************************/