Exemplo n.º 1
0
/****************************************************************
 * 函数名称 : void SMARTCARD_Detect_notify(void *pvParam)
 * 函数功能 : 
 * 输入参数 : 无
 * 返回参数 : 
 * 全局变量 : 
 * 调用函数 : 
 * 创建人   : XuHong
 * 创建日期 : 2002.10.18
 * 修改人   : 
 * 修改日期 : 
 * 版本     : 0.1
 ****************************************************************/
static void SMARTCARD_Detect_notify(void)
{

	S32  	 ErrCode;/*times*/
	Card_Event_t eventStatus=CARD_OUT_EVENT;
	AM_SMC_CardStatus_t tSCIStatus;
	S32 s32ResetTime;	
	U8 atr_tmp[255];
	int atr_recv_count;
	static int cardouttimes =0;
	
	while(TRUE)
	{
		OS_SemWait( Detect_signal );
		ErrCode = AM_SMC_GetCardStatus(g_u8SCIPort,&tSCIStatus);
		if ( ErrCode == AM_SUCCESS )
		{
			if(tSCIStatus == AM_SMC_CARD_IN)
			{
				eventStatus = CARD_IN_EVENT;
			}	
			else
			{
				eventStatus=CARD_OUT_EVENT;  
			}
		}
		
	//	printf("SMARTCARD_Detect_notify----line %d---%d\n",__LINE__,eventStatus);
		if (eventStatus == Global_SC_STATS)
		{
			if(eventStatus == CARD_OUT_EVENT)
			{
				CTICAS_SendStatusToCAcore(1);
				Global_SC_STATS = CARD_OUT_EVENT;
				if(Cas_Get_Last_Err()!=0)
				{
					cardouttimes++;
					if(cardouttimes>=10)
					{
					//	STB_CAS_Notify(2,4,0);
						cardouttimes=0;
					}
				}
			}
			OS_TaskDelay(500);
			OS_SemSignal( Detect_signal );
			continue;
		}
	//	pbiinfo("SMARTCARD_Detect_notify----line %d  evnet%d\n",__LINE__,eventStatus);

		if(eventStatus == CARD_IN_EVENT)
		{	
			
			Global_SC_STATS = CARD_IN_EVENT;
			atr_recv_count = 40;
			memset(atr_tmp,0,sizeof(atr_tmp));
			printf("SMARTCARD_Detect_notify----line %d\n",__LINE__);
			//OS_TaskDelay(200);
			SC_SetParam();
			ErrCode = AM_SMC_Reset(g_u8SCIPort, atr_tmp, &atr_recv_count);
			if(ErrCode !=AM_SUCCESS)
			{
				int i =0;
				OS_TaskDelay(200);
				OS_SemSignal( Detect_signal );
				CTICAS_SendStatusToCAcore(2);
				printf("errrorocode %x -------line %d\n",ErrCode,__LINE__);
				continue;
			}
			else
			{
				CTICAS_SendStatusToCAcore( 0 );
			}
			printf("CARD_IN_EVENT!!!!                Status=%d   ******\n",tSCIStatus);
		} 
		else if(eventStatus == CARD_OUT_EVENT)
		{
			AM_SMC_Deactive(g_u8SCIPort);
			CTICAS_SendStatusToCAcore(1);	
			Clear_All_Current_Keys();
		}
		Global_SC_STATS=eventStatus;

		OS_TaskDelay(500);
		OS_SemSignal( Detect_signal );

	}
	

}
Exemplo n.º 2
0
void task_rtc(void * ptr)
{
	OS_DateAndTime dt;
	UINT32 year, mon, date, day, hour, min, sec;
	char bcd_str[20];
	
	while(1)
	{
		// First get the user command
		Syslog("Input any command: \ns - Set Time\np - Print Time\nq - Quit");
		OS_SemWait(&input_ready);
		
		switch(input_str[0])
		{
		case 's':
			Syslog("Please Input Year: ");
			OS_SemWait(&input_ready);
			if(!bcda2bcdi(input_str, &year) && (year < 0 || year > 99))
			{
				goto error_exit;
			}

			Syslog("Please Input Month: ");
			OS_SemWait(&input_ready);
			if(!bcda2bcdi(input_str, &mon) && (mon < 1 || mon > 12))
			{
				goto error_exit;
			}

			Syslog("Please Input Date: ");
			OS_SemWait(&input_ready);
			if(!bcda2bcdi(input_str, &date) && (date < 1 || date > 31))
			{
				goto error_exit;
			}
	
			Syslog("Please Input Day[1:Sunday ... 7:Saturday]: ");
			OS_SemWait(&input_ready);
			if(!bcda2bcdi(input_str, &day) && (day < 1 || day > 7))
			{
				goto error_exit;
			}

			Syslog("Please Input Hour [0 - 23]: ");
			OS_SemWait(&input_ready);
			if(!bcda2bcdi(input_str, &hour) && (day < 0 || day > 23))
			{
				goto error_exit;
			}

			Syslog("Please Input Minutes [0 - 59]: ");
			OS_SemWait(&input_ready);
			if(!bcda2bcdi(input_str, &min) && (min < 0 || min > 59))
			{
				goto error_exit;
			}

			Syslog("Please Input Seconds [0 - 59]: ");
			OS_SemWait(&input_ready);
			if(!bcda2bcdi(input_str, &sec) && (sec < 0 || sec > 59))
			{
				goto error_exit;
			}
	
			// Copy into OS_DateAndTime structure
			dt.year = year;
			dt.mon = mon;
			dt.date = date;
			dt.day = day;
			dt.hour = hour;
			dt.min = min;
			dt.sec = sec;
	
			while(1)
			{
				Syslog("Do you want to set the time ? [y/n]");
				OS_SemWait(&input_ready);
				if((input_str[0]=='y') || (input_str[0]=='n'))
				{
					break;
				}
			}
			if(input_str[0]=='y')
			{
				if(OS_SetDateAndTime(&dt) == SUCCESS)
				{
					Syslog("Date and Time set successfully...");
				}
				else
				{
					Syslog("Date and Time set FAILED...");
					goto error_exit;
				}
			}
			
			break;
			
		case 'p':
			if(OS_GetDateAndTime(&dt) != SUCCESS)
			{
				Syslog("Getting Date and Time FAILED...");
				goto error_exit;
			}
		
			Syslog("\n\n");
			SyslogStr(NULL, weekdays[dt.day - 1]);
			SyslogStr(NULL, "\t");
		
			bcdi2bcda(dt.mon, bcd_str);
			SyslogStr(NULL, bcd_str);
			SyslogStr(NULL, "/");
		
			bcdi2bcda(dt.date, bcd_str);
			SyslogStr(NULL, bcd_str);
			SyslogStr(NULL, "/");
		
			bcdi2bcda(dt.year, bcd_str);
			SyslogStr(NULL, bcd_str);
			SyslogStr(NULL, " ");
		
			bcdi2bcda(dt.hour, bcd_str);
			SyslogStr(NULL, bcd_str);
			SyslogStr(NULL, ":");
		
			bcdi2bcda(dt.min, bcd_str);
			SyslogStr(NULL, bcd_str);
			SyslogStr(NULL, ":");
		
			bcdi2bcda(dt.sec, bcd_str);
			SyslogStr("", bcd_str);
			
			Syslog("\n");
			
#if OS_ENABLE_CPU_STATS==1 && ENABLE_SYNC_TIMER==1
			Syslog32("Current SYNC Counter Value - ", sync_intr_counter);
#endif 			
			Syslog32("Current Counter Value - ", test_counter);
			Syslog("\n");
			
			break;
		case 'q':
			goto exit;
		default:
			break;			
		}
	}
	
exit:
	return;
error_exit:
	Syslog("Critical Error. Exiting...");
}